ATOM is a lightweight LLM inference engine built on AITER GPU kernels for the AMD ROCm platform.
pip install -e . # editable install
python -m pytest tests/ # all tests (no GPU needed — mocks AITER and torch.cuda)
black . && ruff check . # format + lint (CI enforced)# OpenAI-compatible serving
python -m atom.entrypoints.openai_server --model <model> --kv-cache-dtype fp8 -tp 8
# Offline inference
python -m atom.examples.simple_inference --model <model> --kv-cache-dtype fp8- Accuracy validation: see
/ci-pr-guideforlm_evalsetup and CI thresholds - Performance benchmark: see
/benchmark-guidefor full parameters
openai_server.py → LLMEngine → CoreManager → EngineCore → Scheduler → ModelRunner
(tokenizer) (ZMQ IPC) (inference (batching) (forward pass,
loop) KV cache, CUDAGraphs)
ATOM also has a diffusion subsystem (atom/diffusion/) for video+audio
generation, which is a sibling of atom/model_engine/ rather than an extension
of it — no KV cache, one fixed N-step denoise loop per job, four heterogeneous
networks, and sequence parallelism across a single request:
diffusion_server.py → DiffusionEngine → DiffusionCoreManager → DiffusionEngineCore → PipelineRunner
(/v1/videos) (JobScheduler) (ZMQ, one PUSH/rank) (per-GPU worker) (ComposedPipeline)
Key entry points:
- Server:
atom/entrypoints/openai_server.py - Engine:
atom/model_engine/llm_engine.py→engine_core.py→scheduler.py→model_runner.py - Models:
atom/models/— registered inatom/models/registry.py:support_model_arch_dict - Verify head and deferred status:
ModelRunner.run_modelreturns the forward's hidden states (a decode graph records the forward alone); the head runs after it, eagerly, on the forward's stream (ModelRunner.run_lm_head->LmHeadOutput, handed topostprocess): a verify head's token ids where they stand for the step, elseModelRunner.compute_logits(a lossless drafter's sampled step and a masked rollout vocabulary take the logits). The verify head (atom/model_ops/verify_head.pyVerifyHead, bound byModelRunner._bind_verify_head: the model's ownverify_head, else for a drafted model whoseParallelLMHead.logits_are_headthe shared mono LM head launch (atom/mono/lm_head) in front of ATOM's TritonArgmaxVerifyHead):sample_token_ids(hidden)a verify's output ids and spec status (verify_ids.VerifyOutput),samples_step(batch, spec, rows)whether they stand for the step ofrowsforward rows (samples,draws_top_p(rows): the rows it draws),ids_agreewhether every TP rank's are alike. The verify from a head's ids, exact match or forced acceptance:atom/model_ops/verify_ids.py(IdVerifiers); a vocab-sharded head's picks (ShardedPicks, ATOM's and the V4.1 mono LM head's): a temperature row's id a Gumbel-max draw (verify_ids.HeadDraw; the mono head's byatom/mono/device/race.py), within its top-p in the mono head (atom/mono/lm_head/top_p.py: the set within each rank's K largest,top_p_candidates, sorted by the wave bitonic networks ofatom/mono/device/bitonic.py; past them hi's two-level scan,top_p_scan; the slices both read,top_p_logits); forced acceptance admits every request greedy (LLMEngine); an attention builder may say a step consumes the previous verdict on the device (AttentionMetadataBuilder.consumes_device_verdict: the runner then takes the speculative status after the target's launch) or stages the step before that status and restages what it moves once taken (settles_spec_status/take_spec_status) - Peer embedding:
atom/model_ops/peer_embedding.py— a vocab-parallel embedding read from each row's owner rank's shard (HIP IPC), one launch;shared_peer_embeddingone mapping an embedding and group (a DSpark draft shares its target's) - Model hooks:
atom/model_engine/model_hooks.py—DecodeRound, the part of a step a model's install hands DeepSeek-V4.1's metadata builder (DeepseekV41MetadataBuilder.use_decode_round);DecodeRound.serviceis the step's one routing decision (AttentionMetaData.served_by_round,RoundService) that the builder, its cache, Engram staging, the DSpark proposer and the model's forward all read - Ops:
atom/model_ops/— AITER kernel wrappers (linear, attention, fused_moe) - Structured output:
atom/structured_output/— request validation, schema compilation, grammar state and asynchronous token/mask transfers - Config:
atom/config.py(Config, KVCacheConfig, CompilationConfig) - Env vars:
atom/utils/envs.py(allATOM_*variable definitions) - Pipeline parallel:
atom/model_engine/pp_engine_core.py(head / downstream stage loops) overatom/distributed/pp_transport.py; dynamic chunked PP prefill inatom/model_engine/dynamic_chunking.py(latency model, pure) anddynamic_chunking_worker.py(startup sweep and runtime timing in the runner), sized byScheduler._dynamic_chunk_limit - Ulysses sequence parallel (
-sp, on the PCP rank dimension):atom/distributed/ulysses_sp.py(the SP group, the token shard / gather and the QKV exchange),group_agreement.py(verdicts every rank of a CPU group takes alike); the model runs on a rank's token range throughatom/utils/sp_wrapper.py; the attention and its head gather inatom/model_ops/sp_attention.py, and the MXFP4 MoE through AITER MegaMoE inatom/model_ops/fused_moe/sp_mega_moe.py - Mono decode (fused per-layer decode kernels): the shared mechanisms in
atom/mono/(runtime/: TP consensus and a runner's bind-then-agree construction (consensus.bind_agreed), peer memory and its owned buffer (lifecycle), the step's mailbox zeroing and peer fence, one FlyDSL launch (mailboxes.StepMailboxes.begin_step->step_begin), per-width builds (widths), the routing wrapper's lazy runner (route), debug wait reports, kernel argument tables, compile-only builds and their traced hand-offs (compile.trace/compile.check_traced), the refusals every model shares (deployment), check-mode comparison (compare), the dual-copy scratch's calibration (numa: which copy, one per I/O die, each XCD reads; hi'sdualruns it on its own probe);plan/: the execution model and task placement, build keys, a TP rank's share of the widths (shard: a model'sDimsand its TP refusal), mailbox region layout (layout), int / traced arithmetic (arith) and the hand-off contract a trace is held to (check.check);device/: the tagged mailbox and itspublish, the TP group's peer bases and all-reduce sum (ranks), FP8 / MX codes, FP4 tile loads and the scaled MFMA (mx), a CTA's dual copy (numa) and wave / math primitives), a model's kernels inatom/models/<model>/mono/kernels/(MiniMax-M3; DeepSeek-V4.1 and Kimi-K3, both wrapped after load throughmodels.registry.mono_decode_installers; V4.1's per-step cell decisions live indeepseek_v41/mono/{index,attention,moe}_plan.py, each called by both the kernel and its CPU I3 test; its dual-copy regions innuma_plan.py; K1 and K2 of a layer in one launch (kernels/layer.py), a column-sharded residual's gather (kernels/col_gather.py), and the launches beside the layers, each falling back to the original path where not built (compress_launch,engram_launch,head_launch,draft_ctx_launch;head_launchbinds the shared mono LM head over V4.1's norm and head). The shared mono LM head (atom/mono/lm_head/): a vocab-parallel bf16 head's picks in one launch (kernel: an optional final RMSNorm, the shard's dot (dot), each row's greedy id or temperature draw over every TP rank (argmax), a top-p row's draw within its top-p (top_p:top_p_candidates, elsetop_p_scan)), its hand-offs tagged with the verify launch count so nothing zeroes its own peer buffer between launches;headbinds it as V4.1's head and, for any drafted model whose head is aParallelLMHead(ModelRunner._bind_verify_head,bind_verify_head), in front of ATOM's Triton picks. On gfx1250, V4.1's whole DSpark decode step is one persistent FlyDSL kernel a rank (deepseek_v41/mono/gfx1250/: a target launch through sampling and verification, then a draft launch), which ModelRunner is offered throughatom/mono/runtime/step_override.py; it reads the production MoE's experts in place, andtests/test_deepseek_v41_gfx1250.pyis its CPU test. Kimi-K3 runs K1 (the attention seam through the KDA recurrence) and K2 (o_proj+ the latent MoE) on its KDA layers, on a plain decode or a uniform speculative verify of at most 64 rows (16-row token groups past 16), with or without ReplaySSM. The MLA layers keep their original paged attention but also run K2; an MLA layer that cannot bind K2 stays on the production path alone. Which steps it serves and how a served step is keyed live inkimi_k3/mono/plan.py, apart fromrunner.pyso the CPU test gate can reach them without AITER or FlyDSL. Its DSA layers' indexer (plain decode or verify) runs the sharedatom/mono/dsa_indexer/launch: under DCP over each rank's own keys, without DCP over the replicated cache (a request's rows owned by one rank, a long request's keys split over the ranks) (wq_bthrough the selected KV slots; any model with the V3.2-styleIndexer, keyed and named by the layer'sIndexerShape,plan.unsupportedthe shapes it is not written for); the bf16 GEMV it shares with K1 / K2 isatom/mono/device/gemv.py. GLM-5.2's singlekernels/kernel.pycovers the whole layer,kernels/op.pyis its host wrapper, andkernels/geometry.py/kernels/geometry_config.pyhold its launch geometry and its ownLayerConfig. What is NOT GLM-5.2's sits inatom/mono/: the storage vocabulary and host-side weight preparation inmono/weights/(configthe enum vocabulary andLayerConfig,formatsMX conversion,packing,layertheLayerWeightsABI), ATOM's MXFP4 index arithmetic inplan/tiles.py, and the HIP IPC wrapper inruntime/hip_ipc.py.runtime/peer_memory.pynow holds BOTH peer-buffer implementations side by side —PeerBuffer(aiter's heap) andSymmetricPeerBuffer(HIP directly, GLM-5.2's) — because they are different implementations rather than two copies, and merging them is a GPU behaviour change, not a move; both allocate throughruntime/uncached.py, as do the other models' step scratch buffers (uncached device memory: a hand-off's polls never hit a stale cache line). DeepSeek-V4.1's high-interactivity monokernels (below) keep a third, their own: the hi programs' peer groups (deepseek_v41/mono/hi/runtime/peer.py,PeerGroup) and uncached scratch arenas (hi/runtime/uncached.py, a block retired and reused, never freed), both overruntime/hip_ipc.py. Qwen3.8-Flash-Next's kernels (qwen38/mono/, beside the single-fileqwen4_exp.py) are whole-layer programs composed from FlyDSL stages (kernels/blocks/,kernels/recipe.py); its MTP drafter is wrapped at install like V4.1's (draft_model.MonoDraftModel). Where a model ships amono/contract.pywith a__main__(DeepSeek-V4.1, MiniMax-M3), check its hand-offs without a GPU withARCH=gfx950 python -m atom.models.<model>.mono.contract; GLM-5.2'scontract.pyis the per-step input check only, and Kimi-K3 ships neither it nor acheck.pyyet). DeepSeek-V4.1 also has the high-interactivity monokernels (ATOM_DSV41_MONO_HI, on by default wheredeepseek_v41/mono/hi_gate.pysays they serve: MI355X, TP2, TP4 or TP8, DSpark; at TP8 the shared expert's K is padded in place, 288 -> 320, until ROCm/aiter#7967): one persistent FlyDSL launch a layer (the runtime indeepseek_v41/mono/hi/), the host hook inhi_runner.py/hi_compose.py/hi_dispatch.py, its verify head (HiVerifyHead: the in-graph verify,round/post_verify.py) and its decode round inround/(HiRound) - Diffusion:
atom/diffusion/— framework at the top level (pipeline.py,attention.py,ulysses.py), engine inengine/, server inentrypoints/, and one package per model inmodels/<family>/. Extras:pip install -e ".[diffusion]"
- A source file's header is these three lines, the ATOM line included (every
new file gets all three):
# SPDX-License-Identifier: MIT # Copyright (C) 2026, Advanced Micro Devices, Inc. All rights reserved. # Copyright (c) 2026 ATOM Project Contributors - Change
@support_torch_compiledecorated model files with care — edits are allowed, but debug/instrumentation code inside traced functions breaks Dynamo tracing even with--enforce-eager. Instrument at call sites instead (e.g.,ModelRunner.run_model(),EagleProposer._propose(),DSparkProposer._propose();Drafter.propose()is only the template that calls them), know which functions are traced before editing, and run the compiled path afterwards.deepseek_v4_dspark.pycarries a COMPILE BOUNDARY block at the top naming exactly which functions are traced — read it before touching that file - Multiprocessing must use
spawn—forkcauses CUDA re-initialization crashes - Set
AITER_LOG_LEVEL=WARNINGbefore starting server — suppresses aiter kernel log flooding - Clear compile cache before server restart:
rm -rf /root/.cache/atom/*— stale cache causes silent failures after code changes - Verify server with GPU, not just HTTP:
curl /healthcan return OK even when model is not loaded. Always checkrocm-smi --showmemuse(VRAM% > 0) to confirm - On any server/GPU error, run
/debug-guidefirst — do not blindly retry - Fix-then-sweep: after fixing a bug, immediately grep for the same pattern across the codebase and fix all occurrences in one pass
- Name-matches-function: variable, function, and file names must accurately describe what they do. When behavior changes, rename immediately — stale names mislead future readers
- Adding a model: see
/add-modelfor full guide - Model reuse: DeepSeek V3/V3.2/GLM-5 share
deepseek_v2.py; MTP models indeepseek_mtp.py,qwen3_next_mtp.py, andqwen3_5_mtp.py - Compilation levels:
--level0=eager, 1=torch.compile, 2=dynamo once, 3=piecewise compile (default); CUDA graphs are--cudagraph-mode's, independent of the level
- AITER (
from aiter import ...) — GPU compute kernels - MORI — MoE expert-parallel all-to-all communication
- RCCL — collective communication primitives
| Topic | Source |
|---|---|
| Architecture | docs/architecture_guide.md |
| Environment variables | docs/environment_variables.md |
| Compilation & CUDAGraph | docs/compilation_cudagraph_guide.md |
| Model support | docs/model_support_guide.md |
| Structured output | docs/structured_output_capabilities.md |
| Model ops (AITER kernels) | docs/model_ops_guide.md |
| Scheduling & KV cache | docs/scheduling_kv_cache_guide.md |
| Serving & benchmarking | docs/serving_benchmarking_guide.md |
| Configuration | docs/configuration_guide.md |
| Distributed | docs/distributed_guide.md |
| Dynamic chunked pipeline parallel | docs/dynamic_chunking_guide.md |
| Metrics & observability | docs/metrics_guide.md |
| CI/PR workflow | /ci-pr-guide |
| Performance benchmark | /benchmark-guide |
| Debugging | /debug-guide |
| Adding a model | /add-model |
| MiniMax-H3 (video+audio diffusion) | recipes/MiniMax-H3.md |
| DeepSeek-V4.1-Flash | recipes/DeepSeek-V4.1-Flash.md |
| Qwen3.8-Flash-Next mono decode | recipes/Qwen3.8-Flash-Next-Mono-Program.md |