The Playbook · AWS Trainium2 · 5G Physical Layer · NKI

Porting NVIDIA Aerial 5G L1 to AWS Trainium

A clean-room re-implementation of the Aerial cuPHY approach to 5G physical-layer signal processing as Neuron Kernel Interface kernels — built with AI agents driving a compile-verify-fix loop on real Trainium2 silicon, and verified CRC-exact end to end.

4/4
phases delivered
8
NKI kernels on device
157
tests, CI-gated
2
device bugs the sim missed

Nokia and NVIDIA have shown that the 5G physical layer runs on a programmable AI accelerator. Nokia's AI-RAN work takes it from concept to commercialization on NVIDIA's Aerial. This playbook builds on that. If L1 belongs on an AI accelerator, can it also run on AWS AI silicon like Trainium? This is a question of customer choice: more places to run the workload serves operators better than fewer. The tooling that made targeting a new accelerator tractable was AWS's neuron-agentic-development NKI skills driving Claude Code, hand-building verified custom kernels in days, not quarters.

Clean-room, stated up front

NVIDIA Aerial (Apache-2.0) was read for algorithm understanding only. No CUDA/C++ was copied. Every kernel is an independent implementation validated against a NumPy golden reference. This is a methodology demonstration, not a product.

Section 1

What this pipeline actually does

A phone sends data over the air. It arrives at the tower distorted and noisy — smeared by the channel, faded, phase-rotated, buried in noise. The 5G uplink physical layer (PUSCH) is the base station's job: turn that messy radio signal back into the exact bits the phone sent. Noisy radio in → correct data bits out.

The scenario
📱
Phone
sends data as radio waves
〜〜〜
📡
Antenna
arrives noisy, faded, phase-rotated
→
⚙️
L1 pipeline
6 NKI kernels on Trainium
→
✅
Bits recovered
CRC-checked → network

Section 2

Watch a slot flow through the pipeline

Press play. A received slot moves stage by stage; each box lights up as its NKI kernel fires, showing the Neuron engine and the measured latency accumulating, ending in a CRC check.

Tensor Vector/Scalar active
Idle — press Play.
Each stage in one line: what it does, which kernel, which engine.

Section 3

The build method: reference-first, hardware-in-the-loop

One rule: never write a device kernel before its plain-NumPy reference passes conformance. Order, every time: golden NumPy reference → simulator equivalence → device run. And a conformance policy — hard outputs (decoded bits, CRC) bit-exact; soft outputs (LLRs, channel estimates) within a documented tolerance, never loosened to pass a test.

I drove the build with an AI agent (Claude Code) using the AWS Neuron NKI agents and skills, with a real Trainium2 instance in the loop. The agent did not write correct kernels — it closed the loop fast: draft, verify against the reference in the simulator, hit a real compiler error on-device, fix, re-verify, dozens of times.

Corroborated prior work

AWS researchers argued this statistically in NKI-Agent (arXiv:2607.04395): single-shot NKI solve rates are low, but the same model inside a compile-verify-fix loop on real Trainium compiles/verifies far more often. I used a general model and a different toolkit — not their fine-tuned model — so these results independently corroborate that claim.

"Verify against the reference" is one call. Each NKI kernel runs under nki.simulate_kernel and its output is asserted equal to the NumPy golden reference (hard outputs bit-exact, soft outputs within tolerance):

out = nki.simulate_kernel(demapper_tile_kernel,
                          syms.real.astype(np.float32).reshape(P, 1),
                          syms.imag.astype(np.float32).reshape(P, 1),
                          n0, pts_re, pts_im, mask0, mask1)
ref = demap_llr_float(syms, m, n0)          # NumPy golden reference
np.testing.assert_allclose(out, ref, rtol=1e-3, atol=1e-3)

From kernels/demapper/test_nki_demapper.py. The device test is marked @pytest.mark.device, so the hardware-free CI gate skips it while the on-box run executes it.

Phase 0
Scaffold & conformance harness ✓
CI gate, TV loader, tolerance policy.
Phase 1
NumPy golden references ✓
8 kernels, CRC-exact chain — the ground truth.
Phase 2
NKI kernels in the simulator ✓
Static control flow, matched to the reference.
Phase 3
Device bring-up on Trainium2 ✓
Conformance, benchmarks, fused pipeline, neural receiver.
Phase 4
Deliverables ✓
Reports + this playbook, grounded in measured data.

Section 4

The finding that justifies the whole approach

Two kernels passed the functional simulator and still failed to compile for silicon.

OFDM DFT: combined two matmul results with subtract(a,b) — reading two PSUM (accumulator) inputs in one instruction, which the compiler forbids. Fix: copy PSUM→SBUF before combining.

QAM demapper: sliced an SBUF tile off a non-32-partition-bank boundary. Fix: load the row from HBM so it lands at partition 0.

Both invisible in nki.simulate_kernel; both caught by nki.benchmark (full device compile). This is the case for keeping real hardware in the loop.

Here is the OFDM DFT fix. The illegal version combines two matmul results directly. Each matmul writes to PSUM, so the subtract reads two non-scalar PSUM inputs in one instruction. The compiler rejects it. The fix copies each matmul result from PSUM to SBUF first, then combines and accumulates in SBUF:

    # FAILS on device: subtract reads two PSUM operands in one instruction
    acc_r[...] += nl.subtract(nl.matmul(tr, wr, transpose_x=True),
                               nl.matmul(ti, wi, transpose_x=True))
    # COMPILES: copy each matmul PSUM->SBUF, then combine in SBUF
    mrr = nl.copy(nl.matmul(tr, wr, transpose_x=True))  # Tr@Wr
    mii = nl.copy(nl.matmul(ti, wi, transpose_x=True))  # Ti@Wi
    acc_r[...] += nl.subtract(mrr, mii)

From kernels/ofdm_demod/nki_ofdm_demod.py. The simulator ran the top version fine; neuronx-cc rejected it with "instruction can only read one of its non-scalar inputs from PSUM."

The reference-first rule caught two more before silicon. Single-limb BF16 DFT twiddles missed the accuracy budget (1.3e-3 against a 1e-3 target), fixed with a two-limb representation at 1.9e-6. A 1 - 2*x sign map wrapped for unsigned bytes, where 1 - 2 equals 255, caught as a unit-test failure long before silicon.

Section 5

The same pipeline on GPU and Trainium

The stages are identical either way. Top: the familiar GPU path (Aerial cuPHY). Bottom: the Trainium path in NKI. This isn't a race — it's a recognition.

GPU · cuPHY (CUDA) Trainium · NKI active
Idle — press Play to send the same slot down both lanes.
No GPU latency is measured or claimed — we ran only on Trainium. The GPU lane shows the familiar cuPHY primitives for recognition. The point is portability: the identical 5G DSP chain maps onto a second AI accelerator.

Section 6

Reference architecture at runtime

At deployment, Trainium sits as an inline L1 accelerator behind a fronthaul gateway. The DU terminates the O-RAN 7.2x eCPRI fronthaul — the hard-real-time, PTP-synced transport — and hands IQ samples / soft bits to the Neuron device for the compute-heavy PHY, reading results back. Trainium does compute, not fronthaul transport.

Figure — runtime reference architecture (PUSCH receive path)
The classical Aerial receive chain mapped to Trainium engines. Recurring pattern: nearly every stage is a matmul (Tensor) or an elementwise op with the batch dim on the 128 partitions — with static control flow throughout.
StageTrainium mappingEngine
OFDM demodDFT as matmul, twiddles in SBUF, contraction tiled over 128 partitions, PSUM-accumulatedTensor
Channel estLS at pilots + interpolation as matmul (linear or MMSE — swap the matrix)Vec+Tensor
MMSE equalizeClosed-form analytic inverse, branch-free; subcarriers batched on partitionsVector
QAM demapMax-log-MAP LLRs via masked-min over the constellation (compile-time masks)Vec/Scalar
Rate dematchCircular-buffer combining as a scatter matmul (no gather/scatter)Tensor
LDPC decodeLayered min-sum, parity unrolled at trace time, code blocks batched on partitionsVector

What does an NKI kernel look like? Here is the QAM demapper, the warm-up kernel. Symbols sit on the 128-partition axis, the constellation points sit on the free axis, and the per-bit log-likelihood ratio comes from a masked minimum over the constellation. Control flow is static: no data-dependent branching.

@nki.jit
def demapper_tile_kernel(sym_re, sym_im, n0, pts_re, pts_im, mask0, mask1):
    P, m_bits = sym_re.shape[0], mask0.shape[0]
    out = nl.ndarray((P, m_bits), dtype=nl.float32, buffer=nl.shared_hbm)

    sr, si = nl.load(sym_re), nl.load(sym_im)   # (P,1) symbols on partitions
    inv    = nl.load(n0)
    pr, pi = nl.load(pts_re), nl.load(pts_im)   # (1,M) constellation on free axis

    dr, di = nl.subtract(sr, pr), nl.subtract(si, pi)     # broadcast to (P,M)
    dist2  = nl.add(nl.multiply(dr, dr), nl.multiply(di, di))  # |y - s|^2

    for b in range(m_bits):           # unrolled at trace time (static)
        d0 = nl.min(nl.add(dist2, nl.load(mask0[b:b+1])), axis=1, keepdims=True)
        d1 = nl.min(nl.add(dist2, nl.load(mask1[b:b+1])), axis=1, keepdims=True)
        nl.store(out[:, b:b+1], nl.divide(nl.subtract(d1, d0), inv))  # LLR = (d1-d0)/N0
    return out

From kernels/demapper/nki_demapper.py. The additive masks (0 where the bit matches, +1e9 otherwise) are compile-time constants, so the minimum selects the right hypothesis subset with no branching.

The transferable lesson

Almost everything wants to be a matmul or an elementwise op with the batch dim on partitions, and control flow must be static. That's not a Trainium quirk — it's what makes any accelerator port predictable, and what makes latency deterministic (p99 ≈ p50).

Section 7

Measured on silicon

Per-kernel NeuronCore latency (nki.benchmark, component microbenchmarks)
p50 latency (µs) · p99 ≈ p50 on every kernel
Small-dimension component microbenchmarks, not a full-slot budget. The headline is determinism: static control flow yields no data-dependent latency spikes.

Section 8

A neural receiver on the same accelerator

To close the loop with AI-native RAN: a small MLP demapper compiled to Trainium with torch_neuronx.trace tracks the classical max-log-MAP demapper within ~1% BER across the SNR sweep — 100% bit-agreement at high SNR. Classical DSP kernels and a learned neural PHY, side by side on one engine. That's the AI-native RAN thesis in miniature.

Section 9

Where this fits in Nokia's AI-RAN framework

Mapping this builder's PoC onto Nokia's published vision (not a claim of affiliation). Nokia's AI-RAN white papers frame the space through the AI-RAN Alliance's three pillars — and two of them are exactly what this touches:

Nokia AI-RAN pillarWhat it meansThis project's contribution
AI-and-RANRAN and AI workloads share tensor-optimized computing infrastructure (Nokia: general-purpose accelerators, spare AI compute beyond RAN)A full 5G L1 receive chain as NKI kernels on Trainium — a concrete demonstration that the shared "tensor-optimized" substrate can be AWS AI silicon
AI-for-RANAI enhancing the radio, culminating in the AI-native air interface (AI-AI): traditional chain → Neural Demapper → Neural Receiver (Nokia Fig 5)The traditional NKI chain plus a neural demapper on the same device — the first two rungs of Nokia's roadmap; their CNN mapper reports ~2 dB BER gain, ours tracks classical within ~1% BER on Trainium
The honest one-liner

The two building blocks Nokia's roadmap calls for — L1 on a tensor-optimized accelerator and a neural receiver block — both run on AWS Trainium in this PoC. Not delivering AI-RAN; showing its published architecture has a viable path on a second family of AI chips.

Section 10

What this is — and isn't

  • Not real-time-validated. Benchmarks are component-scale, not a full 273-PRB / 4096-FFT / Z=384-LDPC slot. At real dimensions a single-core fp32 chain will likely exceed a 0.5 ms slot (LDPC is the pole). The path is known — INT8 LDPC, fused graph, multi-core, BF16 — but not done.
  • Validated vs a NumPy reference, not yet NVIDIA's HDF5 test vectors; sign and bit-ordering confirmed by round-trip.
  • No GPU head-to-head on identical vectors; any Aerial comparison is cross-published and labeled as such.
  • No affiliation or endorsement. Mapping this work onto Nokia's and NVIDIA's published visions is illustrative, not a claim of partnership with either company or the AI-RAN Alliance. The framing is the author's; the vision is theirs.
  • Clean-room. Aerial read for understanding, never copied.

Section 11

Why it matters

Nokia and NVIDIA proved the demand: AI-native RAN, with L1 on a programmable AI accelerator, is the direction. The healthiest version of that future is one where L1 acceleration isn't single-sourced — where a vendor can target the accelerator that fits their power, cost, and supply constraints because the PHY is written portably against a clean reference. This project is one data point toward it: a full 5G receive chain, clean-room, on a non-GPU AI accelerator, built in days because AI agents closed the verification loop against real silicon. The demand has been proven by the leaders. The optionality is what the rest of us get to build.

Built with Claude Code driving the AWS Neuron agentic-development NKI skills + a compile-verify-fix loop on real Trainium2. 4 phases · 8 NKI kernels · 157 CI-gated tests · NKI / neuronx-cc 2.23 / torch-neuronx. Clean-room reimplementation; NVIDIA Aerial read for algorithm understanding only. Figures from measured device data.

Write-up: Running 5G L1 signal processing on AWS Trainium (AWS Builder Center).

Source: full kernels, references, and conformance tests at github.com/gubaruch/neuron-aerial.

Credit: the compile-verify-fix-on-Trainium method is the AWS Neuron team's work — NKI-Agent (Tang, Huan, Zhou, Zhang, Wang) and the neuron-agentic-development NKI skills. The method is theirs; the clean-room 5G port is mine.

Format inspired by Hugging Face's Ultra-Scale Playbook (nanotron, Apache-2.0). This is an independent build; not affiliated with or endorsed by Hugging Face, NVIDIA, or Nokia. The views and opinions expressed here are the author's own and do not represent the official positions of Amazon Web Services (AWS).