NVIDIA / NVIDIA/TensorRT-LLM

[Feature]: Lazy RoPE in the modeling file and update the optimize_rope

Open
#13,698 0 comments 0 reactions 1 assignee View on GitHub

@nvchenghaoz is already working on this.

Since May 1, 2026.

feature request Model optimization
Dominant language
Python
Stars
14.7k
Forks
2.8k
Avg merge
2d 23h
Merged PRs (30d)
489

Description

🚀 The feature, motivation and pitch

AutoDeploy pipeline cache snapshots the graph/module before weight loading. For some custom modeling files, RoPE cos/sin tables are currently precomputed during model construction and registered as non-persistent buffers.

Observed cache sizes:

Nano / Nemotron-H: ~21 MB
GLM-4.7-Flash: ~65 MB
Gemma 4: ~1.6 GB

Proposal
Implement two related changes:

  1. Make RoPE lazy in affected modeling files.
    • Do not precompute/register full _ad_cos_cached / _ad_sin_cached buffers in init.
    • Keep only small config-derived state such as inv_freq, scaling factors, and RoPE metadata.
  2. Move optimize_rope after weight loading.
    • Change optimize_rope from pattern_matcher stage to post_load_fusion.
    • Let the optimized/fused RoPE table be materialized after pipeline_cache, so it is not serialized into the cache artifact.
Alternatives

No response

Additional context

No response

Before submitting a new issue...
  • Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.

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.