[NVIDIA] Add Cutlass MLA backend - #17625
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 🚀 |
876c9c4 to
3028233
Compare
| if any(unsupported_features): | ||
| raise NotImplementedError( | ||
| "TritonMLAImpl does not support one of the following: " | ||
| "alibi_slopes, sliding_window, blocksparse_params, " | ||
| "logits_soft_cap") | ||
|
|
||
| if attn_type != AttentionType.DECODER: | ||
| raise NotImplementedError("Encoder self-attention and " | ||
| "encoder/decoder cross-attention " | ||
| "are not implemented for " | ||
| "TritonMLAImpl") | ||
|
|
||
| if is_quantized_kv_cache(self.kv_cache_dtype): | ||
| raise NotImplementedError( | ||
| "TritonMLA V1 with FP8 KV cache not yet supported") |
There was a problem hiding this comment.
Make sure to update the messages for CutlassMLA
LucasWilkinson
left a comment
There was a problem hiding this comment.
The perf is looking really good! thanks for the contribution!
Do you mind doing accuracy checks
VLLM_ATTENTION_BACKEND=CUTLASS_MLA_VLLM_V1 VLLM_USE_V1=1 lm-eval --model vllm --model_args pretrained=deepseek-ai/DeepSeek-V2-Lite-Chat,tensor_parallel_size=2,dtype=auto,gpu_memory_utilization=0.9,trust_remote_code=True,max_model_len=16384 --task gsm8k --num_fewshot 5 --batch_size auto
| self.aot_schedule = current_platform.is_cuda() | ||
|
|
||
| # Dont try to access the runner on AMD | ||
| if self.aot_schedule: |
There was a problem hiding this comment.
we should leave
self.aot_schedule = is_vllm_fa and (get_flash_attn_version() == 3)
and updated:
if current_platform.is_cuda():
self.page_size = self.runner.block_size
to
if self.aot_schedule:
self.page_size = self.runner.block_size
There was a problem hiding this comment.
Do you mean we should do:
self.aot_schedule = is_vllm_fa and (get_flash_attn_version() == 3)
if current_platform.is_cuda():
self.page_size = self.runner.block_size
(... since the self.aot_schedule might be used elsewhere?)
There was a problem hiding this comment.
oh sorry ya aot_schedule is not actually used, aot_schedule stands for ahead-of-time schedule and was meant to indicate if we should use the ahead of time scheduler for flash-attn (something I may add, when I updated FA I had added it for the FA (
vllm/vllm/v1/attention/backends/flash_attn.py
Lines 341 to 354 in 2f925e5
self.aot_schedule = is_vllm_fa and (get_flash_attn_version() == 3) completely. Good catch!
| if use_mla: | ||
| # TODO(lucas): refactor to be more concise | ||
| # we should probably consider factoring out V1 here | ||
| if selected_backend == _Backend.CUTLASS_MLA_VLLM_V1: |
There was a problem hiding this comment.
the perf looks really good! I think we should turn this on by default for blackwell
|
|
||
| B = q_nope.shape[0] | ||
|
|
||
| o = torch.zeros(B, |
There was a problem hiding this comment.
does this need to be torch.zeros? or does torch.empty work (faster)
Do you know any commend to test a model with num_heads = 128? And probably no TP. |
Not that im aware of :/ this is the smallest MLA model I am aware of |
|
This is the smallest model with MLA ( @tlrmchlsmth found it the other day) https://huggingface.co/deepseek-ai/deepseek-vl2-tiny |
just want to clarify that the way I found it was |
|
Ah I don't think it's an MLA model :/ |
There was a problem hiding this comment.
LGTM, other than I do think we should turn it on by default for Blackwell: https://github.com/vllm-project/vllm/pull/17625/files#r2075575324
Any reason not to?
Edit: oh and ideally id still like to see accuracy numbers, i.e.:
VLLM_ATTENTION_BACKEND=CUTLASS_MLA_VLLM_V1 VLLM_USE_V1=1 lm-eval --model vllm --model_args pretrained=deepseek-ai/DeepSeek-V2-Lite-Chat,tensor_parallel_size=2,dtype=auto,gpu_memory_utilization=0.9,trust_remote_code=True,max_model_len=16384 --task gsm8k --num_fewshot 5 --batch_size auto
@LucasWilkinson this |
My main concern is that the CUTLASS MLA kernel has more limited support compared to the Triton version. For example, |
Oh interesting, can we turn it on my default for models with head dim 128? as for block size I think we can force it similar to to FlashMLA ( Lines 145 to 158 in 5e6f939 Im ok landing this for now and opening a new PR to turn it on by default; but I think we still should, we should strive to make the best they can be. |
Ah the only one I know of is DeepSeek V3 or R1, if you have a system that can run that then those accuracy numbers would be good to see! |
|
This pull request has merge conflicts that must be resolved before it can be |
Head branch was pushed to by a user without write access
|
Got the lm_eval output with the cutlass backend, which matches the triton backend: How to repro: # server side: bash run.sh [cutlass]
if [[ "$1" == "cutlass" ]]; then
export VLLM_ATTENTION_BACKEND=CUTLASS_MLA_VLLM_V1
fi
VLLM_LOGGING_LEVEL=DEBUG \
VLLM_WORKER_MULTIPROC_METHOD=spawn \
vllm serve deepseek-ai/DeepSeek-V3 \
--trust-remote-code \
--max-model-len=4096 \
--block-size=128 \
--max-num-seqs=512 \
--gpu_memory_utilization=0.97 \
--data-parallel-size $NUM_GPUS --enable-expert-parallel \
--disable-log-requests &
# client side
lm_eval --model local-completions --tasks gsm8k \
--model_args model=deepseek-ai/DeepSeek-V3,base_url=http://127.0.0.1:8000/v1/completions,num_concurrent=5,max_retries=3,tokenized_requests=False \
--limit 100 |
ea334ae to
2543d9e
Compare
Head branch was pushed to by a user without write access
c06aa6d to
204161e
Compare
|
This PR is pretty red... these tests aren't all failing on main are they? |
I am checking the logs but nothing seems to be related to my change. Can you please advise? @tlrmchlsmth |
|
@tlrmchlsmth ok. I think i have done all I can do. Basically I have reverted all my changes that are for the existing files (only leave one that adding a new file). And you can see the tests are still red. Can you help? |
ba1ea0f to
204161e
Compare
|
Force push the original PR. |
|
@tlrmchlsmth Can you please advise? ^^ |
|
I think we have fixed the CI, could you rebase the PR again? |
204161e to
6f4d0f5
Compare
|
@houseroad Thanks, I've just rebased. However, the |
|
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: kaixih <kaixih@nvidia.com>
Signed-off-by: kaixih <kaixih@nvidia.com>
Signed-off-by: kaixih <kaixih@nvidia.com>
Disable splitk Signed-off-by: kaixih <kaixih@nvidia.com>
6f4d0f5 to
9d3b08b
Compare
This PR introduces the
CUTLASS_MLA_VLLM_V1backend, enabling support forops.cutlass_mla_decode()on NVIDIA Blackwell GPUs.It also includes performance results using DeepSeek-V3 on 8×B200 GPUs under DP+EP parallelism settings, which delivers ~17% improved throughput.
To repro the results:
cc. @kushanam