[PRX] Improve model compilation#12787
Merged
sayakpaul merged 3 commits intohuggingface:mainfrom Dec 8, 2025
Merged
Conversation
…2Im (incompatible with TensorRT).
Member
|
@DavidBert could you review this? @WaterKnight1998 I am not sure why you tagged Quentin on this PR. |
sayakpaul
approved these changes
Dec 4, 2025
Member
sayakpaul
left a comment
There was a problem hiding this comment.
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. |
Member
|
@bot /style |
Contributor
|
Style bot fixed some files and pushed the changes. |
Contributor
Author
|
@sayakpaul PR is ready for merge |
sayakpaul
added a commit
that referenced
this pull request
Dec 12, 2025
* Reimplement img2seq & seq2img in PRX to enable ONNX build without Col2Im (incompatible with TensorRT). * Apply style fixes --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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