[PRX] Improve model compilation #12787
Open
+30
−5
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