interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / docs / qualification / INT8-ACTIVATION-QUAL-v1.md

229 lines · 18677 bytes Raw Blame History Source

INT8-ACTIVATION-QUAL-v1: prospective numerical qualification of the int8 activation path

Status: SPECIFICATION, written before any run (2026-10-11). Nothing in this document has been measured. Owner issue: aien-dev/aienux#34 (L6-B). Draft implementation: PR #300 (branch l6b-int8-dot). Authority: Drake's ruling of 2026-10-11 (aien-architecture#190, comment 6109731585; aienos#34, comment 6109732149). Kernel default stays f32 until a run of this specification records PASS and a separate, reviewed change flips it.

Every threshold below is marked PREREGISTERED: fixed here, before measuring, never edited after a run. Changing one means writing INT8-ACTIVATION-QUAL-v2 and applying it only to runs made after it is merged.

1. Purpose

Decide, with numbers fixed in advance, whether the int8 activation path (activations rounded to ggml's Q8_K grid, integer block dots, usdot on cores that have it) is an acceptable replacement for f32 activations on the supported GB10 hardware. The test must tell two things apart:

2. What the earlier FAIL established (aienos#300)

Sources: docs/l6b-int8-qualification.md, docs/l6b-int8-divergence-diagnosis.md, evidence/l6_host_3f5a22426976_l6b_parity.json, evidence/l6b_int8_divergence_3f5a22426976.json (all on branch l6b-int8-dot / PR #300, not on main).

3. Reference: how the independent quantized reference is produced

The int8 path under test is the crate's own code (quantize_q8k, Q4_K/Q6_K block dots shaped for usdot). A check that reuses that code proves nothing, so three references are used and none shares source with it.

R-A, scalar integer reference (exact tier). A new stand-alone C program, crates/aienos-infer/tests/ref/q8ref.c (to be written by the implementation round; it does not exist yet), built with plain cc -O0 and no vector flags. It is written from the published ggml block layouts (block_q4_K 144 bytes, block_q6_K 210 bytes, block_q8_K) and the Q8_K rule, not from the crate: scale iscale = -127 / max where max is the signed value of largest magnitude in the 256-value block, q = min(127, nearest_int(iscale * x)) with ties-to-even, d = 1 / iscale, plus the 16 group sums. The implementer must quote the governing lines of ggml-quants.c at commit 4a89937 in the docs-read record before writing it (UNVERIFIED here: the rule above is from memory of ggml and from the crate's own tests, not re-read for this document). It unpacks the 4-bit and 6-bit weights with its own shifts and masks and accumulates every product in int64_t. Why it is independent: different language and compiler path, no shared code, no lane structure and no dot-product instruction, wider accumulators. It shares only the published format. Where it and the crate agree bit for bit on integers, a shared mistake would have to be a mistake in the format itself, which R-B below also tests.

R-B, llama.cpp 4a89937, CPU, 1 thread (cross-implementation tier). Already used by #300 (llama_ref.c, llama_ref_hist.c, fixtures tests/fixtures/ref_*.txt). It quantizes activations to Q8_K for these weight types too, but with its own float order, so it is compared with tolerances, never bitwise. It is the tiebreaker for near-ties.

R-C, the crate's own f32 path at the base commit (baseline tier). Defines the f32 logits, the f32 margins and the rollback target. Its logits are recorded (SHA-256 of the little-endian f32 bytes per step) before any int8 change lands, in the same evidence file.

4. Prompts

All prompts use the chat template of the frozen model (Llama-3.2-1B-Instruct-Q4_K_M, sha256 3f5a22426976ab26cfe84dba63c1d08391717abb1af893e10f1b2968d862dcc1), greedy decoding, no system prompt beyond the template's default. Host budget: at most 64 new tokens. Every run must end at id 128009 inside the budget (section 5, T1). Texts are verbatim; \n is a newline.

idtextsource
P1What is the capital of France?existing (fr; golden reply ids 791 6864 315 9822 374 12366 13 128009)
P2Explain copy-on-write in one sentence.existing (cow)
P3Say hi in 3 languages: café, 日本語, 😀 (it's 100% fine).\n\n Thanks!existing (uni)
P4List the three primary colors, separated by commas.new
P5What is 17 plus 25? Answer with just the number.new
P6Write one short sentence about the ocean.new

Reserves, used in this order only if an earlier prompt fails the admission rule: R1 Name one planet in the solar system. then R2 Spell the word "cat" backwards.

Admission rule (PREREGISTERED): a prompt is admitted only if the f32 path itself ends at 128009 within 64 new tokens. Whether P4 to P6 satisfy it is UNVERIFIED (not run). A rejected prompt is replaced by the next reserve and the swap is recorded; the f32 outcome is the only thing consulted, never the int8 outcome. Minimum for a valid run: 6 admitted prompts.

Native leg: the kernel image today carries one fixed prompt (P1, MAX_NEW = 16, KV_CAPACITY = 64). The native leg therefore checks P1 only, until the kernel takes other prompts; that limit is stated in the verdict.

5. Metrics, bounds and failure signals

Two groups. Group X is exact: any miss is an implementation error. Group N is numerical: bounds on expected noise.

Group X, exact (no tolerance)

idcheckboundwhy
X1Quantizer: for every activation vector fed to a matvec during the teacher-forced runs, the crate's Q8_K output (qs, d, group sums) equals R-A's0 differing values; d bit-identicalRounding is deterministic IEEE arithmetic with ties-to-even; there is no legitimate difference. PREREGISTERED
X2Integer block dots: for every block of every matvec (every layer and class, every prompt, every step), the crate's i32 accumulators (sumi, mins for Q4_K; isum for Q6_K) equal R-A's int64 results0 mismatchesBoth are integer sums over identical inputs; order cannot matter. This includes the usdot build and the portable build. PREREGISTERED
X3Scaled row result: crate's f32 row output vs R-A's f64 recomputation from the same integersabs diff <= 1e-6 x max abs of that row's reference#300 measured 6.6e-7 absolute on rows of size about 5.4 (about 1.2e-7 relative); 1e-6 relative leaves roughly 8x headroom and still catches a wrong scale. PREREGISTERED
X4Overflow guard: every i32 accumulator stays below 2^31 and no Q8_K value leaves [-127, 127]0 violationsThe diagnosis derived the bounds on paper; the run asserts them. PREREGISTERED
X5Determinism: each path run twice gives bit-identical logits for every step0 differing bitsNegative control for the harness; also separates noise from nondeterminism. PREREGISTERED
X6No non-finite value (NaN or inf) in any hidden state or logit vector, any path0A non-finite value is never quantization noise. PREREGISTERED

Group N, numerical (teacher-forced along the f32 token history unless stated)

Teacher forcing: both paths are fed the same f32 history, so one flipped choice cannot contaminate later steps.

idmetricboundwhy
N1Per-layer: for every layer and step, max abs(h_int8 - h_f32) / max abs(h_f32) of that layer's output hidden state<= 0.05A priori only: Q8_K rounds each value by at most half a step, about 0.4 percent of the block maximum, and 16 layers compound it; 5 percent is a loose ceiling meant to catch gross errors, not to bound noise tightly. No measurement was used. PREREGISTERED (basis weak, confidence low; X1/X2 carry the weight)
N2Per-step max abs logit difference, int8 vs f32, over the whole vocabulary, every step of every prompt<= 2.0#300 measured 0.43 to 1.29 over 13 steps (largest 1.288); 2.0 leaves about 55 percent headroom over the largest value seen. PREREGISTERED
N3Per-step max abs logit difference, int8 vs llama.cpp (R-B), same history<= 2.0#300 measured 1.304 at index 12 and 0.567 at the first position; same reasoning as N2. PREREGISTERED
N4First decode position of P1, int8 vs llama.cpp max abs logit difference<= 1.0The bound #300 already used (observed 0.567). PREREGISTERED
N5Logit margin: record f32 top1-top2 margin at every step (reported always, used by N6 and N7)reportedThe margin is what makes a flip excusable or not.
N6Divergence rule: a step where int8 top-1 differs from f32 top-1 is excused only if the f32 margin at that step is < T = 1.5T = 1.5 logitsT is above the largest single-logit error seen (1.288) and far above the one observed flip (margin 0.349). It is deliberately stricter than the theoretical maximum (two opposite errors could flip a margin up to 2 x N2); a false FAIL costs a re-specification, a false PASS ships a defect. PREREGISTERED
N7Top-1 agreement rate over all teacher-forced steps of all admitted prompts>= 0.98, and 1.00 over steps whose f32 margin >= TWith about 100 or more steps, 2 percent allows a couple of true near-ties; the per-step rule N6 is the real gate, this is a floor against many small flips. PREREGISTERED
N8Free run (each path decoding its own tokens): token sequences of int8 and f32 are identical, or the first split is at a step excused by N6identical or excusedFree run shows what a user sees. After an excused split the runs may differ; they must still terminate (T1). PREREGISTERED

Termination, required

idcheckbound
T1f32, int8 and llama.cpp free runs each emit 128009 (<|eot_id|>) within the budget, and decoding stops thereall admitted prompts; no token is decoded after 128009. PREREGISTERED
T2Comparisons stop at the first 128009. Positions after it (the unprompted second turn that #300 index 12 sat in) are excluded from every bound and rateby construction

Failure signals (any one means the whole run is FAIL)

  1. Any X1 to X6 miss.
  2. Any step where int8 top-1 differs from f32 top-1 and the f32 margin is >= 1.5 (N6).
  3. Any NaN or inf (X6).
  4. Any run that does not reach 128009 inside the budget (T1), including an int8 run that loops or never stops.
  5. Any N bound exceeded, or N7 below 0.98.
  6. The usdot path and the portable integer path disagree with R-A at all (X2), since both are integer math.
  7. A mutant that is not caught (section 8, negative controls).

A run with any leg skipped is NOT_RUN, never PASS.

6. CPU-feature checks and the fallback

What is needed: usdot is Armv8.6 FEAT_I8MM; the signed sdot form needs FEAT_DotProd. The #300 design selects int8 automatically only when both are present (Features { dotprod, i8mm }, DotPath::select).

7. Rollback

8. Procedure

Order matters: the harness goes red before it goes green.

  1. Freeze: commit this document. The harness reads the bounds from the table below and refuses to run if a constant in code differs; the evidence file stores this document's SHA-256.
  2. Base record: run the f32 path at the base commit; store per-step logit hashes, margins, token ids (R-C).
  3. Negative controls (must FAIL, each one recorded): (a) truncate instead of round in the Q8_K quantizer; (b) off-by-one in a sub-block scale index; (c) drop the Q4_K mins term; (d) swap a Q6_K scale sign. If a mutant passes, the harness is blind and the run is invalid. Also run f32 twice (X5) and f32-vs-f32 through the N rules (must give zero difference).
  4. Host legs L1 to L3 for all admitted prompts: teacher-forced pass (X, N1 to N7), free-run pass (N8, T1), llama.cpp comparison (N3, N4). Release build, pinned to one core, quietlock check clear first, one thread.
  5. Native legs L4, L5, R3 on QEMU (no hardware). A physical-Spark native leg is a separate decision and needs its own attended window; it is not part of v1.
  6. Write evidence/int8_qual_v1_<sha12>.json: commit, doc hash, model hash, feature lines, per-prompt tables, every metric against its bound, every mutant result, verdict. Verdict is PASS only if every row passes and no leg was skipped; FAIL on any failure signal; NOT_RUN otherwise. Nothing is re-tuned after a FAIL; the FAIL is recorded.
  7. After PASS: a separate PR proposes flipping the default, cites the evidence, and waits for Drake's decision.

BOUNDS-v1 (machine-readable, PREREGISTERED)

X3_REL=1e-6 N1_REL=0.05 N2_ABS=2.0 N3_ABS=2.0 N4_ABS=1.0 TIE_T=1.5 N7_AGREE=0.98
MAX_NEW_HOST=64 MIN_PROMPTS=6 EOT=128009 ZERO_EXACT=X1,X2,X4,X5,X6

9. Non-goals

10. Limits and UNVERIFIED items