[논문 리뷰] Compiler-First State Space Duality and Portable $O(1)$ Autoregressive Caching for Inference
논문은 on-device에 캐시된 autoregressive 상태를 이용한 커널 없이 작동하는 Mamba-2 SSD 구현을 XLA를 통해 CPU, NVIDIA GPU 및 TPU v6e로 이식하여 포터블한 O(1) 캐싱과 핸드-작성 커널 없이도 경쟁력 있는 추론 지연을 달성한다.
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에서 컴파일된 제어 흐름을 사용하여 autoregressive 생성을 위한 장치 내 O(1) 캐싱을 실현한다.
- 다양한 모델 규모로 CPU, NVIDIA GPU, 그리고 Google Cloud TPU 간의 이식성, 성능 및 메모리를 평가한다.
제안 방법
- Mamba-2 SSD 알고리즘과 대각 상태, 덩어리로 나뉜 재귀, 그리고 einsum 주도 계산을 설명한다.
- 손으로 작성된 커널 없이 표준 XLA 프리미티브로 완전한 추론 경로(프리필 및 캐시된 자기회귀 디코딩)를 구현한다.
- JAX PyTree로 등록된 컴파일된 제어 흐름을 통해 장치 내 O(1) 캐시를 실현한다.
- TPU v6e, NVIDIA A100, 및 CPU 전반에서 다섯 가지 모델 규모(130M–2.7B)와 시퀀스 길이(128–4096)를 평가한다.
- 퓨전 효과를 보여주고 정적 마스킹과 동적 루프를 비교하여 퓨전된 커널의 효과를 확인하고 정밀도 선택(float32 감소 지수화)의 영향을 제거한다.

실험 결과
연구 질문
- RQ1SSD 속성이 컴파일러 백엔드(XLA)에 의해 활용되어 플랫폼 간 커널 맞춤 없이도 구현을 가능하게 할 수 있는가?
- RQ2,
주요 결과
- TPU v6e에서 XLA가 생성한 코드는 단일 스트림 프리필에서 약 140 TFLOPS(약 15% MFU), 디코드에서 최대 64% 대역폭 활용을 달성한다.
- 그리디 디코딩은 64단계에 걸쳐 PyTorch/CUDA 참조 토큰-대-토큰 일치 및 float32 반올림 허용 오차 내의 은닉 상태 합의와 일치한다.
- 캐싱은 autoregressive 디코딩에 대해 O(1) 단위 복잡도를 제공하며, 장치 내 캐시와 fori_loop를 컴파일해 호스트 동기화를 피한다.
- 同一 소스가 CPU, NVIDIA GPU, Google Cloud TPU에서 수정 없이 실행되어 강한 플랫폼 이식성을 보여준다.
- 정적 마스킹은 융합을 유지하고 동적 행별 마스킹 접근 방식보다 성능이 우수하며, 감소 지수화는 정확도를 유지하기 위해 float32 정밀도가 필요하다.
- 다섯 가지 모델 규모(130M–2.7B)와 최대 4096의 시퀀스 길이에서 디코드 메모리 대역폭 활용은 TPU v6e에서 약 64%를 지속하고, 프리필 MFU는 모델 크기에 따라 확장되며 기기 한계를 강조한다.

이 논문 읽기
누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.
누빈트에서 이 논문 읽기이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.