Skip to main content
QUICK REVIEW

[論文レビュー] Compiler-First State Space Duality and Portable $O(1)$ Autoregressive Caching for Inference

Cosmo Santoni|arXiv (Cornell University)|Mar 10, 2026
Parallel Computing and Optimization TechniquesComputer Science被引用数 0
ひとこと要約

この論文は、オンデバイスキャッシュ付き自己回帰状態を用いたカーネルフリーのコンパイラ主導の Mamba-2 SSD 実装を XLA を介して CPU、NVIDIA GPU、および TPU v6e に移植し、手書きカーネルなしで portable な O(1) キャッシュと競争力の推論レイテンシを実現する。

ABSTRACT

State-space model releases are typically coupled to fused CUDA and Triton kernels, inheriting a hard dependency on NVIDIA hardware. We show that Mamba-2's state space duality algorithm -- diagonal state structure, chunkable recurrence, and einsum-dominated compute with static control flow -- maps cleanly onto what XLA's fusion and tiling passes actually optimise, making custom kernels optional rather than required. We implement the full inference path (prefill, cached autoregressive decoding) as shaped standard primitives under XLA, without hand-written kernels, and realise the architecture's theoretical $O(1)$ state management as a compiled on-device cache requiring no host synchronisation during generation. The implementation runs unmodified on CPU, NVIDIA GPU, and Google Cloud TPU from a single JAX source. On TPU v6e across five model scales (130M--2.7B parameters), XLA-generated code reaches approximately 140 TFLOPS on single-stream prefill ($15%$ MFU) and up to $64%$ bandwidth utilisation on decode. Greedy decoding matches the PyTorch/CUDA reference token-for-token across 64 steps, with hidden-state agreement within float32 rounding tolerance. The pattern transfers to any SSM recurrence satisfying the same structural conditions, on any platform with a mature XLA backend. The implementation is publicly available at https://github.com/CosmoNaught/mamba2-jax and merged into the Bonsai JAX model library.

研究の動機と目的

  • XLA のコンパイラ最適化に状態空間二重性の性質がうまくマップされ、さまざまなハードウェアでカーニルフリー推論を可能にすることを示す。
  • JAX/XLA で制御フローをコンパイルして自己回帰生成の On-device O(1) キャッシュを実現する。
  • CPU、NVIDIA GPU、Google Cloud TPU の複数モデルスケールで portability、性能、メモリを評価する。

提案手法

  • Mamba-2 SSD アルゴリズムとその対角状態、チャンク化再帰、および einsum に支配された計算を説明する。
  • 手書きカーネルなしで標準 XLA 原語として完全な推論経路(プレフィルとキャッシュされた自己回帰デコード)を実装する。
  • JAX PyTree として登録されたコンパイル済み制御フローを介してオンデバイスの O(1) キャッシュを実現する。
  • TPU v6e、NVIDIA A100、CPU の各環境で、5 サイズのモデル(130M–2.7B)とシーケンス長(128–4096)を評価する。
  • 静的マスキングと動的ループを比較して融合効果を示し、精度選択(float32 減衰指数化)のアブレーションを行う。
Figure 1: Autoregressive generation on Cloud TPU v6e across five model scales and six sequence lengths. (a) Speedup from caching. (b) Generation latency: cached (solid) grows linearly, non-cached (dashed) grows quadratically. (c) Per-step throughput: cached throughput is flat regardless of sequence
Figure 1: Autoregressive generation on Cloud TPU v6e across five model scales and six sequence lengths. (a) Speedup from caching. (b) Generation latency: cached (solid) grows linearly, non-cached (dashed) grows quadratically. (c) Per-step throughput: cached throughput is flat regardless of sequence

実験結果

リサーチクエスチョン

  • RQ1コンパイラバックエンド(XLA)によって SSD の特性を活用し、プラットフォーム横断でカスタムカーネルを不要にできるか。
  • RQ2ホスト同期なしで状態空間モデルの O(1) 自己回帰キャッシュをオンデバイスで実現できるか。
  • RQ3CPU、NVIDIA GPU、Google Cloud TPU でカーニルフリーの Mamba-2 SSD の portable 性・性能・メモリ要件はどうなるか。
  • RQ4コンパイラ生成 SSD コードと参照実装を用いた場合の数値的正確さ保証はどうなるか。

主な発見

  • TPU v6e で、XLA 生成コードはシングルストリームのプレフィルで約 140 TFLOPS(約 15% MFU)程度、デコード時には最大で 64% の帯域利用率を達成する。
  • Greedy デコードは 64 ステップにわたり PyTorch/CUDA のリファレンスとトークンごとに一致し、隠れ状態の整合性は float32 四捨五入許容範囲内。
  • キャッシュは自己回帰デコードの O(1) 複雑さを提供し、オンデバイスキャッシュと fori_loop のコンパイル済み化によりホスト同期を回避する。
  • 同じソースを CPU、NVIDIA GPU、Google Cloud TPU で未変更のまま実行でき、プラットフォーム間の高い移植性を示す。
  • 静的マスキングは融合を維持し動的な各行マスキング方式よりも優れ、減衰指数化には正確性を維持するため float32 精度が必要。
  • 5つのモデルスケール(130M–2.7B)とシーケンス長最大 4096 の範囲で、TPU v6e でのデコードメモリ帯域利用は約 64% を維持し、プレフィル MFU はモデルサイズとともにスケールする。デバイスの上限を強調。
Figure 2: Peak memory during autoregressive generation on Cloud TPU v6e. Cached decoding (solid) is constant; non-cached (dashed) grows linearly. At sequence length 4096, the 2.7B non-cached path consumes over 16 GB versus a constant 10.9 GB cached.
Figure 2: Peak memory during autoregressive generation on Cloud TPU v6e. Cached decoding (solid) is constant; non-cached (dashed) grows linearly. At sequence length 4096, the 2.7B non-cached path consumes over 16 GB versus a constant 10.9 GB cached.

この論文を読む

Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。

Nubintでこの論文を読む

このレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。