-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[TRTLLM-6174][feat] Enable FP32 mamba ssm cache #6574
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
[TRTLLM-6174][feat] Enable FP32 mamba ssm cache #6574
Conversation
📝 WalkthroughWalkthroughThis change introduces a new configuration option for specifying the data type used in the Mamba SSM cache throughout the codebase. It adds new fields and parameters to configuration and model classes, updates resource managers to handle the new dtype, and propagates this option through the cache management and model execution pipeline. Associated tests are updated to parameterize and verify this new option. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant LLM API
participant PyTorchConfig
participant ResourceManager
participant Mamba2Mixer
participant ScanCombined
User->>LLM API: Set mamba_ssm_cache_dtype (via config/args)
LLM API->>PyTorchConfig: Pass mamba_ssm_cache_dtype
PyTorchConfig->>ResourceManager: Pass mamba_ssm_cache_dtype to cache manager
ResourceManager->>Mamba2Mixer: Expose mamba_ssm_cache_dtype via get_mamba_ssm_cache_dtype
Mamba2Mixer->>ScanCombined: Call mamba_chunk_scan_combined(..., mamba_ssm_cache_dtype)
ScanCombined->>ScanCombined: Use mamba_ssm_cache_dtype for SSM state allocation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Note 🔌 MCP (Model Context Protocol) integration is now available in Early Access!Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
/bot run |
PR_Github #13865 [ run ] triggered by Bot |
PR_Github #13865 [ run ] completed with state |
a722381
to
cea6d82
Compare
/bot run --disable-fail-fast |
PR_Github #14155 [ run ] triggered by Bot |
PR_Github #14155 [ run ] completed with state |
/bot run --disable-fail-fast |
PR_Github #14219 [ run ] triggered by Bot |
bb5c6fd
to
72f98fa
Compare
/bot run --disable-fail-fast |
PR_Github #14261 [ run ] triggered by Bot |
/bot run --disable-fail-fast |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
.devcontainer/docker-compose.yml (1)
24-27
: Commenting-out the Hugging Face cache mount may slow dev workflows – consider a conditional mount insteadWith the host cache disabled every container rebuild/download will fetch models from scratch, which can be several GB and noticeably slow CI & local iterations.
If the original issue was hosts that don’t have a GPU/HF cache, you can keep the performance benefit while retaining portability:- #- ${LOCAL_HF_HOME}:/huggingface # HF cache + # Mount HF cache only when the env-var is set + ${LOCAL_HF_HOME:-/nonexistent}:/huggingface:roDocker Compose will skip the mount when
LOCAL_HF_HOME
is unset (or you can wrap with a separateprofiles:
entry).
Please verify that repeated model downloads are acceptable for all users/CI runners before merging.tests/unittest/api_stability/references/quant_config.yaml (1)
19-21
: Consider narrowing the type annotation to the supported dtypes.
Optional[str]
gives no compile-time guidance and may hide typos ("fp32"
vs"fp32 "
).
If only a small, closed set of dtypes is valid (e.g."fp16" | "fp32" | "bf16"
), consider updating the sourceQuantConfig
dataclass to:from typing import Literal, Optional mamba_ssm_cache_dtype: Optional[Literal["fp16", "fp32", "bf16"]] = NoneThat will automatically propagate to this reference file and tighten API contracts.
Please confirm whether additional dtypes are expected; if so, enumerate them or keep
str
intentionally.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
.devcontainer/docker-compose.yml
(1 hunks)tensorrt_llm/_torch/modules/mamba/mamba2_mixer.py
(2 hunks)tensorrt_llm/_torch/modules/mamba/ssd_combined.py
(6 hunks)tensorrt_llm/_torch/pyexecutor/_util.py
(2 hunks)tensorrt_llm/_torch/pyexecutor/config.py
(1 hunks)tensorrt_llm/_torch/pyexecutor/model_engine.py
(3 hunks)tensorrt_llm/_torch/pyexecutor/resource_manager.py
(5 hunks)tensorrt_llm/bench/benchmark/low_latency.py
(1 hunks)tensorrt_llm/bench/benchmark/throughput.py
(1 hunks)tensorrt_llm/bench/benchmark/utils/general.py
(5 hunks)tensorrt_llm/bench/build/dataclasses.py
(2 hunks)tensorrt_llm/bench/build/tuning.py
(2 hunks)tensorrt_llm/commands/serve.py
(5 hunks)tensorrt_llm/llmapi/llm_args.py
(2 hunks)tensorrt_llm/models/modeling_utils.py
(1 hunks)tests/unittest/_torch/modeling/test_modeling_nemotron_h.py
(4 hunks)tests/unittest/api_stability/references/quant_config.yaml
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- tensorrt_llm/_torch/pyexecutor/config.py
🚧 Files skipped from review as they are similar to previous changes (14)
- tensorrt_llm/_torch/pyexecutor/_util.py
- tensorrt_llm/models/modeling_utils.py
- tensorrt_llm/bench/benchmark/low_latency.py
- tensorrt_llm/_torch/modules/mamba/ssd_combined.py
- tensorrt_llm/_torch/pyexecutor/model_engine.py
- tensorrt_llm/bench/benchmark/throughput.py
- tests/unittest/_torch/modeling/test_modeling_nemotron_h.py
- tensorrt_llm/_torch/modules/mamba/mamba2_mixer.py
- tensorrt_llm/bench/build/tuning.py
- tensorrt_llm/bench/benchmark/utils/general.py
- tensorrt_llm/_torch/pyexecutor/resource_manager.py
- tensorrt_llm/llmapi/llm_args.py
- tensorrt_llm/bench/build/dataclasses.py
- tensorrt_llm/commands/serve.py
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: in tensorrt-llm, test files (files under tests/ directories) do not require nvidia copyright headers...
Learnt from: galagam
PR: NVIDIA/TensorRT-LLM#6487
File: tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py:1-12
Timestamp: 2025-08-06T13:58:07.506Z
Learning: In TensorRT-LLM, test files (files under tests/ directories) do not require NVIDIA copyright headers, unlike production source code files. Test files typically start directly with imports, docstrings, or code.
Applied to files:
.devcontainer/docker-compose.yml
📚 Learning: in tensorrt-llm, examples directory can have different dependency versions than the root requirement...
Learnt from: yibinl-nvidia
PR: NVIDIA/TensorRT-LLM#6506
File: examples/models/core/mixtral/requirements.txt:3-3
Timestamp: 2025-08-01T15:14:45.673Z
Learning: In TensorRT-LLM, examples directory can have different dependency versions than the root requirements.txt file. Version conflicts between root and examples dependencies are acceptable because examples are designed to be standalone and self-contained.
Applied to files:
.devcontainer/docker-compose.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Pre-commit Check
🔇 Additional comments (1)
tests/unittest/api_stability/references/quant_config.yaml (1)
19-21
: API-stability baseline updated – ensure downstream tests are refreshed.Adding a new parameter means any existing serialized configs or golden API-stability snapshots must be regenerated. Verify that:
- All existing YAML baselines were updated (not only this one).
- CI includes at least one test case exercising
mamba_ssm_cache_dtype="fp32"
to avoid regressions.Failing to do so will cause silent drift between implementation and reference data.
PR_Github #14394 [ run ] triggered by Bot |
/bot run --disable-fail-fast |
PR_Github #14418 [ run ] triggered by Bot |
PR_Github #14394 [ run ] completed with state |
PR_Github #14418 [ run ] completed with state |
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.
Nice! I like it better in the quant config. Makes much more sense
Thanks for the changes in all the entrypoints and in max batch size tuning as well
Generally approved, just uncomment the forgotten commented line
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.
uncommented that line. Approved
/bot run |
PR_Github #14516 [ run ] triggered by Bot |
PR_Github #14516 [ run ] completed with state |
Signed-off-by: Shahar Mor <[email protected]> refactor mamba ssm cache dtype init Signed-off-by: Shahar Mor <[email protected]>
9df6d72
to
32da275
Compare
/bot run |
PR_Github #14699 [ run ] triggered by Bot |
PR_Github #14699 [ run ] completed with state |
Signed-off-by: Shahar Mor <[email protected]>
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.
LGTM
/bot run |
PR_Github #14711 [ run ] triggered by Bot |
PR_Github #14711 [ run ] completed with state |
Summary by CodeRabbit
New Features
Tests
Description
Test Coverage
GitHub Bot Help
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...
Provide a user friendly way for developers to interact with a Jenkins server.
Run
/bot [-h|--help]
to print this help message.See details below for each supported subcommand.
run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]
Launch build/test pipelines. All previously running jobs will be killed.
--reuse-test (optional)pipeline-id
(OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.--disable-reuse-test
(OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.--disable-fail-fast
(OPTIONAL) : Disable fail fast on build/tests/infra failures.--skip-test
(OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.--stage-list "A10-PyTorch-1, xxx"
(OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.--gpu-type "A30, H100_PCIe"
(OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.--test-backend "pytorch, cpp"
(OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.--only-multi-gpu-test
(OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.--disable-multi-gpu-test
(OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.--add-multi-gpu-test
(OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.--post-merge
(OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx"
(OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".--detailed-log
(OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.--debug
(OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in thestage-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.