pytorch / pytorch/TensorRT

❓ [Question] Excessive GPU memory usage during constant folding pass causes OOM (Torch-TensorRT + Qwen-Image)

Open
#4,128 2 comments 0 reactions 1 assignee View on GitHub

@cehongwang is already working on this.

Since Mar 17, 2026.

question story: Dynamic Shapes & Symbolic Tracing
Dominant language
Python
Stars
3k
Forks
410
Avg merge
3d 18h
Merged PRs (30d)
78

Description

❓ Question

When compiling and running the Qwen-Image model with Torch-TensorRT, the peak GPU memory usage exceeds 95GB, resulting in CUDA out-of-memory (OOM) errors.

For comparison, using the Inductor backend only requires around 64GB peak VRAM. After debugging, the issue appears to originate primarily from the constant folding pass:

https://github.com/pytorch/TensorRT/blob/08bfca206ca47da4a4f217072124a6840f451511/py/torch_tensorrt/dynamo/lowering/passes/constant_folding.py#L22-L65

What you have already tried

Setting offload_module_to_cpu=True successfully bypasses the problematic constant folding behavior and avoids the GPU OOM. However, this workaround significantly increases host (system RAM) memory consumption to an unacceptable level.

Environment

  • PyTorch Version:2.9
  • CPU Architecture: x86
  • OS (e.g., Linux): Linux
  • Python version: 3.12
  • CUDA version: 12.9

Are there any better / recommended ways to reduce peak GPU memory (or host memory) usage during the lowering / compilation phase?

Is there any plan in future releases to optimize the constant folding pass for lower memory footprint?

Any suggestions or insights would be greatly appreciated!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.