Skip to content

Add Mamba-2 kernels (causal-conv1d + mamba-ssm) to slime image for Nemotron-H - #5225

Open
yeshsurya wants to merge 1 commit into
Azure:mainfrom
yeshsurya:yeshwanth/slime-add-mamba-kernels-nemotron-h
Open

Add Mamba-2 kernels (causal-conv1d + mamba-ssm) to slime image for Nemotron-H#5225
yeshsurya wants to merge 1 commit into
Azure:mainfrom
yeshsurya:yeshwanth/slime-add-mamba-kernels-nemotron-h

Conversation

@yeshsurya

Copy link
Copy Markdown
Contributor

Why

The slime-pytorch-2.9-cuda12.8 curated image does not ship the Mamba CUDA kernels, so Megatron's MambaMixer aborts with ImportError: MambaSSM is not installed at model-build time. This blocks training hybrid Mamba-2 / MoE models such as Nemotron-H (model_type: nemotron_h), even though the image already contains:

  • the native nemotron_h bridge in the bundled megatron.bridge (megatron/bridge/models/nemotronh/nemotron_h_bridge.py), and
  • nemotron_h rollout support in sglang 0.5.11.

Kernels were the only missing piece for end-to-end Nemotron-H post-training.

What

  • Dockerfile: build causal-conv1d v1.5.0.post8 and mamba-ssm v2.3.2.post1 from their pinned git tags after the apex step.
    • Built from git tags because the PyPI sdists omit csrc/*.cpp and fail the ninja build (missing and no known rule to make it).
    • mamba-ssm 2.3.2.post1 imports the modern transformers.generation.GenerateDecoderOnlyOutput symbol and guards its optional TileLang (Mamba-3 MIMO) import, so it loads cleanly on this image's transformers with no source patch.
    • --no-deps keeps the curated torch / sglang / tilelang stack pinned (the image installs a cu128-nightly tilelang for flash-linear-attention; the Mamba-2 path Nemotron-H uses does not need tilelang).
    • TORCH_CUDA_ARCH_LIST="8.0;9.0" covers A100 + H100. Kernel refs are overridable ARGs.
  • smoke_test.py: assert the causal_conv1d + mamba_ssm.ops.triton kernels Megatron's MambaMixer uses import, and mamba_ssm >= 2.3.2.
  • spec.yaml: advertise Mamba: "2".

Validation

The causal-conv1d 1.5.0.post8 + mamba-ssm 2.3.2.post1 pair was validated end-to-end against :7 on a cluster: both kernels import, and Megatron wires the mamba params (mamba_num_heads=64, mamba_num_groups=8, mamba_state_dim=128, spec=mamba_stack_spec). Image auto-versions via asset.yaml (version: auto).

…motron-H

The slime-pytorch-2.9-cuda12.8 image does not ship the Mamba CUDA kernels, so
Megatron's MambaMixer aborts with "MambaSSM is not installed" at model-build
time. This blocks training hybrid Mamba-2/MoE models such as Nemotron-H
(model_type nemotron_h), whose bridge is already registered in the bundled
megatron.bridge and whose rollout is already supported by sglang 0.5.11.

Build causal-conv1d v1.5.0.post8 and mamba-ssm v2.3.2.post1 from their pinned
git tags (the PyPI sdists omit csrc/*.cpp and fail the ninja build). Version
2.3.2.post1 imports the modern transformers.generation.GenerateDecoderOnlyOutput
symbol and guards its optional TileLang (Mamba-3 MIMO) import, so it loads
cleanly on this image's transformers with no source patch; --no-deps keeps the
curated torch / sglang / tilelang stack pinned. TORCH_CUDA_ARCH_LIST covers
A100 (8.0) and H100 (9.0). This pair was validated end-to-end on the cluster
(kernels import, Megatron wires the mamba params).

smoke_test.py now asserts the causal_conv1d and mamba_ssm.ops.triton kernels
Megatron's MambaMixer uses import, and spec.yaml advertises Mamba: "2".

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5999648c-af8f-455b-b1cd-2e9451320aeb
@yeshsurya
yeshsurya requested review from a team as code owners July 21, 2026 01:23
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.

1 participant