Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a mixed precision test and fix mixed precision errors for layers #1242

Merged

Conversation

mattdangerw
Copy link
Member

No description provided.

@mattdangerw
Copy link
Member Author

/gcbrun

@mattdangerw
Copy link
Member Author

Ah I think this needs a keras-core release to pass. Will sync with Francois.

)
intermediate_shape = list(decoder_sequence_shape)
intermediate_shape[-1] = self.intermediate_dim
self._feedforward_output_dense.build(tuple(intermediate_shape))
self._feedforward_layer_norm = keras.layers.LayerNormalization(
epsilon=self.layer_norm_epsilon,
name="output_layer_norm",
dtype=self.dtype_policy,
name="feedforward_layer_norm",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a random thought while I saw these

With the new distribution API, we're going to need to be careful about changing layer names moving forward!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Trying to get us in a nice consistent state before we do.

This will always be done in full precision, regardless of dtype, and
scale by `temperature`.
"""
dtype = logits.dtype
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe logits_dtype? (For consistency of style with inputs_dtype a few files up)

output_data = layer(input_data)
for tensor in tree.flatten(output_data):
dtype = standardize_dtype(tensor.dtype)
if "float" in dtype:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like assertDType should be good here no?

@jbischof
Copy link
Contributor

Is mixed precision working in Keras Core now?

@mattdangerw
Copy link
Member Author

Is mixed precision working in Keras Core now?

Yes, or at least it should be largely with the latest release. Landed the loss scaling optimizer, which was the main piece we were missing, as well as a few other fixes.

@mattdangerw
Copy link
Member Author

/gcbrun

5 similar comments
@mattdangerw
Copy link
Member Author

/gcbrun

@mattdangerw
Copy link
Member Author

/gcbrun

@mattdangerw
Copy link
Member Author

/gcbrun

@mattdangerw
Copy link
Member Author

/gcbrun

@mattdangerw
Copy link
Member Author

/gcbrun

@mattdangerw
Copy link
Member Author

Merging, last breakage unrelated #1251

@mattdangerw mattdangerw merged commit 5cf2c5e into keras-team:master Sep 21, 2023
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants