TrnRT: Open-Source LLM Inference Engine for AWS Trainium (GLM-5.3-Flash, NKI Megakernels)
TrnRT is an open-source inference engine for large language models on AWS Trainium, released by RunAnywhere under the Apache 2.0 license. It serves an OpenAI-compatible API from a single trn2.48xlarge, runs decode as NKI megakernels at roughly one kernel per layer half, and keeps a prefix cache spanning device and host memory. GLM-5.3-Flash is the first supported model.
The project matters because it is a rare piece of independent, production-shaped software for the Trainium ecosystem, which has historically lagged NVIDIA's CUDA stack in tooling and community support. TrnRT ships with published benchmark numbers, a verification gate against an earlier build, and an offline compile pipeline that removes compilation from the serving box entirely.
What TrnRT is and what it runs on
TrnRT targets exactly one hardware configuration today: AWS Trainium2 on the trn2.48xlarge instance, which contains 16 chips with 96 GiB of HBM each, running Neuron SDK 2.32 (neuronx-cc 2.27) and Python 3.13.
| Target | Status |
|---|---|
AWS Trainium2, trn2.48xlarge (16 chips, 2 engines × TP 32, LNC 2) |
Supported |
| GLM-5.3-Flash (320B MoE, 18B active, FP8, 1M-token context) | Supported |
| More open models | Coming soon |
GLM-5.3-Flash is a 320B-parameter mixture-of-experts model with 18B active parameters, FP8 weights, and a 1M-token context window. The repository states that the engine, router, caches, and compile pipeline are built to carry additional model families, and docs/ARCHITECTURE.md documents what a new model family requires. Model requests are accepted through a GitHub issue template.
The headline benchmark: 3.57M tokens per minute on one box
On SemiAnalysis AgentX, a harness that replays real coding-agent sessions, one trn2.48xlarge served a 1M-token context with 32 concurrent agents for one hour per measurement point. The default configuration is decode batch 12.
| Decode batch | Requests / min | Tokens / min | Decode tok/s per user (p50) | First token, cached (p50) | $ / M tokens (spot) |
|---|---|---|---|---|---|
| 4 | 19.3 | 2.36M | 46.6 | 76.73 s | $0.061 |
| 8 | 25.2 | 3.02M | 29.4 | 28.82 s | $0.047 |
| 12 (default) | 28.9 | 3.57M | 22.3 | 6.53 s | $0.040 |
Tokens counted include input (cached input included) and output. The spot price used is $8.60/h in us-east-2 as of 3 Nov 2026. On an EC2 Capacity Block at $35.76/h, the batch-12 cost is $0.167 per million tokens.
The table shows a clear throughput-versus-latency tradeoff: moving from batch 4 to batch 12 raises aggregate throughput by roughly 51% and cuts the cached first-token latency from 76.73 s to 6.53 s, while per-user decode speed falls from 46.6 tok/s to 22.3 tok/s.
Separately, the project reports a batch-8 decode step of 24 ms, down from 32.2 ms before NKI megakernels were introduced.
Converting tokens per minute to tokens per second
A Hacker News commenter, @bookernath, argued that tokens per minute is an unusual unit and asked for a per-second figure to make comparison with alternatives easier:
Tokens per minute is a strange metric, I usually see tok/s. A per-second figure would be more accessible in comparing this to alternatives.
The repository publishes only the per-minute figures. Converting them arithmetically, 3.57M tokens/min is approximately 59,500 tokens/s aggregate across the box at batch 12; 3.02M tokens/min is approximately 50,300 tokens/s at batch 8; and 2.36M tokens/min is approximately 39,300 tokens/s at batch 4. These derived values are not published by the project.
How the NKI megakernels work
Decode on Trainium2 is not limited by memory bandwidth in TrnRT's design; small instructions, kernel boundaries, and exposed collectives dominate the runtime. Each decode megakernel therefore follows three rules: keep the working set in SBUF, use both physical cores symmetrically, and move the collectives into the kernel.
The engine fuses one kernel per layer half for decode, covering KDA attention, the fused DSA layer, mHC, and the MoE FFN. docs/MEGAKERNELS.md walks through every kernel in the repository.
Architecture: two engines, a session-affine router, and a two-tier prefix cache
Clients reach a session-affine router on port 8000, which sends each session to one of two engines. Each engine is tensor-parallel over 32 logical NeuronCores on 8 chips. This gives two engines per box, each with tensor parallelism of 32.
The prefix cache is a radix tree over FP8 KV pages, plus a host-memory tier for evicted pages and state checkpoints. Because routing is session-affine, a conversation stays on one engine's prefix cache; the OpenAI client example passes a session_id in extra_body to pin a conversation.
Context handling combines sparse attention with a top-2,048 selection and linear attention with fixed-size state, which is how the engine reaches a 1M-token context window without unbounded state growth.
Offline compilation: the serving box compiles nothing by default
Every graph in TrnRT is built on a CPU host, and the serving box loads them without compiling anything by default. The compile cache is produced in five CLI steps — compile shapes, compile decisions, compile capture, compile compile, and compile strip — and the project notes the process takes hours on any x86_64 host with no NeuronCore required.
The serving step then mounts the compiled cache and the downloaded model weights into the container and runs trnrt serve --model /model --port 8000. The full guide covers start-up checks and the batch 4, 8, and 12 configurations.
Verification against the benchmarked build
The published benchmark numbers were measured with an earlier build of TrnRT. The current repository passes three checks against that build:
- Graph equivalence: EQUAL on all 32 ranks, for all 157 graphs that the default batch-12 configuration compiles.
- Outputs: byte-identical to that build's on 384 of 384 requests.
- Serving: the two-engine serve in the Quickstart passes end to end.
Details are in docs/KNOWN_ISSUES.md under a verification-status heading.
Repository layout
trnrt/
├── __main__.py CLI: serve, engine, compile
├── serve/ OpenAI API, session-affine router, output parsers
├── engine/ scheduler, prefix caches, tensor parallelism
├── models/ GLM-5.3-Flash: KDA, DSA, mHC, MoE, FP8 loading
├── kernels/ NKI decode megakernels and prefill kernels
└── compile/ offline compile: shapes, capture, neuronx-cc, strip
docker/ the serving and compile image
tools/ graph-equivalence gate, device checks, doc checks
tests/ CPU test suite (no NeuronCore needed)
docs/ guides, results, kernel notes
Development uses make dev for an editable install with test and lint tools on Python 3.13, and make check for lint, type-check, and the CPU test suite. Pull requests target the development branch.
What the OpenAI-compatible API covers
The server exposes chat and completions endpoints, streaming, tool calls, and reasoning output. Any OpenAI client can point at http://localhost:8000/v1 with an unused API key. The project publishes separate documentation for the API surface, configuration flags, and deployment.
Community reaction and open questions
The Hacker News discussion was small — five comments — but raised three recurring questions about the project and the Trainium ecosystem generally.
Why is the Trainium software ecosystem still thin?
@coredog64 praised the effort while questioning why a company of Amazon's size has not invested more heavily in the stack:
Good on these folks for doing something useful with Trainium. I'm always surprised that the Tranium ecosystem is as poor as it is. Amazon's market cap is nearly $3T and they can't throw a couple L6s and a modest token budget at this? Making Trainium work as seamlessly as possible as an Nvidia substitute is a clear flywheel play.
This is the strongest signal in the thread: the value of TrnRT is partly technical and partly that it fills a gap the platform vendor has left open.
How does the cost per token compare to NVIDIA and AMD?
@kevo1ution asked directly:
curious how the token/$ on trainuim compare to nvidia chips and amd. is the future "chipless" inference?
The repository does not publish cross-vendor comparisons, so the $0.040 per million tokens at spot and $0.167 on a capacity block at batch 12 stand as Trainium-only figures.
How does it compare to SGLang?
@badmonster0 asked:
how does this compare with sglang
No comparison was offered in the thread. The relevant structural difference visible in the repository is that TrnRT is Trainium-specific — its megakernels are written in NKI, its compile pipeline targets neuronx-cc, and its only supported hardware is trn2.48xlarge — whereas SGLang is a general-purpose serving framework aimed primarily at GPU backends.
Licensing and attribution
TrnRT is licensed under Apache License 2.0. It includes code derived from other Apache-2.0 projects, documented in NOTICE and THIRD_PARTY_NOTICES.md. The project credits the AWS Neuron team for NKI and its documentation, Z.ai for releasing GLM-5.3-Flash, and SemiAnalysis for AgentX and its public traces.
RunAnywhere states that TrnRT is an independent open-source project, not affiliated with or endorsed by Amazon Web Services. AWS, Amazon Web Services, Trainium, Inferentia, and Neuron are trademarks of Amazon.com, Inc. or its affiliates.