interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / docs / inference / LLAMA3-ENGINE-VERIFICATION.md

235 lines · 11637 bytes Raw Blame History Source

Llama 3.x engine cut: verification record

Date: 2026-10-06. Branch next-phase/engine-llama3, based on next-phase/compose-v5 (1ac121d). Machine: DGX Spark (GB10, sm_121).

Tags: PROVEN means measured here with the command shown. INFERRED means it follows from code reading or from a related measurement. UNVERIFIED means not checked.

What the cut does

  1. ModelConfig and the tensor catalog come from the model's own config.json (aien_inference_abi::load_model_config, checkpoint::llama_catalog). Anything that is not LlamaForCausalLM, uses an activation other than silu, has attention or MLP bias, or uses a rope_type other than default or llama3 is refused with the field named.
  2. Tied embeddings: when tie_word_embeddings is true the catalog has no lm_head.weight, TransformerWeights.lm_head is None, and output_projection() returns the embedding table itself. No copy is made. Both the CPU reference and the Omega GPU backend read the output projection through that one accessor.
  3. llama3 rope scaling (Llama3RopeScaling, RopeParams) follows the wavelength bands of the HF reference. Plain rope keeps the exact old expression, so TinyLlama is bit identical.
  4. ChatTokenizer::from_model_dir picks the chat template (Zephyr or Llama 3 instruct) from tokenizer_config.json or chat_template.jinja, the stop set from generation_config.json eos_token_id (falling back to config.json), and the context length from max_position_embeddings. The template text carries no BOS; the tokenizer post-processor adds exactly one.
  5. COMPOSE_ASSISTANT_PREFIX is now "filename:" (compose-v5 had "filename: " with a trailing space). One constant, used by the daemon proposer, the gate driver and the tests.
  6. finish_reason reuses compose-v5's plumbing (commit 2af89bd); this cut only checks that it reaches the receipt (see below).
  7. The daemon reads config.json when it sits next to the checkpoint (AIEN_MODEL_PATH / AIEN_MODEL_DIR); with no such file it keeps the built-in TinyLlama config. The default model is unchanged.

Side fix found on the way: the batched decode path had a hard-wired stop set {0, 1, 2}. In the Llama 3 vocabulary those ids are !, " and #, so a reply would have ended at the first !. The batch path now uses the model's stop set (ModelConfig::stop_token_ids, legacy {0,1,2} only when the config names none).

Inputs (sha256)

modelfilesha256
TinyLlama-1.1B-Chat-v1.0model.safetensors6e6001da2106d4757498752a021df6c2bdc332c650aae4bae6b0c004dcf14933
config.json486bedda3a6988332e60d9638a09ca4b260d34ebcf1b19e22cf3b140b63d8fe9
generation_config.json18046d04f5bd8b4998095ecabdd17a1bf0053d9acdccead4a05be4a3575f3c5c
tokenizer.jsonbcd04f0eadf90287bd26e1a183ac487d8a141b09b06aecb7725bbdd343640f2e
unsloth/Llama-3.2-1B-Instruct (5a8abab)model.safetensors1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f
config.jsondfb67fd8afe73a1c75245824ef9d64a6ba8983025447e3bf76aa1ea57ee46152
generation_config.json6d4f979915331212d7672c68b22a4ddad9e21ed8126cf2bd1ea6b2b88f595c1c
tokenizer.json6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b
tokenizer_config.json9ddd255c19fe319c8d4e891163540382e9fbda99f394674f2a929efc47d57458
chat_template.jinja5816fce10444e03c2e9ee1ef8a4a1ea61ae7e69e438613f3b17b69d0426223a4
unsloth/Llama-3.2-3B-Instruct (006f5dc)model-00001-of-00002.safetensors13cbd6d16e927a0c5bad54102514e6e18b4a47b3a6eb911e39d678d328d19f55
model-00002-of-00002.safetensors7b770216613ac5c34d7c54bdff1fa616bc4e338a9d0b20af6303e48c295ee23c
model.safetensors.index.json0a57c30afc07c81610ae7fe013bea3b9d50365f9a8145ae98e8714220f3d7c7c
config.jsoneadff796b79b82cefa0537004668d70a1dd099fd4986b91ef88398ed91b26311
generation_config.json8bab06a398ca622f8b941eb0b5f425d71d007080436cfa4f37d6c03c23b756a9
tokenizer.json6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b
tokenizer_config.json9ddd255c19fe319c8d4e891163540382e9fbda99f394674f2a929efc47d57458

GPU engine: prebuilt libomega_gpu.a from omega 62b6a28 (sha256 ef80e431...), linked with AIEN_OMEGA_GPU_LIB.

How the gates were run

The gate driver is a small scratch example kept out of the tree (it hard-codes the three NEXT-PHASE-1 tasks). It follows the daemon path exactly: load_model_config then load_from_safetensors (strict catalog), the shared KV spine, NativeTransformerBackend, ChatTokenizer::from_model_dir, one warm-up turn on WARM_UP_TEXT, then for each task proposal_prompt -> format_chat + "filename:", greedy, 96 tokens max, the model's stop set.

# CPU (reference backend)
AIEN_FORCE_CPU_STUB=1 cargo build --release --example llama3diag -p aien-runtime
llama3diag <model_dir> tasks 96 > l1b-cpu.json
# GPU (Omega backend), under the quiet lock
AIEN_OMEGA_GPU_LIB=<libomega_gpu.a> cargo build --release --example llama3diag -p aien-runtime
quietlock hold --owner np1-engine --minutes 20 -- env DIAG_BACKEND=omega llama3diag <model_dir> tasks 96

The HF reference is transformers greedy decoding in float32 on the exact prompt ids the Rust side produced (so tokenizer and model are checked separately), run from a scratch script outside the repo. It also records the smallest top-1 vs top-2 logit gap along each reply.

Gate A: tests and lint

Gate B: CPU

PROVEN TinyLlama regression. Through the new config.json path (Zephyr template, stop [2]) on the v4 attempt-1 prompt: the same prompt ids, the same 48 output ids as v4, and the same warm-up token (29956).

PROVEN Llama-3.2-1B, CPU reference, all three tasks token-for-token equal to HF float32 greedy, all ending on eos (128009):

taskprompt tokensoutput tokensstopsmallest logit gap
NOTES.md10616eos0.349
docs/HOURS.txt11716eos2.918
checklist.md11318eos0.0058

Task 3 had a near tie (0.0058) and still matched.

Replies (prefix included):

filename: README.md
# Project Notes
This project keeps every change inside its workspace.

filename: docs/HOURS.txt
open 09:00
close 17:30

filename: checklist.md
lock: Locking system
key: Key management
lamp: Lighting system

The 1B model names the wrong file in task 1 (README.md) and decorates task 3. That is the model's answer, matched by HF; it is not an engine error.

PROVEN Llama-3.2-3B (two shard files, so this also exercises the sharded loader), CPU reference, all three tasks token-for-token equal to HF float32 greedy, all ending on eos. Weight load 33.4 s, warm-up 12.7 s (first id 2181).

taskprompt tokensoutput tokensstopsmallest logit gapprefill msdecode tok/s
NOTES.md10665eos0.131115430.86
docs/HOURS.txt11716eos1.922127850.82
checklist.md11341eos0.300124980.85

The 3B model answers task 2 exactly. In task 1 it writes docs/README.md and in task 3 it puts the full workspace path in the filename line. Both are model answers that HF also gives.

Gate C: GPU (Omega backend, no CUDA)

PROVEN Llama-3.2-1B on the Omega GB10 backend: all ops native (`rmsnorm, apply_rope, matmul_vec, matmul_batch, swiglu, gqa_attention, paged_attention, paged_attention_batch, compute_logits`), no fallbacks. All three replies token-for-token equal to the CPU run (and so to HF), all ending on eos.

taskprefill msdecode tok/stotal ms
NOTES.md20615.154975
docs/HOURS.txt21925.165097
checklist.md22145.215479

Warm-up turn 9866 ms (124 prompt tokens, first id 40). Weight load 11.7 s. Load average was about 7.5 during the run because the workspace test suite was running at the same time, so these times are an upper bound, not a benchmark.

PROVEN, BLOCKED Llama-3.2-3B on the Omega backend does not run. The omega attention kernel accepts only head_dim == 64 (stated in aien-omega-gpu, and returned as TOO_LARGE on the first decode step); Llama 3.2 3B uses head_dim 128. The strict real-model guard stopped the run instead of falling back to CPU, which is the intended behavior. The gap is in the omega engine (pinned 62b6a28), not in this cut. Llama 3.2 1B (head_dim 64) and TinyLlama (64) are unaffected.

A first attempt failed earlier, at channel creation with "out of memory" (RM_ALLOC status NV_ERR_NO_MEMORY), while the HF 3B reference run was holding host memory. The retry passed that stage and hit the head_dim limit above. INFERRED the first failure was memory pressure from the concurrent run.

finish_reason reaches the receipt

Notes and limits