Repository navigation
[v1] - Mamba1 Attention Metadata - #21249
Conversation
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
There was a problem hiding this comment.
Code Review
This pull request introduces v1-style attention metadata support for Mamba-1 models and refactors the Mamba state shape calculation into a centralized MambaStateShapeCalculator class. The refactoring improves code organization and maintainability. The v1 support is well-integrated, with clear logic separation based on the VLLM_USE_V1 environment variable.
heheda12345
left a comment
There was a problem hiding this comment.
Thanks for the great job.
Some questions:
- Do we need
enforce-eagerto run mamba1? I'm OK with supporting cuda graph in a future PR. - Can you show some lm-eval result on mamba1 model?
- Please update
tests/models/language/generation/test_hybrid.pyandtests/v1/test_oracle.py - Is Jamba supported now?
- Please update the doc like https://docs.vllm.ai/en/latest/usage/v1_guide.html#mamba-models and https://docs.vllm.ai/en/latest/usage/v1_guide.html#mamba-models
|
This pull request has merge conflicts that must be resolved before it can be |
There was a problem hiding this comment.
How different is the Mamba1AttentionMetdata to the Mamba2AttentionMetadata? Do we really need two separate classes?
There was a problem hiding this comment.
Good question. I think we should keep both since Mamba2AttentionMetadata contains fields that aren't relevant for mamba1 like chunk_indices, chunk_offsets and triton kernels related fields that mamba1 doesn't need which would add overhead to the class.
There was a problem hiding this comment.
I prefer to keep mamba1 and mamba2 as seperate metadata classes. Comparing with one metadata class with many optional entry and branches for different types of layers, I prefer this pluggable design. We can extract common logic to a parent class if we find some after more models like minimax are added. @tdoublep WDYT?
There was a problem hiding this comment.
@heheda12345 Sorry I missed this question. Yes I agree let's keep the metadata classes separate and then factor the common things into a CommonMambaAttentionMetadata or something once it is clear what is truly common. This one is ready and we have the LFM2 and MiniMax-Text ones nearly there too, so we should be able to look at that soon.
There was a problem hiding this comment.
I prefer to keep mamba1 and mamba2 as seperate metadata classes. Comparing with one metadata class with many optional entry and branches for different types of layers, I prefer this pluggable design. We can extract common logic to a parent class if we find some after more models like minimax are added. @tdoublep WDYT?
|
This pull request has merge conflicts that must be resolved before it can be |
|
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: asafg <asafg@ai21.com>
|
PR looks good. Thanks for adding Jamba and Mamba1 to V1! |
|
V1 test failure is known flaky test (see #22385), and the quantization test and blackwell tests look unrelated. This one is good to merge imo. |
Signed-off-by: asafg <asafg@ai21.com> Co-authored-by: asafg <asafg@ai21.com> Signed-off-by: Jinzhen Lin <linjinzhen@hotmail.com>
Signed-off-by: asafg <asafg@ai21.com> Co-authored-by: asafg <asafg@ai21.com> Signed-off-by: Noam Gat <noamgat@gmail.com>
Signed-off-by: asafg <asafg@ai21.com> Co-authored-by: asafg <asafg@ai21.com>
Signed-off-by: asafg <asafg@ai21.com> Co-authored-by: asafg <asafg@ai21.com>
Signed-off-by: asafg <asafg@ai21.com> Co-authored-by: asafg <asafg@ai21.com> Signed-off-by: Diego-Castan <diego.castan@ibm.com>
Signed-off-by: asafg <asafg@ai21.com> Co-authored-by: asafg <asafg@ai21.com>
Signed-off-by: asafg <asafg@ai21.com> Co-authored-by: asafg <asafg@ai21.com> Signed-off-by: Xiao Yu <xiao.yu@amd.com>
Signed-off-by: asafg <asafg@ai21.com> Co-authored-by: asafg <asafg@ai21.com>
Signed-off-by: asafg <asafg@ai21.com> Co-authored-by: asafg <asafg@ai21.com>
Signed-off-by: asafg <asafg@ai21.com> Co-authored-by: asafg <asafg@ai21.com>
Signed-off-by: asafg <asafg@ai21.com> Co-authored-by: asafg <asafg@ai21.com>
Signed-off-by: asafg <asafg@ai21.com> Co-authored-by: asafg <asafg@ai21.com>
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.Purpose
Add full v1-style attention-metadata support to Mamba-1 models. The following was added
Mamba1AttentionMetadataBuilderto create the attention metadata for mamba-1 modelsMambaStateShapeCalculatoraggregated mamba state shape calculation logic for all mamba models under the same static class for better readability and navigationselective_scan_fwdto support V1 memory layoutTest Plan
Updated the following tests -
test_hybrid.py- Now tests Mamba1 and Jamba in V1test_oracle.py- Removed Mamba1 from unsupported V1 modelRunning all tests in
test_hybrid.py,test_oracle.pyandtest_mamba_ssm.py(due to kernel change) pass.Running mamba1 in main branch would raise an error
lm_eval results with
state-spaces/mamba-130m-hfvLLM V0 with Mamba1
VLLM_USE_V1=0 HF_ALLOW_CODE_EVAL=1 lm_eval --model vllm \ --model_args pretrained=state-spaces/mamba-130m-hf,enforce_eager=True,enable_prefix_caching=False,tensor_parallel_size=1 \ --tasks humaneval \ --batch_size auto \ --confirm_run_unsafe_code | Tasks |Version| Filter |n-shot|Metric| |Value | |Stderr| |---------|------:|-----------|-----:|------|---|-----:|---|-----:| |humaneval| 1|create_test| 0|pass@1| |0.0244|± |0.0121|vLLM V1 with Mamba1
VLLM_USE_V1=1 HF_ALLOW_CODE_EVAL=1 lm_eval --model vllm \ --model_args pretrained=state-spaces/mamba-130m-hf,enable_prefix_caching=False,tensor_parallel_size=1 \ --tasks humaneval \ --batch_size auto \ --confirm_run_unsafe_code | Tasks |Version| Filter |n-shot|Metric| |Value | |Stderr| |---------|------:|-----------|-----:|------|---|-----:|---|-----:| |humaneval| 1|create_test| 0|pass@1| |0.0244|± |0.0121|This PR now enables this vLLM V1 to work with models that use Mamba1 like Mamba1 and Jamba