interplane.Get Omega
Read in your language

benchmarks-mv

Measurement harnesses and evidence bundles for AIEN on the NVIDIA DGX Spark GB10. Speed is reported against the machine's physical limit and my own previous run. Attachment of AienOS.

Brought by drakestapleton

branch main Branches Tags History

benchmarks-mv / evidence / q36-step-model-20261031 / q36-step-model.wl

163 lines · 12374 bytes Raw Blame History
1(* q36-step-model.wl: the fitted step-time model of the Qwen3.6-35B-A3B decode stroke on one GB10 (DRA-64).
2 Version q36-step-model/1, 2026-10-31. Changes only through a model-revision issue.
3 Needs q36in (inputs.wl, generated from the sha256-pinned files by scripts/extract-inputs.sh) evaluated first.
4
5 t(n) = a + b n + c U(n) + h Ceiling[n/4] [ms per stroke of n heads]
6 U(n) = experts read per layer per stroke = routed-expert union of the n heads + 1 shared expert.
7 The a, b, c, h published on Linear DRA-64 are frozen in q36Published; predict[] always uses them.
8
9 Fit procedure (the one that reproduces the published numbers, see report key "fitPublishedProcedure"):
10 c = (gate_up + down chip time of the stamped lever-2 eight-head stroke) / U(8)
11 h = (lm_head chip time of that stroke) / (its lm_head launches)
12 a, b = least squares of median(n) - c U(n) - h Ceiling[n/4] over the lever-2 ladder n = 1, 2, 4, 8.
13 [INFERENCE] c and h come from ONE stamped shared-chip stroke (timeline_last_stroke, total_ns 77738400), not from a
14 median, so they carry that stroke's noise and the stamping overhead. c assumes gate_up + down time is fully
15 proportional to U, with no fixed per-launch term; a fixed term, if any, is absorbed into a and b.
16 In-sample residuals of the published model are up to about 8.5 % of the prediction (report key
17 "publishedModelResidualFraction"), so a no-op lever can approach the 10 % rule at n = 4 from shared-chip drift alone.
18
19 Use by later lever issues: recordLever["lever-3", n, U, measuredMs] returns predicted, measured, residual and the
20 verdict; |residual| > 10 % of the prediction means OPEN_MODEL_REVISION_ISSUE (a new versioned .wl, never an edit). *)
21
22q36ModelVersion = "q36-step-model/1 (DRA-64, 2026-10-31)";
23
24(* ---- frozen model (Linear DRA-64 text) ---- *)
25q36Published = <|"a" -> 913/100, "b" -> 329/100, "c" -> 696/1000, "h" -> 481/100, "rms" -> 24/10,
26 "U" -> {9, 163/10, 307/10, 556/10}, "Uindep8" -> 584/10, "tokS8measured" -> 955/10, "tokS8indep" -> 933/10|>;
27q36Halfunit = <|"a" -> 5/1000, "b" -> 5/1000, "c" -> 5/10000, "h" -> 5/1000, "rms" -> 5/100|>;
28q36Ns = {1, 2, 4, 8};
29q36CeilingGBs = 273; (* GB10 LPDDR5X ceiling quoted in motor-chip README L154 *)
30q36MaxHeadsQualified = 8; (* OMEGA_GPU_Q36_MAX_HEADS 8u, omega-mv 474197e4 src/omega_gpu_q36_graph.h L66 *)
31
32q36t[n_, u_, p_Association] := p["a"] + p["b"] n + p["c"] u + p["h"] Ceiling[n/4];
33predict[n_, u_] := q36t[n, u, q36Published];
34predictTokS[n_, u_] := 1000 n/predict[n, u];
35q36Uindep[n_] := 1 + 256 (1 - (1 - 8/256)^n); (* independent top-8 draws from 256 routed experts, + shared *)
36q36RevisionThreshold = 1/10;
37recordLever[lever_String, n_, u_, measuredMs_] := Module[{p = predict[n, u], r},
38 r = (measuredMs - p)/p;
39 <|"lever" -> lever, "n" -> n, "U" -> q36Num[u], "predictedMs" -> q36Num[p], "measuredMs" -> q36Num[measuredMs],
40 "residual" -> q36Num[r],
41 "verdict" -> If[Abs[r] > q36RevisionThreshold, "OPEN_MODEL_REVISION_ISSUE", "WITHIN_MODEL"],
42 "scope" -> If[n > q36MaxHeadsQualified, "architecture projection until OMEGA_GPU_Q36_MAX_HEADS > 8 is qualified", "fitted range"]|>];
43
44(* ---- derived inputs ---- *)
45(* The stroke gate's median (and the README ladder) is the upper median: element Floor[len/2]+1 of the sorted list.
46 Wolfram's Median averages the middle pair for an even count; both are reported, the fit uses the gate's. *)
47q36GateMedian[x_List] := Sort[x][[Floor[Length[x]/2] + 1]];
48q36MedMs[in_] := Table[q36GateMedian[in["ladderNs" <> ToString[k]]]/10^6, {k, q36Ns}];
49q36MedMsMean[in_] := Table[Median[in["ladderNs" <> ToString[k]]]/10^6, {k, q36Ns}];
50q36UfromCells[cells_] := 1 + Mean[cells];
51q36ExpertsNs[in_] := in["stampsKindNs"]["gate_up"] + in["stampsKindNs"]["down"];
52q36Fit[ms_, u_, in_] := Module[{c, h, r, ab, fitted},
53 c = (q36ExpertsNs[in]/10^6)/u[[4]];
54 h = (in["stampsKindNs"]["lm_head"]/10^6)/in["stampsKindLaunches"]["lm_head"];
55 r = ms - c u - h Ceiling[q36Ns/4];
56 ab = LeastSquares[Transpose[{ConstantArray[1, 4], q36Ns}], r];
57 fitted = ab[[1]] + ab[[2]] q36Ns + c u + h Ceiling[q36Ns/4];
58 <|"a" -> ab[[1]], "b" -> ab[[2]], "c" -> c, "h" -> h, "rms" -> Sqrt[Mean[(ms - fitted)^2]],
59 "residualsMs" -> ms - fitted|>];
60q36FreeFit[ms_, u_] := Module[{x = LinearSolve[Transpose[{ConstantArray[1, 4], q36Ns, u, Ceiling[q36Ns/4]}], ms]},
61 <|"a" -> x[[1]], "b" -> x[[2]], "c" -> x[[3]], "h" -> x[[4]],
62 "note" -> "four parameters through four points: an interpolation, RMS 0 by construction"|>];
63q36Rms[ms_, u_] := Sqrt[Mean[(ms - Table[predict[q36Ns[[i]], u[[i]]], {i, 4}])^2]];
64q36Reproduced[fit_] := AllTrue[{"a", "b", "c", "h", "rms"}, Abs[fit[#] - q36Published[#]] <= q36Halfunit[#] &];
65q36Num[x_] := N[Round[x, 1/10^6]]; (* display only: exact arithmetic throughout, rounded to 1e-6 at output *)
66q36NumAssoc[a_Association] := Map[If[NumericQ[#] || VectorQ[#, NumericQ], q36Num[#], #] &, a];
67
68q36Report[in_] := Module[{ms, uLinear, uMatched, uQuoted, uIndep, fitLinear, fitMatched, fitIndep, stampMed,
69 u8stamp, bw, bwRow, checks, proj, variants, pinnedMeans},
70 ms = q36MedMs[in];
71 stampMed = q36GateMedian[in["stampsNs"]]/10^6;
72 uLinear = q36Published["U"];
73 uMatched = q36UfromCells /@ {in["cells[ladder1-p1]"], in["cells[ladder2-p1p2]"], in["cells[ladder4-p1234]"],
74 in["cells[ladder8-setb]"]};
75 uIndep = q36Uindep /@ q36Ns;
76 (* the README quotes behind the Linear U: 4 chat prompts (29.7), mean of 8-prompt sets a and b (54.7, 54.5) *)
77 uQuoted = <|"U4 from 4chat" -> q36UfromCells[in["cells[4chat]"]],
78 "U8 from mean(set a, set b)" -> 1 + Mean[{Mean[in["cells[8a]"]], Mean[in["cells[ladder8-setb]"]]}],
79 "U2 candidate code+p2" -> q36UfromCells[in["cells[pair-code-p2]"]],
80 "U2 candidate code+review" -> q36UfromCells[in["cells[pair-code-review]"]],
81 "U2 of the ladder pair p1+p2" -> uMatched[[2]]|>;
82 pinnedMeans = <|"4p" -> {Mean[in["cells[ladder4-p1234]"]], in["pinnedUnionMean[4p]"]},
83 "4chat" -> {Mean[in["cells[4chat]"]], in["pinnedUnionMean[4chat]"]},
84 "8prompts" -> {Mean[in["cells[8a]"]], in["pinnedUnionMean[8prompts]"]},
85 "8prompts-b" -> {Mean[in["cells[ladder8-setb]"]], in["pinnedUnionMean[8prompts-b]"]}|>;
86 fitLinear = q36Fit[ms, uLinear, in];
87 fitMatched = q36Fit[ms, uMatched, in];
88 fitIndep = q36Fit[ms, uIndep, in];
89 (* per-class achieved bandwidth on the stamped lever-2 stroke (set b heads; U from the ladder-8 set-b union).
90 Stamps cost chip time: these are stamped-timeline rates, not speed receipts. bytes/ns = GB/s. *)
91 u8stamp = uMatched[[4]];
92 bwRow[name_, bytes_, kinds_List] := Module[{ns = Total[in["stampsKindNs"] /@ kinds]},
93 {name, q36Num[bytes], Total[in["stampsKindLaunches"] /@ kinds], q36Num[ns/10^6], q36Num[bytes/ns],
94 q36Num[100 (bytes/ns)/q36CeilingGBs]}];
95 bw = {{"class", "bytes per stroke", "launches", "ms", "GB/s", "% of 273 GB/s"},
96 bwRow["experts gate_up+down (U8 set b)", in["bytes[layers]"] u8stamp in["bytes[expert]"], {"gate_up", "down"}],
97 bwRow["experts gate_up", in["bytes[layers]"] u8stamp in["bytes[gate_up]"], {"gate_up"}],
98 bwRow["experts down", in["bytes[layers]"] u8stamp in["bytes[down]"], {"down"}],
99 bwRow["lm_head bf16 (2 four-head reads)", in["stampsKindLaunches"]["lm_head"] in["bytes[lm_head]"], {"lm_head"}],
100 bwRow["mix (FP8 + scales)", in["bytes[mix]"], {"mix"}],
101 bwRow["o_proj (FP8 + scales)", in["bytes[o_proj]"], {"o_proj"}],
102 bwRow["router (bf16 256x2048)", in["bytes[router]"], {"router"}],
103 bwRow["ab (bf16 in_proj_a,b)", in["bytes[ab]"], {"ab"}],
104 bwRow["superseded: experts at 768-wide 3x2048x768 B", in["bytes[layers]"] u8stamp 3*2048*768, {"gate_up", "down"}]};
105 variants = <|
106 "measured union (Linear U8 = 55.6)" -> <|"U8" -> 556/10, "tMs" -> q36Num[predict[8, 556/10]],
107 "tokS" -> q36Num[predictTokS[8, 556/10]]|>,
108 "independent-draw union (U8 = 1 + 256(1-(31/32)^8))" -> <|"U8" -> q36Num[q36Uindep[8]],
109 "tMs" -> q36Num[predict[8, q36Uindep[8]]], "tokS" -> q36Num[predictTokS[8, q36Uindep[8]]]|>,
110 "independent-draw union, Linear rounding (U8 = 58.4)" -> <|"U8" -> 584/10, "tMs" -> q36Num[predict[8, 584/10]],
111 "tokS" -> q36Num[predictTokS[8, 584/10]]|>,
112 "ladder-matched union (U8 set b)" -> <|"U8" -> q36Num[u8stamp], "tMs" -> q36Num[predict[8, u8stamp]],
113 "tokS" -> q36Num[predictTokS[8, u8stamp]]|>|>;
114 proj = Prepend[Table[{n, q36Num[q36Uindep[n]], q36Num[predict[n, q36Uindep[n]]], q36Num[predictTokS[n, q36Uindep[n]]],
115 If[n > q36MaxHeadsQualified, "architecture projection until OMEGA_GPU_Q36_MAX_HEADS > 8 is qualified",
116 "independent-draw variant (fitted range n <= 8)"]}, {n, {1, 2, 4, 8, 16, 32, 64}}],
117 {"n", "U independent draws", "t ms", "tok/s", "status"}];
118 checks = <|
119 "ladderMediansMatchReadme" -> AllTrue[Abs[ms - in["readmeLadderMs"]], # <= 5/10000 &],
120 "ladderMediansMatchFileField" -> (ms == Table[in["ladderFileMedianNs" <> ToString[k]], {k, q36Ns}]/10^6),
121 "stampsMedianMatchesLog" -> (Abs[stampMed - in["stampsLogMedianMs"]] <= 5/10000),
122 "stampsKindsSumToTotal" -> (Total[Values[in["stampsKindNs"]]] == in["stampsTotalNs"]),
123 "ladderHeadsAre1248" -> ({in["ladderHeads1"], in["ladderHeads2"], in["ladderHeads4"], in["ladderHeads8"]} == q36Ns),
124 "pinnedUnionMeansRederived" -> AllTrue[Values[pinnedMeans], Abs[#[[1]] - #[[2]]] <= 10^-9 &],
125 "expertBytesContract" -> (in["bytes[expert]"] == 3*2048*512 + 3*16*4*2 == 3146112 &&
126 in["bytes[shared]"] == in["bytes[expert]"] && in["bytes[gate_up]"] + in["bytes[down]"] == in["bytes[expert]"] &&
127 in["bytes[routed_expert_tensor_sets_layer0]"] == 256 && in["bytes[layers]"] == 40),
128 "lmHeadBytes" -> (in["bytes[lm_head]"] == 248320*2048*2),
129 "mixBytesMatchReadme0944GB" -> (Round[in["bytes[mix]"]/10^9, 1/1000] == 944/1000),
130 "fitPublishedReproducedLinearU" -> q36Reproduced[fitLinear],
131 "linearU4U8MatchPinnedUnions" -> (Round[uQuoted["U4 from 4chat"], 1/10] == uLinear[[3]] &&
132 Round[uQuoted["U8 from mean(set a, set b)"], 1/10] == uLinear[[4]]),
133 "indepFormulaMatchesPinnedFiles" -> (Abs[q36Uindep[8] - 1 - in["pinnedUnionIndep[8prompts]"]] <= 10^-9 &&
134 Abs[q36Uindep[4] - 1 - in["pinnedUnionIndep[4p]"]] <= 10^-9),
135 (* publishedPin*: pins of the published Linear text against q36Published; they do not read the inputs *)
136 "publishedPinT8" -> (predict[8, 556/10] == 837676/10000 && Round[predictTokS[8, 556/10], 1/100] == 9550/100),
137 "publishedPinIndep8" -> (Round[q36Uindep[8], 1/10] == 584/10 && Round[predictTokS[8, q36Uindep[8]], 1/10] == 933/10),
138 "weightClassesBelowCeiling" -> AllTrue[Most[Rest[bw]][[All, 5]], # <= q36CeilingGBs &]|>;
139 <|"version" -> q36ModelVersion,
140 "checks" -> checks,
141 "allChecksPass" -> AllTrue[Values[checks], TrueQ],
142 "ladderMediansMs (gate upper median)" -> q36Num[ms], "readmeLadderMs" -> in["readmeLadderMs"],
143 "ladderMediansMs (Wolfram Median, mean of middle pair)" -> q36Num[q36MedMsMean[in]],
144 "stampsMedianMs" -> q36Num[stampMed],
145 "U" -> <|"linear (frozen)" -> q36Num[uLinear], "ladder-matched" -> q36Num[uMatched],
146 "independent draws" -> q36Num[uIndep], "quoted-sources" -> q36NumAssoc[uQuoted],
147 "ladder-matched minus linear" -> q36Num[uMatched - uLinear]|>,
148 "pinnedUnionMeans {wolfram, file}" -> Map[q36Num, pinnedMeans],
149 "fitPublishedProcedure (linear U)" -> q36NumAssoc[fitLinear],
150 "fitPublishedProcedure (ladder-matched U)" -> q36NumAssoc[fitMatched],
151 "fitPublishedProcedure (independent-draw U)" -> q36NumAssoc[fitIndep],
152 "freeFit (linear U)" -> q36NumAssoc[q36FreeFit[ms, uLinear]],
153 "publishedModelRmsMs (linear U)" -> q36Num[q36Rms[ms, uLinear]],
154 "publishedModelResidualsMs (linear U)" -> q36Num[ms - Table[predict[q36Ns[[i]], uLinear[[i]]], {i, 4}]],
155 "publishedModelResidualFraction (linear U, (measured - predicted)/predicted)" ->
156 q36Num[Table[(ms[[i]] - predict[q36Ns[[i]], uLinear[[i]]])/predict[q36Ns[[i]], uLinear[[i]]], {i, 4}]],
157 "variantsN8" -> variants,
158 "bandwidth (stamped lever-2 stroke)" -> bw,
159 "projection" -> proj,
160 "revisionRuleExamples" -> {recordLever["example within", 8, 556/10, 105/100 predict[8, 556/10]],
161 recordLever["example breach", 8, 556/10, 115/100 predict[8, 556/10]]}|>];
162
163q36Report[q36in]