Skip to content

Conversation

@lucaslie
Copy link
Member

@lucaslie lucaslie commented Oct 30, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved data type handling consistency for Mamba model caching and state management.
    • Enhanced metadata preparation for better model compatibility.
  • Refactor

    • Streamlined backend architecture for improved code maintainability and reduced complexity.

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

  • 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.

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.

Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>
@lucaslie lucaslie requested a review from a team as a code owner October 30, 2025 20:56
@lucaslie lucaslie requested a review from MrGeva October 30, 2025 20:56
@lucaslie lucaslie self-assigned this Oct 30, 2025
@lucaslie lucaslie moved this from Backlog to In review in AutoDeploy Board Oct 30, 2025
@lucaslie lucaslie linked an issue Oct 30, 2025 that may be closed by this pull request
1 task
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2025

📝 Walkthrough

Walkthrough

These changes extend the Mamba SSM caching infrastructure by introducing a dedicated dtype configuration option, updating metadata tuple signatures to include additional state information, and refactoring the Triton backend to inherit from the Torch backend implementation to eliminate duplicate interface methods.

Changes

Cohort / File(s) Summary
Cache Configuration Enhancement
tensorrt_llm/_torch/auto_deploy/custom_ops/attention_interface.py
Added optional mamba_dtype field to CacheConfig dataclass to support dtype-specific caching logic for Mamba operations.
Torch Backend Mamba Updates
tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/torch_backend_mamba.py
Updated get_prepare_metadata_op to return 4-tuple including use_initial_states flag. Modified get_cache_initializers to derive dtype from source node metadata and use cache_config.mamba_dtype as fallback for SSM cache construction.
Triton Backend Refactoring
tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/triton_backend_mamba.py
Changed TritonBackendSSM inheritance from AttentionDescriptor to TorchBackendSSM. Removed 8 duplicate methods (is_paged, get_attention_layout, get_num_qkv_args, get_source_attention_op, get_prepare_metadata_op, get_cache_initializers, get_global_buffer_initializers, get_constants). Retained only get_cached_attention_op as the public interface. Updated imports accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant TorchBackendSSM as get_cache_initializers<br/>(Torch Backend)
    participant NodeMeta as source_attn_node<br/>.meta["val"]
    participant CacheConfig
    participant SSMCache as ssm_state_cache

    Caller->>TorchBackendSSM: get_cache_initializers(source_attn_node, cache_config)
    TorchBackendSSM->>NodeMeta: Extract dtype
    NodeMeta-->>TorchBackendSSM: dtype (from node metadata)
    TorchBackendSSM->>CacheConfig: Check cache_config.mamba_dtype
    alt mamba_dtype available
        CacheConfig-->>TorchBackendSSM: mamba_dtype
        TorchBackendSSM->>SSMCache: Create with mamba_dtype
    else mamba_dtype not set
        CacheConfig-->>TorchBackendSSM: None
        TorchBackendSSM->>SSMCache: Use node dtype as fallback
    end
    SSMCache-->>Caller: Cache with resolved dtype
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • triton_backend_mamba.py — Requires careful verification that inheriting from TorchBackendSSM correctly replaces all 8 removed methods and that the public API contract is maintained. Ensure no unintended behavioral changes from inheritance-based method resolution.
  • torch_backend_mamba.py — Verify dtype resolution logic correctly prioritizes cache_config.mamba_dtype over node dtype, and confirm the expanded 4-tuple return from get_prepare_metadata_op is handled correctly by all callers.
  • attention_interface.py — Confirm backward compatibility; the optional field should not affect existing code paths that don't use it.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description is largely incomplete and consists primarily of template boilerplate with empty placeholders. The "Description" section contains only a comment placeholder with no explanation of the issue or solution, the "Test Coverage" section is similarly empty with only a comment, and while the final PR Checklist item is checked, none of the substantive guidance items regarding code guidelines, test cases, dependencies, or documentation are addressed. This represents a failure to meet the basic requirement of communicating what changes were made and why they were necessary. The author should fill in the Description section with a clear explanation of the issue being fixed (mamba cache dtype extraction) and the solution implemented. Additionally, the Test Coverage section must include information about what tests validate these changes, and the PR Checklist items should be verified and commented on as appropriate for the changes made. At minimum, the description should explain the motivation for changing the cache dtype handling and the impact of the triton backend refactoring.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "[#8763][fix] AutoDeploy: correct mamba cache dtype extraction" clearly and specifically describes the main technical issue being addressed in the changes. While the changeset includes additional refactoring (such as TritonBackendSSM class hierarchy changes), the title appropriately focuses on the primary fix: correcting how mamba cache dtype is extracted and used in the cache configuration system. The title follows the repository template format, is concise and readable, and provides enough specificity for a developer scanning history to understand the core change.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent 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 b87448b and 9bb6822.

📒 Files selected for processing (3)
  • tensorrt_llm/_torch/auto_deploy/custom_ops/attention_interface.py (1 hunks)
  • tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/torch_backend_mamba.py (3 hunks)
  • tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/triton_backend_mamba.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Use only spaces, no tabs; indent with 4 spaces.

Files:

  • tensorrt_llm/_torch/auto_deploy/custom_ops/attention_interface.py
  • tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/torch_backend_mamba.py
  • tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/triton_backend_mamba.py
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: Python code must target Python 3.8+.
Indent Python code with 4 spaces; do not use tabs.
Maintain module namespace when importing; prefer 'from package.subpackage import foo' then 'foo.SomeClass()' instead of importing the class directly.
Python filenames should be snake_case (e.g., some_file.py).
Python classes use PascalCase names.
Functions and methods use snake_case names.
Local variables use snake_case; prefix 'k' for variables that start with a number (e.g., k_99th_percentile).
Global variables use upper SNAKE_CASE prefixed with 'G' (e.g., G_MY_GLOBAL).
Constants use upper SNAKE_CASE (e.g., MY_CONSTANT).
Avoid shadowing variables from an outer scope.
Initialize all externally visible members of a class in the constructor.
Prefer docstrings for interfaces that may be used outside a file; comments for in-function or file-local interfaces.
Use Google-style docstrings for classes and functions (Sphinx-parsable).
Document attributes and variables inline so they render under the class/function docstring.
Avoid reflection when a simpler, explicit approach suffices (e.g., avoid dict(**locals()) patterns).
In try/except, catch the most specific exceptions possible.
For duck-typing try/except, keep the try body minimal and use else for the main logic.

Files:

  • tensorrt_llm/_torch/auto_deploy/custom_ops/attention_interface.py
  • tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/torch_backend_mamba.py
  • tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/triton_backend_mamba.py
**/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).

Files:

  • tensorrt_llm/_torch/auto_deploy/custom_ops/attention_interface.py
  • tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/torch_backend_mamba.py
  • tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/triton_backend_mamba.py
🧠 Learnings (2)
📓 Common learnings
Learnt from: Fridah-nv
PR: NVIDIA/TensorRT-LLM#6760
File: tensorrt_llm/_torch/auto_deploy/models/quant_config_reader.py:81-98
Timestamp: 2025-08-09T02:04:49.623Z
Learning: In TensorRT-LLM's auto_deploy module, torch.dtype values in configuration dictionaries must be stored as string representations (e.g., "float16" instead of torch.float16) because OmegaConf.merge does not support torch.dtype types. These string representations are converted to actual torch.dtype objects in downstream code.
Learnt from: ixlmar
PR: NVIDIA/TensorRT-LLM#8263
File: examples/models/contrib/sdxl/run_sdxl.py:0-0
Timestamp: 2025-10-13T13:55:04.170Z
Learning: The `diffusers` library (e.g., `DiffusionPipeline`, `StableDiffusionXLPipeline`, `StableDiffusion3Pipeline`) uses the `torch_dtype` parameter in `from_pretrained()` calls, not `dtype`. Only the `transformers` library has migrated to using `dtype`.
📚 Learning: 2025-10-20T16:54:09.824Z
Learnt from: nvchenghaoz
PR: NVIDIA/TensorRT-LLM#8469
File: tensorrt_llm/_torch/auto_deploy/custom_ops/rms_norm.py:6-6
Timestamp: 2025-10-20T16:54:09.824Z
Learning: In tensorrt_llm/_torch/auto_deploy/custom_ops/rms_norm.py, the import `from ...modules.mamba.layernorm_gated import _layer_norm_fwd` is correct and should not be changed to modules.fla.layernorm_gated. The _layer_norm_fwd function exists in both modules/mamba/layernorm_gated.py and modules/fla/layernorm_gated.py, but the mamba version is the intended implementation for this use case.

Applied to files:

  • tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/triton_backend_mamba.py
🧬 Code graph analysis (1)
tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/triton_backend_mamba.py (2)
tensorrt_llm/_torch/auto_deploy/custom_ops/attention_interface.py (2)
  • AttentionRegistry (859-882)
  • MHACallable (695-699)
tensorrt_llm/_torch/auto_deploy/custom_ops/mamba/torch_backend_mamba.py (1)
  • TorchBackendSSM (302-375)
⏰ 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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

[Feature]: AutoDeploy: Allow for specifying mamba cache dtype

1 participant