-
Notifications
You must be signed in to change notification settings - Fork 6.6k
[PRX] Improve model compilation #12787
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
[PRX] Improve model compilation #12787
Conversation
…2Im (incompatible with TensorRT).
|
@DavidBert could you review this? @WaterKnight1998 I am not sure why you tagged Quentin on this PR. |
sayakpaul
left a comment
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.
Changes seem safe for me to merge!
|
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. |
|
@bot /style |
|
Style bot fixed some files and pushed the changes. |
DavidBert
left a comment
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.
LGTM! Thanks
|
@sayakpaul PR is ready for merge |
What does this PR do?
This PR reimplements the
img2seqandseq2imgutilities in the PRX model to enable successful ONNX export and TensorRT inference.Previously, these utilities depended on
torch.nn.functional.foldandtorch.nn.functional.unfold. During ONNX export, this resulted in the use of theCol2ImONNX operator, which is not supported by the TensorRT ONNX operator set, causing engine building to fail.The new implementation removes the dependency on
Col2Imwhile preserving the expected functionality and output shapes, ensuring compatibility across ONNX runtimes and TensorRT. The approach follows theunpatchifylogic used elsewhere in the library, for example indit_transformer_2d.py.Fixes #12786
Code to help you verify
Export model to onnx
Convert model to tensorrt
docker run --rm --gpus all -it \ -v "$(pwd):/workspace" \ -w /workspace \ nvcr.io/nvidia/tensorrt:25.11-py3 \ trtexec \ --onnx=prx.onnx \ --saveEngine=prx_engine.plan \ --fp16 \ --memPoolSize=workspace:16384 \ --minShapes=hidden_states:2x16x128x128,timestep:2,encoder_hidden_states:2x256x2304,attention_mask:2x256 \ --optShapes=hidden_states:2x16x128x128,timestep:2,encoder_hidden_states:2x256x2304,attention_mask:2x256 \ --maxShapes=hidden_states:2x16x128x128,timestep:2,encoder_hidden_states:2x256x2304,attention_mask:2x256 \ --verboseBefore 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.
@sayakpaul @DavidBert @qgallouedec