-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[https://nvbugs/5427801][fix] Torch compile support for Llama4 and Ea… #6978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughCentralized attention execution by adding Changes
Sequence Diagram(s)sequenceDiagram
participant LlamaModel as modeling_llama
participant Attn as Attention
participant CustomOp as attn_custom_op_inplace
participant Impl as _attn_impl
LlamaModel->>Attn: forward_impl(q, k, v, attn_metadata, attention_mask, None, None, mrope_config)
alt Use custom inplace op
Attn->>CustomOp: run(..., mrope params, enable_attn_nvfp4_output=False)
CustomOp-->>Attn: attn_output (tensor or tuple)
else
Attn->>Impl: _attn_impl(..., mrope params)
Impl-->>Attn: attn_output (tensor or tuple)
end
Attn-->>LlamaModel: attn_output (wrapped as Fp4QuantizedTensor if tuple)
LlamaModel->>LlamaModel: o_proj(attn_output)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
/bot run |
|
PR_Github #15578 [ run ] triggered by Bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🔭 Outside diff range comments (4)
tensorrt_llm/_torch/models/modeling_speculative.py (2)
330-332: Raise the correct exception typeRaising NotImplemented (a sentinel) will error out with a TypeError. Use NotImplementedError.
Apply this diff:
- raise NotImplemented( + raise NotImplementedError( f"get_draft_model does not support speculative decoding mode {spec_dec_mode}." )
1-1: Missing SPDX copyright headerPer repository guidelines, prepend the NVIDIA SPDX header.
Apply this patch at the top of the file:
+# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0tensorrt_llm/_torch/modules/attention.py (1)
1-1: Missing SPDX copyright headerPer repository guidelines, prepend the NVIDIA SPDX header.
Apply this patch at the top of the file:
+# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0tensorrt_llm/_torch/models/modeling_llama.py (1)
1-1: Missing SPDX copyright headerPer repository guidelines, prepend the NVIDIA SPDX header.
Apply this patch at the top of the file:
+# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0
🧹 Nitpick comments (2)
tensorrt_llm/_torch/modules/attention.py (1)
401-415: Return semantics are consistent; consider documenting Fp4QuantizedTensor pathforward_impl returns either a Tensor or an Fp4QuantizedTensor (when output_sf is available). This is fine; add a short docstring or comment to set expectations for callers.
tensorrt_llm/_torch/models/modeling_llama.py (1)
179-181: Redundant tuple handling after forward_implforward_impl returns a Tensor (or Fp4QuantizedTensor). The tuple case won’t occur; remove for clarity.
Apply this minimal cleanup:
- if isinstance(attn_output, tuple): - attn_output = Fp4QuantizedTensor(attn_output[0], attn_output[1])
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
tensorrt_llm/_torch/models/modeling_llama.py(1 hunks)tensorrt_llm/_torch/models/modeling_speculative.py(1 hunks)tensorrt_llm/_torch/modules/attention.py(3 hunks)tests/integration/defs/accuracy/test_llm_api_pytorch.py(1 hunks)tests/integration/test_lists/waives.txt(0 hunks)
💤 Files with no reviewable changes (1)
- tests/integration/test_lists/waives.txt
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
**/*.py: Python code must target Python 3.8+
Python indentation: 4 spaces, no tabs
Maintain module namespace in imports (from package.subpackage import foo; then use foo.SomeClass())
Python file names use snake_case
Python class names use PascalCase
Python functions/methods and local variables use snake_case; variables starting with a number get k_ prefix (e.g., k_99th_percentile)
Global variables use G_ prefixed UPPER_SNAKE_CASE (e.g., G_MY_GLOBAL)
Constants use UPPER_SNAKE_CASE in Python
Avoid shadowing variables from outer scopes in Python
Initialize all externally visible members of a Python class in init
Prefer docstrings for interfaces used outside a file; comments for local code
Use Google-style docstrings for classes and functions (Sphinx-parsable)
Document attributes/variables inline with short docstrings
Avoid reflection when simple alternatives exist (e.g., prefer explicit parameters over dict(**locals()))
In try/except, catch the narrowest exceptions possible
For duck-typing with try/except, keep try body minimal and put logic in else
Files:
tensorrt_llm/_torch/models/modeling_speculative.pytensorrt_llm/_torch/models/modeling_llama.pytensorrt_llm/_torch/modules/attention.pytests/integration/defs/accuracy/test_llm_api_pytorch.py
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh,py}
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
Prepend NVIDIA copyright header (current year) to all source files
Files:
tensorrt_llm/_torch/models/modeling_speculative.pytensorrt_llm/_torch/models/modeling_llama.pytensorrt_llm/_torch/modules/attention.pytests/integration/defs/accuracy/test_llm_api_pytorch.py
🔇 Additional comments (3)
tests/integration/defs/accuracy/test_llm_api_pytorch.py (1)
553-556: TorchCompileConfig wiring looks correctThe torch_compile_config is constructed and threaded into pytorch_config as expected. This aligns with the new torch.compile-aware attention path.
Also applies to: 561-561
tensorrt_llm/_torch/modules/attention.py (1)
95-96: Good: explicit named argument for enable_attn_nvfp4_outputSwitching to a named argument improves clarity and guards against call-site drift.
tensorrt_llm/_torch/models/modeling_llama.py (1)
169-178: No unexpectedattention_sinkskwargs found onforward_implcallsI ran the provided ripgrep checks and confirmed that the only call site passing
attention_sinkstoforward_implis in
tensorrt_llm/_torch/models/modeling_llama.py:169–178.
All other uses offorward_impl(including named-arg calls in flashinfer.py) only pass the expected parameters.
No further action needed here.
|
PR_Github #15578 [ run ] completed with state |
e8c599b to
c7bf0fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
tensorrt_llm/_torch/models/modeling_llama.py (2)
178-180: Remove dead tuple handling after forward_implforward_impl now returns either a Tensor or an Fp4QuantizedTensor (wrapping happens inside), so this tuple case is obsolete. Removing it reduces noise and avoids masking future mismatches.
- if isinstance(attn_output, tuple): - attn_output = Fp4QuantizedTensor(attn_output[0], attn_output[1])
491-498: Llama4DecoderLayer does not pass attention_mask (unlike LlamaDecoderLayer) — verify encoder/prefill useLlamaDecoderLayer sets attention_mask to FULL when not generation and passes it into self_attn. Llama4DecoderLayer doesn’t set or pass attention_mask, so it will always use the default CAUSAL. If Llama4Model can be used in encoder/prefill-only scenarios (is_generation=False), this will compute a causal mask incorrectly.
Proposed alignment with LlamaDecoderLayer:
@@ class Llama4DecoderLayer(DecoderLayer): @@ self.moe_allreduce = MoEAllReduce(self.mapping) + # Match LlamaDecoderLayer behavior: use FULL mask when not generating (encoder/prefill). + self.attention_mask = PredefinedAttentionMask.CAUSAL + if not model_config.is_generation: + self.attention_mask = PredefinedAttentionMask.FULL @@ # Self Attention hidden_states = self.self_attn( position_ids=position_ids, hidden_states=hidden_states, attn_metadata=attn_metadata, + attention_mask=self.attention_mask, all_reduce_params=AllReduceParams( enable_allreduce=not self.disable_attn_allreduce), **kwargs, )If Llama4 is never used in prefill-only mode, feel free to ignore; otherwise, this avoids subtle accuracy regressions.
Also applies to: 655-659
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
tensorrt_llm/_torch/models/modeling_llama.py(1 hunks)tensorrt_llm/_torch/models/modeling_speculative.py(1 hunks)tensorrt_llm/_torch/modules/attention.py(3 hunks)tests/integration/defs/accuracy/test_llm_api_pytorch.py(1 hunks)tests/integration/test_lists/waives.txt(0 hunks)
💤 Files with no reviewable changes (1)
- tests/integration/test_lists/waives.txt
🚧 Files skipped from review as they are similar to previous changes (3)
- tensorrt_llm/_torch/models/modeling_speculative.py
- tests/integration/defs/accuracy/test_llm_api_pytorch.py
- tensorrt_llm/_torch/modules/attention.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
**/*.py: Python code must target Python 3.8+
Python indentation: 4 spaces, no tabs
Maintain module namespace in imports (from package.subpackage import foo; then use foo.SomeClass())
Python file names use snake_case
Python class names use PascalCase
Python functions/methods and local variables use snake_case; variables starting with a number get k_ prefix (e.g., k_99th_percentile)
Global variables use G_ prefixed UPPER_SNAKE_CASE (e.g., G_MY_GLOBAL)
Constants use UPPER_SNAKE_CASE in Python
Avoid shadowing variables from outer scopes in Python
Initialize all externally visible members of a Python class in init
Prefer docstrings for interfaces used outside a file; comments for local code
Use Google-style docstrings for classes and functions (Sphinx-parsable)
Document attributes/variables inline with short docstrings
Avoid reflection when simple alternatives exist (e.g., prefer explicit parameters over dict(**locals()))
In try/except, catch the narrowest exceptions possible
For duck-typing with try/except, keep try body minimal and put logic in else
Files:
tensorrt_llm/_torch/models/modeling_llama.py
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh,py}
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
Prepend NVIDIA copyright header (current year) to all source files
Files:
tensorrt_llm/_torch/models/modeling_llama.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Pre-commit Check
🔇 Additional comments (2)
tensorrt_llm/_torch/models/modeling_llama.py (2)
169-176: Fixed: removed unsupported kwarg and switched to forward_impl — LGTMDropping the extraneous attention_sinks kwarg and delegating to forward_impl aligns with the new centralized attention path and should resolve the TypeError seen earlier. Passing None placeholders for output scales is consistent with removing per-call scale wiring.
169-176: forward_impl requires explicit None placeholders
Theforward_implsignature intensorrt_llm/_torch/modules/attention.pydeclares its last three parameters without defaults:def forward_impl( self, q: torch.Tensor, k: Optional[torch.Tensor], v: Optional[torch.Tensor], attn_metadata: AttentionMetadata, attention_mask: AttentionMask, attention_window_size: Optional[int], attention_mask_data: Optional[torch.Tensor], mrope_config: Optional[dict], ):Because neither
attention_window_sizenorattention_mask_datahave default values, the twoNoneplaceholders are required. The current invocation is correct and must remain as-is.Likely an incorrect or invalid review comment.
8585a28 to
374d859
Compare
|
/bot run |
|
PR_Github #15602 [ run ] triggered by Bot |
374d859 to
9032282
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
tensorrt_llm/_torch/models/modeling_speculative.py (1)
365-370: Make merge of extra_attrs robust; avoid hard assertions and accidental overwritesAsserting on unexpected keys or missing registries can abort initialization in benign situations. Using dict.update() can clobber existing indices if they collide. Prefer filtering to known registries, ensure the target registry exists, and perform a non-clobbering merge.
Apply this diff:
- if draft_config is not None: - for key, value in draft_config.extra_attrs.items(): - assert key in ('attn_layers', 'mla_layers') - assert key in model_config.extra_attrs - model_config.extra_attrs[key].update(value) + if draft_config is not None and getattr(draft_config, "extra_attrs", None): + for key, value in draft_config.extra_attrs.items(): + # Only merge layer registries we rely on + if key not in ("attn_layers", "mla_layers") or not value: + continue + target = model_config.extra_attrs.setdefault(key, {}) + # Merge without clobbering existing indices (draft indices should be disjoint) + for idx, ref in value.items(): + if idx in target: + # Keep existing target ref; draft indices are expected to be offset/disjoint. + continue + target[idx] = reftensorrt_llm/_torch/modules/attention.py (1)
375-385: Harden forward_impl signature to accept ignored kwargs for forward-compatibilityCallers may pass benign extra kwargs (e.g., new flags). Accept and ignore unknown kwargs to avoid breaking changes.
Apply this diff:
- def forward_impl( + def forward_impl( self, q: torch.Tensor, k: Optional[torch.Tensor], v: Optional[torch.Tensor], attn_metadata: AttentionMetadata, attention_mask: AttentionMask, attention_window_size: Optional[int], attention_mask_data: Optional[torch.Tensor], - mrope_config: Optional[dict], - ): + mrope_config: Optional[dict], + **kwargs, + ):
🧹 Nitpick comments (1)
tensorrt_llm/_torch/modules/attention.py (1)
473-481: Propagate extra kwargs from forward() to forward_implIf forward() receives benign extras, pass them through so forward_impl can ignore them. This reduces the risk of subtle breakages when call sites evolve.
Apply this diff:
- output = self.forward_impl(q, - k, - v, - attn_metadata, - attention_mask, - attention_window_size, - attention_mask_data, - mrope_config=mrope_config) + output = self.forward_impl(q, + k, + v, + attn_metadata, + attention_mask, + attention_window_size, + attention_mask_data, + mrope_config=mrope_config, + **kwargs)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
tensorrt_llm/_torch/models/modeling_llama.py(1 hunks)tensorrt_llm/_torch/models/modeling_speculative.py(1 hunks)tensorrt_llm/_torch/modules/attention.py(3 hunks)tests/integration/defs/accuracy/test_llm_api_pytorch.py(1 hunks)tests/integration/test_lists/waives.txt(0 hunks)
💤 Files with no reviewable changes (1)
- tests/integration/test_lists/waives.txt
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/integration/defs/accuracy/test_llm_api_pytorch.py
- tensorrt_llm/_torch/models/modeling_llama.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
**/*.py: Python code must target Python 3.8+
Python indentation: 4 spaces, no tabs
Maintain module namespace in imports (from package.subpackage import foo; then use foo.SomeClass())
Python file names use snake_case
Python class names use PascalCase
Python functions/methods and local variables use snake_case; variables starting with a number get k_ prefix (e.g., k_99th_percentile)
Global variables use G_ prefixed UPPER_SNAKE_CASE (e.g., G_MY_GLOBAL)
Constants use UPPER_SNAKE_CASE in Python
Avoid shadowing variables from outer scopes in Python
Initialize all externally visible members of a Python class in init
Prefer docstrings for interfaces used outside a file; comments for local code
Use Google-style docstrings for classes and functions (Sphinx-parsable)
Document attributes/variables inline with short docstrings
Avoid reflection when simple alternatives exist (e.g., prefer explicit parameters over dict(**locals()))
In try/except, catch the narrowest exceptions possible
For duck-typing with try/except, keep try body minimal and put logic in else
Files:
tensorrt_llm/_torch/models/modeling_speculative.pytensorrt_llm/_torch/modules/attention.py
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh,py}
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
Prepend NVIDIA copyright header (current year) to all source files
Files:
tensorrt_llm/_torch/models/modeling_speculative.pytensorrt_llm/_torch/modules/attention.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Pre-commit Check
🔇 Additional comments (1)
tensorrt_llm/_torch/modules/attention.py (1)
95-96: Disabling NVFP4 output on the torch.compile custom-op path — LGTMSetting enable_attn_nvfp4_output=False here is correct; it avoids an unsupported path under torch.compile for TRTLLM and keeps quantization handling centralized.
|
PR_Github #15602 [ run ] completed with state |
NVIDIA#6858) Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com>
9032282 to
6eac92e
Compare
|
/bot run |
|
PR_Github #15614 [ run ] triggered by Bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
tensorrt_llm/_torch/modules/attention.py (1)
1-1: Prepend NVIDIA 2025 copyright header (repo policy).This Python source file is missing the required NVIDIA copyright header.
Apply this diff at the top of the file:
+# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. import math
♻️ Duplicate comments (1)
tensorrt_llm/_torch/modules/attention.py (1)
375-385: Harden forward_impl signature for forward-compatibility and add return typing/docstring.Accepting and ignoring extra kwargs prevents runtime breaks when upstreams pass benign extras (e.g., attention_sinks). Also add a concise docstring and an explicit return type.
Apply this diff:
- def forward_impl( + def forward_impl( self, q: torch.Tensor, k: Optional[torch.Tensor], v: Optional[torch.Tensor], attn_metadata: AttentionMetadata, attention_mask: AttentionMask, attention_window_size: Optional[int], attention_mask_data: Optional[torch.Tensor], mrope_config: Optional[dict], - ): + **_ignored_kwargs, + ) -> Union[torch.Tensor, Fp4QuantizedTensor]: + """ + Centralized attention execution used by compiled TRTLLM/FLASHINFER backends. + Accepts and ignores extra keyword arguments for forward-compatibility. + Args: + q, k, v: QKV tensors (fused or unfused depending on backend). + attn_metadata: Attention metadata. + attention_mask: Mask spec (e.g., PredefinedAttentionMask.CAUSAL). + attention_window_size: Optional sliding-window limit. + attention_mask_data: Optional mask payload for runtime backends. + mrope_config: Optional dict with mrope_rotary_cos_sin and/or mrope_position_deltas. + Returns: + Tensor or Fp4QuantizedTensor depending on quantization mode. + """Additionally update imports to include Any only if you decide to annotate _ignored_kwargs values; otherwise it can remain untyped:
# near the top of the file from typing import Optional, Union, cast # current # change to: from typing import Optional, Union, cast, Any
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
tensorrt_llm/_torch/models/modeling_llama.py(1 hunks)tensorrt_llm/_torch/models/modeling_speculative.py(1 hunks)tensorrt_llm/_torch/modules/attention.py(3 hunks)tests/integration/defs/accuracy/test_llm_api_pytorch.py(1 hunks)tests/integration/test_lists/waives.txt(0 hunks)
💤 Files with no reviewable changes (1)
- tests/integration/test_lists/waives.txt
🚧 Files skipped from review as they are similar to previous changes (3)
- tensorrt_llm/_torch/models/modeling_speculative.py
- tests/integration/defs/accuracy/test_llm_api_pytorch.py
- tensorrt_llm/_torch/models/modeling_llama.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
**/*.py: Python code must target Python 3.8+
Python indentation: 4 spaces, no tabs
Maintain module namespace in imports (from package.subpackage import foo; then use foo.SomeClass())
Python file names use snake_case
Python class names use PascalCase
Python functions/methods and local variables use snake_case; variables starting with a number get k_ prefix (e.g., k_99th_percentile)
Global variables use G_ prefixed UPPER_SNAKE_CASE (e.g., G_MY_GLOBAL)
Constants use UPPER_SNAKE_CASE in Python
Avoid shadowing variables from outer scopes in Python
Initialize all externally visible members of a Python class in init
Prefer docstrings for interfaces used outside a file; comments for local code
Use Google-style docstrings for classes and functions (Sphinx-parsable)
Document attributes/variables inline with short docstrings
Avoid reflection when simple alternatives exist (e.g., prefer explicit parameters over dict(**locals()))
In try/except, catch the narrowest exceptions possible
For duck-typing with try/except, keep try body minimal and put logic in else
Files:
tensorrt_llm/_torch/modules/attention.py
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh,py}
📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)
Prepend NVIDIA copyright header (current year) to all source files
Files:
tensorrt_llm/_torch/modules/attention.py
🔇 Additional comments (5)
tensorrt_llm/_torch/modules/attention.py (5)
70-97: Good: In custom-op path, explicitly disable NVFP4 attention output.Passing enable_attn_nvfp4_output=False avoids NVFP4 output under torch.compile, which is consistent with the comment and avoids unsupported runtime paths.
394-401: Custom in-place op gating under torch.compile and supported backends looks correct.The condition ensures we only route through the custom op when:
- the layer is registered (so weakrefs/metadata can be resolved),
- backend is TRTLLM or FLASHINFER,
- and torch is compiling.
This minimizes surprises in eager runs.
401-415: Allocate output once and invoke custom op in-place: efficient and clean.Using create_output() to pre-allocate and mutating in-place avoids extra allocations/copies. Nice.
416-424: NVFP4 tuple handling preserved in non-custom path.Wrapping output into Fp4QuantizedTensor when output_sf is present maintains the previous contract and allows o_proj to consume quantized output seamlessly.
473-480: Forward now cleanly delegates to forward_impl.Centralization reduces duplication and keeps backend routing logic in one place.
|
PR_Github #15614 [ run ] completed with state |
Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com>
|
/bot run |
|
PR_Github #15690 [ run ] triggered by Bot |
|
PR_Github #15690 [ run ] completed with state |
|
/bot run |
|
PR_Github #15748 [ run ] triggered by Bot |
|
PR_Github #15748 [ run ] completed with state |
|
/bot run |
|
PR_Github #15854 [ run ] triggered by Bot |
|
PR_Github #15854 [ run ] completed with state |
#6978) Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com>
NVIDIA#6978) Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com> Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
NVIDIA#6978) Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com> Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
NVIDIA#6978) Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com> Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
NVIDIA#6978) Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com> Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
NVIDIA#6978) Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com> Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
…… (#6858)
This is a Cherry-pick from main branch.
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Tests
Description
Test Coverage
GitHub Bot Help
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...Provide a user friendly way for developers to interact with a Jenkins server.
Run
/bot [-h|--help]to print this help message.See details below for each supported subcommand.
run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]Launch build/test pipelines. All previously running jobs will be killed.
--reuse-test (optional)pipeline-id(OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.--disable-reuse-test(OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.--disable-fail-fast(OPTIONAL) : Disable fail fast on build/tests/infra failures.--skip-test(OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.--stage-list "A10-PyTorch-1, xxx"(OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.--gpu-type "A30, H100_PCIe"(OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.--test-backend "pytorch, cpp"(OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.--only-multi-gpu-test(OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.--disable-multi-gpu-test(OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.--add-multi-gpu-test(OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.--post-merge(OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx"(OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".--detailed-log(OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.--debug(OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in thestage-listparameter to access the appropriate container environment. Note: Does NOT update GitHub check status.For guidance on mapping tests to stage names, see
docs/source/reference/ci-overview.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip testing for latest commit on pull request.
--comment "Reason for skipping build/test"is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.reuse-pipeline
reuse-pipelineReuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.