-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[None][perf] Accelerate global scale calculations for deepEP fp4 combine #7126
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
📝 WalkthroughWalkthroughAdds an additive FP4 per-token global-scale computation: a vectorized templated CUDA kernel + host launcher (FP16/BF16), header declaration, C++/PyTorch binding (trtllm.calculate_nvfp4_global_scale), Python integration in fused_moe_wide_ep, and unit tests and a Python custom-op stub. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Python as fused_moe_wide_ep
participant Op as trtllm.calculate_nvfp4_global_scale
participant Cpp as torch_ext (C++ binding)
participant Host as HostWrapper computePerTokenGlobalScaleForFP4Quantization<T>
participant Kernel as CUDA kernel
participant GS as globalScale buffer
Python->>Op: call(input, tokensPerBatch?)
Op->>Cpp: dispatch by dtype, validate shapes
Cpp->>Host: launch(b,m,n,input,tokensPerBatch,globalScale,SMcount,stream)
Host->>Kernel: <<<grid,block>>> computePerTokenGlobalScaleForFP4QuantizationKernel<T>
Kernel->>GS: reduce per-token maxAbs → write scale = 2688.0f / maxAbs
Kernel-->>Host: done
Host-->>Cpp: return globalScale tensor
Cpp-->>Op: return at::Tensor
Op-->>Python: use globalScale in low_latency_combine_fp4
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (4)
🧰 Additional context used📓 Path-based instructions (3)**/*.{c,cc,cpp,cxx,cu}📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Files:
**/*.{c,cc,cpp,cxx,cu,h,hh,hpp,hxx,cuh}📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Files:
**/*.{c,cc,cpp,cxx,h,hh,hpp,hxx,cu,cuh,py}📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Files:
⏰ 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)
🔇 Additional comments (2)
✨ 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
|
7f80217
to
0f0f0e5
Compare
/bot run |
PR_Github #16046 [ 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: 4
🧹 Nitpick comments (9)
cpp/tensorrt_llm/kernels/quantization.h (2)
91-94
: Add API contract (shape, dtype, semantics) to the new declaration.Please document constraints clearly (rank 2/3, hidden_size multiple of 16, supported input dtypes, tokensPerBatch semantics and dtype). This avoids mismatches between callers and the .cu implementation.
Proposed header doc right above the declaration:
+//! Compute per-token NVFP4 global scales. +//! Input: +//! - b: batch size (1 for [token_num, hidden_size], or batch for [batch, token_num, hidden_size]). +//! - m: token_num per batch (uniform upper bound when tokensPerBatch is provided). +//! - n: hidden_size, must be divisible by 16. +//! - input: device pointer to {half|__nv_bfloat16}, contiguous. +//! - tokensPerBatch: optional device pointer to int32 of length b; tokensPerBatch[i] in [0, m]. +//! Output: +//! - globalScale: device pointer to float32 with shape [b, m, 1] (or [m, 1] when b == 1). +//! Stream: +//! - stream on which the kernel is launched. template <typename T> void computePerTokenGlobalScaleForFP4Quantization(int b, int m, int n, T const* input, int const* tokensPerBatch, float* globalScale, int multiProcessorCount, cudaStream_t stream = 0);
91-94
: Consider int32_t for dimension parameters for cross-platform consistency.Most kernels take int32-sized dims; using int32_t for b/m/n may reduce implicit casts at call sites and inside kernels.
tensorrt_llm/_torch/modules/fused_moe/fused_moe_wide_ep.py (1)
692-694
: Great swap-in of the CUDA op; add a lightweight guard for dtype and operator availability.The CUDA op supports fp16/bf16 only. If final_hidden_states ever becomes fp32 here, the call will throw. Also, when the extension isn’t loaded (e.g., custom builds), we can fall back to the reference formula.
Patch:
- global_scales = torch.ops.trtllm.calculate_nvfp4_global_scale( - final_hidden_states, recv_expert_count) + # Ensure supported dtype (operator expects fp16/bf16) + assert final_hidden_states.dtype in (torch.float16, torch.bfloat16), \ + f"calculate_nvfp4_global_scale expects fp16/bf16, got {final_hidden_states.dtype}" + try: + global_scales = torch.ops.trtllm.calculate_nvfp4_global_scale( + final_hidden_states, recv_expert_count) + except (RuntimeError, AttributeError) as e: + # Fallback to Python reference if the op is unavailable + max_abs = final_hidden_states.abs().amax(dim=-1, keepdim=True).to(torch.float32) + global_scales = (448 * 6) / max_abscpp/tensorrt_llm/thop/fp4Quantize.h (1)
30-31
: Document the new public API signature and expectations.Please add a short Doxygen-style comment to clarify accepted ranks, dtype, shape of the returned tensor, and tokensPerBatch dtype/shape. This improves discoverability and prevents misuse.
Suggested header comment:
- at::Tensor calculate_nvfp4_global_scale(at::Tensor const& input, std::optional<at::Tensor> const& tokensPerBatch); +//! Calculate NVFP4 per-token global scales. +//! input: [token_num, hidden] or [batch, token_num, hidden], dtype: fp16/bf16, contiguous, hidden % 16 == 0 +//! tokensPerBatch (optional): 1D int32 tensor of length batch; tokensPerBatch[i] in [0, token_num] +//! Returns: same leading dims as input with last dim = 1, dtype float32 +at::Tensor calculate_nvfp4_global_scale(at::Tensor const& input, std::optional<at::Tensor> const& tokensPerBatch);tests/unittest/_torch/thop/test_fp4_calculate_global_scale.py (3)
25-29
: Match reference formula with in-code constant; consider naming a constant.The repeated literal (448 * 6) would be clearer as a named constant to convey meaning (e.g., kNVFP4_SCALE_NUMERATOR).
-def reference_calculate_global_scale(input_tensor): +NVFP4_SCALE_NUMERATOR = 448 * 6 + +def reference_calculate_global_scale(input_tensor): max_abs_values = input_tensor.abs().max(dim=-1, keepdim=True).values.to( torch.float32) - global_scales = (448 * 6) / max_abs_values + global_scales = NVFP4_SCALE_NUMERATOR / max_abs_values return global_scales
93-100
: Fix long line flagged by Ruff and avoid dumping massive tensors on failure.The assert message exceeds 120 chars and printing full tensors harms readability/perf.
- torch.testing.assert_close( - custom_result, - reference_result, - atol=1e-3, - rtol=1e-3, - msg= - f"Shape: {input_shape}, dtype: {dtype}, custom_result: {custom_result}, reference_result: {reference_result}" - ) + torch.testing.assert_close( + custom_result, + reference_result, + atol=1e-3, + rtol=1e-3, + msg=f"Mismatch for shape={input_shape}, dtype={dtype}" + )
171-219
: Add negative tests for tokensPerBatch dtype, device mismatch, and out-of-range values.The CUDA entry point currently doesn’t validate tokensPerBatch dtype/device/range; add tests to pin the expected behavior.
Proposed additions inside test_calculate_nvfp4_global_scale_invalid_inputs:
@@ def test_calculate_nvfp4_global_scale_invalid_inputs(self): @@ with self.assertRaises(Exception): torch.ops.trtllm.calculate_nvfp4_global_scale( input_tensor, tokens_per_batch) + # Wrong dtype for tokensPerBatch (int64 instead of int32) + input_tensor = torch.randn((4, 32, 4096), dtype=torch.float16, device='cuda') + tokens_per_batch = torch.randint(1, 33, (4,), device='cuda', dtype=torch.int64) + with self.assertRaises(Exception): + torch.ops.trtllm.calculate_nvfp4_global_scale(input_tensor, tokens_per_batch) + + # tokensPerBatch on a different device (if multiple GPUs are available) + if torch.cuda.device_count() >= 2: + input_tensor = input_tensor.to('cuda:0') + tokens_per_batch = torch.randint(1, 33, (4,), device='cuda:1', dtype=torch.int32) + with self.assertRaises(Exception): + torch.ops.trtllm.calculate_nvfp4_global_scale(input_tensor, tokens_per_batch) + + # tokensPerBatch values out of range + input_tensor = torch.randn((4, 32, 4096), dtype=torch.float16, device='cuda') + tokens_per_batch = torch.tensor([0, 32, 65, -1], device='cuda', dtype=torch.int32) # includes > max and negative + with self.assertRaises(Exception): + torch.ops.trtllm.calculate_nvfp4_global_scale(input_tensor, tokens_per_batch)I can follow up with matching validation in the CUDA binding.
cpp/tensorrt_llm/thop/fp4Quantize.cpp (1)
238-251
: Bindings look correct. Consider registering a CPU stub that throws a clearer error.When called on CPU tensors, the operator currently fails the CUDA checks. A CPU backend that throws a NotImplementedError with a short message can improve UX.
Example:
TORCH_LIBRARY_IMPL(trtllm, CUDA, m) { m.impl("fp4_quantize", TORCH_FN(torch_ext::fp4_quantize)); m.impl("calculate_nvfp4_global_scale", TORCH_FN(torch_ext::calculate_nvfp4_global_scale)); } + +TORCH_LIBRARY_IMPL(trtllm, CPU, m) +{ + m.impl("calculate_nvfp4_global_scale", [](at::Tensor const&, c10::optional<at::Tensor> const&) -> at::Tensor { + C10_THROW_ERROR(NotImplementedError, "calculate_nvfp4_global_scale is CUDA-only"); + }); +}cpp/tensorrt_llm/kernels/quantization.cu (1)
2-2
: Update copyright year to 2025The copyright header should reflect the current year (2025) for new code additions.
- * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. All rights reserved.
📜 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 (6)
cpp/tensorrt_llm/kernels/quantization.cu
(3 hunks)cpp/tensorrt_llm/kernels/quantization.h
(1 hunks)cpp/tensorrt_llm/thop/fp4Quantize.cpp
(2 hunks)cpp/tensorrt_llm/thop/fp4Quantize.h
(1 hunks)tensorrt_llm/_torch/modules/fused_moe/fused_moe_wide_ep.py
(1 hunks)tests/unittest/_torch/thop/test_fp4_calculate_global_scale.py
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh}
: In C++, close namespaces with a comment naming the namespace (e.g., } // namespace foo)
Prefer const/constexpr variables over #define for constants
Declare variables const if not modified after initialization
Use Allman brace style in C++
C++ filenames use lowerCamelCase and must be case-insensitively unique within a build target
C++ type names use UpperCamelCase
Local variables, methods, and namespaces use lowerCamelCase
Global non-static variables not in anonymous namespace use gPrefix lowerCamelCase (e.g., gExample)
Static globals or globals in anonymous namespaces use sPrefix lowerCamelCase
Locally visible static variables start with 's' (e.g., static std::once_flag sFlag;)
Member variables use mPrefix lowerCamelCase; public members may omit but are encouraged to use 'm'
Constants (enums, global/static/function-scope magic numbers) use kPREFIXED_UPPER_SNAKE (e.g., kDIGIT_NUM)
If macros are unavoidable, use UPPER_SNAKE_CASE (prefer constants over #define)
Constructor parameter that conflicts with a public member name gets trailing underscore (foo_)
Literal suffixes should be uppercase (e.g., 1234L not 1234l)
C++: use spaces only; indent 4 spaces
Run clang-format (LLVM style) before submitting; wrap lines at 120 characters
If formatting must be bypassed, use // clang-format off/on around the section
Prefer smart pointers; use unique_ptr for sole ownership, shared_ptr for shared; weak_ptr only in exceptional cases
Do not use deprecated pre-C++11 smart pointers
Use C++ style comments; avoid C comments except special inline cases; prefer // single-line
Capitalize and punctuate full-sentence comments
Follow Doxygen rules: use //! for comments and //!< for members in C++
Disable code with #if/#endif and mnemonic conditions; avoid commented-out code; avoid dead code
Do not throw exceptions across library boundaries
Use least-forceful casts; avoid removing const/volatile; avoid C-style and functional casts (except constructors); p...
Files:
cpp/tensorrt_llm/thop/fp4Quantize.h
cpp/tensorrt_llm/kernels/quantization.h
cpp/tensorrt_llm/thop/fp4Quantize.cpp
cpp/tensorrt_llm/kernels/quantization.cu
**/*.{h,hpp,hxx,hh,cuh,cpp,cxx,cc,cu}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Parameter names must be consistent between declarations and definitions
Files:
cpp/tensorrt_llm/thop/fp4Quantize.h
cpp/tensorrt_llm/kernels/quantization.h
cpp/tensorrt_llm/thop/fp4Quantize.cpp
cpp/tensorrt_llm/kernels/quantization.cu
**/*.{h,hpp,hxx,hh,cuh}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Header files must use include guards named TRTLLM__H without underscores prefix/suffix (e.g., TRTLLM_FOO_BAR_HELLO_H)
Files:
cpp/tensorrt_llm/thop/fp4Quantize.h
cpp/tensorrt_llm/kernels/quantization.h
**/*.{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:
cpp/tensorrt_llm/thop/fp4Quantize.h
cpp/tensorrt_llm/kernels/quantization.h
tests/unittest/_torch/thop/test_fp4_calculate_global_scale.py
cpp/tensorrt_llm/thop/fp4Quantize.cpp
tensorrt_llm/_torch/modules/fused_moe/fused_moe_wide_ep.py
cpp/tensorrt_llm/kernels/quantization.cu
**/*.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:
tests/unittest/_torch/thop/test_fp4_calculate_global_scale.py
tensorrt_llm/_torch/modules/fused_moe/fused_moe_wide_ep.py
**/*.{cpp,cxx,cc,cu}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
**/*.{cpp,cxx,cc,cu}
: Avoid literal values except for 0, nullptr, true, false; use named constexpr for other literals
Place semicolon of empty for/while loop on a new line
Always use brace-delimited bodies for switch/while/do-for/if/else
Use inline C comments in argument lists when parameter meaning is unclear (e.g., /* checkForErrors = */ false)
Do not use assignment in subexpressions (e.g., if (x = y) ... is forbidden)
Switch on enums should enumerate all values and omit default to catch new values at compile time
Structure switch statements; prohibit fallthrough except between empty cases; each case ends with break or throw; return at end of case not allowed; put break inside braces for compound case
Prefer anonymous namespaces over static for internal linkage of functions
Every defined function must be called at least once (no unused methods)
Files:
cpp/tensorrt_llm/thop/fp4Quantize.cpp
cpp/tensorrt_llm/kernels/quantization.cu
🧠 Learnings (1)
📚 Learning: 2025-07-28T17:06:08.621Z
Learnt from: moraxu
PR: NVIDIA/TensorRT-LLM#6303
File: tests/integration/test_lists/qa/examples_test_list.txt:494-494
Timestamp: 2025-07-28T17:06:08.621Z
Learning: In TensorRT-LLM testing, it's common to have both CLI flow tests (test_cli_flow.py) and PyTorch API tests (test_llm_api_pytorch.py) for the same model. These serve different purposes: CLI flow tests validate the traditional command-line workflow, while PyTorch API tests validate the newer LLM API backend. Both are legitimate and should coexist.
Applied to files:
tests/unittest/_torch/thop/test_fp4_calculate_global_scale.py
🪛 Ruff (0.12.2)
tests/unittest/_torch/thop/test_fp4_calculate_global_scale.py
99-99: Line too long (121 > 120)
(E501)
⏰ 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 (5)
cpp/tensorrt_llm/kernels/quantization.h (1)
91-94
: computePerTokenGlobalScaleForFP4Quantization parameter names are consistent
The declaration incpp/tensorrt_llm/kernels/quantization.h
(line 92) and the definition incpp/tensorrt_llm/kernels/quantization.cu
(line 374) use the same parameter names and order (b, m, n, input, tokensPerBatch, globalScale, multiProcessorCount, stream
). No changes needed.cpp/tensorrt_llm/kernels/quantization.cu (4)
305-324
: VecType implementation looks correctThe template specializations for
half
and__nv_bfloat16
properly map to their vectorized types (half2
and__nv_bfloat162
), which is appropriate for vectorized max-abs reduction.
406-407
: Consolidate duplicate template instantiationsThe template instantiations for
computePerTokenGlobalScaleForFP4Quantization
appear to be duplicated - once forhalf
(lines 406-407) and once for__nv_bfloat16
(lines 417-419). This is correct and matches the pattern for other functions in the file.Also applies to: 417-419
343-344
: Synchronization inblockReduceMaxV2
is correctThe
blockReduceMaxV2
implementation internally handles thread coordination:
- After each warp computes its partial maximum via
warpReduceMaxV2
, threads withlane == 0
write their results into the shared array.- A full-block barrier (
__syncthreads()
) follows, ensuring all writes complete before any thread reads from shared memory.- Finally, each thread loads either its warp’s shared result or a sentinel value and calls
warpReduceMaxV2
again to compute the block-wide maximum.No additional barriers are required, as warp‐level shuffles used by
warpReduceMaxV2
are implicitly synchronous within a warp. You can safely callblockReduceMaxV2
without adding extra synchronization.
379-379
: Quantization kernel alignment requirement needs clarificationThe assertion
TLLM_CHECK(n % (ElemsPerVec * 32) == 0 and b > 0);ensures that the number of elements per row (
n
) is a multiple ofElemsPerVec * 32
(i.e. vector-width × warp size), not justElemsPerVec
. As a result, for FP16 (ElemsPerVec = 8
) you requiren % 256 == 0
, whereas the bare vectorized load only needsn % 8 == 0
.• If the extra factor of 32 is intentional (to guarantee full-warp coalesced loads for performance), please document this rationale in a comment above the check.
• Otherwise, consider relaxing the check toTLLM_CHECK(n % ElemsPerVec == 0 and b > 0);so that smaller, non-warp-aligned row sizes are supported.
PR_Github #16046 [ run ] completed with state |
/bot run |
PR_Github #16095 [ 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: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tensorrt_llm/_torch/custom_ops/cpp_custom_ops.py (1)
1-1
: Add NVIDIA copyright header tocpp_custom_ops.py
This source file is missing the required NVIDIA copyright header mandated by
CODING_GUIDELINES.md
for all non-test Python files. Please prepend the following at the very top oftensorrt_llm/_torch/custom_ops/cpp_custom_ops.py
:+# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. from typing import List, Optional
• File to update:
–tensorrt_llm/_torch/custom_ops/cpp_custom_ops.py
• After inserting, verify the exact punctuation, capitalization, and any surrounding blank lines match the project’s canonical header style (you can mirror an existing header from another source file, e.g., a
.cpp
in the repo).
🧹 Nitpick comments (1)
tensorrt_llm/_torch/custom_ops/cpp_custom_ops.py (1)
182-187
: Add an optional default for tokens_per_batch in the meta stub and early‐error checksYou can safely make the second argument optional in the fake (meta) kernel without impacting the real CUDA dispatch or existing Python‐op signature. The C++ registration already declares
m.def("calculate_nvfp4_global_scale(Tensor input, Tensor? tokensPerBatch) -> Tensor");
so downstream calls (including all existing call sites and tests on CUDA) will continue to require you to pass a second argument when executing on CUDA. The Python‐only default (
=None
) and shape assertions live entirely in the fake kernel used during tracing/compile.– Modify the fake registration in tensorrt_llm/_torch/custom_ops/cpp_custom_ops.py:
@torch.library.register_fake("trtllm::calculate_nvfp4_global_scale") -def _(input: torch.Tensor, tokens_per_batch: Optional[torch.Tensor]): +def _(input: torch.Tensor, tokens_per_batch: Optional[torch.Tensor] = None): shape = list(input.shape) shape[-1] = 1 + # Meta‐time sanity checks + if tokens_per_batch is not None: + assert tokens_per_batch.ndim == 1, "tokens_per_batch must be 1D [batch]" + assert tokens_per_batch.shape[0] == input.shape[0], \ + "tokens_per_batch length must match input.batch size" return input.new_empty(shape, dtype=torch.float32)– No changes are needed to any C++ files—the schema in
cpp/tensorrt_llm/thop/fp4Quantize.cpp
already matches(Tensor, Tensor?) -> Tensor
.
– All existing Python call sites (e.g. infused_moe_wide_ep.py
) still pass two arguments.
– The real‐device tests in
tests/unittest/_torch/thop/test_fp4_calculate_global_scale.py
will continue to run unchanged, since they invoke the CUDA kernel, not the fake.This adds lightweight meta‐time validation and improves trace‐time ergonomics without affecting production behavior.
📜 Review details
Configuration used: Path: .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 (1)
tensorrt_llm/_torch/custom_ops/cpp_custom_ops.py
(1 hunks)
🧰 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/custom_ops/cpp_custom_ops.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/custom_ops/cpp_custom_ops.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
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.
Some nits. LGTM.
PR_Github #16095 [ run ] completed with state |
Signed-off-by: Yilin Zhang <[email protected]>
8197039
to
aecf242
Compare
/bot run |
PR_Github #16509 [ run ] triggered by Bot |
PR_Github #16509 [ run ] completed with state |
Summary by CodeRabbit
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-list
parameter 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.md
and the
scripts/test_to_stage_mapping.py
helper.kill
kill
Kill all running builds associated with pull request.
skip
skip --comment COMMENT
Skip 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-pipeline
Reuse 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.