Skip to content

[WIP] Enable FlashInfer checkpointing SSU for Mamba STP - #43102

Draft
danielafrimi wants to merge 3 commits into
vllm-project:mainfrom
danielafrimi:flashinfer-checkpointing-ssu-stp-default
Draft

danielafrimi wants to merge 3 commits into
vllm-project:mainfrom
danielafrimi:flashinfer-checkpointing-ssu-stp-default

Conversation

@danielafrimi

Copy link
Copy Markdown
Contributor

Draft/WIP branch to share the current STP FlashInfer checkpointing SSU integration work.

What is included:

  • Adds FlashInfer checkpointing_ssu buffers for Mamba2 STP decode.
  • Defaults the STP bridge to --mamba-checkpoint-interval 1 without a separate opt-in kernel-selection flag.
  • Routes checkpointing replay/counter state through stable-slot Mamba copy functions for FlashInfer.
  • Adds focused STP parity and Mamba copy-function tests.

Current validation:

  • tests/v1/worker/test_mamba_utils.py passes.
  • tests/kernels/mamba/test_checkpointing_ssu_stp.py passed in the cluster container.
  • Async + CUDA graph server starts.

Known blocker:

  • Real Nemotron-H serving/eval is not correct yet under the new checkpointing kernel. Direct stronger synthetic parity now reproduces a first-token mismatch for model-like tensor magnitudes, so this PR is for review/sharing only, not merge-ready.

Notes:

  • No pre-commit was run.
  • Results/log directories are intentionally not included.

Signed-off-by: Daniel Afrimi <dafrimi@login-lyris01.lyris.clusters.nvidia.com>
@mergify mergify Bot added the v1 label May 19, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements FlashInfer checkpointing Selective State Update (SSU) for Mamba2, introducing a checkpoint_interval configuration and integrating the checkpointing_ssu kernel into the FlashInfer backend. The implementation includes updates to the Mamba2 mixer for managing checkpointing trackers and cache, as well as new utility functions for stable state copying. Review feedback identifies an inconsistency in the parity tests where the initial state dtype was hardcoded instead of using the parameterized type, and suggests that the numerical tolerances should be tightened to ensure better precision in the final version.

Comment on lines +238 to +245
initial_state = 0.1 * torch.randn(
cache_size,
nheads,
head_dim,
dstate,
device=device,
dtype=torch.float16,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The initial_state is created with a hardcoded dtype=torch.float16, while the test is parameterized with dtype=torch.bfloat16. This is inconsistent. To make the test more robust and general, consider using the parameterized dtype for the initial_state as well. This would test the case where state and inputs have the same bfloat16 dtype. If testing mixed precision is intended, it would be better to make it explicit, for example by parameterizing the state dtype separately.

Suggested change
initial_state = 0.1 * torch.randn(
cache_size,
nheads,
head_dim,
dstate,
device=device,
dtype=torch.float16,
)
initial_state = 0.1 * torch.randn(
cache_size,
nheads,
head_dim,
dstate,
device=device,
dtype=dtype,
)

Comment on lines +312 to +318
torch.testing.assert_close(
new_out.float(),
old_out.float(),
atol=3e-2,
rtol=3e-2,
msg=f"STP output mismatch at decode step {step}",
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The tolerances atol=3e-2 and rtol=3e-2 are very high for a numerical parity test. This may hide regressions or indicate significant numerical differences between the two kernels. While I understand from the PR description that this is a work-in-progress and there are known mismatches, it's important to aim for much tighter tolerances (e.g., 1e-5) for the final version.

Daniel Afrimi added 2 commits May 20, 2026 02:36
Adds STP replay coverage for non-contiguous state indices, destination slot moves, and a production-shaped reproducer for remaining checkpointing drift. Also avoids the known large-batch checkpointing_ssu drift by advancing STP replay one request at a time.\n\nValidation: python -m pytest tests/kernels/mamba/test_checkpointing_ssu_stp.py -q -> 5 passed, 1 xfailed.\n\nKnown remaining issue: live concurrent four-prompt serving with async scheduling + CUDA graph is still under investigation; full GSM8K has not been rerun on this commit yet.

Signed-off-by: Daniel Afrimi <dafrimi@login-lyris01.lyris.clusters.nvidia.com>
GSM8K limit-50 conc50 with CUDA graph + async: new checkpointing STP 0.92 strict / 0.92 flexible, matching old FI STP baseline 0.92 strict / 0.92 flexible.

Signed-off-by: Daniel Afrimi <dafrimi@login-lyris01.lyris.clusters.nvidia.com>
@mergify

mergify Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @danielafrimi.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant