Infinity × d-Matrix

Performant Full-Model Inference on d‑Matrix Corsair: 20x Speedup

How Infinity and d-Matrix implemented optimized models for SRAM.
Qwen 3 · 9 minute read
Arash Fayyazi

Arash Fayyazi

d-Matrix

Aseem Bathla

Aseem Bathla

d-Matrix

Ishan Paidhungat

Ishan Paidhungat

Infinity

Jeremy Nixon

Jeremy Nixon

Infinity

Luke Bechtel

Luke Bechtel

Infinity

Ramya Ramachandran

Ramya Ramachandran

d-Matrix

Sayantan Sarkar

Sayantan Sarkar

d-Matrix

Sravya Tirukkovalur

Sravya Tirukkovalur

Infinity

Sree Ganesan

Sree Ganesan

d-Matrix

Infinity and d-Matrix worked hand in hand to optimize the performance of Qwen 3 by 20x tokens / second on a single Corsair card compared with Infinity’s original implementation. Context length is also extended by 16x.

Corsair is a memory-centric inference accelerator where compute is tightly integrated with on-chip SRAM (the same general category as chips like Groq or Cerebras) and is designed to sidestep the GPU memory bottleneck where model weights must constantly move across the memory wall. The Corsair is broken into two packages per card, each organized into a hierarchy of chiplets, gangs, slices, cores, and SRAM banks. Mapping a model onto this hardware requires efficient memory packing across the spatial and temporal dimensions. Each weight, activation, and cache must be laid out in memory to prevent simultaneous same-region writes. The Infinity inference optimization system extended the d-Matrix Model Builder SDK to lay the model out across both dimensions: parallelism was matched to each operation spatially, memory was planned around residency and lifetimes temporally, and tooling was created to verify the resulting program end to end.

Tensor Parallelism + Head-Parallel Attention + Batch Parallelism + Pipelining

For Qwen 3, dense work is distributed across 16 hardware gangs. The primary axis is weight-sharding: each gang owns SRAM-resident output-column shards of the Q, output, and MLP projection weights. Qwen’s 16 query heads map one per gang; eight KV heads are duplicated across gang pairs; AllGather reconstructs complete activations where needed.

Inside each gang, weights are further sharded across four slices and their cores for parallel dot product accumulation. Because attention computation depends on state specific to each sequence, the KV cache and attention masks must reside on the slices performing that sequence’s computation. We therefore combine four forms of parallelism.

Execution topology

Four kinds of parallelism

The same topology serves prefill and decode: pipelining splits layers across packages, tensor parallelism shards dense work across gangs, head parallelism gives each gang one attention head, and batch parallelism isolates per-sequence state on slices.

Pipelining

Package 0

layers 0–13

Package 1

layers 14–27
Within each layer
Tensor parallelism

Dense math

Q/K/V · O-proj · MLP: sharded across 16 gangs
Head parallelism

Attention heads

16 heads · one per gang: head-local KV, no cross-gang traffic
Batch parallelism

via slice parallelism

0
1
2
3
QKᵀ · softmax · KV state: batch b → slice b
Rejoin

Dense math

gather · all-gather: return to gang shards

Figure 1. The execution strategy changes with the operation. The same topology serves prefill and decode.

01

Pipelining reduces pressure without constant crossings

Layers 0–13 occupy one package and layers 14–27 the other. Activations remain within a package for 14 layers, so the model requires only one package-boundary transfer.

02

Tensor parallelism spreads regular, arithmetic-heavy work

QKV, output projection, and the MLP have enough arithmetic intensity to amortize gathers and reductions, so they run broadly across gangs.

03

Head parallelism runs all 16 heads concurrently

Each of the 16 gangs owns one attention head end-to-end with head-local KV, so heads compute in parallel with no cross-gang communication inside attention.

04

Batch Parallelism is achieved via slice parallelism

At batch four, sequence b maps to slice b, which owns its KV cache, mask, and runtime position.

Decode deliberately switches execution modes at attention. RMSNorm, QKV, output projection, and the MLP run jointly across the batch as dense TP-sharded kernels, preserving useful kernel size and avoiding redundant work per sequence. KV updates, QKᵀ, softmax, and value-cache reads then run in private per-slice lanes because their state and addressing are sequence-specific. Those slice outputs are gathered before rejoining the shared dense path.

Load, Prefill, Decode

Parameter loading, prefill, and decode have different lifetimes, shapes, and scheduling priorities. While we currently run prefill and decode both on the Corsair, separating them also lets us presage disaggregated inference, using the Corsair to perform Decode while performing Prefill elsewhere.

Prefill

Wide · throughput-oriented
  • Processes the prompt across many tokens
  • Builds the initial KV cache at every layer
  • Uses 64-token tiles across 16 gangs
  • One gated graph, dispatched once per batch
›_

Decode

Narrow · latency-sensitive
  • Processes one new token per sequence
  • Reads and extends each sequence’s KV cache
  • Alternates shared dense and private attention
  • One graph advances all four sequences
Figure 2. Prefill favors wide token parallelism; decode is governed by the latency of a stateful single-step loop.

Prefill preserves slice ownership through one gated graph dispatched once per batch; only the active batch’s local attention and KV writes are enabled.

During decode, prompt length, sequence slot, and iteration number determine cache addresses and attention masks. This allows a single compiled program to support varying sequence lengths while preserving an independent KV cache trajectory for each sequence. d-Matrix architected its dynamically parameterized instructions with this variability in mind. Reverse Polish Notation, or RPN, expressions compute the required addressing and masking parameters at runtime.

We package the model into three explicit phases:

Phase 01

Parameter load

Place model weights and persistent data into the physical memory locations that will consume them.

Phase 02

Prefill

Process the prompt, produce hidden states, and construct every layer’s initial KV cache.

Phase 03

Decode loop

Generate the next token for each sequence and append its key/value entry without reloading weights.

Figure 3. Phase separation allows different shapes and schedules while keeping SRAM-resident parameters shared.
The SRAM Advantage

The big advantage of an SRAM chip like the Corsair is that the large projection and feed-forward weights remain in SRAM across prefill and decode. Only small phase-specific state is rematerialized. Every layer needs its own allocation in the correct package, gang, slice, core, and bank.

Weights and KV-cache state persist, while activation and scratch regions are recycled as layers and iterations complete. This separation of lifetimes makes the full layout fit.

Memory lifetimes

Keep what is expensive. Reuse what is transient.

The layout is shaped as much by tensor lifetime as tensor size.

LoadPrefillDecode

Model weights

Place in SRAM
Resident
Resident

KV cache

Build
Read + extend

Activation / scratch

Allocate
Reuse by layer
Reuse by step
Figure 4. Persistent SRAM allocations span phase boundaries; transient regions overlap only when their live ranges permit it. Reuse by layer overwrites the previous layer's activations once the next layer consumes them; reuse by step recycles them within a layer as attention output gives way to MLP output, for example.

Agentic Tools for Full-Model Enablement

Three tools drove the optimization loop together: hardware probing and profiling to measure the chip, MemoryScope with its sanitizer to plan and prove the placement, and Agentic Debugging to inspect what actually happens on the device.

The optimization loop

Measure. Plan and prove. Localize.

Each tool removes uncertainty at a different level of the stack.

01 · Measure

Microbenchmarks & profiling

Maps real instruction costs and memory behavior, then identifies where the full model is spending system time.

02 · Plan + prove

MemoryScope & Sanitizer

Searches placements across capacity, lifecycle, and locality, then statically verifies the resulting memory accesses.

03 · Localize

Agentic Debugging

Drives breakpoints and memory inspection across custom three-phase workloads, with an agent able to run the workflow.

Figure 5. The goal is to reject bad plans and memory failures as early (and as cheaply) as possible.
Agentic Hardware Probing and an Agentic Profiler

A datasheet gives useful ceilings. It does not tell us the latency of a real instruction at our tile shape, the effective bandwidth at our access stride, or where a particular memory path becomes a bottleneck.

We built dependency-controlled microbenchmarks that isolate one behavior at a time, then used end-to-end profiling to reveal which behaviors mattered in the complete graph. The measurements compose into an empirical performance model, giving each kernel a speed-of-light bound. This lets us ask: is meaningful headroom left, or should we move to the next bottleneck?

Hardware probing builds a map of the hardware. On a young architecture, it is one of the first investments worth making.

MemoryScope AI Compiler and Graph & Memory Sanitizer: Plan, Then Prove

At model scale, a program may compile and run while one operation overwrites a live tensor, reads bytes never produced, or interprets a valid buffer with the wrong layout. Our tooling addresses the problem at three levels: measure the execution, plan and lint the memory, then inspect numerical state.

Model shape determines weights and intermediates, context length sets KV depth, and batch size sets the number of caches. Infinity’s AI compiler, MemoryScope, searches placements and parallelism choices across all three.

Capacity

Fit weights, KV cache, and activations within every tier’s per-slice budget.

Lifecycle

Overlap transient allocations only after their previous contents are no longer live.

Locality

Co-locate producers and consumers; minimize communication, staging, and cross-slice movement.

Explicit lifecycles let transient regions overlap safely. Locality keeps weights resident, co-locates producers and consumers, and penalizes cross-slice traffic. The MemoryScope plan is then lowered into the d-Matrix SDK, generating the Qwen 3 workload.

The companion Graph & Memory Sanitizer then reconstructs reads, writes, and operation dependencies from compiled instruction streams. It flags conflicting writes, missing producers, incomplete producers, capacity overflows, uninitialized accesses, and suspicious reuse. It runs on every generated program, turning many hardware mysteries into compiler-time failures with concrete memory receipts. After our initial implementation, we rewrote the sanitizer in Rust, speeding it up by ~90x, fast enough to integrate into development pipelines as a static check.

Agentic Debugging: Turn Inspection Into a Workflow

d-Matrix’s original debugger could set breakpoints and inspect the chip’s address spaces. Together, we generalized it for custom load-prefill-decode programs, then documented the conventions an engineering agent needs to drive it. The agent can bisect execution, compare intermediate memory with references, and localize numerical errors end to end, compressing cases that once required days of manual bisection.

Building a Performant Model, Not Just a Fast Kernel

No single technique enables full-model performance. It comes from several choices reinforcing one another and from making each choice reusable for the next model and the next optimization.

Four Core Ideas

01

Natural parallelism.

Dense compute goes wide across gangs; sequence state remains local to slices; layers cross packages once.

02

SRAM weights only load once.

Parameters load once into their physical destinations, then remain beside the compute throughout prefill and decode.

03

Lifetime tracking expands capacity.

SRAM-resident weights and persistent KV state coexist with aggressively recycled activation and scratch regions.

04

Tooling compounds optimization.

Microbenchmarks and profiling, MemoryScope and its sanitizer, and Agentic Debugging shorten every subsequent iteration.

The work happened as a continuous joint loop with the d-Matrix engineering team. Model behavior informed SRAM placement; hardware measurements reshaped the parallel graph; integration needs extended the kernel library and Model Builder SDK; and debugging discoveries improved the tools.

There is more performance to unlock, alongside larger models, longer contexts, and broader reuse of the memory and debugging infrastructure.

Partnership announcement

Infinity and d-Matrix partner to advance performant full-model inference

Read the announcement behind this collaboration, and what the two teams are building next on Corsair.

Read the announcement

About Infinity

Infinity builds model-aware systems that extract inference performance generic engines leave behind. Its work spans hardware-aware model enablement, automated kernel optimization, memory planning, profiling, and reproducible validation. Learn more at infinity.inc.

About d-Matrix

d-Matrix is pioneering accelerated computing for AI inference, addressing the limits of latency, cost, and energy. Its Corsair compute accelerators and software platform deliver fast, sustainable inference at data-center scale. Learn more at d-matrix.ai.