[Feature]: Lazy RoPE in the modeling file and update the optimize_rope
Open
@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:
- 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.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.