@descix/frqtl-web 0.7.0-p2 → 0.7.0-p3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +4 -4
- package/README.md +1 -1
- package/dist/dist-manifest.json +12 -9
- package/dist/notebooks/aim-mailman-small-tensor.html +253 -0
- package/dist/notebooks/doo-same-bits-any-order.html +488 -0
- package/dist/notebooks/notebooks.json +12 -0
- package/dist/sdk.html +1 -1
- package/dist/shim/engine/router.js +2 -2
- package/dist/shim/host/device.js +3 -1
- package/dist/shim/host/host-auth.js +176 -0
- package/dist/shim/registry/studio-landing.js +21 -18
- package/dist/studio/app-assets/{SceneCodeEditor-Ck982ITn.js → SceneCodeEditor-DnAM0Uhi.js} +1 -1
- package/dist/studio/app-assets/index-YDj5QEI1.js +173 -0
- package/dist/studio/app.html +1 -1
- package/llms.txt +5 -5
- package/package.json +1 -1
- package/dist/studio/app-assets/index-DX5L-7-w.js +0 -173
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
<frqtl-notebook version="1" title="Deterministic and out of order: the same bits in any order">
|
|
2
|
+
|
|
3
|
+
<cell type="markdown">
|
|
4
|
+
# Deterministic and out of order: the same bits in any order
|
|
5
|
+
|
|
6
|
+
**DOO** is a property of integer arithmetic: a transform returns the same bits whatever the order of its operations and whatever device runs them. This notebook measures it in your browser on the EGPT math SDK (`caps.math`, the compiled WASM engine) and fingerprints every answer with SHA-256, so "the same" means the same bytes, not "close enough".
|
|
7
|
+
|
|
8
|
+
One integer matrix product, `C = A · B`, on two seeded 32×32 matrices of small integers (−127 to 127, the range an 8-bit weight takes), is computed five ways:
|
|
9
|
+
|
|
10
|
+
| Way | How the work is ordered |
|
|
11
|
+
|---|---|
|
|
12
|
+
| (a) naive | the triple loop, row by row, `k` from 0 up |
|
|
13
|
+
| (b) Strassen | seven block products instead of eight, with extra additions and subtractions |
|
|
14
|
+
| (c) eight orders and a tree | the `k` sum split across eight workers, each worker shuffling its own share, the eight partial results added in eight different orders, then once more as a pairwise tree |
|
|
15
|
+
| (d) server and client | the `k` sum cut in two: one half on the "server", one half on the "client", the partial result sent as text over the wire and added |
|
|
16
|
+
| (e) columns first | the output filled column by column, `k` counted down |
|
|
17
|
+
|
|
18
|
+
Every digest must be equal. Then each fact runs again in float64 (and float32 where it matters) as the **negative control**: the same shapes, the same orders, and the digests disagree. A gate that cannot fail is not a gate; the float rows are this notebook's proof that it can.
|
|
19
|
+
|
|
20
|
+
The cells reproduce the cases of the EGPT exact-GEMM test suite (Strassen = naive; AllReduce order independence; Kahan summation unnecessary; gradient swamping; 1000 steps of descent with zero drift) with the SDK's shipped arithmetic, and add nothing to the math. Click **Run All**; the summary at the end collects every row.
|
|
21
|
+
</cell>
|
|
22
|
+
|
|
23
|
+
<cell type="markdown">
|
|
24
|
+
## Setup: the matrices, the digest, and the shared loops
|
|
25
|
+
|
|
26
|
+
The matrices come from a seeded generator, so every reader gets the same `A` and `B`. Integer results are fingerprinted from their exact decimal strings; float results from the raw 64 bits of every entry. The helpers take `math` as an argument, so every cell builds its own EGPT values.
|
|
27
|
+
</cell>
|
|
28
|
+
|
|
29
|
+
<cell type="js" lane="math" id="doo-setup" out="kit">
|
|
30
|
+
const { math } = caps;
|
|
31
|
+
|
|
32
|
+
// mulberry32: a small seeded generator, so the matrices are the same for every reader.
|
|
33
|
+
function mulberry32(a) {
|
|
34
|
+
return function () {
|
|
35
|
+
a |= 0; a = a + 0x6D2B79F5 | 0;
|
|
36
|
+
let t = Math.imul(a ^ a >>> 15, 1 | a);
|
|
37
|
+
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
|
|
38
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const N = 32;
|
|
42
|
+
const rnd = mulberry32(20261103);
|
|
43
|
+
const randInt = () => Math.floor(rnd() * 255) - 127; // -127 .. 127
|
|
44
|
+
const A = Array.from({ length: N }, () => Array.from({ length: N }, randInt));
|
|
45
|
+
const B = Array.from({ length: N }, () => Array.from({ length: N }, randInt));
|
|
46
|
+
|
|
47
|
+
async function sha256Hex(text) {
|
|
48
|
+
const bytes = new TextEncoder().encode(text);
|
|
49
|
+
const buf = await crypto.subtle.digest('SHA-256', bytes);
|
|
50
|
+
return Array.from(new Uint8Array(buf), (b) => b.toString(16).padStart(2, '0')).join('');
|
|
51
|
+
}
|
|
52
|
+
// An exact result: every entry's decimal string, rows joined. breakSymbolicToString is the
|
|
53
|
+
// SDK's explicit boundary verb from an EGPT value to text.
|
|
54
|
+
const digestExact = (C) => sha256Hex(C.map((row) => row.map((v) => v.breakSymbolicToString()).join(',')).join(';'));
|
|
55
|
+
// A float result: the raw 64 bits of every entry.
|
|
56
|
+
const f64 = new Float64Array(1), u8 = new Uint8Array(f64.buffer);
|
|
57
|
+
const bitsHex = (x) => { f64[0] = x; return Array.from(u8, (b) => b.toString(16).padStart(2, '0')).join(''); };
|
|
58
|
+
const digestFloat = (C) => sha256Hex(C.map((row) => row.map(bitsHex).join(',')).join(';'));
|
|
59
|
+
|
|
60
|
+
// EGPT values from plain integers (each cell calls this with its own math).
|
|
61
|
+
const toReal = (m, M) => M.map((row) => row.map((v) => m.EGPTReal.fromBigInt(BigInt(v))));
|
|
62
|
+
const zeros = (m, r, c) => Array.from({ length: r }, () => Array.from({ length: c }, () => m.EGPTReal.fromBigInt(0n)));
|
|
63
|
+
// The suite's matAdd / matSub, on the SDK's EGPTMath.
|
|
64
|
+
const matAdd = (m, X, Y) => X.map((row, i) => row.map((v, j) => m.EGPTMath.add(v, Y[i][j])));
|
|
65
|
+
const matSub = (m, X, Y) => X.map((row, i) => row.map((v, j) => m.EGPTMath.subtract(v, Y[i][j])));
|
|
66
|
+
// The float control's operands: the same integers as decimal weights (A/10, B/10).
|
|
67
|
+
const Af = A.map((row) => row.map((v) => v / 10));
|
|
68
|
+
const Bf = B.map((row) => row.map((v) => v / 10));
|
|
69
|
+
|
|
70
|
+
// The suite's eight orderings of eight workers (AllReduce order independence).
|
|
71
|
+
const ORDERINGS = [
|
|
72
|
+
[0, 1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 1, 3, 5, 7], [3, 7, 1, 5, 0, 4, 2, 6],
|
|
73
|
+
[6, 0, 3, 5, 7, 2, 4, 1], [1, 0, 3, 2, 5, 4, 7, 6], [4, 5, 6, 7, 0, 1, 2, 3], [7, 0, 6, 1, 5, 2, 4, 3],
|
|
74
|
+
];
|
|
75
|
+
const short = (h) => h.slice(0, 16);
|
|
76
|
+
|
|
77
|
+
// The table look the three summary cells share (DOM is touched only when they call it).
|
|
78
|
+
const GREEN = 'background:#0f2417;color:#7ee2a8;', RED = 'background:#2a0c0c;color:#ff8a8a;';
|
|
79
|
+
const cellCss = 'padding:2px 8px;border-bottom:1px solid #2a2a2a;vertical-align:top;';
|
|
80
|
+
function table(head, rows) {
|
|
81
|
+
const t = document.createElement('table');
|
|
82
|
+
t.style.cssText = 'border-collapse:collapse;font:0.76rem/1.3 ui-monospace,monospace;margin:4px 0;width:100%;';
|
|
83
|
+
const tr0 = document.createElement('tr');
|
|
84
|
+
for (const h of head) { const th = document.createElement('th'); th.textContent = h; th.style.cssText = cellCss + 'text-align:left;color:#ccc;font-weight:600;'; tr0.appendChild(th); }
|
|
85
|
+
t.appendChild(tr0);
|
|
86
|
+
for (const r of rows) {
|
|
87
|
+
const tr = document.createElement('tr');
|
|
88
|
+
r.cells.forEach((c, i) => { const td = document.createElement('td'); td.textContent = c; td.style.cssText = cellCss + (r.css[i] || 'color:#ddd;'); tr.appendChild(td); });
|
|
89
|
+
t.appendChild(tr);
|
|
90
|
+
}
|
|
91
|
+
return t;
|
|
92
|
+
}
|
|
93
|
+
function banner(ok, text) {
|
|
94
|
+
const b = document.createElement('div');
|
|
95
|
+
b.style.cssText = 'font:600 0.9rem/1.4 system-ui,sans-serif;padding:6px 10px;border-radius:6px;margin:2px 0 6px;' + (ok ? GREEN + 'border:1px solid #1f5a36;' : RED + 'border:1px solid #5a1f1f;');
|
|
96
|
+
b.textContent = text;
|
|
97
|
+
return b;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
console.log(`A and B: ${N}x${N} integers in [-127, 127], seed 20261103`);
|
|
101
|
+
console.log(`A[0][0..7] = ${A[0].slice(0, 8).join(', ')}`);
|
|
102
|
+
console.log(`B[0][0..7] = ${B[0].slice(0, 8).join(', ')}`);
|
|
103
|
+
return { kit: { N, A, B, Af, Bf, mulberry32, sha256Hex, digestExact, digestFloat, toReal, zeros, matAdd, matSub, ORDERINGS, short, GREEN, RED, table, banner } };
|
|
104
|
+
</cell>
|
|
105
|
+
|
|
106
|
+
<cell type="markdown">
|
|
107
|
+
## (a) The naive triple loop
|
|
108
|
+
|
|
109
|
+
Row by row, column by column, `k` from 0 up: one multiply and one add per term, on the SDK's `EGPTMath`. This digest is the reference every other way must match.
|
|
110
|
+
</cell>
|
|
111
|
+
|
|
112
|
+
<cell type="js" lane="math" id="doo-naive" in="kit" out="rowNaive">
|
|
113
|
+
const { math } = caps;
|
|
114
|
+
const { EGPTMath } = math;
|
|
115
|
+
const k = inputs.kit;
|
|
116
|
+
const A = k.toReal(math, k.A), B = k.toReal(math, k.B);
|
|
117
|
+
const C = k.zeros(math, k.N, k.N);
|
|
118
|
+
for (let i = 0; i < k.N; i++)
|
|
119
|
+
for (let j = 0; j < k.N; j++) {
|
|
120
|
+
let dot = C[i][j];
|
|
121
|
+
for (let p = 0; p < k.N; p++) dot = EGPTMath.add(dot, EGPTMath.multiply(A[i][p], B[p][j]));
|
|
122
|
+
C[i][j] = dot;
|
|
123
|
+
}
|
|
124
|
+
const digest = await k.digestExact(C);
|
|
125
|
+
console.log(`C[0][0..3] = ${C[0].slice(0, 4).map((v) => v.breakSymbolicToString()).join(', ')}`);
|
|
126
|
+
console.log(`(a) naive sha256 ${digest}`);
|
|
127
|
+
return { rowNaive: { way: '(a) naive triple loop, row order', digests: [digest] } };
|
|
128
|
+
</cell>
|
|
129
|
+
|
|
130
|
+
<cell type="markdown">
|
|
131
|
+
## (b) Fact 1: Strassen equals naive, bit for bit
|
|
132
|
+
|
|
133
|
+
Strassen's decomposition trades one of eight block products for extra additions and subtractions. In float those extra operations round differently, so Strassen and naive disagree in the last bits; in exact integers they cannot. The cell first runs the suite's own two 2×2 cases (`[[12,37],[89,53]]·[[41,67],[29,71]]` and the large-primes case), then applies the same seven products recursively to the 32×32 blocks, down to single entries. The float control runs the same recursion and the same naive loop on `A/10`, `B/10`.
|
|
134
|
+
</cell>
|
|
135
|
+
|
|
136
|
+
<cell type="js" lane="math" id="doo-strassen" in="kit" out="rowStrassen">
|
|
137
|
+
const { math } = caps;
|
|
138
|
+
const { EGPTReal, EGPTMath } = math;
|
|
139
|
+
const k = inputs.kit;
|
|
140
|
+
const add = (x, y) => EGPTMath.add(x, y), sub = (x, y) => EGPTMath.subtract(x, y), mul = (x, y) => EGPTMath.multiply(x, y);
|
|
141
|
+
|
|
142
|
+
// The suite's seven products on one 2x2 (Strassen = Naive, exact).
|
|
143
|
+
function strassen2(Ai, Bi) {
|
|
144
|
+
const [[a, b], [c, d]] = Ai, [[e, f], [g, h]] = Bi;
|
|
145
|
+
const M1 = mul(add(a, d), add(e, h)), M2 = mul(add(c, d), e), M3 = mul(a, sub(f, h));
|
|
146
|
+
const M4 = mul(d, sub(g, e)), M5 = mul(add(a, b), h), M6 = mul(sub(c, a), add(e, f)), M7 = mul(sub(b, d), add(g, h));
|
|
147
|
+
return [[add(sub(add(M1, M4), M5), M7), add(M3, M5)], [add(M2, M4), add(sub(add(M1, M3), M2), M6)]];
|
|
148
|
+
}
|
|
149
|
+
function naive2(Ai, Bi) {
|
|
150
|
+
return [0, 1].map((i) => [0, 1].map((j) => add(mul(Ai[i][0], Bi[0][j]), mul(Ai[i][1], Bi[1][j]))));
|
|
151
|
+
}
|
|
152
|
+
const eq2 = (X, Y) => X.every((row, i) => row.every((v, j) => v.equals(Y[i][j])));
|
|
153
|
+
const cases = [
|
|
154
|
+
[[[12, 37], [89, 53]], [[41, 67], [29, 71]]],
|
|
155
|
+
[[[997, 853], [641, 479]], [[359, 743], [601, 257]]],
|
|
156
|
+
];
|
|
157
|
+
for (const [Ai, Bi] of cases) {
|
|
158
|
+
const s = strassen2(k.toReal(math, Ai), k.toReal(math, Bi)), n = naive2(k.toReal(math, Ai), k.toReal(math, Bi));
|
|
159
|
+
console.log(`suite case ${JSON.stringify(Ai)}·${JSON.stringify(Bi)}: Strassen ${JSON.stringify(s.map((r) => r.map((v) => v.breakSymbolicToString())))} = naive: ${eq2(s, n)}`);
|
|
160
|
+
if (!eq2(s, n)) throw new Error('Strassen != naive on a suite case');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// The same seven products, applied recursively to the blocks of an n x n matrix (n a power of two).
|
|
164
|
+
// ops = { add, sub, mul } on entries: EGPT for the exact run, plain float64 for the control.
|
|
165
|
+
function strassen(X, Y, ops) {
|
|
166
|
+
const n = X.length;
|
|
167
|
+
if (n === 1) return [[ops.mul(X[0][0], Y[0][0])]];
|
|
168
|
+
const h = n / 2;
|
|
169
|
+
const q = (M, r, c) => M.slice(r * h, r * h + h).map((row) => row.slice(c * h, c * h + h));
|
|
170
|
+
const madd = (P, Q) => P.map((row, i) => row.map((v, j) => ops.add(v, Q[i][j])));
|
|
171
|
+
const msub = (P, Q) => P.map((row, i) => row.map((v, j) => ops.sub(v, Q[i][j])));
|
|
172
|
+
const [a, b, c, d] = [q(X, 0, 0), q(X, 0, 1), q(X, 1, 0), q(X, 1, 1)];
|
|
173
|
+
const [e, f, g, hh] = [q(Y, 0, 0), q(Y, 0, 1), q(Y, 1, 0), q(Y, 1, 1)];
|
|
174
|
+
const M1 = strassen(madd(a, d), madd(e, hh), ops), M2 = strassen(madd(c, d), e, ops), M3 = strassen(a, msub(f, hh), ops);
|
|
175
|
+
const M4 = strassen(d, msub(g, e), ops), M5 = strassen(madd(a, b), hh, ops), M6 = strassen(msub(c, a), madd(e, f), ops);
|
|
176
|
+
const M7 = strassen(msub(b, d), madd(g, hh), ops);
|
|
177
|
+
const C11 = madd(msub(madd(M1, M4), M5), M7), C12 = madd(M3, M5), C21 = madd(M2, M4), C22 = madd(msub(madd(M1, M3), M2), M6);
|
|
178
|
+
return [...C11.map((row, i) => [...row, ...C12[i]]), ...C21.map((row, i) => [...row, ...C22[i]])];
|
|
179
|
+
}
|
|
180
|
+
const C = strassen(k.toReal(math, k.A), k.toReal(math, k.B), { add, sub, mul });
|
|
181
|
+
const digest = await k.digestExact(C);
|
|
182
|
+
console.log(`(b) Strassen 32x32 sha256 ${digest}`);
|
|
183
|
+
|
|
184
|
+
// Float control: the same recursion and the naive loop on A/10, B/10.
|
|
185
|
+
const fops = { add: (x, y) => x + y, sub: (x, y) => x - y, mul: (x, y) => x * y };
|
|
186
|
+
const Fs = strassen(k.Af, k.Bf, fops);
|
|
187
|
+
const Fn = k.Af.map((row, i) => k.Bf[0].map((_, j) => { let s = 0; for (let p = 0; p < k.N; p++) s += row[p] * k.Bf[p][j]; return s; }));
|
|
188
|
+
const fStrassen = await k.digestFloat(Fs), fNaive = await k.digestFloat(Fn);
|
|
189
|
+
let differ = 0;
|
|
190
|
+
for (let i = 0; i < k.N; i++) for (let j = 0; j < k.N; j++) if (Fs[i][j] !== Fn[i][j]) differ++;
|
|
191
|
+
console.log(`float64 control: naive sha256 ${fNaive}`);
|
|
192
|
+
console.log(`float64 control: Strassen sha256 ${fStrassen} (${differ} of ${k.N * k.N} entries differ)`);
|
|
193
|
+
if (fStrassen === fNaive) throw new Error('negative control did not fail: float Strassen matched float naive');
|
|
194
|
+
return { rowStrassen: {
|
|
195
|
+
way: '(b) Strassen, seven block products',
|
|
196
|
+
digests: [digest],
|
|
197
|
+
fact: 'Strassen = naive, bit for bit',
|
|
198
|
+
exact: `2 suite cases equal; 32x32 digest ${k.short(digest)}`,
|
|
199
|
+
float: `float64 Strassen ≠ naive: ${differ} of ${k.N * k.N} entries differ`,
|
|
200
|
+
} };
|
|
201
|
+
</cell>
|
|
202
|
+
|
|
203
|
+
<cell type="markdown">
|
|
204
|
+
## (c) Fact 2: eight reduction orders and a tree, all equal
|
|
205
|
+
|
|
206
|
+
A data center splits a sum across workers and adds the partial results in whatever order they arrive. The suite's AllReduce test adds eight workers' results in eight orders and once as a pairwise tree, the shape a GPU reduction takes. This cell runs the suite's own case (eight 2×2 gradients), then does the same with the matrix product: the `k` sum is split across eight workers of four terms each, every worker shuffles its own four terms (a different shuffle for each ordering), and the eight partial matrices are added in the suite's eight orders and as a tree. The float control repeats every step on `A/10`, `B/10`.
|
|
207
|
+
</cell>
|
|
208
|
+
|
|
209
|
+
<cell type="js" lane="math" id="doo-orders" in="kit" out="rowOrders">
|
|
210
|
+
const { math } = caps;
|
|
211
|
+
const { EGPTReal, EGPTMath } = math;
|
|
212
|
+
const k = inputs.kit;
|
|
213
|
+
const eqM = (X, Y) => X.every((row, i) => row.every((v, j) => v.equals(Y[i][j])));
|
|
214
|
+
|
|
215
|
+
// The suite's own case: worker w holds [[4w+1, 4w+2], [4w+3, 4w+4]].
|
|
216
|
+
{
|
|
217
|
+
const workers = Array.from({ length: 8 }, (_, w) => k.toReal(math, [[4 * w + 1, 4 * w + 2], [4 * w + 3, 4 * w + 4]]));
|
|
218
|
+
const sums = k.ORDERINGS.map((ord) => ord.reduce((acc, idx) => k.matAdd(math, acc, workers[idx]), k.zeros(math, 2, 2)));
|
|
219
|
+
let tree = [...workers];
|
|
220
|
+
while (tree.length > 1) { const next = []; for (let i = 0; i < tree.length; i += 2) next.push(i + 1 < tree.length ? k.matAdd(math, tree[i], tree[i + 1]) : tree[i]); tree = next; }
|
|
221
|
+
const all = [...sums, tree[0]].every((S) => eqM(S, sums[0]));
|
|
222
|
+
console.log(`suite case: 8 orders + tree all equal ${JSON.stringify(sums[0].map((r) => r.map((v) => v.breakSymbolicToString())))}: ${all}`);
|
|
223
|
+
if (!all) throw new Error('AllReduce suite case disagreed');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// The matrix product: K split across 8 workers of 4 terms; each worker shuffles its own terms.
|
|
227
|
+
const W = 8, share = k.N / W;
|
|
228
|
+
function partials(A, B, ord, ops, zero) {
|
|
229
|
+
const rnd = k.mulberry32(1000 + ord); // one shuffle per ordering
|
|
230
|
+
return Array.from({ length: W }, (_, w) => {
|
|
231
|
+
const terms = Array.from({ length: share }, (_, t) => w * share + t);
|
|
232
|
+
for (let t = terms.length - 1; t > 0; t--) { const s = Math.floor(rnd() * (t + 1)); [terms[t], terms[s]] = [terms[s], terms[t]]; }
|
|
233
|
+
return A.map((row) => B[0].map((_, j) => terms.reduce((acc, p) => ops.add(acc, ops.mul(row[p], B[p][j])), zero())));
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function reduceAll(A, B, ops, zero) {
|
|
237
|
+
const madd = (P, Q) => P.map((row, i) => row.map((v, j) => ops.add(v, Q[i][j])));
|
|
238
|
+
const results = k.ORDERINGS.map((order, o) => {
|
|
239
|
+
const parts = partials(A, B, o, ops, zero);
|
|
240
|
+
return order.reduce((acc, idx) => (acc ? madd(acc, parts[idx]) : parts[idx]), null);
|
|
241
|
+
});
|
|
242
|
+
let tree = partials(A, B, 8, ops, zero);
|
|
243
|
+
while (tree.length > 1) { const next = []; for (let i = 0; i < tree.length; i += 2) next.push(i + 1 < tree.length ? madd(tree[i], tree[i + 1]) : tree[i]); tree = next; }
|
|
244
|
+
return [...results, tree[0]];
|
|
245
|
+
}
|
|
246
|
+
const exactOps = { add: (x, y) => EGPTMath.add(x, y), mul: (x, y) => EGPTMath.multiply(x, y) };
|
|
247
|
+
const exact = reduceAll(k.toReal(math, k.A), k.toReal(math, k.B), exactOps, () => EGPTReal.fromBigInt(0n));
|
|
248
|
+
const digests = [];
|
|
249
|
+
for (let i = 0; i < exact.length; i++) {
|
|
250
|
+
digests.push(await k.digestExact(exact[i]));
|
|
251
|
+
console.log(`${i < 8 ? 'order ' + i : 'tree '} sha256 ${digests[i]}`);
|
|
252
|
+
}
|
|
253
|
+
const floatRes = reduceAll(k.Af, k.Bf, { add: (x, y) => x + y, mul: (x, y) => x * y }, () => 0);
|
|
254
|
+
const fdigests = [];
|
|
255
|
+
for (let i = 0; i < floatRes.length; i++) {
|
|
256
|
+
fdigests.push(await k.digestFloat(floatRes[i]));
|
|
257
|
+
console.log(`float64 control ${i < 8 ? 'order ' + i : 'tree '} sha256 ${fdigests[i]}`);
|
|
258
|
+
}
|
|
259
|
+
const distinct = new Set(digests).size, fdistinct = new Set(fdigests).size;
|
|
260
|
+
console.log(`exact: ${digests.length} results, ${distinct} distinct digest(s); float64: ${fdigests.length} results, ${fdistinct} distinct`);
|
|
261
|
+
if (fdistinct < 2) throw new Error('negative control did not fail: every float order agreed');
|
|
262
|
+
return { rowOrders: {
|
|
263
|
+
way: '(c) eight orders across eight workers, and a tree',
|
|
264
|
+
digests,
|
|
265
|
+
fact: 'eight orders and a tree, all equal',
|
|
266
|
+
exact: `suite case equal; 32x32: 9 results, ${distinct} distinct digest`,
|
|
267
|
+
float: `float64: 9 results, ${fdistinct} distinct digests`,
|
|
268
|
+
floatDigests: fdigests,
|
|
269
|
+
} };
|
|
270
|
+
</cell>
|
|
271
|
+
|
|
272
|
+
<cell type="markdown">
|
|
273
|
+
## (d) Server and client
|
|
274
|
+
|
|
275
|
+
The `k` sum is cut in two. The "server" computes the first half, the "client" the second; the client's partial result crosses the wire as plain text (decimal strings, the way it would travel over a network) and the server adds it to its own. Nothing about the answer depends on which machine did which half, so the work can go wherever there is room for it.
|
|
276
|
+
</cell>
|
|
277
|
+
|
|
278
|
+
<cell type="js" lane="math" id="doo-split" in="kit" out="rowSplit">
|
|
279
|
+
const { math } = caps;
|
|
280
|
+
const { EGPTReal, EGPTMath } = math;
|
|
281
|
+
const k = inputs.kit;
|
|
282
|
+
const half = k.N / 2;
|
|
283
|
+
function partial(A, B, from, to) {
|
|
284
|
+
return A.map((row) => B[0].map((_, j) => {
|
|
285
|
+
let s = EGPTReal.fromBigInt(0n);
|
|
286
|
+
for (let p = from; p < to; p++) s = EGPTMath.add(s, EGPTMath.multiply(row[p], B[p][j]));
|
|
287
|
+
return s;
|
|
288
|
+
}));
|
|
289
|
+
}
|
|
290
|
+
// The client: its own EGPT values, its half of k, and a text message back.
|
|
291
|
+
const clientWire = partial(k.toReal(math, k.A), k.toReal(math, k.B), half, k.N).map((row) => row.map((v) => v.breakSymbolicToString()));
|
|
292
|
+
// The server: its half of k, then the client's text parsed and added.
|
|
293
|
+
const serverPart = partial(k.toReal(math, k.A), k.toReal(math, k.B), 0, half);
|
|
294
|
+
const fromWire = clientWire.map((row) => row.map((s) => EGPTReal.fromBigInt(BigInt(s))));
|
|
295
|
+
const C = k.matAdd(math, serverPart, fromWire);
|
|
296
|
+
const digest = await k.digestExact(C);
|
|
297
|
+
console.log(`client sent ${clientWire.length * clientWire[0].length} partial sums as text; first: ${clientWire[0][0]}`);
|
|
298
|
+
console.log(`(d) server + client sha256 ${digest}`);
|
|
299
|
+
return { rowSplit: { way: '(d) k cut in two: server half + client half over the wire', digests: [digest] } };
|
|
300
|
+
</cell>
|
|
301
|
+
|
|
302
|
+
<cell type="markdown">
|
|
303
|
+
## (e) A different device order: columns first
|
|
304
|
+
|
|
305
|
+
The same product, filled column by column with `k` counted down: the order a device that streams the second matrix by columns would take.
|
|
306
|
+
</cell>
|
|
307
|
+
|
|
308
|
+
<cell type="js" lane="math" id="doo-columns" in="kit" out="rowColumns">
|
|
309
|
+
const { math } = caps;
|
|
310
|
+
const { EGPTReal, EGPTMath } = math;
|
|
311
|
+
const k = inputs.kit;
|
|
312
|
+
const A = k.toReal(math, k.A), B = k.toReal(math, k.B);
|
|
313
|
+
const C = k.zeros(math, k.N, k.N);
|
|
314
|
+
for (let j = 0; j < k.N; j++)
|
|
315
|
+
for (let i = 0; i < k.N; i++) {
|
|
316
|
+
let s = EGPTReal.fromBigInt(0n);
|
|
317
|
+
for (let p = k.N - 1; p >= 0; p--) s = EGPTMath.add(s, EGPTMath.multiply(A[i][p], B[p][j]));
|
|
318
|
+
C[i][j] = s;
|
|
319
|
+
}
|
|
320
|
+
const digest = await k.digestExact(C);
|
|
321
|
+
console.log(`(e) columns first sha256 ${digest}`);
|
|
322
|
+
return { rowColumns: { way: '(e) columns first, k counted down', digests: [digest] } };
|
|
323
|
+
</cell>
|
|
324
|
+
|
|
325
|
+
<cell type="markdown">
|
|
326
|
+
## Fact 3: Kahan compensation is exactly zero
|
|
327
|
+
|
|
328
|
+
Float code carries a correction term (Kahan summation) to win back the low bits each addition drops. The suite's case is deliberately adversarial: 256 products alternating near 1 and near 10⁻¹², summed three ways (left to right, pairwise tree, Kahan). In exact arithmetic all three agree and the compensation term is exactly 0: nothing was dropped, so there is nothing to win back. In float64 the left-to-right sum and the tree disagree, and the compensation term is not zero.
|
|
329
|
+
</cell>
|
|
330
|
+
|
|
331
|
+
<cell type="js" lane="math" id="doo-kahan" in="kit" out="rowKahan">
|
|
332
|
+
const { math } = caps;
|
|
333
|
+
const { EGPTReal, EGPTMath } = math;
|
|
334
|
+
const K = 256;
|
|
335
|
+
// The suite's case: a[i] = 1000000+i or 1/(1000000+i), b[i] = 1/(999999+i) or 999999+i, alternating.
|
|
336
|
+
const a = Array.from({ length: K }, (_, i) => i % 2 === 0 ? EGPTReal.fromBigInt(BigInt(1000000 + i)) : EGPTReal.fromRational(1n, BigInt(1000000 + i)));
|
|
337
|
+
const b = Array.from({ length: K }, (_, i) => i % 2 === 0 ? EGPTReal.fromRational(1n, BigInt(999999 + i)) : EGPTReal.fromBigInt(BigInt(999999 + i)));
|
|
338
|
+
const products = a.map((x, i) => EGPTMath.multiply(x, b[i]));
|
|
339
|
+
let naive = EGPTReal.fromBigInt(0n);
|
|
340
|
+
for (const p of products) naive = EGPTMath.add(naive, p);
|
|
341
|
+
let tree = [...products];
|
|
342
|
+
while (tree.length > 1) { const next = []; for (let i = 0; i < tree.length; i += 2) next.push(i + 1 < tree.length ? EGPTMath.add(tree[i], tree[i + 1]) : tree[i]); tree = next; }
|
|
343
|
+
let sum = EGPTReal.fromBigInt(0n), comp = EGPTReal.fromBigInt(0n);
|
|
344
|
+
for (const p of products) {
|
|
345
|
+
const y = EGPTMath.subtract(p, comp);
|
|
346
|
+
const t = EGPTMath.add(sum, y);
|
|
347
|
+
comp = EGPTMath.subtract(EGPTMath.subtract(t, sum), y);
|
|
348
|
+
sum = t;
|
|
349
|
+
}
|
|
350
|
+
const compZero = comp.equals(EGPTReal.fromBigInt(0n));
|
|
351
|
+
const allEqual = naive.equals(tree[0]) && naive.equals(sum);
|
|
352
|
+
console.log(`exact: left-to-right = tree = Kahan: ${allEqual}; compensation term = ${comp.breakSymbolicToString()}`);
|
|
353
|
+
if (!allEqual || !compZero) throw new Error('exact Kahan case disagreed');
|
|
354
|
+
|
|
355
|
+
// Float64 control: the same 256 products, the same three sums.
|
|
356
|
+
const af = Array.from({ length: K }, (_, i) => i % 2 === 0 ? 1000000 + i : 1 / (1000000 + i));
|
|
357
|
+
const bf = Array.from({ length: K }, (_, i) => i % 2 === 0 ? 1 / (999999 + i) : 999999 + i);
|
|
358
|
+
const pf = af.map((x, i) => x * bf[i]);
|
|
359
|
+
let fn = 0; for (const p of pf) fn += p;
|
|
360
|
+
let ft = [...pf];
|
|
361
|
+
while (ft.length > 1) { const next = []; for (let i = 0; i < ft.length; i += 2) next.push(i + 1 < ft.length ? ft[i] + ft[i + 1] : ft[i]); ft = next; }
|
|
362
|
+
let fs = 0, fc = 0;
|
|
363
|
+
for (const p of pf) { const y = p - fc; const t = fs + y; fc = (t - fs) - y; fs = t; }
|
|
364
|
+
console.log(`float64: left-to-right ${fn}, tree ${ft[0]}, Kahan ${fs}; compensation term ${fc}`);
|
|
365
|
+
if (fn === ft[0] && fc === 0) throw new Error('negative control did not fail: float sums agreed with zero compensation');
|
|
366
|
+
return { rowKahan: {
|
|
367
|
+
fact: 'Kahan compensation exactly zero (K=256)',
|
|
368
|
+
exact: `3 sums equal; compensation = ${comp.breakSymbolicToString()}`,
|
|
369
|
+
float: `float64: left-to-right ≠ tree; compensation = ${fc.toExponential(3)}`,
|
|
370
|
+
} };
|
|
371
|
+
</cell>
|
|
372
|
+
|
|
373
|
+
<cell type="markdown">
|
|
374
|
+
## Fact 4: gradient swamping, and 1000 steps with zero drift
|
|
375
|
+
|
|
376
|
+
Training updates a large weight by a tiny step. The suite's case is `10⁸ − 10⁻⁸`. As exact rationals the update keeps every digit: `9999999999999999/100000000`, and subtracting the old weight gives back exactly `−1/100000000`. The same holds at `10¹⁵ − 10⁻¹⁵`. Float tells the precision story honestly: float32 drops `10⁻⁸` against `10⁸` outright; float64 keeps it, but inexactly (about `1.49 × 10⁻⁸`, not `10⁻⁸`), and drops `10⁻¹⁵` against `10¹⁵` outright.
|
|
377
|
+
|
|
378
|
+
The suite then runs 1000 steps of descent on a 2×2 weight: `W ← W − (1/7)·dW` from 1000 with `dW` all ones, and `W ← W − (3/1000)·dW` from `[[100,200],[300,400]]` with `dW = [[1,2],[3,4]]`. The exact runs land on the closed form, `6000/7` and `[[97,194],[291,388]]`; float64 and float32 drift.
|
|
379
|
+
</cell>
|
|
380
|
+
|
|
381
|
+
<cell type="js" lane="math" id="doo-swamping" in="kit" out="rowSwamping">
|
|
382
|
+
const { math } = caps;
|
|
383
|
+
const { EGPTReal, EGPTMath } = math;
|
|
384
|
+
const k = inputs.kit;
|
|
385
|
+
const R = (n, d) => EGPTReal.fromRational(BigInt(n), BigInt(d));
|
|
386
|
+
const I = (n) => EGPTReal.fromBigInt(BigInt(n));
|
|
387
|
+
const s = (v) => v.breakSymbolicToString();
|
|
388
|
+
|
|
389
|
+
// 10^8 - 10^-8 and 10^15 - 10^-15, exact.
|
|
390
|
+
const w8 = I(100000000n), g8 = R(1n, 100000000n);
|
|
391
|
+
const u8 = EGPTMath.subtract(w8, g8), d8 = EGPTMath.subtract(u8, w8);
|
|
392
|
+
const w15 = I(1000000000000000n), g15 = R(1n, 1000000000000000n);
|
|
393
|
+
const d15 = EGPTMath.subtract(EGPTMath.subtract(w15, g15), w15);
|
|
394
|
+
console.log(`exact: 10^8 - 10^-8 = ${s(u8)}; minus 10^8 = ${s(d8)}`);
|
|
395
|
+
console.log(`exact: (10^15 - 10^-15) - 10^15 = ${s(d15)}`);
|
|
396
|
+
const ok8 = u8.equals(R(9999999999999999n, 100000000n)) && d8.equals(R(-1n, 100000000n)) && d15.equals(R(-1n, 1000000000000000n));
|
|
397
|
+
|
|
398
|
+
// 1000 steps of descent, the suite's two 2x2 cases.
|
|
399
|
+
function descend(W0, dW, lr) {
|
|
400
|
+
let W = k.toReal(math, W0); const D = k.toReal(math, dW);
|
|
401
|
+
for (let step = 0; step < 1000; step++) W = k.matSub(math, W, D.map((row) => row.map((v) => EGPTMath.multiply(lr, v))));
|
|
402
|
+
return W;
|
|
403
|
+
}
|
|
404
|
+
const W7 = descend([[1000, 1000], [1000, 1000]], [[1, 1], [1, 1]], R(1, 7));
|
|
405
|
+
const W3 = descend([[100, 200], [300, 400]], [[1, 2], [3, 4]], R(3, 1000));
|
|
406
|
+
const ok7 = W7.every((row) => row.every((v) => v.equals(R(6000, 7))));
|
|
407
|
+
const ok3 = [[97, 194], [291, 388]].every((row, i) => row.every((v, j) => W3[i][j].equals(I(v))));
|
|
408
|
+
console.log(`exact: 1000 steps, lr 1/7 → ${JSON.stringify(W7.map((r) => r.map(s)))} (6000/7 everywhere: ${ok7})`);
|
|
409
|
+
console.log(`exact: 1000 steps, lr 3/1000 → ${JSON.stringify(W3.map((r) => r.map(s)))} (closed form: ${ok3})`);
|
|
410
|
+
if (!(ok8 && ok7 && ok3)) throw new Error('exact swamping or descent case disagreed');
|
|
411
|
+
|
|
412
|
+
// Float control.
|
|
413
|
+
const f32 = Math.fround;
|
|
414
|
+
const f32kept = f32(f32(1e8) - f32(1e-8)) - f32(1e8);
|
|
415
|
+
const f64kept8 = (1e8 - 1e-8) - 1e8;
|
|
416
|
+
const f64kept15 = (1e15 - 1e-15) - 1e15;
|
|
417
|
+
let w64 = 1000; for (let step = 0; step < 1000; step++) w64 -= 1 / 7;
|
|
418
|
+
let w32 = f32(1000); const lr32 = f32(1 / 7); for (let step = 0; step < 1000; step++) w32 = f32(w32 - lr32);
|
|
419
|
+
console.log(`float32: (10^8 - 10^-8) - 10^8 = ${f32kept} (update dropped)`);
|
|
420
|
+
console.log(`float64: (10^8 - 10^-8) - 10^8 = ${f64kept8} (kept, inexactly)`);
|
|
421
|
+
console.log(`float64: (10^15 - 10^-15) - 10^15 = ${f64kept15} (update dropped)`);
|
|
422
|
+
console.log(`float64: 1000 steps, lr 1/7 → ${w64}; nearest float64 to 6000/7 is ${6000 / 7}; drift ${(w64 - 6000 / 7).toExponential(3)}`);
|
|
423
|
+
console.log(`float32: 1000 steps, lr 1/7 → ${w32}; nearest float32 to 6000/7 is ${f32(6000 / 7)}`);
|
|
424
|
+
return { rowSwamping: {
|
|
425
|
+
fact: 'gradient swamping; 1000 steps, zero drift',
|
|
426
|
+
exact: `10^8 − 10^-8 = ${s(u8)}; 1000 steps → ${s(W7[0][0])}`,
|
|
427
|
+
float: `f32 drops 10^-8; f64 keeps ${(-f64kept8).toExponential(3)}, drops 10^-15 at 10^15; 1000 steps drift ${(w64 - 6000 / 7).toExponential(2)}`,
|
|
428
|
+
} };
|
|
429
|
+
</cell>
|
|
430
|
+
|
|
431
|
+
<cell type="markdown">
|
|
432
|
+
## Summary
|
|
433
|
+
|
|
434
|
+
Three tables collect every row. The first is the five ways of computing `C = A · B`: every digest must be the one the naive loop produced. The second is the float64 control of fact 2, the eight orders and the tree, each digest against float order 0. The third is the four facts, the exact run beside its float control. Green is the integer arithmetic agreeing with itself; red is the float control failing to, which is what it is there to show.
|
|
435
|
+
</cell>
|
|
436
|
+
|
|
437
|
+
<cell type="js" lane="math" id="doo-summary" in="kit, rowNaive, rowStrassen, rowOrders, rowSplit, rowColumns">
|
|
438
|
+
const { display } = caps;
|
|
439
|
+
const ref = inputs.rowNaive.digests[0];
|
|
440
|
+
const ways = [inputs.rowNaive, inputs.rowStrassen, inputs.rowOrders, inputs.rowSplit, inputs.rowColumns];
|
|
441
|
+
const sameAll = ways.every((w) => w.digests.every((d) => d === ref));
|
|
442
|
+
const { GREEN, RED, table, banner } = inputs.kit;
|
|
443
|
+
console.log(sameAll ? `ALL FIVE WAYS: THE SAME BITS, sha256 ${ref}` : `MISMATCH: ${ways.filter((w) => !w.digests.every((d) => d === ref)).map((w) => w.way).join('; ')}`);
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
const wrap = document.createElement('div');
|
|
447
|
+
wrap.appendChild(banner(sameAll, sameAll ? '✓ Five ways, one answer: every digest equals the naive loop\'s' : '✗ MISMATCH: a way produced different bits'));
|
|
448
|
+
wrap.appendChild(table(['way', 'sha256 of C', 'equal to (a)'], ways.map((w) => {
|
|
449
|
+
const eq = w.digests.filter((d) => d === ref).length, ok = eq === w.digests.length;
|
|
450
|
+
return { cells: [w.way, w.digests[0].slice(0, 24) + '…', (ok ? '✓ ' : '✗ ') + `${eq} of ${w.digests.length}`], css: [null, null, ok ? GREEN : RED] };
|
|
451
|
+
})));
|
|
452
|
+
display(wrap);
|
|
453
|
+
</cell>
|
|
454
|
+
|
|
455
|
+
<cell type="js" lane="math" id="doo-float-summary" in="kit, rowOrders">
|
|
456
|
+
const { display } = caps;
|
|
457
|
+
const { RED, table, banner } = inputs.kit;
|
|
458
|
+
const fd = inputs.rowOrders.floatDigests;
|
|
459
|
+
const distinct = new Set(fd).size;
|
|
460
|
+
const wrap = document.createElement('div');
|
|
461
|
+
wrap.appendChild(banner(false, `✗ Float64 control: the same eight orders and the tree give ${distinct} different answers out of ${fd.length}`));
|
|
462
|
+
wrap.appendChild(table(['float64 control', 'sha256 of C', 'against float order 0'], fd.map((d, i) => ({
|
|
463
|
+
cells: [i < 8 ? `order ${i}` : 'tree', d.slice(0, 24) + '…', i === 0 ? '✗ the float reference' : d === fd[0] ? '✗ same' : '✗ differs'],
|
|
464
|
+
css: [RED, RED, RED],
|
|
465
|
+
}))));
|
|
466
|
+
display(wrap);
|
|
467
|
+
</cell>
|
|
468
|
+
|
|
469
|
+
<cell type="js" lane="math" id="doo-facts-summary" in="kit, rowStrassen, rowOrders, rowKahan, rowSwamping">
|
|
470
|
+
const { display } = caps;
|
|
471
|
+
const { GREEN, RED, table } = inputs.kit;
|
|
472
|
+
const facts = [inputs.rowStrassen, inputs.rowOrders, inputs.rowKahan, inputs.rowSwamping];
|
|
473
|
+
display(table(['fact', 'exact (integer / rational)', 'float control'],
|
|
474
|
+
facts.map((f) => ({ cells: [f.fact, '✓ ' + f.exact, '✗ ' + f.float], css: [null, GREEN, RED] }))));
|
|
475
|
+
</cell>
|
|
476
|
+
|
|
477
|
+
<cell type="markdown">
|
|
478
|
+
## What DOO buys
|
|
479
|
+
|
|
480
|
+
Every way of ordering the work above returned the same bits, on whatever split of workers, in whatever order the partial results arrived, with half of it done on a second machine. That is the property that lets a hot spot move. Under the AIM model (Address Is the Map: reaching a value and calculating it are the same cost, priced in the same units), a pass is a truck-load of letters, and the time is set by the fullest lane: memory, CPU, GPU, or the client's own device. A pass that is out of balance has idle lanes, and an idle lane is budget spent for nothing. DOO is what makes rebalancing safe: the sum can be cut anywhere and finished anywhere, and the answer does not change. Float cannot offer that; the red rows above are what it does instead.
|
|
481
|
+
|
|
482
|
+
More of the same arithmetic, in the notebooks this one builds on:
|
|
483
|
+
|
|
484
|
+
- **EGPTMatrix SDK Parity Tests** (`egpt-matrix-test`): the matrix surface, GEMM with α, β and an accumulator, exact.
|
|
485
|
+
- **EGPTFFT SDK Parity Tests** (`egpt-fft-test`): a forward and inverse transform that round-trips to the last bit.
|
|
486
|
+
</cell>
|
|
487
|
+
|
|
488
|
+
</frqtl-notebook>
|
|
@@ -9,6 +9,18 @@
|
|
|
9
9
|
"title": "Hello, FRQTL",
|
|
10
10
|
"group": "Start Here"
|
|
11
11
|
},
|
|
12
|
+
{
|
|
13
|
+
"id": "doo-same-bits-any-order",
|
|
14
|
+
"file": "doo-same-bits-any-order.html",
|
|
15
|
+
"title": "Deterministic and out of order: the same bits in any order",
|
|
16
|
+
"group": "Address Is the Map"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": "aim-mailman-small-tensor",
|
|
20
|
+
"file": "aim-mailman-small-tensor.html",
|
|
21
|
+
"title": "Address Is the Map: the mailman on a small tensor",
|
|
22
|
+
"group": "Address Is the Map"
|
|
23
|
+
},
|
|
12
24
|
{
|
|
13
25
|
"id": "view-vendored-d3",
|
|
14
26
|
"file": "view-vendored-d3.html",
|
package/dist/sdk.html
CHANGED
|
@@ -132,7 +132,7 @@ universe.experimentTickFunctions.push(<span class="keyword">function</span> (u)
|
|
|
132
132
|
|
|
133
133
|
<p>In the browser (<code>@descix/frqtl-web</code>), <code>bootScene(mount, sketch)</code> boots the engine and the renderer and runs a sketch — a <code>buildExperiment(exp)</code> function whose first statement creates the world. Import the parts the sketch uses from the same dist the doors come from:</p>
|
|
134
134
|
|
|
135
|
-
<pre><code><span class="keyword">const</span> DIST = <span class="string">'https://cdn.jsdelivr.net/npm/@descix/frqtl-web@0.7.0-
|
|
135
|
+
<pre><code><span class="keyword">const</span> DIST = <span class="string">'https://cdn.jsdelivr.net/npm/@descix/frqtl-web@0.7.0-p3/dist'</span>;
|
|
136
136
|
<span class="keyword">const</span> { bootScene } = <span class="keyword">await</span> import(DIST + <span class="string">'/frqtl/experiments/_shared/doors.js'</span>);
|
|
137
137
|
<span class="keyword">const</span> { SphereEmitter } = <span class="keyword">await</span> import(DIST + <span class="string">'/frqtl/parts/index.js'</span>);
|
|
138
138
|
|
|
@@ -152,7 +152,7 @@ var DIST_PROFILE = buildDistProfile('../..');
|
|
|
152
152
|
// lib/shim/engine/test/router.test.mjs asserts them against the two
|
|
153
153
|
// package.json#version fields so a forgotten bump fails `make verify`, not a
|
|
154
154
|
// silent stale-CDN-URL bug.
|
|
155
|
-
var CDN_SDK_VERSION = '0.7.0-
|
|
155
|
+
var CDN_SDK_VERSION = '0.7.0-p3'; // sdk/frqtl-web/package.json#version (the ONE version owner) — bound by router.test.mjs
|
|
156
156
|
var CDN_MATH_SDK_VERSION = '0.3.3-p2.1'; // sdk/egpt-math-sdk/package.json#version — bound by router.test.mjs; bumped with each npm publish
|
|
157
157
|
|
|
158
158
|
/**
|
|
@@ -526,7 +526,7 @@ var _assertProfileParity = (function () {
|
|
|
526
526
|
* // CDN mode (static hosting — the artifact host shell has no server, no page anchor):
|
|
527
527
|
* const cdnRouter = engineRouter({ mode: 'cdn', engine: 'wasm' });
|
|
528
528
|
* console.log(cdnRouter.resolve('compat/engine.js'));
|
|
529
|
-
* // 'https://cdn.jsdelivr.net/npm/@descix/frqtl-web@0.7.0-
|
|
529
|
+
* // 'https://cdn.jsdelivr.net/npm/@descix/frqtl-web@0.7.0-p3/dist/frqtl/compat/engine.js'
|
|
530
530
|
*
|
|
531
531
|
* // CDN mode, self-hosted: a copy of dist/ served from the consumer's own origin:
|
|
532
532
|
* const selfHosted = engineRouter({ mode: 'cdn', engine: 'wasm', base: 'https://example.org/vendor/frqtl-web/dist' });
|
package/dist/shim/host/device.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* page (an app framed by the DeSciX shell measures its own frame). A window without
|
|
12
12
|
* matchMedia THROWS: every browser has it, so its absence is a caller passing the wrong object.
|
|
13
13
|
*
|
|
14
|
-
* Its
|
|
14
|
+
* Its four consumers ask it once each, at load:
|
|
15
15
|
* - the host-view call site (lib/features/ide/studio/host-view-entry.js) asks the shell for NoChrome on a phone, CodeSite
|
|
16
16
|
* elsewhere;
|
|
17
17
|
* - STUDIO (lib/features/ide/AuthorView.jsx) opens with its side panels collapsed on a phone and puts its Hand tool
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
* surface (lib/features/ide/studio-try-it.js);
|
|
20
20
|
* - FraqtlIde (lib/features/ide/index.jsx) opens the STUDIO tab card with the controls of that surface
|
|
21
21
|
* (presets.js presetExplainerFor).
|
|
22
|
+
* - the IDE header's Sign In control (lib/features/ide/sign-in.js) shows only on a phone, where the shell's
|
|
23
|
+
* full-screen view hides the shell's own Sign In.
|
|
22
24
|
* The static build compiles it into both: the stable host-view entry is bundled as its own self-contained module
|
|
23
25
|
* (apps/ide/vite.config.js frqtl-host-view-entry), the IDE's rollup graph carries its own copy of the same source.
|
|
24
26
|
*
|