Uh oh!
There was an error while loading. Please reload this page.
Avoid creating tensor in CosmosAttnProcessor2_0 (#11761) - #11763
Conversation
a-r-r-o-w
commented
Jun 21, 2025
Just wanted to make a note that the reason this has to be a tensor is because it seemingly breaks ONNX export. I had it implemented the same way earlier but changed to this after suggestions from the nvidia team. cc @asfiyab-nvidia |
yiyixuxu
commented
Jun 23, 2025
ohh thanks for the info @a-r-r-o-w but I think this size ratio is actually determined by config ( |
a-r-r-o-w
commented
Jun 24, 2025
@yiyixuxu Yeah it shouldn't vary and we can compute this beforehand. I think the problem stemmed from using an integer (or int-like type) to do the repeat_interleave instead of a tensor. So, it doesn't matter if we compute it with I don't think we have most of our model definitions compatible with ONNX though (has this been checked before?), so I think it might be okay to make a not and break this compatibility? |
yiyixuxu
commented
Jun 27, 2025
ohh thanks @a-r-r-o-w do you have the original conversation about onnx export breaking? we could try to look into a solution if there is a reproducible script for the issue otherwise, I think the easiest way is we could put an if else in with |
a-r-r-o-w
commented
Jun 27, 2025
@yiyixuxu Unfortunately, there's not much to gather from the original conversation. You can find it here: #10660 (comment) Your suggestion sounds good to me |
yiyixuxu
commented
Jun 27, 2025
cc @chenxiao111222 can you add a if torch.onnx.is_in_onnx_export( ) and keep the original code path there? |
a-r-r-o-w
commented
Jul 5, 2025
Gentle ping @chenxiao111222. Let me know if you would like me to update with the required changes 🤗 |
chenxiao111222
commented
Jul 9, 2025
I'm sorry for the late reply. I mainly use native PyTorch, so I didn't pay attention to the ONNX issue. If you're willing to fix it, please feel free to do so. |
HuggingFaceDocBuilderDev
commented
Jul 10, 2025
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. |
…uggingface#11763) * Avoid creating tensor in CosmosAttnProcessor2_0 (huggingface#11761) * up --------- Co-authored-by: yiyixuxu <yixu310@gmail.com>
…uggingface#11763) * Avoid creating tensor in CosmosAttnProcessor2_0 (huggingface#11761) * up --------- Co-authored-by: yiyixuxu <yixu310@gmail.com>
What does this PR do?
Fixes#11761
Before submitting
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.