All Posts
Blog
6
 min read

More tokens per dollar on AWS Trainium2: optimizing Qwen3.5-35B-A3B in days

Summary

New open models now arrive every few weeks. Many models are only optimized initially for the accelerators they have been developed on. But inference teams want to serve each one with more tokens per second and a lower cost per token. Together with AWS, yasp showed how fast that can happen on AWS Trainium2: our model optimization platform took Qwen3.5-35B-A3B, a modern 256-expert hybrid mixture-of-experts model, from a first working port to optimized serving in days. As a partner building with AWS’s new native PyTorch backend TorchNeuron, yasp makes sure new models don’t just run on Trainium, but run at their best.

  • Up to 83% more output tokens per second from the same Trainium2 chip (37% to 83% across 1 to 8 concurrent users).
  • Up to 45% lower cost per token on the same hardware, with each of eight concurrent users receiving 53 instead of 29 output tokens per second, which is well above human reading speed.
  • Days, not months: from first port to optimized serving, with every kernel verified for correctness on the chip.

‍

The challenge: models are tuned for the hardware they were built on

For teams running inference, the goal is simple: more tokens, at a lower cost, for every model their users ask for. The catch is that most models are tuned for very few architectures, most often the one they were developed on. On any other accelerator, a new model usually runs soon after release, but running at its best takes specialist kernel work for every model and target.

On AWS Trainium2, this matters in particular: the chip rewards kernels that closely match its architecture, and some operations in new model designs, such as the recurrent state updates in linear attention, do not map to it well out of the box. That is the gap yasp’s platform is built to close.

What is AWS Trainium?

Trainium is AWS’s own AI chip, designed by Annapurna Labs for training and serving AI models at scale. Trainium2 is its second generation chip and is available in Amazon EC2 Trn2 instances and Trn2 UltraServers. Developers program it through the AWS Neuron SDK, which supports PyTorch, JAX and vLLM, and write custom kernels with the Neuron Kernel Interface (NKI) language and compiler. With TorchNeuron, AWS’s native PyTorch backend, standard PyTorch models run on Trainium, and custom NKI kernels plug in as PyTorch operators. For this post, we used trn2.3xlarge instances each with one Trainium2 chip.

What are the yasp model optimization platform and Gaia?

yasp gets the newest AI models running at their best on the hardware you choose, in days instead of months. Bring a model, target hardware and a typical workload: the model optimization platform profiles, plans, optimizes, benchmarks and deploys the model in a loop until the gains are in. Gaia is the kernel-generation system at its core. It operates autonomously, generating and improving candidate kernels in a self-improving fashion with the target hardware in the loop for certifying each candidate kernel against reward hacks, for functional correctness against the reference and statistically robust speedup estimates.

What we did

We picked Qwen3.5-35B-A3B as a realistic test for what teams want to serve in 2026: 40 layers that interleave Gated DeltaNet linear attention (30x) and grouped-query attention (10x), each followed by a mixture-of-experts block with 256 experts. With 67 GB of bf16 weights, it runs on one Trainium2 chip in a single trn2.3xlarge instance when distributed with tensor parallelism across the chip’s four logical cores, served with vLLM Neuron, which builds on vLLM with TorchNeuron (AWS’s native PyTorch backend for Trainium). We ported the reference implementation from HuggingFace following the official guidelines in order to serve the model on Trainium2 via vLLM. For that initial port, we added support for the recurrent state of hybrid models to vLLM-Neuron. We focused on the decode path as an example and pointed Gaia at the three blocks where most of the time is spent according to profiling. Gaia autonomously generated, tested and verified optimized kernels for each of them directly on Trainium2.

The results: more tokens, lower cost per token

More tokens per second

At eight concurrent users, one Trainium2 chip now serves 427 output tokens per second, 83% more than the initial port. Across 1 to 8 users, the gain ranges from 37% to 83%. Every user benefits as well: at eight concurrent users, each user now receives about 53 output tokens per second instead of 29. Improving throughput and interactivity at the same time means that Gaia moves the Pareto frontier as a whole (Figure 1).

Concurrent users Interactivity
output tok/s per user
Initial port
output tok/s per chip
With Gaia
output tok/s per chip
Gain
193.6 → 128.093.6128.0+37%
265.9 → 105.4131.8210.8+60%
448.0 → 80.6191.8322.3+68%
829.2 → 53.4233.7427.2+83%

Table 1: Interactivity and output throughput on one Trainium2 chip, initial port vs. with Gaia (vLLM 0.24.0, bf16, chat workload with 1,024 input and 1,024 output tokens). Interactivity is the output token rate each user receives (x-axis of Figure 1); throughput is the total per chip.

Figure 1: Throughput per chip vs. tokens per second per user, initial port vs. with Gaia.
More tokens per dollar

The hardware and its price did not change, only the kernels. So every throughput gain is a price-performance gain: each Trainium2 hour now produces up to 83% more output tokens, and the cost of each token falls accordingly, whatever your pricing.

Concurrent users Tokens per dollar Cost per token
1+37%−27%
2+60%−37%
4+68%−40%
8+83%−45%

Table 2: Price-performance on the same Trainium2 instance, optimized model vs. initial port. Derived from measured throughput; independent of pricing.

In other words, the same workload needs up to 45% less Trainium2 time.

How Gaia got there

Gaia worked on the three blocks that dominate decode time in parallel. For one of them, it generated and benchmarked twelve candidate kernels in about eight hours on a single accelerator. Gaia’s kernels plug into the stack through TorchNeuron’s NKI custom operators, the extension point AWS provides for exactly this. Each block showed a different strength of the approach.

Specializing for the model’s shapes. AWS’s kernel library is built to serve many models well. For Qwen3.5’s specific expert shapes, Gaia generated specialized NKI kernels that make the most of Trainium2 for this model.

Finding the right boundary, together with engineers. For the linear-attention block, the best result combined a narrow kernel for the recurrent state update with a whole-layer kernel. One of our engineers did that combination, and what we learned went straight back into Gaia.

Learning from AWS’s reference kernels. Qwen3.5’s attention head dimension falls outside the shapes the library’s attention kernel supports. Gaia learned tiling and work-overlap strategies from AWS’s attention reference kernel and carried them over to this model, which produced the best attention result in the stack.

Same answers, verified on the chip

Speed only counts if the answers stay the same. Gaia’s harness checks every candidate kernel against the reference. At model level, the optimized model passes every hard check of the equivalence procedure in AWS’s Neuron tools, and matches or exceeds the initial port on the GSM8K benchmark within error.

Metric Threshold Optimized model
Cosine similarity p5≥ 0.950.99812
KL divergence p95≤ 0.10.00584
Top-1 agreement> 50%100.0%

Table 3: Selected Neuron equivalence metrics for the optimized model.

What AWS and yasp say

New model architectures are arriving faster than ever, and our customers want to run them cost-efficiently on AWS Trainium as soon as they are released. This work shows that Trainium’s price performance advantage can reach new models like the one presented within days. yasp’s model optimization platform is a strong complement to the AWS Neuron stack, and a great example of what our partners can build on it. We look forward to continuing the collaboration. – Kamran Khan, Head of Business Development and GTM AWS/Annapurna ML
Teams should not have to choose between the newest model and the best economics. With Gaia, a brand-new model reaches its best on AWS Trainium in days, and our customers get more tokens for every dollar they spend on inference. – Stefan Krassin, CEO, yasp

What this means for you

If you serve open models at scale and want each new release on the hardware with the best economics as soon as it is out, the bottleneck is no longer the hardware. It is the kernels, and that gap now closes in days. yasp is one of the partners building with TorchNeuron to extend the Trainium ecosystem.

Deciding where to run inference? Book a Trainium feasibility check. Bring your model and the traffic you serve, and we will show you the throughput, latency and price-performance it reaches on Trainium2, measured on real hardware, not estimated.

Building on Trainium? Request access to our model optimization platform or book a technical session with our team.

‍

Figure 1: Pipeline utilization of the PyTorch Inductor solution

See gaia & kronos in action

Bring your model. 30 minutes. No slides.

Get Started
Get Started
Share