[TRTLLM-9615][feat] Support synchronization through PP ranks in the distributed tuning system#10011
Conversation
|
/bot run --disable-fail-fast |
|
PR_Github #28400 [ run ] triggered by Bot. Commit: |
📝 WalkthroughWalkthroughChanges enhance distributed autotuning with pipeline-parallel cache synchronization and introduce a new backend-aware FP4 GEMM runner with independent nested tuning configuration. Changes
Sequence DiagramsequenceDiagram
participant ME as Model Engine
participant AT as AutoTuner
participant PR as Previous PP Rank
participant CR as Current Rank
participant NR as Next PP Rank
ME->>CR: _run_autotuner_warmup()
alt Non-first PP rank
CR->>PR: request cached tuning data
PR-->>CR: send cached tuning data
CR->>AT: cache_sync_pp_recv()
AT->>AT: merge received cache data
end
CR->>AT: forward pass with tuning
AT->>AT: profile & select tactics
alt Non-last PP rank
AT->>AT: cache_sync_pp_send()
AT->>NR: send collected cache data
NR-->>NR: receive for next stage
end
CR-->>ME: return tuned result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tensorrt_llm/_torch/autotuner.py (1)
121-129: Clarify the new default distributed tuning strategy and update docs accordingly
TuningConfig.distributed_tuning_strategynow defaults toDistributedTuningStrategy.BROADCAST, but the enum docstring still describesINDEPENDENTas the default for non‑comm ops. This is a user‑visible behavioral change that may surprise call sites that relied on the old implicit default.Recommend (a) updating the documentation comment to explicitly say the default is
BROADCAST, and (b) double‑checking any call sites that expect per‑rank independent tuning to ensure they now passdistributed_tuning_strategy=DistributedTuningStrategy.INDEPENDENTexplicitly.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
tensorrt_llm/_torch/autotuner.py(6 hunks)tensorrt_llm/_torch/custom_ops/torch_custom_ops.py(2 hunks)tensorrt_llm/_torch/pyexecutor/model_engine.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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 in Python, even if only one class or function from a module is used (e.g., usefrom package.subpackage import fooand thenfoo.SomeClass()instead offrom package.subpackage.foo import SomeClass)
Python filenames should use snake_case (e.g.,some_file.py)
Python class names should use PascalCase (e.g.,class SomeClass)
Python function and method names should use snake_case (e.g.,def my_awesome_function():)
Python local variable names should use snake_case, with prefixkfor variable names that start with a number (e.g.,k_99th_percentile = ...)
Python global variables should use upper snake_case with prefixG(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
Python comments should be reserved 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 type and description (e.g.,self.x = 5followed by"""<type>: Description of 'x'""")
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 specific errors possible instead of catching all exceptions
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 to implement the logic
Files:
tensorrt_llm/_torch/pyexecutor/model_engine.pytensorrt_llm/_torch/autotuner.pytensorrt_llm/_torch/custom_ops/torch_custom_ops.py
**/*.{cpp,h,cu,py}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
All TensorRT-LLM Open Source Software code files should contain an NVIDIA copyright header that includes the current year at the top
Files:
tensorrt_llm/_torch/pyexecutor/model_engine.pytensorrt_llm/_torch/autotuner.pytensorrt_llm/_torch/custom_ops/torch_custom_ops.py
🧠 Learnings (6)
📚 Learning: 2025-08-19T12:45:11.997Z
Learnt from: amitz-nv
Repo: NVIDIA/TensorRT-LLM PR: 7033
File: tensorrt_llm/_torch/pyexecutor/model_engine.py:0-0
Timestamp: 2025-08-19T12:45:11.997Z
Learning: In tensorrt_llm/_torch/pyexecutor/model_engine.py, DoRA (Delta Orthogonal Rank Adaptation) functionality was removed from the PyTorch flow to eliminate issues with inverted DoRA detection logic. The original is_dora condition was checking if scaling_vec_pointer == 0, which was potentially incorrect.
Applied to files:
tensorrt_llm/_torch/pyexecutor/model_engine.py
📚 Learning: 2025-07-17T09:01:27.402Z
Learnt from: amitz-nv
Repo: NVIDIA/TensorRT-LLM PR: 5616
File: tensorrt_llm/executor/worker.py:375-384
Timestamp: 2025-07-17T09:01:27.402Z
Learning: In tensorrt_llm/executor/worker.py, the LoRA adapter cache optimization logic that checks `is_adapter_in_cpu_cache()` and conditionally passes None for weights/config has a known race condition issue that cannot be solved with simple error handling or verification checks. This is a known limitation that requires a more comprehensive solution.
Applied to files:
tensorrt_llm/_torch/pyexecutor/model_engine.py
📚 Learning: 2025-08-21T09:41:49.347Z
Learnt from: eopXD
Repo: NVIDIA/TensorRT-LLM PR: 6768
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:2010-2045
Timestamp: 2025-08-21T09:41:49.347Z
Learning: In cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, updateSequenceCacheBlockOffsets is specifically for updating bookkeeping when blocks are added during the context phase, not for refreshing offsets after detach operations. During detach operations, GenerationRequest::removeFrontBlock handles the necessary cache block bookkeeping internally.
Applied to files:
tensorrt_llm/_torch/pyexecutor/model_engine.py
📚 Learning: 2025-12-12T03:27:08.565Z
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 9655
File: tensorrt_llm/_torch/pyexecutor/sampler.py:3031-3031
Timestamp: 2025-12-12T03:27:08.565Z
Learning: In files under tensorrt_llm/_torch/pyexecutor, avoid accessing torch.Tensor objects inside for-loops when iterating over requests. Convert batched tensors to Python lists beforehand using tensor.tolist(), and then iterate over those lists. This improves performance by reducing tensor-bound operations inside hot loops. Apply this pattern to similar code paths that process batches to access simple Python data structures (lists) inside loops.
Applied to files:
tensorrt_llm/_torch/pyexecutor/model_engine.py
📚 Learning: 2025-11-14T11:22:03.729Z
Learnt from: nzmora-nvidia
Repo: NVIDIA/TensorRT-LLM PR: 9163
File: tensorrt_llm/_torch/auto_deploy/custom_ops/quant.py:107-113
Timestamp: 2025-11-14T11:22:03.729Z
Learning: In TensorRT-LLM AutoDeploy custom ops, when adding hardware capability checks to select between kernel implementations (e.g., cuBLAS vs. CUDA kernel), use descriptive variable names that identify the specific GPU architectures or families being targeted (e.g., `is_blackwell_geforce_or_ada`) rather than generic names like `enable_cuda_core`. This makes it clear that the code is selecting an implementation path based on hardware capabilities, not enabling/disabling hardware features.
Applied to files:
tensorrt_llm/_torch/custom_ops/torch_custom_ops.py
📚 Learning: 2025-12-12T10:07:31.564Z
Learnt from: lirundong
Repo: NVIDIA/TensorRT-LLM PR: 9725
File: tensorrt_llm/_torch/custom_ops/cuda_tile_custom_ops.py:110-178
Timestamp: 2025-12-12T10:07:31.564Z
Learning: In PyTorch custom operators registered with torch.library.custom_op, mutable operators that return None and specify mutates_args do not require a register_fake decorator. Mutation tracking is handled automatically without needing a FakeTensor kernel. This applies to Python custom op definitions in tensorrt_llm/_torch/custom_ops that use mutates_args and return None; verify you are not relying on register_fake in these cases.
Applied to files:
tensorrt_llm/_torch/custom_ops/torch_custom_ops.py
🧬 Code graph analysis (2)
tensorrt_llm/_torch/pyexecutor/model_engine.py (1)
tensorrt_llm/_torch/autotuner.py (3)
get(624-627)cache_sync_pp_recv(1520-1524)cache_sync_pp_send(1526-1539)
tensorrt_llm/_torch/custom_ops/torch_custom_ops.py (2)
tensorrt_llm/_torch/autotuner.py (4)
TuningConfig(72-128)DynamicTensorSpec(42-54)ConstraintSpec(58-68)DistributedTuningStrategy(26-38)tensorrt_llm/_torch/utils.py (3)
get_last_power_of_2_num_tokens_buckets(276-283)last_positive_power_of_2(253-258)fp4_scale_infer_shape(286-291)
⏰ 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 (4)
tensorrt_llm/_torch/pyexecutor/model_engine.py (1)
652-661: PP cache sync hooks correctly wrapped around autotuner warmup forwardThe pre‑forward
cache_sync_pp_recv()and post‑forwardcache_sync_pp_send()calls are placed in the right spot (inside the autotune context and aftersetup_distributed_state), so the PP cache is synchronized only when a real warmup batch exists. The integration here looks sound; any safety checks aroundmapping/distare appropriately centralized inAutoTuner.tensorrt_llm/_torch/autotuner.py (2)
360-365: Profiling cache typing & merge helper look consistentAnnotating
self.cacheasDict[Tuple, Tuple]and wiringmerge_cache_data()to a simpledict.update()matches how keys/values are produced (get_cache_key, JSON (de)serialization) and consumed (get_specific_custom_op, TP/PP merge/broadcast paths). No functional issues here.Also applies to: 433-438
617-620: Per‑op distributed strategy tracking for PP sync is reasonableRecording
tuning_config.distributed_tuning_strategyinto_map_op_to_distributed_strategy[custom_op]insidechoose_one()gives the PP sync code enough information to skipINDEPENDENTops while still handling others. This is a low‑overhead way to drive the new PP cache propagation without changing existing tuning callsites.Also applies to: 806-809
tensorrt_llm/_torch/custom_ops/torch_custom_ops.py (1)
694-703: NVFP4 unified runner tuning config and independent distributed strategy look correctDefining
NVFP4GemmUnifiedRunner.tuning_configwith the sameDynamicTensorSpec/ConstraintSpecasFP4GemmRunnerwhile explicitly settingdistributed_tuning_strategy=DistributedTuningStrategy.INDEPENDENTkeeps the existing shape‑bucket behavior but marks the top‑leveltrtllm::nvfp4_gemm::gemmtuning as per‑rank only. Wiringnvfp4_gemmto passNVFP4GemmUnifiedRunner.tuning_configintoAutoTuner.choose_oneensures this independent strategy is actually used.That fits well with the new PP cache sync semantics: lower‑level FP4/cuBLASLt/CuteDSL kernels can still use BROADCAST/MERGE as needed, while the unified backend selection remains nested and PP‑local.
Also applies to: 952-957
|
PR_Github #28400 [ run ] completed with state |
|
/bot run --disable-fail-fast |
|
PR_Github #28470 [ run ] triggered by Bot. Commit: |
|
PR_Github #28470 [ run ] completed with state |
|
/bot run --disable-fail-fast |
|
PR_Github #28542 [ run ] triggered by Bot. Commit: |
|
PR_Github #28542 [ run ] completed with state
|
02c8eae to
2b0ead5
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #28720 [ run ] triggered by Bot. Commit: |
|
PR_Github #28720 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
1 similar comment
|
/bot run --disable-fail-fast |
|
PR_Github #28903 [ run ] triggered by Bot. Commit: |
|
PR_Github #28903 [ run ] completed with state |
dcf589b to
231f7c4
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #29125 [ run ] triggered by Bot. Commit: |
|
PR_Github #29497 [ run ] triggered by Bot. Commit: |
|
PR_Github #29497 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #29514 [ run ] triggered by Bot. Commit: |
Signed-off-by: Yukun He <23156053+hyukn@users.noreply.github.com>
70317dc to
a7d3db7
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #29523 [ run ] triggered by Bot. Commit: |
|
PR_Github #29523 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #29528 [ run ] triggered by Bot. Commit: |
|
/bot run --disable-fail-fast |
|
PR_Github #29571 [ run ] triggered by Bot. Commit: |
|
/bot run --disable-fail-fast |
|
PR_Github #29609 [ run ] triggered by Bot. Commit: |
|
PR_Github #29609 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #29679 [ run ] triggered by Bot. Commit: |
|
PR_Github #29679 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #29720 [ run ] triggered by Bot. Commit: |
|
PR_Github #29720 [ run ] completed with state |
…istributed tuning system (NVIDIA#10011) Signed-off-by: Yukun He <23156053+hyukn@users.noreply.github.com>
…istributed tuning system (NVIDIA#10011) Signed-off-by: Yukun He <23156053+hyukn@users.noreply.github.com> Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com>
…istributed tuning system (NVIDIA#10011) Signed-off-by: Yukun He <23156053+hyukn@users.noreply.github.com>
…istributed tuning system (NVIDIA#10011) Signed-off-by: Yukun He <23156053+hyukn@users.noreply.github.com> Signed-off-by: Daniil Kulko <kulkodaniil@gmail.com>
Summary by CodeRabbit
Release Notes
New Features
Updates
✏️ 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 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.