10AI Research

Granite Mamba2 Inference Optimization

#ModelScoreStepsIn tokOut tokAvg costAvg time
1GLM-5.3
0.8196
±0.069
473213.6M614k$61.427.6h
2Claude Fable 5.1
0.8187
±0.024
670287.5M1.2M$171.778.3h
3Kimi K3
0.7379
±0.070
627277.1M826k$100.9915.7h
4Qwen3.8-Max
0.7366
±0.060
497163.7M1.8M$52.9618.0h
5DeepSeek V4 Flash Exp
0.7262
±0.152
749295.7M756k$5.2513.5h
6Grok 4.6
0.6077
±0.188
18342.8M659k$49.334.0h
7GPT-5.6
0.5617
±0.164
370104.3M241k$101.964.5h
8Inkling
0.4710
±0.430
995.3M28k$5.181.3h
9Gemini 3.7 Flash
0.3885
±0.232
31899.7M538k$10.961.5h
10Muse Spark 1.2
0.3055
±0.420
29483.5M532k$15.812.2h

Background

State-space models like Mamba2 replace attention with a recurrent selective-scan, which makes their inference profile very different from a transformer's: long prefill is a chunked parallel scan, while decode is a per-token recurrence over convolution and SSM cache state. Production inference engines squeeze this path with hand-tuned Triton kernels, and the gap between a straightforward eager PyTorch implementation and an optimized one is large.

The workspace is a standalone port of the real Hugging Face GraniteMoeHybridMambaLayer, with weights extracted from the pinned checkpoint ibm-granite/granite-4.0-h-1b-base (layer-0 Mamba weights, final norm, and tied embedding head). Everything runs in bfloat16 on CUDA, which constrains optimization choices such as Triton intrinsics and accumulation precision.

Task

The agent must implement CandidateBlock in /app/src/candidate_impl.py(a stub subclassing the reference is provided) and make the layer's inference path faster without changing its semantics. The performance bar is an optimized implementation built on the same production Triton kernels vendored in /app/vllm_ops/: match it, then beat it.

  • Keep the fixed constructor and forward(hidden_states, cache=None, attention_mask=None) signature; the internal cache layout may change as long as the returned cache still exposes conv_state, ssm_state, has_previous_state, and decode-position semantics.
  • Match the reference on hidden states, convolution and SSM cache states, and last-token readout logits, across prefill, cached decode, and variable-length padded batches. Speed only counts once parity holds.
  • Gains are measured on long prefill, batched variable-length prefill, and per-token decode latency; consistent gains across shapes beat a single outlier.
  • torch.compile, Triton, custom CUDA kernels, CUDA streams, and calls into transformers are all allowed. /app/reference_impl.py, /app/task_fixtures.py, and /app/vllm_ops/ must stay untouched; all changes go in the single candidate file.

What The Agent Gets

A ready-to-run workspace at /app: the fixed reference port (reference_impl.py, a clean port of the HF torch_forward path that does not call transformers inside the forward), the extracted checkpoint slice in assets/, the vendored vLLM Triton kernels in vllm_ops/ as building blocks, and fixed utilities in task_fixtures.py including the visible correctness and benchmark workloads.

Local loops are provided: verify_api.py checks parity against both the reference and the pinned transformers implementation, and run_dev_bench.py runs a local latency comparison. The hidden optimized baseline itself is not exposed to candidate code. There is no internet access at run time; the image bakes a ready .venv, so uv run --no-sync python ... works offline, and a sandbox-timer CLI reports the remaining budget.

Verification

A clean-room verifier runs in a fresh container on the captured /app: it restages pristine copies of the fixed files (task_fixtures.py, reference_impl.py, vllm_ops/) so only the candidate file carries over, then runs a correctness gauntlet followed by a paired GPU benchmark. Candidate code executes only inside an unprivileged worker process; the trusted parent owns workload generation, comparisons, and timing.

  • Correctness is checked against both the eager reference and the pinned transformers implementation on hidden prefill and decode workloads: hidden states, conv and SSM cache states, readout logits, and readout KL divergence. Any failure zeroes the result before performance is considered.
  • The timed path is additionally validated at the large benchmark shapes, with tolerances calibrated from the trusted baseline's own drift, and an output digest is compared on every timed call, so returning garbage-fast output only on the timed shapes is a hard correctness failure.
  • Speed is a paired ABBA benchmark against a hidden optimized baseline built on the same Triton kernel family, timed exclusively on the trusted parent's wall clock (worker self-reported timings are never scored), with median-of-pairs aggregation and a frozen Triton autotune cache.
  • The reward is the fraction of starter runtime eliminated: with G the geometric-mean speedup over the unchanged starter (measured against a live no-op floor), a correct candidate scores 0 when G ≤ 1 and 1 − 1/G otherwise; 2x maps to 0.5, 4x to 0.75.
  • Source scans reject references to verifier internals and any delegation to the trusted baseline; build failures and a missing candidate file zero the result.

Environment

Base imagenvidia/cuda:12.8.1-devel-ubuntu22.04
Tools availableCUDA, PyTorch, C/C++ toolchain, Python 3
Compute8 CPUs · 64 GB RAM
GPU1× B200
Time limit20h

Changes From V1

This task is an improved revision of Granite Mamba2 Inference Optimization from FrontierSWE V1.

  • The score changed from an uncapped geometric-mean speedup over the hidden optimized baseline (1.0 = parity) to the fraction of starter runtime eliminated: 0 when the aggregate speedup over the unchanged starter is ≤ 1, otherwise 1 − 1/G, anchored by a live no-op floor measured in the same run.
  • Timing moved from worker-reported CUDA-event measurements to the trusted parent's wall clock as the sole scored source, so candidate code can no longer influence its own timings; worker CUDA numbers are retained as diagnostics only.
  • New benchmark-shape correctness gates: the timed path is validated at the large benchmark shapes against the eager reference with baseline-calibrated tolerances, and an output digest is checked on every timed call, closing the gap between small checked shapes and large timed shapes.
  • Verification is now clean-room: the captured /appis rescored in a separate pinned container that restages pristine fixed files, with the candidate worker running as an unprivileged user in per-user private IPC directories and a frozen Triton autotune cache, replacing V1's in-place hash checks.
  • The submission contracted from a /app/submission/ tree (helper files allowed) to the single file /app/src/candidate_impl.py, with source scans rejecting references to verifier internals or delegation to the trusted baseline.
  • Infrastructure moved to the new harbor schema with artifact capture, and the /app/.timer daemon files were replaced by the sandbox-timer CLI.

References

  • IBM Granite 4.0-H 1B base (Apache-2.0): A single-layer slice (layer-0 Mamba weights, final norm, and tied embedding head) is extracted from the pinned checkpoint revision at image build; no weights are vendored in the task repository.
  • vLLM Mamba2 Triton kernels (Apache-2.0): Extracted SSM scan / chunk / state-passing Triton kernels (main branch, March 2026), themselves adapted from state-spaces/mamba by Tri Dao and Albert Gu, vendored as agent-visible building blocks in /app/vllm_ops/; the hidden optimized baseline calls the same kernels.
  • Hugging Face Transformers (Apache-2.0): /app/reference_impl.py is a standalone port of the GraniteMoeHybridMambaLayer torch_forward path; the pinned package (4.57.6) is also installed in the image and used as a parity target.
  • mamba-ssm / causal-conv1d (Apache-2.0 / BSD-3-Clause): Pinned pip packages (mamba-ssm==2.3.1, causal-conv1d==1.6.1) compiled into the image as CUDA extensions the optimized baseline relies on; not vendored.