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

Use Value dim shape for Attention compute_output_shape #19284

Merged
merged 4 commits into from
Mar 18, 2024

Conversation

sampathweb
Copy link
Collaborator

Fixes #19257 by using Value dim shape for compute_output_shape of Attention layer.

Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Unit tests are failing, I think some golden values need to be updated.

def test_attention_compute_output_shape(self):
layer = layers.Attention()
input_shape = [(2, 8, 7), (2, 8, 5), (2, 8, 7)] # Shapes of Q, V, K
self.assertAllEqual(layer.compute_output_shape(input_shape) == (2, 8, 5))
Copy link
Member

Choose a reason for hiding this comment

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

Please call the layer on an input and read its shape, to ensure match between actual shape and computed shape.

Copy link
Collaborator Author

@sampathweb sampathweb Mar 18, 2024

Choose a reason for hiding this comment

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

Updated to match it with output.shape

@sampathweb sampathweb force-pushed the use-value-dim-shape-attention branch from 9b26297 to ececf6e Compare March 18, 2024 21:50
@@ -173,9 +173,6 @@ def _parse_name(self, name):
return "float16", "float32"
elif name == "mixed_bfloat16":
return "bfloat16", "float32"
elif name == "uint8":
Copy link
Collaborator Author

@sampathweb sampathweb Mar 18, 2024

Choose a reason for hiding this comment

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

This is redundant. Its addressed in the try block so removing it.

Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Mar 18, 2024
@fchollet fchollet merged commit b2ef949 into keras-team:master Mar 18, 2024
7 of 9 checks passed
@google-ml-butler google-ml-butler bot removed ready to pull Ready to be merged into the codebase kokoro:force-run labels Mar 18, 2024
@sampathweb sampathweb deleted the use-value-dim-shape-attention branch March 18, 2024 22:28
james77777778 added a commit to james77777778/keras that referenced this pull request Mar 19, 2024
…nse`

Add qlora-like technique to `quantized_call` in `Dense`

Update `save_own_variables` and `load_own_variables`

Update `benchmark.py`

update version string.

Set dtype policy for uint8 (keras-team#19327)

* Set Quantization policy for uint8 to float

* Add uint8 to dtype_policies

Use Value dim shape for Attention compute_output_shape (keras-team#19284)

* Use Value dim shape for Attention compute_output_shape

* Fix attention layer compute output shape

* fix format

* check compute_output_shape with output

Update `quantized_call` in `EinsumDense` to support training with quantized weights
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

Keras 3 Attention layer value tensor dimension
4 participants