Repository navigation
[CPU] Adds support for fp32 attention sinks - #56252
dllehr-amd merged 2 commits into
Conversation
amukho
left a comment
There was a problem hiding this comment.
Can you please update the tag to use [CPU] instead of [ZENTORCH] in this PR since the fix is generic for all CPU backends?
The changes look good to me...
e342fb3 to
d39b59e
Compare
| cached = getattr(self, "_sinks_fp32", None) | ||
| if cached is None: | ||
| self._sinks_fp32 = s_aux.to(torch.float32) | ||
| s_aux = self._sinks_fp32 |
There was a problem hiding this comment.
Just a quick question would it make sense to convert self.sinks = self._sinks_fp32? and leave our code just passing self.sinks?
There was a problem hiding this comment.
Yes that would be a another way to go ahead as well. The main reason for creating another variable was to not modify the user set sinks during the forward pass. I have modified the code as per you comment.
| # are loaded, rather than at __init__ time). | ||
| s_aux = self.sinks | ||
| if s_aux is not None and s_aux.dtype != torch.bfloat16: | ||
| cached = getattr(self, "_sinks_fp32", None) |
There was a problem hiding this comment.
similar to my comment below if we converted self.sinks to fp32 when needed could we just check the sinks dtype and be done with it?
There was a problem hiding this comment.
Modified the code as per the comment.
|
✅ @Ankit-Jaiswal-AMD, CI is now available for this PR.
|
|
/ci run |
|
❌ This PR is 499 commits behind upstream |
d39b59e to
67ec8b4
Compare
|
Hi @Ankit-Jaiswal-AMD, the pre-commit checks have failed. Please run: uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-filesThen, commit the changes and push to your branch. For future commits, |
|
/ci run |
|
❌ This PR is 1 commit behind upstream |
8a57822 to
2acc969
Compare
|
/ci run |
|
✅ Triggered Buildkite CI #89793 for commit |
Signed-off-by: Ankit Jaiswal <ankit.jaiswal@amd.com>
2acc969 to
e2d3802
Compare
|
/ci run |
|
✅ Triggered Buildkite CI #90380 for commit |
|
/ci retry |
|
✅ Queued 6 failed job(s) for retry in Buildkite CI #90380. |
|
/ci retry |
|
✅ Queued 1 failed job(s) for retry in Buildkite CI #90380. |
|
/ci retry |
dllehr-amd
left a comment
There was a problem hiding this comment.
Thanks @Ankit-Jaiswal-AMD for addressing my concerns. LGTM!
Signed-off-by: Ankit Jaiswal <ankit.jaiswal@amd.com> Co-authored-by: Douglas Lehr <91553416+dllehr-amd@users.noreply.github.com>

Purpose
This PR adds support for fp32 in attention sinks, to support running the gpt-oss-20B-Bf16 model on fp16. It converts all the tensors other than bf16 to fp32 to compute attention sinks.
It also updates the unit tests and adds test coverage for fp16.
Test Plan
python -m pytest tests/kernels/attention/test_cpu_attn.py -qpython -m pip install . --no-build-isolation --no-deps --force-reinstallTest Result
The Unit tests passed.
1242 passed, 1478 skipped, 14 warnings in 818.95s (0:13:38)The accuracy benchmark passes, with comparable accuracy.
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.