feat/rfc/poc: Agnostic GPU#45235
Conversation
5c63621 to
391209f
Compare
This adds a small wrapper around common GPU calls that aims to break out of redundant vendor specific calls.
fe59e1c to
1f4860e
Compare
2a2c7ce to
123b776
Compare
3192fa2 to
0ff77ab
Compare
|
View the CircleCI Test Summary for this PR: https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=45235&sha=0ff77a |
|
[For maintainers] Suggested jobs to run (before merge) run-slow: olmo_hybrid, qwen3_5, qwen3_5_moe, qwen3_next |
|
I think we probably just want to remove those |
That's possible, yeah. There are only 6 occurrences of There are, however, 422 |
|
We can work on the others over time 😅. I'd definitely be curious to know if we could get rid of |
|
All right, I'm gonna close this for now, but I may be back with a more suitable example if I get around to finding one. Thanks for the feedback. |
What does this PR do?
This PR adds a tiny "agnostic.gpu" utility that is meant to allow easy replacing of unnecessarily hard-coded vendor-specific code.
The code does not use
torch.acceleratoras it is still considered experimental, but feedback on that opinion is welcome.The example provided patches the flash linear attention Fused RMS norm gate patch to not require CUDA. The upstream library claims to be platform agnostic, so in theory, this should work on other platforms as well. This is a POC/RFC only, and I haven't tested whether this works in practice, but that seems to be slightly irrelevant to what this PR is meant to provide (if
FusedRMSNormGatedis not, in fact, supported on e.g. XPU devices, that is an upstream issue, which does not affect the validity of this patch).If something that does this is already present and I simply haven't found it, then I'd love to know about it. If there are other reasons that I'm not seeing as for why we need to insist on hard coded cuda checks for a seemingly platform agnostic feature, I'd love to hear that as well.
Code Agent Policy
The code was 90% human-written*. The idea was solidified/sanity-checked through chats with DeepSeek.
(* exception being the "is available" part, which was derived from a snippet DeepSeek threw at me while chatting:
)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
These seem relevant: