Skip to content

Comments

[TRTLLM-10296][fix] Fix the potential misaligned access due to vectorized ld/st instructions in NVLinkOneSided A2A.#10539

Merged
bobboli merged 3 commits intoNVIDIA:mainfrom
bobboli:alltoall_alignment
Jan 20, 2026
Merged

[TRTLLM-10296][fix] Fix the potential misaligned access due to vectorized ld/st instructions in NVLinkOneSided A2A.#10539
bobboli merged 3 commits intoNVIDIA:mainfrom
bobboli:alltoall_alignment

Conversation

@bobboli
Copy link
Collaborator

@bobboli bobboli commented Jan 8, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Added alignment validation for data pointers in mixture of experts distributed operations.
  • Refactor

    • Improved workspace sizing and memory buffer alignment for mixture of experts all-to-all communication operations, introducing cacheline-aligned offsets to enhance performance and stability.

✏️ Tip: You can customize this high-level summary in your review settings.

Description

Test Coverage

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

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.

Details

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 the stage-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.

@bobboli bobboli requested review from a team as code owners January 8, 2026 07:49
@bobboli
Copy link
Collaborator Author

bobboli commented Jan 8, 2026

/bot run --disable-fail-fast

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

The changes refactor memory management in MOE all-to-all operations to enforce cache-line alignment requirements. A global alignment constant is introduced in C++, and workspace size calculations across multiple files are reworked to accumulate sizes incrementally with explicit alignment padding rather than computing separate components. Alignment validation checks are added for data pointers.

Changes

Cohort / File(s) Summary
C++ Cache-line Alignment Refactoring
cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp
Introduces global CACHELINE_ALIGNMENT constant (128 bytes). Reworks moeA2ADispatchOp to replace separate buffer sizing with per-payload offset tracking via payloadRecvBufferOffsets. Adds cumulative currentOffset logic with alignment-based padding. Implements 16-byte alignment validation for rankWorkSpacePtr and payload data pointers. Adjusts recv buffer setup and combinePayloadOffset computation to use new offset tracking.
Python Workspace Calculation - Distributed
tensorrt_llm/_torch/distributed/moe_alltoall.py
Replaces separate payload_size_dispatch and payload_size_combine calculations with single cumulative workspace_size accumulation. Processes hidden states, token selections, scales, and payload bytes incrementally, each followed by 128-byte padding. Fixes minor comment typo.
Python Workspace Calculation - NVLink
tensorrt_llm/_torch/modules/fused_moe/communication/nvlink_one_sided.py
Reworks calculate_required_workspace_size to accumulate workspace incrementally from auxiliary data size through dispatch and combine phases. Replaces separate component calculations with cumulative sizing and explicit alignment padding via pad_up.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete. While the title and summary are clear, the required 'Description' and 'Test Coverage' sections are missing. Only the template structure is present without actual content explaining the issue, solution, or test safeguards. Add a 'Description' section explaining the misalignment issue and the solution approach. Add a 'Test Coverage' section listing relevant tests that validate the alignment fixes.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing misaligned memory access in NVLinkOneSided A2A due to vectorized load/store instructions. It follows the repository template with ticket ID, type, and concise description.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🤖 Fix all issues with AI agents
In @cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp:
- Around line 254-259: The TORCH_CHECK message mislabels
offsets[PAYLOAD_DATA_OFFSET_INDEX] as "auxiliary data + payloads" when it is
actually the starting offset (auxiliary data size); update the check in the
block around requiredSize/currentOffset/sizePerRank/TORCH_CHECK to either remove
the erroneous breakdown or show an accurate breakdown: compute auxSize =
offsets[PAYLOAD_DATA_OFFSET_INDEX] and payloadsSize = currentOffset - auxSize
and include those values in the error text so the message reports "need at least
X bytes (Y aux + Z payloads), but got sizePerRank" or simply drop the
parenthetical breakdown.
- Line 426: Fix the comment "Typially, newly allocated torch tensors are at
least 16-byte aligned." by correcting the typo to "Typically" and removing the
incorrect guarantee about 16-byte alignment; replace it with a brief note that
PyTorch does not guarantee 16-byte alignment for allocations (CPU uses runtime
allocator aligned to alignof(void*), CUDA alignment varies) and state that
strict alignment must be verified explicitly or enforced via a custom allocator
or explicit checks where alignment-sensitive code (e.g., any buffer-alignment
logic near moeAlltoAllOp or related tensor handling) depends on it.

In @tensorrt_llm/_torch/distributed/moe_alltoall.py:
- Around line 57-82: The code calls pad_up(workspace_size, 128) several times
but ignores its return value; update each call to assign the aligned result back
to workspace_size (e.g., replace pad_up(workspace_size, 128) with workspace_size
= pad_up(workspace_size, 128)) after computing auxiliary size from
MoeAlltoAll.get_aux_data_size and after each incremental addition (unquantized
token hidden states, token_selected_experts, token_final_scales, extra payload
bytes per token, and the combine workspace) so the alignment is actually applied
before returning workspace_size.

In @tensorrt_llm/_torch/modules/fused_moe/communication/nvlink_one_sided.py:
- Around line 84-109: The calls to pad_up(...) are currently ignored so
alignment is not applied; update each invocation to capture its return value by
assigning back to workspace_size (e.g., workspace_size = pad_up(workspace_size,
128)) for all occurrences in the workspace computation block that uses
workspace_size (within the NVLinkOneSided workspace calculation routine),
ensuring each alignment call updates workspace_size after adding the unquantized
token states, token_selected_experts, token_final_scales, extra payload bytes,
and the combine workspace.
🧹 Nitpick comments (3)
tensorrt_llm/_torch/distributed/moe_alltoall.py (1)

62-62: Fix typo in comment.

The comment has a typo: "size,i" should be "size, i" (missing space after comma).

📝 Proposed fix
-# but due to the variety of quantization recipes, we cannot know the exact size,i
+# but due to the variety of quantization recipes, we cannot know the exact size, i
cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp (2)

36-36: Rename constant to follow naming convention.

Per coding guidelines, constants should use uppercase snakecase with prefix 'k' (e.g., kCachelineAlignment).

♻️ Proposed fix
-static constexpr size_t CACHELINE_ALIGNMENT = 128;
+static constexpr size_t kCachelineAlignment = 128;

Note: This change would require updating all references throughout the file (lines 72, 77, 82, 88, 94, 243, 264, 337).

As per coding guidelines, constant naming should use kPascalCase pattern.


337-337: Minor redundancy: currentOffset is already aligned.

At line 243, currentOffset is aligned to CACHELINE_ALIGNMENT after each payload. When the loop completes, currentOffset is already aligned, so the alignOffset call here is redundant.

However, this is defensive programming that protects against future code changes and has no performance impact.

♻️ Optional simplification
-    int64_t combinePayloadOffset = static_cast<int64_t>(alignOffset(currentOffset, CACHELINE_ALIGNMENT));
+    // currentOffset is already aligned after the loop
+    int64_t combinePayloadOffset = static_cast<int64_t>(currentOffset);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 43839c7 and 5f6ab4c.

📒 Files selected for processing (3)
  • cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp
  • tensorrt_llm/_torch/distributed/moe_alltoall.py
  • tensorrt_llm/_torch/modules/fused_moe/communication/nvlink_one_sided.py
🧰 Additional context used
📓 Path-based instructions (5)
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: The code developed for TensorRT-LLM should conform to Python 3.8+
Indent Python code with 4 spaces. Do not use tabs
Always maintain the namespace when importing Python modules, even if only one class or function from a module is used
Python filenames should use snake_case (e.g., some_file.py)
Python classes should use PascalCase (e.g., class SomeClass)
Python functions and methods should use snake_case (e.g., def my_awesome_function():)
Python local variables should use snake_case, with prefix k for variable names that start with a number (e.g., k_99th_percentile)
Python global variables should use upper snake_case with prefix G (e.g., G_MY_GLOBAL)
Python constants should use upper snake_case (e.g., MY_CONSTANT)
Avoid shadowing variables declared in an outer scope in Python
Initialize all externally visible members of a Python class in the constructor
For Python interfaces that may be used outside a file, prefer docstrings over comments
Use comments in Python for code within a function, or interfaces that are local to a file
Use Google-style docstrings for Python classes and functions, which can be parsed by Sphinx
Python attributes and variables can be documented inline with the format """<type>: Description"""
Avoid using reflection in Python when functionality can be easily achieved without reflection
When using try-except blocks in Python, limit the except clause to the smallest set of errors possible
When using try-except blocks in Python to handle multiple possible variable types (duck-typing), keep the body of the try as small as possible and use the else block for the main logic

Files:

  • tensorrt_llm/_torch/distributed/moe_alltoall.py
  • tensorrt_llm/_torch/modules/fused_moe/communication/nvlink_one_sided.py
**/*.{cpp,cc,cxx,h,hpp,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

All TensorRT-LLM source files (.cpp, .h, .cu, .py, and other source files) should contain an NVIDIA copyright header with the year of latest meaningful modification

Files:

  • tensorrt_llm/_torch/distributed/moe_alltoall.py
  • tensorrt_llm/_torch/modules/fused_moe/communication/nvlink_one_sided.py
  • cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp
**/*.{cpp,cc,cxx,h,hpp,hxx,cu,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{cpp,cc,cxx,h,hpp,hxx,cu,cuh}: Closing braces of namespaces should have a comment saying the namespace it closes (e.g., } // namespace foo)
Prefer const or constexpr variables over #defines whenever possible
A variable that is not modified after its initialization should be declared as const
For naming of constants in C++, use uppercase snakecase with prefix 'k' (e.g., kDIGIT_NUM)
Except for 0, nullptr, true, and false, all other literals should only be used for variable initialization and not in comparisons or expressions
Use Allman indentation style for brace notation in C++ code
Put the semicolon for an empty for or while loop in a new line
The statement forming the body of a switch, while, do..while, or for statement must be a compound statement (use brace-delimited statements)
If and else statements should always be followed by brace-delimited statements, even if empty or a single statement
C++ filenames should use camelCase with first letter lowercase (e.g., thisIsAFilename.cpp)
All types (including class names) in C++ should use PascalCase with uppercase first letter (e.g., FooBarClass)
Local variables, methods, and namespaces in C++ should use camelCase with first letter lowercase (e.g., localFooBar)
Non-magic-number global variables that are non-static and not defined in anonymous namespace should use camelCase prefixed with 'g' (e.g., gDontUseGlobalFoos)
Non-magic-number global variables that are static or defined in an anonymous namespace should use camelCase prefixed with 's' (e.g., sMutableStaticGlobal)
Locally visible static variables should use camelCase with 's' as the first letter (e.g., static std::once_flag sFlag;)
Public, private, and protected class member variables should use camelCase prefixed with 'm' (e.g., mNbFooValues)
Do not use Hungarian notation in C++ except for 'apps hungarian' (e.g., 'nb' to indicate count: mNbLayers)
If a constructor parameter name conflicts with a public me...

Files:

  • cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp
**/*.{cpp,cc,cxx,cu}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{cpp,cc,cxx,cu}: Use smart pointers for allocating objects on the heap in C++
Prefer unique_ptr for single resource ownership and shared_ptr for shared resource ownership in C++. Use weak_ptr only in exceptional cases
In C++ function calls where parameters are not obvious, use inline C comments to document the parameter (e.g., doSomeOperation(/* checkForErrors = */ false);)
Use the least forceful cast necessary in C++, or no cast if possible
Casting a pointer to void* in C++ should be implicit (except if removing const)
Casting in C++ should not remove any const or volatile qualification from the type of a pointer or reference
Do not use C-style casts (other than void casts) and functional notation casts (other than explicit constructor calls) in C++
Casting from void* to T* in C++ should be done with static_cast, not reinterpret_cast
Use reinterpret_cast in C++ as a last resort, where const_cast and static_cast won't work
Avoid dynamic_cast in C++
Do not use assignment operator in C++ subexpressions (e.g., x = y = z or if (x = y))
When practical, a C++ switch statement controlled by an enum should have a case for each enum value and not have a default clause
C++ switch statements should be well structured as structured multi-way branches, not as 'glorified gotos'
In C++ switch statements, prohibit fall-through except from one case label to another. Each case clause must be terminated with a break or throw
Do not end a C++ case clause with return; use break or throw instead
If a C++ switch clause is a compound statement, put the break inside the braces
Do not use C library functions in C++ whenever possible. Use C++ alternatives like brace initialization or std::fill_n() instead of memset()

Files:

  • cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp
**/*.{h,hpp,hxx,cpp,cc,cxx,cu,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

All C++ class templates, function templates, class template member functions, and class template static members must be instantiated at least once

Files:

  • cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp
🧠 Learnings (10)
📓 Common learnings
Learnt from: jhaotingc
Repo: NVIDIA/TensorRT-LLM PR: 7856
File: cpp/tensorrt_llm/thop/fp8BlockScaleMoe.cpp:159-166
Timestamp: 2025-09-19T21:28:13.751Z
Learning: In TensorRT-LLM blockScaleMoe routing (cpp/tensorrt_llm/kernels/trtllmGenKernels/blockScaleMoe/runner.cu), the DeepSeek routing method performs reinterpret_cast<float*>(routingLogits) at line 89, which could cause issues if routing_logits are BF16. However, Qwen3-FP8 models use RenormalizeNaive routing method and are not affected by this dtype casting issue.
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6915
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:4616-4626
Timestamp: 2025-08-19T03:35:20.866Z
Learning: In the MOE profiler TMA workspace preparation (cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu), the overlapping of TMA WS regions for NONE and FINALIZE variants is deliberate design to save memory space, as confirmed by djns99. The comment "reuse the same pointers to save space" reflects this intentional behavior.
📚 Learning: 2025-08-14T06:36:40.701Z
Learnt from: timlee0212
Repo: NVIDIA/TensorRT-LLM PR: 6886
File: tensorrt_llm/_torch/models/modeling_deepseekv3.py:0-0
Timestamp: 2025-08-14T06:36:40.701Z
Learning: In DeepSeek V3 model (tensorrt_llm/_torch/models/modeling_deepseekv3.py), the disagreement between AllReduce.__init__ guard and _compute_mlp_tp_size logic for MNNVL usage is expected by design. The AllReduce component and MLP TP-size computation intentionally use different criteria for MNNVL availability decisions.

Applied to files:

  • tensorrt_llm/_torch/distributed/moe_alltoall.py
📚 Learning: 2025-08-19T03:35:20.866Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6915
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:4616-4626
Timestamp: 2025-08-19T03:35:20.866Z
Learning: In the MOE profiler TMA workspace preparation (cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu), the overlapping of TMA WS regions for NONE and FINALIZE variants is deliberate design to save memory space, as confirmed by djns99. The comment "reuse the same pointers to save space" reflects this intentional behavior.

Applied to files:

  • tensorrt_llm/_torch/distributed/moe_alltoall.py
  • tensorrt_llm/_torch/modules/fused_moe/communication/nvlink_one_sided.py
  • cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp
📚 Learning: 2025-08-09T20:57:04.084Z
Learnt from: sklevtsov-nvidia
Repo: NVIDIA/TensorRT-LLM PR: 3294
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_gemm_tma_warp_specialized_input.cu:118-127
Timestamp: 2025-08-09T20:57:04.084Z
Learning: In the CUTLASS MoE finalize fusion implementation (cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_gemm_tma_warp_specialized_input.cu), when setting `fused_finalize_epilogue.stride_final_output` with shape `(hidden_size, num_output_tokens, 1)`, the `num_rows_in_final_output` should be set to `num_output_tokens` (not `hidden_size`) because of a swap+transpose operation that maps rows of the output tensor to `hidden_size` and columns to `num_output_tokens`.

Applied to files:

  • tensorrt_llm/_torch/distributed/moe_alltoall.py
  • tensorrt_llm/_torch/modules/fused_moe/communication/nvlink_one_sided.py
  • cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp
📚 Learning: 2025-09-29T15:14:28.503Z
Learnt from: amitz-nv
Repo: NVIDIA/TensorRT-LLM PR: 8063
File: tensorrt_llm/lora_manager.py:1080-1112
Timestamp: 2025-09-29T15:14:28.503Z
Learning: In tensorrt_llm/lora_manager.py, when calculating part_sizes for attn_qkv fused LoRA modules, the sizes are correctly multiplied by tp_size because model_config.num_heads and model_config.num_kv_heads are already divided by tp_size (per-TP-rank values), so multiplication is needed to get the original full concatenated dimension size. The interleave_fused_lora_weights_for_tp function provides proper validation with asserts for total size and TP divisibility.

Applied to files:

  • tensorrt_llm/_torch/modules/fused_moe/communication/nvlink_one_sided.py
📚 Learning: 2025-09-29T15:14:28.503Z
Learnt from: amitz-nv
Repo: NVIDIA/TensorRT-LLM PR: 8063
File: tensorrt_llm/lora_manager.py:1080-1112
Timestamp: 2025-09-29T15:14:28.503Z
Learning: In tensorrt_llm/lora_manager.py, when calculating part_sizes for attn_qkv fused LoRA modules, the sizes are correctly multiplied by tp_size because model_config.num_heads and model_config.num_kv_heads are already divided by tp_size (per-TP-rank values), so multiplication is needed to get the original full concatenated dimension size. The interleave_fused_lora_weights_for_tp function provides proper validation.

Applied to files:

  • tensorrt_llm/_torch/modules/fused_moe/communication/nvlink_one_sided.py
📚 Learning: 2025-08-14T23:23:27.449Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6915
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:4010-4012
Timestamp: 2025-08-14T23:23:27.449Z
Learning: For MOE (Mixture of Experts) code reviews in TensorRT-LLM, avoid repeatedly suggesting finalize fusion validation checks and safety assertions. The user djns99 has indicated these suggestions are repetitive and unwanted across multiple MOE-related changes.

Applied to files:

  • cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp
📚 Learning: 2025-09-23T15:12:38.312Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device allreduce implementation (cpp/tensorrt_llm/thop/allreduceOp.cpp), the goto pattern in runNCCLAllReduceDeviceFusion is intentionally used for future extensibility, allowing multiple switch cases to fallback to the default handler. While not aesthetically ideal, this pattern supports adding more fusion cases later that can reuse the same fallback logic.

Applied to files:

  • cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp
📚 Learning: 2025-09-19T21:28:13.751Z
Learnt from: jhaotingc
Repo: NVIDIA/TensorRT-LLM PR: 7856
File: cpp/tensorrt_llm/thop/fp8BlockScaleMoe.cpp:159-166
Timestamp: 2025-09-19T21:28:13.751Z
Learning: In TensorRT-LLM blockScaleMoe routing (cpp/tensorrt_llm/kernels/trtllmGenKernels/blockScaleMoe/runner.cu), the DeepSeek routing method performs reinterpret_cast<float*>(routingLogits) at line 89, which could cause issues if routing_logits are BF16. However, Qwen3-FP8 models use RenormalizeNaive routing method and are not affected by this dtype casting issue.

Applied to files:

  • cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp
📚 Learning: 2025-09-23T14:58:05.372Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/kernels/nccl_device/config.cu:42-49
Timestamp: 2025-09-23T14:58:05.372Z
Learning: In TensorRT-LLM NCCL device kernels (cpp/tensorrt_llm/kernels/nccl_device/), the token partitioning intentionally uses ceil-like distribution (same token_per_rank for all ranks) to ensure all ranks launch the same number of blocks. This is required for optimal NCCL device API barrier performance, even though it may launch extra blocks for non-existent tokens on later ranks. Runtime bounds checking in the kernel (blockID validation) handles the overshoot cases.

Applied to files:

  • cpp/tensorrt_llm/thop/moeAlltoAllOp.cpp
🧬 Code graph analysis (2)
tensorrt_llm/_torch/distributed/moe_alltoall.py (1)
tensorrt_llm/_torch/modules/fused_moe/communication/nvlink_one_sided.py (1)
  • get_aux_data_size (71-72)
tensorrt_llm/_torch/modules/fused_moe/communication/nvlink_one_sided.py (2)
tensorrt_llm/_torch/distributed/moe_alltoall.py (1)
  • get_aux_data_size (44-46)
tensorrt_llm/llmapi/llm_args.py (1)
  • ep_size (388-392)
⏰ 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/thop/moeAlltoAllOp.cpp (5)

207-218: LGTM! Well-documented alignment strategy.

The comments clearly explain the three-part alignment guarantee:

  1. Base workspace pointer is validated (checked at line 264)
  2. Starting offset is aligned by calculateOffsets
  3. Per-payload offsets maintain alignment during updates

This ensures recv buffers meet the 128-byte alignment requirement for vectorized load/store operations.


226-244: LGTM! Proper alignment enforcement for payloads.

The 16-byte alignment check for input payloads is appropriate since these tensors are allocated externally. The recv buffer offset calculation correctly maintains cache-line alignment by:

  1. Recording the current aligned offset
  2. Adding the payload size
  3. Aligning to the next cache-line boundary

This ensures vectorized memory operations can proceed safely.


310-312: LGTM! Consistent use of aligned offsets.

The recv buffer pointers and tensor views now correctly use payloadRecvBufferOffsets to ensure each payload buffer starts at a cache-line aligned address. This is consistent with the alignment strategy and prevents misaligned access.

Also applies to: 330-333


368-370: LGTM! Consistent alignment validation.

The 16-byte alignment check for the payload is consistent with the dispatch operation and appropriate for external tensors used in vectorized operations.


264-265: The workspace pointer alignment check is valid.

The runtime check validates that rankWorkSpacePtr is 128-byte aligned, which is guaranteed by the underlying memory allocation. MnnvlMemory allocates memory with rank_stride calculated as a multiple of fabric_page_size (512 MB), making it inherently 128-byte aligned. Since rankWorkSpacePtr = workspacePtr + epRank * workspace.stride(0) and stride(0) = rank_stride, the alignment check will always pass.

@bobboli
Copy link
Collaborator Author

bobboli commented Jan 8, 2026

/bot kill

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31031 [ run ] triggered by Bot. Commit: 5f6ab4c

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31033 [ kill ] triggered by Bot. Commit: 744e749

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31031 [ run ] completed with state ABORTED. Commit: 5f6ab4c

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31033 [ kill ] completed with state SUCCESS. Commit: 744e749
Successfully killed previous jobs for commit 744e749

@bobboli
Copy link
Collaborator Author

bobboli commented Jan 8, 2026

/bot run

@bobboli bobboli changed the title [TRTLLM-10296][fix] Fix the potential misaligned access due to vectorized ld/st instructions in NVLinkOneSided A2A. [TRTLLM-10296][fix] Fix the potential misaligned access due to vectorized ld/st instructions in NVLinkOneSided A2A. Jan 8, 2026
@tensorrt-cicd
Copy link
Collaborator

PR_Github #31041 [ run ] triggered by Bot. Commit: 744e749

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31041 [ run ] completed with state SUCCESS. Commit: 744e749
/LLM/main/L0_MergeRequest_PR pipeline #23983 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

…ons in NVLinkOneSided A2A.

Signed-off-by: Bo Li <22713281+bobboli@users.noreply.github.com>
… in the A2A kernel.

Signed-off-by: Bo Li <22713281+bobboli@users.noreply.github.com>
Signed-off-by: Bo Li <22713281+bobboli@users.noreply.github.com>
@bobboli bobboli force-pushed the alltoall_alignment branch from 744e749 to f7c55b2 Compare January 15, 2026 07:49
@bobboli
Copy link
Collaborator Author

bobboli commented Jan 15, 2026

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32096 [ run ] triggered by Bot. Commit: f7c55b2

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32096 [ run ] completed with state SUCCESS. Commit: f7c55b2
/LLM/main/L0_MergeRequest_PR pipeline #24875 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

@bobboli
Copy link
Collaborator Author

bobboli commented Jan 15, 2026

/bot run --reuse-test

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32139 [ run ] triggered by Bot. Commit: f7c55b2

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32139 [ run ] completed with state SUCCESS. Commit: f7c55b2
/LLM/main/L0_MergeRequest_PR pipeline #24917 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

@bobboli
Copy link
Collaborator Author

bobboli commented Jan 16, 2026

/bot run --reuse-test

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32202 [ run ] triggered by Bot. Commit: f7c55b2

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32202 [ run ] completed with state SUCCESS. Commit: f7c55b2
/LLM/main/L0_MergeRequest_PR pipeline #24968 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

@bobboli
Copy link
Collaborator Author

bobboli commented Jan 17, 2026

/bot run --reuse-test

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32417 [ run ] triggered by Bot. Commit: f7c55b2

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32417 [ run ] completed with state DISABLED
CI server is currently disabled for scheduled maintenance. Estimated completion time: 8 PM PST on 1/17.

@bobboli
Copy link
Collaborator Author

bobboli commented Jan 18, 2026

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32463 [ run ] triggered by Bot. Commit: f7c55b2

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32463 [ run ] completed with state SUCCESS. Commit: f7c55b2
/LLM/main/L0_MergeRequest_PR pipeline #25149 completed with status: 'SUCCESS'

@bobboli bobboli merged commit f3a985c into NVIDIA:main Jan 20, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants