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 / release / ORACLE-FIXTURE-CAND4.md

169 lines · 9473 bytes Raw Blame History Rendered
1# CAND-4 oracle fixture: provenance
2
3The release gate (`scripts/check-release-candidate.sh`) requires two oracle-fixture digests in the `[model]` table of
4`release/candidate.toml`. CAND-3's fixture (`crates/aien-inference-abi/fixtures/tinyllama_oracle.*`) belongs to
5TinyLlama and does not apply to CAND-4's model (unsloth/Llama-3.2-1B-Instruct, snapshot 5a8abab). This file records
6how the CAND-4 fixture was made, with the same procedure as CAND-3's.
7
8## What it is
9
10An independent reference: Hugging Face Transformers runs the model on the CPU in FP32 (eager attention) on one fixed
11chat prompt and records 132 activation tensors (embedding, per layer post_rmsnorm, post_rope_q, post_rope_k,
12post_attention, post_attn_residual, post_attn_norm, post_swiglu, post_residual for 16 layers, final norm, logits,
13last-token logits), the top-10 next-token logits and 16 greedy tokens. It does not use any AIEN code.
14
15The oracle was made once as scratch outside every repository. AIEN does not depend on it at
16build, test or run time: no Python and no Hugging Face code is committed, and nothing in the build, the tests or the
17runtime runs it. Only its two output files and their digests are kept, as a recorded reference. The architecture
18record is the additive amendment `qualification/candidates/CAND-4.amendment-1.toml` (aien-architecture#152); the
19frozen CAND-4 manifest itself is unchanged. The release gate (`scripts/check-release-candidate.sh`) reads
20only `release/candidate.toml`: it requires the two digests to be present there as sha256 values, and it never reads
21the architecture manifest, so it needs no repointing to the amendment file.
22
23| file (crates/aien-inference-abi/fixtures/) | bytes | sha256 |
24|---|---|---|
25| llama32_1b_oracle.safetensors | 50834760 | bf1d83edc1b802ad25cfbbce7a043658d3d4797bd67955447ce8630b51f515ed |
26| llama32_1b_oracle_manifest.json | 23139 | 6df1b39eb351db7f8626734e8de882b572c8678bab924b932640621b21235e82 |
27
28Stored in plain git like CAND-3's fixture (no LFS). The tokenizer and config copies the generator also writes are
29not committed (their names would overwrite CAND-3's files); they are the model's own files, pinned by digest in the
30`[model]` table: tokenizer.json 6b9e4e7f..., config.json dfb67fd8..., tokenizer_config.json 9ddd255c....
31
32## Inputs
33
34- Model: ~/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/snapshots/5a8abab4a5d6f164389b1079fb721cfab8d7126c,
35 model.safetensors 1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f (the manifest records it as `model_sha256`).
36- Prompt: the CAND-3 system and user text ("You are a sovereign AI assistant." / "Explain the role of an operating
37 system in one sentence.") in the Llama 3 layout that AIEN renders (`ChatTemplate::Llama3::render`,
38 crates/aien-inference-abi/src/tokenizer.rs), BOS added by the tokenizer: 34 tokens
39 `128000 128006 9125 128007 271 2675 527 264 46384 15592 18328 13 128009 128006 882 128007 271 849 21435 279 3560 315
40 459 10565 1887 304 832 11914 13 128009 128006 78191 128007 271`.
41
42## Generator
43
44- Origin: `scripts/generate_tinyllama_oracle.py` as of `d2cacfa^` (the commit before "Remove the remaining Python
45 scripts", d2cacfa; first added in 8c34468), file sha256 6247aa9d4bded40fa8756be278eec3c043ec6e65c506ccbc1f579807ae006b0d.
46- It was run as scratch tooling outside every repository (Drake's rule: no Python in any AIEN repo, build, CI or
47 tooling; agents may use Python as scratch). The script is not committed. The adapted copy has sha256
48 7f7fa648c1aed28560a3d7547d63a788ad8625df0b425f2aed404946a30e96ee.
49- Changes are constants only: snapshot path, model id, output file names, prompt text, and the expected prompt tokens,
50 first greedy token, 16 greedy tokens and decoded text (each taken from the run's own failure message, as the
51 original constants were). The procedure, hooks, dtype, tolerances and file format are unchanged. Diff:
52
53```diff
54--- generate_tinyllama_oracle.orig.py
55+++ generate_llama32_1b_oracle.py
56@@ -22,32 +22,31 @@
57
58 PINNED_SNAPSHOT = (
59 "~/.cache/huggingface/hub/"
60- "models--TinyLlama--TinyLlama-1.1B-Chat-v1.0/snapshots/"
61- "fe8a4ea1ffedaf415f4da2f062534de366a451e6"
62+ "models--unsloth--Llama-3.2-1B-Instruct/snapshots/"
63+ "5a8abab4a5d6f164389b1079fb721cfab8d7126c"
64 )
65
66 CANONICAL_PROMPT = (
67- "<|system|>\n"
68- "You are a sovereign AI assistant.</s>\n"
69- "<|user|>\n"
70- "Explain the role of an operating system in one sentence.</s>\n"
71- "<|assistant|>\n"
72+ "<|start_header_id|>system<|end_header_id|>\n\n"
73+ "You are a sovereign AI assistant.<|eot_id|>"
74+ "<|start_header_id|>user<|end_header_id|>\n\n"
75+ "Explain the role of an operating system in one sentence.<|eot_id|>"
76+ "<|start_header_id|>assistant<|end_header_id|>\n\n"
77 )
78
79 EXPECTED_PROMPT_TOKENS = [
80- 1, 529, 29989, 5205, 29989, 29958, 13, 3492, 526, 263, 577, 369, 7577, 319,
81- 29902, 20255, 29889, 2, 13, 29966, 29989, 1792, 29989, 29958, 13, 9544,
82- 7420, 278, 6297, 310, 385, 13598, 1788, 297, 697, 10541, 29889, 2, 13,
83- 29966, 29989, 465, 22137, 29989, 29958, 13
84+ 128000, 128006, 9125, 128007, 271, 2675, 527, 264, 46384, 15592, 18328, 13,
85+ 128009, 128006, 882, 128007, 271, 849, 21435, 279, 3560, 315, 459, 10565,
86+ 1887, 304, 832, 11914, 13, 128009, 128006, 78191, 128007, 271
87 ]
88
89 EXPECTED_GREEDY_16 = [
90- 2744, 13598, 1788, 313, 3267, 29897, 338, 263, 7047, 393, 767, 1179,
91- 278, 12837, 322, 7047
92+ 2127, 10565, 1887, 320, 3204, 8, 374, 264, 3241, 6324, 430, 29972,
93+ 6500, 12035, 5070, 11
94 ]
95
96 EXPECTED_DECODED_TEXT = (
97- "An operating system (OS) is a software that manages the hardware and software"
98+ "An operating system (OS) is a software layer that manages computer hardware resources,"
99 )
100
101
102@@ -208,8 +207,8 @@
103 greedy_next_token_text = tokenizer.decode([greedy_next_token_id])
104
105 print(f"Greedy next token: ID={greedy_next_token_id} ({repr(greedy_next_token_text)}), logit={greedy_next_token_logit:.4f}")
106- if greedy_next_token_id != 2744:
107- raise ValueError(f"Greedy next token mismatch: expected 2744, got {greedy_next_token_id}")
108+ if greedy_next_token_id != 2127:
109+ raise ValueError(f"Greedy next token mismatch: expected 2127, got {greedy_next_token_id}")
110
111 top_tokens_meta = []
112 for idx, logit in zip(top10_token_ids, top10_logit_values):
113@@ -256,7 +255,7 @@
114 for name, tensor in activations.items()
115 }
116
117- safetensors_path = os.path.join(output_dir, "tinyllama_oracle.safetensors")
118+ safetensors_path = os.path.join(output_dir, "llama32_1b_oracle.safetensors")
119 print(f"Saving {len(contiguous_activations)} oracle tensors to {safetensors_path}...")
120 safetensors.torch.save_file(contiguous_activations, safetensors_path)
121 safetensors_sha256 = compute_file_sha256(safetensors_path)
122@@ -290,10 +289,10 @@
123 }
124
125 manifest = {
126- "model_id": "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
127+ "model_id": "unsloth/Llama-3.2-1B-Instruct",
128 "model_sha256": model_sha256,
129 "tokenizer_sha256": tokenizer_sha256,
130- "safetensors_file": "tinyllama_oracle.safetensors",
131+ "safetensors_file": "llama32_1b_oracle.safetensors",
132 "safetensors_sha256": safetensors_sha256,
133 "safetensors_bytes": safetensors_bytes,
134 "prompt_text": CANONICAL_PROMPT,
135@@ -319,7 +318,7 @@
136 "tensors": tensor_catalog,
137 }
138
139- manifest_path = os.path.join(output_dir, "tinyllama_oracle_manifest.json")
140+ manifest_path = os.path.join(output_dir, "llama32_1b_oracle_manifest.json")
141 with open(manifest_path, "w", encoding="utf-8") as f:
142 json.dump(manifest, f, indent=2)
143 manifest_sha256 = compute_file_sha256(manifest_path)
144```
145
146## Run
147
148- Environment: ~/.venv, torch 2.14.0+cu130, transformers 5.17.0, safetensors 0.8.0 (CPU only), on the Spark
149 (Linux 7.0.0-1019-nvidia aarch64), 2026-10-06.
150- Command: `~/.venv/bin/python3 -I generate_llama32_1b_oracle.py --output-dir out` (about 13 s wall).
151- Ran twice into separate directories: both runs gave byte-identical files (the two sha256 above).
152- Result: next token 2127 "An" (logit 30.5234; then 791 "The" 28.4298, 32 "A" 26.6412). 16 greedy tokens
153 `2127 10565 1887 320 3204 8 374 264 3241 6324 430 29972 6500 12035 5070 11`, text
154 "An operating system (OS) is a software layer that manages computer hardware resources,".
155
156## Independence check against the CAND-4 aien-cli
157
158Result: AGREE (decoded text level). On 2026-10-06 20:41Z the CAND-4 aien-cli (sha256
159ad6b7eb5330ea19d31d02e68271624d5c964bcbc24983742caae845f62c4c324, the frozen REAL3 build) ran as a daemon on the GB10
160(`Backend: NativeTransformerBackend/OmegaGb10Backend`, model and tokenizer digests as above, `AIEN_REQUIRE_BLACKWELL=1`,
161private socket and state dirs, under a quietlock hold). One `StreamTurn` control request with the same system and
162user messages, `max_tokens` 16, `temperature` 0.0 returned 16 tokens with the text
163"An operating system (OS) is a software layer that manages computer hardware resources,", identical to the
164oracle's 16-token greedy text.
165
166Limits: aien-cli exposes decoded text, not token ids or logits, so this check compares the 16-token text and count,
167not the activations or logits in the fixture. The prompt rendering on the aien-cli side is AIEN's own
168(`ChatTemplate::Llama3`); its token ids were not printed. Logit-level parity against this fixture (as the TinyLlama
169strict test does for CAND-3) is not run here.