Conversation
Pack only after all weights are loaded, keep layout state local to each linear, and preserve fused projection slicing. Add a shared-head and repeated-packing regression.
Reuse existing layers, request-state pools and Decode graphs for pure Mamba-2. Support indexed states, checkpoint preparation, tensor parallelism and standard service entrypoints. Keep recurrence, state-isolation and lifecycle regressions with bounded repeat counts.
This was referenced Sep 19, 2026
Open
Reuse the recurrent-state guard for physical KV page zero and synchronize before replacing captured graphs. Extend the existing packed-linear regression to compare ordinary Qwen decode before and after recapture.
big-hip
marked this pull request as ready for review
September 20, 2026 15:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Support the prepared
state-spaces/mamba2-130mcheckpoint through the existing inference, benchmark and service entrypoints, with eager Prefill and indexed recurrent Decode on NVIDIA and MetaX. Reuse existing parallel linears, causal convolution, normalization, request-state management and Decode graphs.Model-specific code stays in
csrc/models/mamba2/. Shared correctness changes isolate packed-linear layouts, finish tied-weight loading before capture, and preserve active recurrent/Attention caches when recapturing graphs. Unsupported service configurations fail before worker setup. The source diff contains 18 files (+1424/-32), including three regression modules (653 lines) and 65 README lines. No experiment logs, weights, profiles or fork-specific workflows are included.Base:
InfiniLM-v0.2.9c. Dependencies: InfiniCore #1562 for scan kernels/MetaX precision policy and #1566 for graph allocation/recording correctness. The separate InfiniLM Qwen MTP PR is not required.Motivation
Add a pure SSM architecture without CPU model-compute fallback. For 130M TP1 BF16, convolution plus FP32 SSM state is approximately 18.25 MiB per request, independent of processed history length. The existing scheduler still applies its logical page budget; the state pool contains
max(2, num_blocks // 4)rows including reserved zero state.Type of Change
feat— new model architecture.fix— required loading/layout and graph-capture correctness.Test Results of Involved Models on Supported Platforms (Please attach screenshots)
Current source
8a591cb1, combined Core runtimea3ac4df4+ scan/MetaXf634435b:LM was rebuilt from an empty build directory against the consolidated Core headers, then linked to and tested with the newly built combined runtime. Core used an isolated integration worktree and an existing build cache. Loaded library paths/hashes are recorded. The A6000 workstation is shared; these are correctness results, not new performance or physical peak-memory measurements. No test was skipped in the listed A6000 runs. TP/dtype labels refer to Mamba; the ordinary synthetic Qwen2 fixture is FP16 TP1 in both suites.
The retained checks cover continuation, TP, dynamic graph request indices, batch fallback to device eager, live-request recapture, pool rebuild, admission under state exhaustion, cancellation, EOS/length release and slot reuse. Ordinary Qwen exercises the shared loader/packing/capture changes. This is bounded regression coverage, not a soak test or certification of every Mamba-2 checkpoint.
The recapture regression failed before
8a591cb1: warmup overwrote physical KV page zero of a live ordinary Qwen request, producing 127/128 logits outside the original1e-3tolerance. The same check passes after saving/restoring that page; no tolerance was relaxed. Synchronization/cache backup is restricted to capture and does not add per-Decode copying.Current-source review, raw logs, JUnit results and build provenance.
Earlier matching-model-source entrypoint checks covered text inference, offline benchmark, evaluation adapter and HTTP service. The five-sample MMLU run scored 0/5; it demonstrates adapter execution only. The current C500 run reran
examples/test_infer.py; the offline/evaluation/HTTP entrypoint evidence remains archived. Current service lifecycle coverage usesLLMEnginedirectly. Archived logs and provenance.Fresh C500 validation used one nominal 64 GiB card, MACA 3.7.0.38 / driver 3.8.30, PyTorch 2.8.0+metax3.7.0.7, Python 3.12.11 and Transformers 4.56.2. Both projects built from empty build directories using cached Boost/pybind11 dependencies. Source checksums matched the recorded revisions before and after testing; no production code or numerical assertion changed. No C500 test was skipped. Environment, current-source logs, commands and benchmark records.
Benchmark / Performance Impact
Current C500/MACA 3.7 check: no measured Decode-graph speedup. BF16 TP1, batch one, 128 input + 128 greedy output tokens, 16-token Decode warmup; two process pairs in eager/graph then graph/eager order, three measured requests per process (six per mode). Prefill was eager in both. Capture, loading and tokenization were excluded.
All 12 measured output hashes matched. Graph output rate was about 2.3% lower overall; the two ordered pairs differed in magnitude, so this bounded measurement does not establish a general regression cause. Keep the existing eager default for this measured configuration. No new process peak-memory or sustained HTTP-throughput claim is made.
Archived C500 BF16 TP1 comparison: 50% compute / 32,000 MiB slice, MACA 3.5.3, PyTorch 2.8.0+metax3.5.3.9; 128 input tokens, batch one, 128 greedy output tokens, 16 Decode warmup tokens and three repetitions. Existing Decode graphs reduced the median of per-run mean ITLs from 12.54 to 7.67 ms; finite-request output rate increased from 79.48 to 128.95 token/s. Prefill was eager in both configurations. Capture, loading and tokenization were excluded. This is not a new throughput measurement or sustained service benchmark.
Fixed WikiText subset: 8 passages / 4099 prediction targets; C500 BF16 mean NLL 3.14331950 versus archived official NVIDIA BF16 3.13971278. This is a bounded quality check; low-precision cross-shape logits are not bitwise identical. Official NVIDIA graph inference remained faster in the archived A6000 comparison.
Source review and current-source NVIDIA/MetaX TP1 acceptance are complete. The C500 verification blocker is resolved. Upstream CI approval and the two prerequisite Core PRs remain merge requirements; fork success does not imply upstream CI has run.
Notes for Reviewers
Scope: pure Mamba-2, one B/C group, convolution width four, head-wise D, gated RMSNorm after gating, and unbounded time steps. No hybrid Attention/SSM, quantization, scheduler chunked Prefill, prefix-state snapshots, remote state transfer, speculative rollback or PP. Ascend and Moore scan backends are not provided by this adaptation.
Shared loader/linear/compiler code also affects ordinary models. The Qwen compatibility regression covers the relevant tied-head, pre-transpose and recapture paths; it does not imply that all existing models/platforms were rerun. See the review evidence for exact source and runtime revisions.
CI / ChatOps
Current-head fork format and Ruff checks passed. The standard LM push CI only checks formatting; its Ruff job checks the formatter script. These are not GPU tests.
Independent fork CPU validation passed: both Core and LM builds succeeded, followed by 33 passed, zero failed, zero skipped configuration, loading and service-preflight checks. The downloaded artifact confirms the combined Core source tree matches the local GPU build. This separate validation branch pins both Core dependencies and the exact LM head; no fork workflow enters this source PR. Earlier workflow setup failures (missing
xxhash, then incompatible optional xmake caching) were corrected without changing production code or test assertions. CPU contracts do not replace accelerator tests.Core prerequisite CI: #1562 and #1566. These workflows build/test CPU on Ubuntu and Windows. GPU validation is recorded separately above. Upstream
action_requiredstill needs maintainer approval; fork results do not override upstream workflow policy.Checklist
Title, Branch, and Commits
feat(nvidia): …,fix(cuda/gemm): …).<type>/xxx-yyyy-zzzzwhere<type>matches the PR title's Conventional Commits type and words are joined with hyphens (seeCONTRIBUTING.md§Branches).CONTRIBUTING.md§Pull Requests).InfiniLM-v0.2.9c(270feb3e) without merge commits; the remote base was verified unchanged at publication.fixup!/squash!/wipcommits remain.Scope and Design
CONTRIBUTING.md§Code/General).printf/std::cout/print(...)left behind, orTODOwithout an owner and issue link.General Code Hygiene (applies to all languages)
CONTRIBUTING.md§Code/General).CONTRIBUTING.md§Code/General).the `seqlens_k` tensor) (CONTRIBUTING.md§Code/General).CONTRIBUTING.md§Code/General).CONTRIBUTING.md§Code/General; §Python).C++ Specific (if C++ files changed)
CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).new/delete; RAII / smart pointers / existing allocators are used.scripts/format.py.csrc/models/llama_legacy/.Python Specific (if Python files changed)
CONTRIBUTING.md§Python).CONTRIBUTING.md§Python).scripts/format.py.python/infinilm/auto_config.py.Testing
examples/test_infer.py), or specify the reason for skipping.examples/bench.py), or specify the reason for skipping.test/bench/test_benchmark.py), or specify the reason for skipping.python/infinilm/server/inference_server.py+scripts/test_perf.py), or specify the reason for skipping.Build, CI, and Tooling
Documentation
README.md,CONTRIBUTING.md, or inline docs updated when behavior, build flags, or developer workflow changed.Security and Safety