Repository navigation
Fix some tests (especially compile with fullgraph=True on Python<3.11) - #38319
Conversation
|
|
||
| logits = output.logits | ||
| torch.testing.assert_close(EXPECTED_LOGITS, logits[:, :3, :3], rtol=1e-3, atol=1e-3) | ||
| torch.testing.assert_close(EXPECTED_LOGITS, logits[:, -3:, :3], rtol=1e-3, atol=1e-3) |
There was a problem hiding this comment.
The test was looking at the first 3 tokens in the seq_len dimension, but as we have padding tokens it does not really make sense... And as we don't use the mask workaround (unmask the fully unattended rows) on newer torch versions because the fix got upstreamed, we get different results here with the mask refactor. On the last 3 tokens though, there are no changes, as it should
There was a problem hiding this comment.
OK, but could you very concisely explain why it works before the mask refactor PR? Just to get a bit of context
There was a problem hiding this comment.
It's simply that we used to change these positions of the mask, attending to them instead of skipping them - so we used to get numerical values for them, now we just have 0s instead as we don't attend to them at all
|
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. |
| EXPECTED_LOGITS_LEFT = { | ||
| 7: torch.Tensor( | ||
| [[0.1904, 0.0500, 0.7187], [0.1933, 0.0515, 0.7187], [0.2001, 0.0559, 0.7148]], | ||
| ).to(torch_device), | ||
| 8: torch.Tensor([[0.1914, 0.0508, 0.7188], [0.1953, 0.0510, 0.7227], [0.1973, 0.0562, 0.7148]]).to( | ||
| torch_device | ||
| ), | ||
| 9: torch.Tensor([[0.1904, 0.0513, 0.7227], [0.1943, 0.0518, 0.7227], [0.1982, 0.0557, 0.7148]]).to( | ||
| torch_device | ||
| ), | ||
| } | ||
|
|
There was a problem hiding this comment.
Same as for cohere - does not make sense to check logits for padded positions, and behavior has changed
There was a problem hiding this comment.
If you think better to remove this check instead of changing to -3:, :3 (like what you did for cohere), ok for me
There was a problem hiding this comment.
Yes this one was specifically looking at the padded positions, we would only get 0s now so no need to test
There was a problem hiding this comment.
I mean attention output would be 0, then logits will get constant value based on later ops on the 0s value at those positions
| 8: torch.Tensor([[0.2217, 0.5195, -0.3828], [0.8203, -0.2295, 0.6055], [0.2676, -0.7109, 0.2461]]).to( | ||
| torch_device | ||
| 8: torch.Tensor([[ 0.2207, 0.5234, -0.3828], [ 0.8203, -0.2285, 0.6055], [ 0.2656, -0.7109, 0.2451]]).to( | ||
| torch_device, |
There was a problem hiding this comment.
I adjusted values for A100 only, as they were not correct - for T4 they are still the same, as once again there is no regresion on this test except for fully padded positions (but we never care about them) 🤗
| def _prefetch_layer_in_context(self, layer_idx: int) -> None: | ||
| """Performs the actual copy of the layer to device cache.""" | ||
| if len(self.key_cache) >= layer_idx: | ||
| if len(self.key_cache) > layer_idx: |
There was a problem hiding this comment.
do we need to ping gante here?
There was a problem hiding this comment.
We can but it's a simple fix (if ==, then will be out of positions as Python is 0-indexed) on the Cache I added myself before 🤗 We did not have the issue before on the tests because this scenario would not happen as we are supposed to have interleaved layers in the HybridCache, but in the mask refactor I made it similar to StaticCache if no interleaved pattern in the config, so the issue came up!
cc @gante though, for reference!
There was a problem hiding this comment.
Gooddddddddd (I am asking as I don't know much about the history of this )
There was a problem hiding this comment.
I have no idea about how this should be, but it seems this just revert your changes in the mask refactor PR. So ok for me
ydshieh
left a comment
There was a problem hiding this comment.
Great. The change in cache_utils.py I don't have the expertise, others changes works for me 🙏 Thank you a lot 🫡
|
Alright, merging as I'm certain on the cache change! |
What does this PR do?
Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.