-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
Remove _supports_static_cache = True for some model classes #34975
base: main
Are you sure you want to change the base?
Conversation
@@ -330,6 +330,8 @@ def forward(self, hidden_states): | |||
) # [num_tokens, num_experts] | |||
gates = zeros.scatter(1, top_k_indices, 1) # [num_tokens, num_experts] | |||
expert_size = gates.long().sum(0) # [num_experts,] | |||
# (This cause torch.compile to fail with `torch._dynamo.exc.Unsupported: Backend compiler failed with a fake tensor exception at`) | |||
# (and `DataDependentOutputException`) | |||
expert_size = expert_size.tolist() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jimba
has this line expert_size = expert_size.tolist()
too and it has no _supports_static_cache = True
. Let do the same for this model.
if attention_mask.max() != 0: | ||
raise ValueError("Custom 4D attention mask should be passed in inverted form with max==0`") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the only place I see an extra check attention_mask.max() != 0
within if attention_mask is not None and attention_mask.dim() == 4
. Not sure if we really need it, but it gives another different error (different from what expert_size = expert_size.tolist()
give above) if we use torch compile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @mayank31398 you may know better if this check is really necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not in granite modeling code though
@@ -1155,7 +1156,7 @@ def forward( | |||
elif position_ids is None: | |||
position_ids = cache_position.unsqueeze(0) | |||
|
|||
if (pixel_values, image_encoder_embeddings, perceiver_embeddings).count(None) != 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will fail torch compile with another different type error.
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
What does this PR do?
Remove
_supports_static_cache = True
for some model classes. See the comments in changes.They were True before because it is set simply we can use static cache without torch.compile. But after #34247, static is kind tied to
torch.compile
and we should say it works if it works with torch.compile