Skip to content

feat(metax): add native MLA, DeepseekMoe and scalar Mul for 021 - #1050

Merged
baominghelly merged 1 commit into
InfiniTensor:masterfrom
rubik-hua:metax-021-ops
Nov 26, 2026
Merged

baominghelly merged 1 commit into
InfiniTensor:masterfrom
rubik-hua:metax-021-ops

Conversation

@rubik-hua

@rubik-hua rubik-hua commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

feat(metax): add native MLA, DeepseekMoe and scalar Mul for 021
Support DeepseekV2-style 021 model inference on MetaX GPUs:

  • Native MLA paged attention: flash_mla_launch host launchers plus
    varlen-prefill and kvcache-decode providers for the 576/512 fused
    latent cache, fp16/bf16.
  • Native DeepseekMoe: expert-grouped strided GEMMs via mcBLAS with
    device-side routing and chunked packing for long-context prefill.
  • Scalar Mul (tensor, double, tensor) for the routed-scaling factor.
  • DeepseekMoe falls back to a stream-ordered workspace lease when
    the dispatch handle provides none (python bindings).
  • Unit tests for scalar Mul and DeepseekMoe; MLA is covered by the
    upstream mla_latent_prefill/decode cases (index-1 provider).

Together these run the fused MoE path end to end on MetaX with no
engine-side fallback: on 021-32B TP2 (C550, MACA 3.5.3) prefill TTFT
drops from 2340 ms to 207 ms (54.7 to 618 tok/s) and decode improves
from 46.7 ms to 42.0 ms per token versus the CPU-routed per-expert
Gemm fallback.

021模型所需要的算子实现

验证
python3 examples/test_infer.py --device metax --model=/mnt/infini/infrahi/infinilm-models/021/021-32B-A4B-256k-20261024/021-32B-A4B-256k-20261024 --tp 2 --disable-prefix-caching --enable-paged-attn --attn flash-attn --use-mla --prompt "你是谁,你能做啥"

image

python examples/bench.py --device metax
--model=/mnt/infini/infrahi/infinilm-models/021/021-32B-A4B-256k-20261024/021-32B-A4B-256k-20261024
--tp 2 --enable-paged-attn --use-mla --attn flash-attn --disable-prefix-caching
--warmup --batch-size 1 --input-len 128 --output-len 64

image

单元测试:
image

@rubik-hua
rubik-hua requested a review from a team November 19, 2026 02:55
@rubik-hua rubik-hua changed the title feat(metax): add scalar Mul and native DeepseekMoe for DeepSeek-style MoE feat(metax): add native MLA, DeepseekMoe and scalar Mul for 021 Nov 23, 2026
@rubik-hua
rubik-hua force-pushed the metax-021-ops branch 3 times, most recently from 89d4d19 to ca25ee7 Compare November 23, 2026 11:34
Comment thread src/native/cuda/metax/ops/mul/kernel.h Resolved
Comment thread src/native/cuda/metax/ops/mul/scalar.h Resolved
   Support DeepseekV2-style 021 model inference on MetaX GPUs:

  - Native MLA paged attention: flash_mla_launch host launchers plus
    varlen-prefill and kvcache-decode providers for the 576/512 fused
    latent cache, fp16/bf16.
  - Native DeepseekMoe: expert-grouped strided GEMMs via mcBLAS with
    device-side routing and chunked packing for long-context prefill.
  - Scalar Mul (tensor, double, tensor) for the routed-scaling factor.
  - DeepseekMoe falls back to a stream-ordered workspace lease when
    the dispatch handle provides none (python bindings).
@baominghelly
baominghelly merged commit 4cc48dc into InfiniTensor:master Nov 26, 2026
14 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants