AI • Science • Technology • Future

Business AI

Laplace 3B: Linear Attention for Predictable AI Inference on AWS

Image from the original article
Featured image: original publisher image. Via original publisher.

Large language models typically use transformer architectures with softmax attention. During inference, their key-value (KV) cache grows with context length, increasing memory use and limiting concurrency.

Why Linear Attention Matters

Traditional transformers compute pairwise token interactions, scaling quadratically with sequence length. This creates a growing KV cache during inference, which can strain memory and reduce serving efficiency.

i14 developed Laplace 3B, a linear attention model that replaces softmax attention with Gated Linear Attention (GLA). This change reduces training complexity from O(T²) to O(T) and keeps inference memory constant.

Each sequence uses a fixed 29.5 MB recurrent state, regardless of context length. This stability makes memory use predictable, especially for long-running agents or document analysis.

Model Architecture and Design

Each layer replaces attention with a GLA mixer that uses a fixed-size matrix state to store context.

The model processes each token through a convolution layer with a 4-wide kernel and SiLU activation. This creates a 4-gram summary before attention.

After convolution, the output is projected into four streams: queries, keys, values, and a gate. The gate controls how much of the value is copied to the output.

The GLA mixer maintains a per-head state matrix of size 96×192. This state decays over time using a geometric schedule. Head 0 forgets tokens in one step, while head 15 retains memory for up to 2,048 tokens.

After attention, a feed-forward network with GLU activation processes the output. The network uses two up-projections and one down-projection, with a residual connection.

Implementation on AWS Trainium2

i14 adapted Laplace 3B for AWS Trainium2 using native PyTorch through TorchNeuron Native. This replaced a GPU-optimized Triton kernel with standard PyTorch operators.

The implementation required three key changes:

  1. Using native PyTorch operators to implement GLA, with 16 chunks of 128 tokens to match the 128 partitions of the NeuronCore on-chip buffer.
  2. Redesigning Muon’s communication using all_to_all collectives, which cut per-rank traffic by 24 times and increased training throughput by 1.63 times.
  3. Compiling the backward pass by statically unrolling the 16-step GLA recurrence to fit on-chip memory and graph size limits.

The chunk size of 128 tokens aligns with the 128 SBUF partitions.

Training Performance

Training occurred on a trn2.48xlarge instance with 16 Trainium2 chips and 64 logical NeuronCores. The full training spanned 190,735 steps over 100 billion tokens from the FineWeb-Edu dataset.

After warmup, throughput stabilized at about 120,000 tokens per second. This rate held through step 84,210, covering approximately 44 billion tokens.

Loss dropped smoothly from 11.4 to 2.3729. Gradient norms declined to about 0.05, with no spikes or divergence. These results indicate stable convergence without numerical instability.

Inference Performance

Using an unmodified vLLM engine, Laplace 3B served 11,544 output tokens per second at 1,280 concurrent sequences on one trn2.48xlarge instance.

The 29.5 MB per-sequence state is roughly 82 times smaller than a comparable KV cache at 8,192 tokens. Expanding the prompt from 2,048 to 8,192 tokens increased cost by only 0.5%.

A wrapper in vLLM replaces the token mixer to read and write the recurrent state. The model is declared attention-free, so vLLM allocates one fixed page per sequence.

NeuronCore-v3 internal architecture
NeuronCore-v3 internal architecture. Via original publisher. · Source

The largest cost comes from large projections, which consume 13.27 ms—near the 12 ms HBM-streaming floor.

Most of the time is spent on small operators dispatched one at a time under eager PyTorch. This highlights the role of operator dispatch in inference latency.

Scaling and Real-World Benchmarks

Without tensor parallelism, throughput scales linearly with the number of replicas. On one replica, eager decode achieved 133 output tokens per second. With 64 replicas, it reached 6,772 tokens per second.

Compiling the decode step removed operator dispatch and increased throughput 1.7 times, to 11,544 tokens per second.

Fixed-batch benchmarks hide real-world costs. Each new batch width requires a new shape compilation, which takes about 11 seconds.

Padding batch widths to fixed sizes eliminated this overhead. Compiled decode improved throughput 3.52 times under staggered arrivals, compared to 1.46 times on fixed batches.

Because BF16 reassociation causes minor output differences, eager decode is preferred when exact reproducibility is needed.

Key Takeaways

  • Native PyTorch supports custom architectures on Trainium2. i14 retained its GLA design using TorchNeuron Native.
  • Communication design significantly impacts performance. The Muon all_to_all approach reduced per-rank traffic by 24 times and boosted training throughput by 1.63 times.
  • Fixed recurrent state keeps inference memory predictable. Each sequence uses 29.5 MB regardless of context length.
  • Operator dispatch is a major decode bottleneck, not HBM bandwidth or arithmetic operations.
  • Real-world traffic patterns reveal hidden costs. Fixed batches mask the cost of shape compilation.

Why This Matters for AI Applications

For agentic systems, long histories don’t require larger memory allocations. This enables more persistent memory without increasing per-sequence memory use.

Teams facing high serving costs, low concurrency, or memory limits due to growing KV caches can evaluate Laplace 3B on AWS Trainium2.

For developers, this demonstrates how custom attention designs can be deployed efficiently on cloud accelerators with minimal overhead.

More broadly, it shows that hardware-aware design—aligned with architecture—can deliver predictable performance at scale.

Learn more at the original source.

Explore the i14 platform at i14.ai.

See the AWS Neuron SDK documentation at awsdocs-neuron.readthedocs-hosted.com.

For more on AWS Trainium, visit aws.amazon.com/ai/machine-learning/trainium.

Read about the AWS Generative AI Innovation Center’s work in AWS Generative AI Innovation Center.

For AI agents with structured workflows, see how Smartsheet MCP on AWS enables context management.

Sources & further reading

Featured image: original publisher image. Via original publisher. Image source