Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

neuronx-cc Internals

A reverse-engineering reference for neuronx_cc 2.24.5133.0+58f8de22 (the AWS Neuron compiler), reconstructed from static analysis of the cp310/cp311/cp312 wheels. Every address, offset, and symbol on these pages is pinned to that build.

What this wiki is

neuronx_cc is the ahead-of-time compiler that turns a machine-learning graph into a NEFF — the executable container the Neuron runtime (libnrt.so) loads onto Trainium / Inferentia NeuronCore devices. Its two front doors are XLA HLO (emitted by PyTorch-XLA or JAX through libneuronpjrt) and NKI, a Python kernel DSL that traces directly to the backend IR.

This book is the specification a competent systems engineer would need to reimplement that compiler. It documents the whole descent — HLO/StableHLO optimization, the hlo2penguin MLIR front half, the Penguin middle-end, NKI tracing and lowering, the BIR backend IR, the libwalrus backend (scheduling, register/memory allocation, per-engine code generation, multi-core linking), and the on-disk NEFF format — anchored at every step to the binary evidence that supports it.

Everything here derives from static analysis alone: demangled symbols, decompiled function bodies, pybind11 and Cython string pools, embedded assert messages, and recovered __FILE__ source paths inside the shipped binaries. There is no access to source. Where a claim is inferred rather than directly observed, it is labelled; see Methodology & the Confidence Model.

Start here

  1. The Compile Pipeline at a Glance — the IR descent from framework graph to NEFF, with the binary that owns each stage.
  2. Binary Inventory & the .so Map — the tool ELFs, the eight starfish/lib shared objects, and the Cython module galaxy.
  3. Methodology & the Confidence Model — what "binary-derived" means here, the four-tier confidence ladder, and what is provably not recoverable.
  4. Glossary & Naming Conventions — NEFF, BIR, Penguin, KLR, walrus, pelican, the engines, the codenames.

How the book is organized

The reference is fifteen parts. Part 0 (this apparatus) orients; Parts 1–14 descend the pipeline and then bottom out in cross-cutting references.

PartSubjectDirectory
0Reference apparatus — pipeline, methodology, inventory, glossary
1Hardware & engine model (the arch object model, the six engines, LNC)arch/
2The Tonga ISA — the 64-byte bundle, access-pattern descriptors, per-engine encodingsisa/
3Frontend, driver, flags & diagnosticsfrontend/
4hlo-opt + hlo2penguin — HLO/MLIR optimization and Penguin emissionhlo-opt/
5Penguin IR & the middle-end (layout, tiling, fusion, scheduling, ISL glue)penguin/
6NKI — the Python kernel DSL, tracing, lowering, and the production kernel librarynki/
7BIR, libBIR, the JSON wire format, pelican::Expr, and the simulatorbir/
8The libwalrus backend — passes, allocators, schedulers, codegen, linker, verifiers, perf modelwalrus/
9Numeric semantics — dtypes, the cast engine, MX microscalingnumerics/
10Activation & the piecewise-polynomial (PWP) function tablesactivation/
11Custom ops & the GPSIMD Xtensa CPUscustomop/
12The NEFF container & packagingformats/
13Distribution, collectives & SPMD partitioningdistribution/
14Appendices — opcode/dtype/error/symbol reference tablesappendix/

NOTE — pages land part-by-part. The navigation sidebar lists what is written; the full ~355-page plan is tracked separately, one task per page. A section that is not yet linked is planned, not missing.

Companion wikis