@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
package/CLAUDE.md
CHANGED
|
@@ -5,7 +5,7 @@ in the browser. Physics comes out of local per-pixel rules — a frame moves one
|
|
|
5
5
|
occupancy, momentum — rather than force equations or wave PDEs. Double-slit fringes, wave interference
|
|
6
6
|
and blackbody spectra are computed live from the automaton, not replayed.
|
|
7
7
|
|
|
8
|
-
`0.7.0-
|
|
8
|
+
`0.7.0-p3` (npm dist-tag `next`). The node twin is `@descix/frqtl-node` (the same modules,
|
|
9
9
|
plus `bootNode` and the hosted eyes).
|
|
10
10
|
|
|
11
11
|
## Install
|
|
@@ -38,7 +38,7 @@ refused by name), and `await recipeContext.setDeclared(name, patch)` changes one
|
|
|
38
38
|
`parts/<NewKind>.js` (class renamed, imports rewritten to package specifiers), points the entry at it and re-runs in place.
|
|
39
39
|
`runner.declared` rows read `inParts` and `module`.
|
|
40
40
|
|
|
41
|
-
Read a real part before writing your own: `https://cdn.jsdelivr.net/npm/@descix/frqtl-web@0.7.0-
|
|
41
|
+
Read a real part before writing your own: `https://cdn.jsdelivr.net/npm/@descix/frqtl-web@0.7.0-p3/dist/frqtl/parts/DetectorWall.js`.
|
|
42
42
|
|
|
43
43
|
## Boot it — the two doors (`@descix/frqtl-web/boot`)
|
|
44
44
|
bootScene(mount, buildExperiment, { renderer: 'p5' | 'three', seed, onTick, render })
|
|
@@ -63,7 +63,7 @@ imports `./boot`, `./registry`, `./project`, `./host-view` or `./site-graph` by
|
|
|
63
63
|
row, so read the manifest from the same root: `new URL('dist-manifest.json', root)`. A page that holds only its map
|
|
64
64
|
recovers the root through `FRQTL_WEB_HOST_SPECIFIERS`: `imports[row.specifier]` minus `row.libPath`.
|
|
65
65
|
The root is an absolute URL or starts with `/`, `./` or `../`. A sketch held as text boots as `bootProject(mount, sketchProject(text))`.
|
|
66
|
-
Or skip the map: `<script src="https://cdn.jsdelivr.net/npm/@descix/frqtl-web@0.7.0-
|
|
66
|
+
Or skip the map: `<script src="https://cdn.jsdelivr.net/npm/@descix/frqtl-web@0.7.0-p3/dist/frqtl-web.min.js"></script>` then `FRQTL.bootScene(…)`,
|
|
67
67
|
`FRQTL.Wall`, …
|
|
68
68
|
|
|
69
69
|
String kinds: `exp.addObject('Wall', props)` resolves the kind in the SCENE's realm (the frame the scene
|
|
@@ -122,6 +122,6 @@ Everything is a Frame (recursive); there is no separate "particle" class.
|
|
|
122
122
|
- The published build is WASM-only on the engine side (compiled surface).
|
|
123
123
|
|
|
124
124
|
## Curated notebooks
|
|
125
|
-
Index: `https://cdn.jsdelivr.net/npm/@descix/frqtl-web@0.7.0-
|
|
125
|
+
Index: `https://cdn.jsdelivr.net/npm/@descix/frqtl-web@0.7.0-p3/dist/notebooks/notebooks.json`
|
|
126
126
|
|
|
127
127
|
## No account, credits, or tokens are needed for anything above.
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ comes out of local per-pixel rules — a frame moves one pixel per tick, single
|
|
|
5
5
|
rather than force equations. Interference, blackbody spectra and atom-like binding emerge from the
|
|
6
6
|
automaton.
|
|
7
7
|
|
|
8
|
-
`0.7.0-
|
|
8
|
+
`0.7.0-p3` (npm dist-tag `next`). The node twin is `@descix/frqtl-node` — the same
|
|
9
9
|
modules, built from the same source. See it run: https://egpt-frqtl.descix.net (the showcase scenes in STUDIO and
|
|
10
10
|
the GYM).
|
|
11
11
|
|
package/dist/dist-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descix/frqtl-web",
|
|
3
|
-
"version": "0.7.0-
|
|
3
|
+
"version": "0.7.0-p3",
|
|
4
4
|
"files": {
|
|
5
5
|
"boot/node-refusal.js": "23ce7b8bb34fb86d19970b7e4275e463ae2963cf8a5c3b4ffe72bd6ff6261b47",
|
|
6
6
|
"css/bootstrap.min.css": "3c8f27e6009ccfd710a905e6dcf12d0ee3c6f2ac7da05b0572d3e0d12e736fc8",
|
|
@@ -264,8 +264,10 @@
|
|
|
264
264
|
"frqtl/parts/Tunnel.js": "7a7c3e52caa5f018178c596d735e6062c4cac1545d014216d3027ba9f457d07d",
|
|
265
265
|
"frqtl/parts/Wall.js": "7af7a41f7c8348deee1237a20e37e9c0e69cd3669ab315efaa8eeac03fbbccb8",
|
|
266
266
|
"frqtl/parts/index.js": "70b8e227e09663889f4c7942d385f843d977579765723f829880fd6e9868ac53",
|
|
267
|
+
"notebooks/aim-mailman-small-tensor.html": "b836e9b5a2264dd2a9180fee426648469a7696cae7b58fdf5fd693136764095d",
|
|
267
268
|
"notebooks/arithmetic-basics.html": "05054772caf11b0965fdc256fd5a1c6bbd09284234358abe37af1934ab232aec",
|
|
268
269
|
"notebooks/complex-twiddle.html": "fb9f0927e88c71e6dc21ad9ca57d58c5d018917ab61d426d541463bc0bfdd71b",
|
|
270
|
+
"notebooks/doo-same-bits-any-order.html": "6b6dbcb80dc8b1b385b43f793b788b8662552ea6d2c9f64074c49616f17f4a59",
|
|
269
271
|
"notebooks/egpt-fft-test.html": "1b58be299089a654058b8daa59cac1bfadb1665f99c67273101eafe36e8e9ae0",
|
|
270
272
|
"notebooks/egpt-matrix-test.html": "0bdfacd75d036b0c82d9064a9e0adb5e1590e3e33e418a8444a7bc6cbbb390eb",
|
|
271
273
|
"notebooks/egpt-polynomial-test.html": "89db85391f402b1044f5311aee9f436b6b1df128712d0e21ab0bb886c1d1c53d",
|
|
@@ -290,7 +292,7 @@
|
|
|
290
292
|
"notebooks/iso-number-theory-four-views.html": "55f8655078a8bd4c35c22531177a7a035661183683d6bb193b60e52298233baa",
|
|
291
293
|
"notebooks/iso-pi-log-fraction-loop.html": "17112759c5328001009b95f239f35532d8d2ac66742bc5af06f38da71323392a",
|
|
292
294
|
"notebooks/matrix.html": "d52d62a45fcdb2a9754664e280f4c97f4590ec35046b4997b4700afbbd941025",
|
|
293
|
-
"notebooks/notebooks.json": "
|
|
295
|
+
"notebooks/notebooks.json": "6e3e21eed006c213b9b602455bbf8d3d3245369373eae8624d0602970e378b59",
|
|
294
296
|
"notebooks/polynomials.html": "c990a386756b7e83a565e1246549a1241fa9757e07a30a724c73d691be2a53ce",
|
|
295
297
|
"notebooks/prime-composite.html": "57469ba011c1a1082a614647acde985340fb8d5286fedc6fb0fd76f56d0e26e9",
|
|
296
298
|
"notebooks/rational-core.html": "62817c4f3d8aa7c9aa7b26e7adca54c3a648539de74daf5fdfa2a9ebb9327522",
|
|
@@ -302,7 +304,7 @@
|
|
|
302
304
|
"notebooks/stats.html": "360db52d77ef46c690e7c865a7ce672d5032b916a0a0796f6070d5f17b03132b",
|
|
303
305
|
"notebooks/transcendentals.html": "1dfc5d40f0e3e6cccc785fb73d73ef82e24048d7affd10143370779ef2032b8c",
|
|
304
306
|
"notebooks/view-vendored-d3.html": "debeeef830f8c328b3b6e13b0b8fe26021ba55802b89d8dbe78b8a0c6c002eac",
|
|
305
|
-
"sdk.html": "
|
|
307
|
+
"sdk.html": "9ba07c54645e2ec99385e059e1477e248a86ea964868bfacc47b0fd665dbd94b",
|
|
306
308
|
"shim/bundle/index.js": "edc501a039ce47102657604df71fbc17ba3e4760ca087055351231c7469f5c50",
|
|
307
309
|
"shim/bundle/indexHtml.js": "2c4fbc502bb33fce93596cee19e143a58bb63c18d0b18ea597f81610e3a9a027",
|
|
308
310
|
"shim/bundle/zip.js": "00f7b5fb5f36ff40a59d86758c503d9d7fb43949c1b5a4f2e7367c43d92786f9",
|
|
@@ -311,14 +313,15 @@
|
|
|
311
313
|
"shim/controls/registry.js": "3df843d774968d18e012624f2aba2fb09b08ede9e21b6c1f6687d4f3e9b46d3e",
|
|
312
314
|
"shim/engine/boot-phases.js": "c6e12e12824bcf6f1a289f46e41c898a5416c80c131594525145aae9a3eefbfa",
|
|
313
315
|
"shim/engine/engine-stack-boot.js": "0abf57dcff2ca2bb025c787a17875d49d54d9218ac08c78cb9c678dbb6118d08",
|
|
314
|
-
"shim/engine/router.js": "
|
|
316
|
+
"shim/engine/router.js": "dcb0289143fc86dc74be1f5921695f75c026741496ac19e902b905be3ccf409a",
|
|
315
317
|
"shim/engine/site-assemble.mjs": "37c9915c34b102daa8fe6389f8d66a1e3379e074e87d2ad79b0cff7a81a2d4b6",
|
|
316
318
|
"shim/engine/site-graph.js": "4d5e5f9ecc2cefcf30eab25203178c0bb13230e9ce7f34bb3b36178f6b79dcb9",
|
|
317
319
|
"shim/experiment-frame/index.js": "5a0219aaa225d8f808c405b08623ce85ada37d83fb4f55f983db3303e431e47f",
|
|
318
320
|
"shim/expr/ast-schema.js": "4f1133b887639bbd86fab976292323bf4a955cdc873ff7ca8e8a8eb3b416923f",
|
|
319
321
|
"shim/field-descriptor/index.js": "050091a9cab0bd37b32b5d8a52fc9bca3b42a089c188d7e49a11cf88b5c069f7",
|
|
320
322
|
"shim/frame-data/index.js": "df6957b0b4a8e0ee0035bc970647b90089b421ae7f05911cc047d48457164be6",
|
|
321
|
-
"shim/host/device.js": "
|
|
323
|
+
"shim/host/device.js": "67bcc932f31ddd08ef7667344f5f8894badd4d9dfd3e767c72d9e1dd327f54bd",
|
|
324
|
+
"shim/host/host-auth.js": "dabf305a2329227f0592a588681e20dd78063a85919ee1685d2a9b01dfe5ebcf",
|
|
322
325
|
"shim/host/host-view.js": "feec2f5fdc318e75cd01768c24891f85d2694a269696fcfffd9567d31983cf43",
|
|
323
326
|
"shim/host/index.js": "fade4b171218965570aa2e67e841920ebb3d972ff15e1cfa0394fd3fa123d82c",
|
|
324
327
|
"shim/index.js": "dd3708d4935e597d9ca46a23077064bd1f460bb1e86315372c9d147bdfb3f0d1",
|
|
@@ -358,7 +361,7 @@
|
|
|
358
361
|
"shim/registry/roster-link.js": "7c079eec1350640c8399e16f2515e1cdfb5c6cd31f77c16dfda85ec782a538d0",
|
|
359
362
|
"shim/registry/roster.js": "df0dcc70d4c2202913a1e3e8788e9f1907ad63e43150c85960ebdfe9864d53db",
|
|
360
363
|
"shim/registry/scene-source.js": "913ef72fc7caeeafc2eb6a28a2dcced752579e63c83b48d51f5bf36f67c55a88",
|
|
361
|
-
"shim/registry/studio-landing.js": "
|
|
364
|
+
"shim/registry/studio-landing.js": "db2d76a241935828495ed063e6220026a13b80df402672b9ed960c128871b16e",
|
|
362
365
|
"shim/render-state/apply.js": "94a9e60cb1722c9a82aa00f2f161fd65e6f438147333856a786e42a4ad5b7064",
|
|
363
366
|
"shim/render-state/index.js": "72a6a3dcd8037893cb8fbd7ef32b126770e7efaec70847f8e4f2915ddb690b43",
|
|
364
367
|
"shim/render/capture-envelope.js": "74db53dbc8c87d1b52452bcb858b1cc5210593062fec0b98609cd59cab63777a",
|
|
@@ -374,11 +377,11 @@
|
|
|
374
377
|
"shim/storage/local-storage-provider.js": "e14894e5d33bce961e66a2816e4b5c23b8e00534398ca9635d19de117f0f150e",
|
|
375
378
|
"shim/storage/make-namespace-store.js": "f88cfc65244cd7a3c3a43c173001855bb95571916a117b22f38d051823f2856f",
|
|
376
379
|
"site-assemble/browser-refusal.js": "257840fda32b088f86d05935c29d4913f74e0214dc985b309b1d8363c6ec2782",
|
|
377
|
-
"studio/app-assets/SceneCodeEditor-
|
|
380
|
+
"studio/app-assets/SceneCodeEditor-DnAM0Uhi.js": "ee19be4801677a5ff232657eab796091b9ab93731526f6e8d95d9287ee7b63f5",
|
|
378
381
|
"studio/app-assets/host-view.js": "30f55d6976968cf0acf7870830870ffad0d439d779759af60a3aaf66c2063cf1",
|
|
379
382
|
"studio/app-assets/index-DMlx7z1P.css": "23e79037f0089ce0782be5898ec5c2fb32cb067a0f66a87a24126b09cb4793da",
|
|
380
|
-
"studio/app-assets/index-
|
|
381
|
-
"studio/app.html": "
|
|
383
|
+
"studio/app-assets/index-YDj5QEI1.js": "5af45849a15532dbda6adf0cf0d25b056c25b8830dfddc1baba8b9e1677400b6",
|
|
384
|
+
"studio/app.html": "08559835febcbfbad848d4492706d94dd015110525a3a2e10e03bcb5a063bcb4",
|
|
382
385
|
"vendor/d3-array/src/array.js": "0083c26850f97fa2735802530964aa737683402bbc560d14e0e27696b0c693bb",
|
|
383
386
|
"vendor/d3-array/src/ascending.js": "cb830a957d172fa6f6f52c67ef09a264986c3e795156930d342ed74edcea5e6b",
|
|
384
387
|
"vendor/d3-array/src/bin.js": "41f7cc39e146683c5da6ea7489903de2c5edb9bf725ca15b7cd015f603b306ac",
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
<frqtl-notebook version="1" title="Address Is the Map: the mailman on a small tensor">
|
|
2
|
+
|
|
3
|
+
<cell type="markdown">
|
|
4
|
+
# Address Is the Map: the mailman on a small tensor
|
|
5
|
+
|
|
6
|
+
**AIM**, Address Is the Map: the cost of reaching an address is the cost of calculating the path to get there. Fetching a value and calculating it are paid in the same currency, so the two can be traded. This notebook walks the AIM accounting on one small tensor you can read whole. It is the accounting of **the AIM model** (the dashboard that prices a full model on a full socket), at notebook scale: the same town, the same road capacities, the same rule that the time of a pass is the time of its fullest lane.
|
|
7
|
+
|
|
8
|
+
The analogy, used the whole way through:
|
|
9
|
+
|
|
10
|
+
| Term | What it is |
|
|
11
|
+
|---|---|
|
|
12
|
+
| the post office | one core |
|
|
13
|
+
| the sorting desk | the registers |
|
|
14
|
+
| the rings of the town | the mail room (L1), the building (L2), the block (L3), the city (DRAM) |
|
|
15
|
+
| a letter | one weight position that must be used this token |
|
|
16
|
+
| a house | one distinct value; every letter for that value goes to the same house |
|
|
17
|
+
| the truck | the bytes one trip brings back: a 64-byte crate |
|
|
18
|
+
| gas | calculation cycles |
|
|
19
|
+
| a flyer | one value delivered to many positions |
|
|
20
|
+
| rearranging the town | the one-time sort of the static weights, paid once, never per token |
|
|
21
|
+
|
|
22
|
+
The objective is **time** on a fixed budget: every lane of the socket costs dollars per second whether or not mail moves, so an idle lane is budget lost. A pass is done when its fullest lane is done.
|
|
23
|
+
</cell>
|
|
24
|
+
|
|
25
|
+
<cell type="markdown">
|
|
26
|
+
## The tensor: a few frequent values, many rare ones
|
|
27
|
+
|
|
28
|
+
A 16×16 tensor of integers with a known histogram: 64 possible values (the odd numbers 1, 3, 5, …, 127, each with a sign), drawn so that a few values get most of the positions and most values get few. The generator is the AIM model's own "a few houses get most of the mail" option (a Zipf draw, skew 1.1, seed 7), so the two can be compared input for input.
|
|
29
|
+
</cell>
|
|
30
|
+
|
|
31
|
+
<cell type="js" lane="math" id="aim-tensor" out="tensor">
|
|
32
|
+
// mulberry32 and the Zipf draw, the same recipe the AIM model uses for its "a few houses" option.
|
|
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 ROWS = 16, COLS = 16, N = ROWS * COLS, HOUSES = 64, SKEW = 1.1, SEED = 7;
|
|
42
|
+
const rnd = mulberry32(SEED);
|
|
43
|
+
const w = []; let tot = 0;
|
|
44
|
+
for (let k = 1; k <= HOUSES; k++) { const p = 1 / Math.pow(k, SKEW); w.push(p); tot += p; }
|
|
45
|
+
const cdf = []; let acc = 0;
|
|
46
|
+
for (const p of w) { acc += p / tot; cdf.push(acc); }
|
|
47
|
+
const value = new Int32Array(N); // the odd part: which house
|
|
48
|
+
const sign = new Uint8Array(N);
|
|
49
|
+
for (let i = 0; i < N; i++) {
|
|
50
|
+
const u = rnd(); let lo = 0, hi = HOUSES - 1;
|
|
51
|
+
while (lo < hi) { const mid = (lo + hi) >> 1; if (cdf[mid] < u) lo = mid + 1; else hi = mid; }
|
|
52
|
+
value[i] = 2 * lo + 1;
|
|
53
|
+
sign[i] = rnd() < 0.5 ? 1 : 0;
|
|
54
|
+
}
|
|
55
|
+
// The histogram, busiest house first: this order is how the town gets arranged.
|
|
56
|
+
const counts = new Map();
|
|
57
|
+
for (let i = 0; i < N; i++) counts.set(value[i], (counts.get(value[i]) || 0) + 1);
|
|
58
|
+
const book = [...counts.entries()].sort((a, b) => b[1] - a[1]).map(([v, n]) => ({ value: v, count: n }));
|
|
59
|
+
|
|
60
|
+
for (let r = 0; r < ROWS; r++) {
|
|
61
|
+
const row = [];
|
|
62
|
+
for (let c = 0; c < COLS; c++) { const i = r * COLS + c; row.push(((sign[i] ? '-' : '+') + value[i]).padStart(4)); }
|
|
63
|
+
console.log(row.join(''));
|
|
64
|
+
}
|
|
65
|
+
console.log(`${N} letters, ${book.length} distinct houses (values)`);
|
|
66
|
+
let run = 0;
|
|
67
|
+
book.slice(0, 8).forEach((b, i) => { run += b.count; console.log(` house ${String(b.value).padStart(3)}: ${String(b.count).padStart(3)} letters (top ${i + 1} cover ${(100 * run / N).toFixed(0)}%)`); });
|
|
68
|
+
console.log(` … and ${book.filter((b) => b.count <= 2).length} houses with 1 or 2 letters each`);
|
|
69
|
+
return { tensor: { ROWS, COLS, N, value, sign, book } };
|
|
70
|
+
</cell>
|
|
71
|
+
|
|
72
|
+
<cell type="markdown">
|
|
73
|
+
## The town, and the accounting
|
|
74
|
+
|
|
75
|
+
Each ring of the town has room (how many bytes fit) and a road (how many bytes per cycle it carries to the desk, per core). These are the AIM model's figures for one core of a 56-core server socket at 2 GHz:
|
|
76
|
+
|
|
77
|
+
| Ring | Room | Road, bytes per cycle |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| sorting desk (registers) | 10 KiB | 64 |
|
|
80
|
+
| mail room (L1) | 48 KiB | 128 |
|
|
81
|
+
| the building (L2) | 2 MiB | 64 |
|
|
82
|
+
| the block (L3, this core's share) | 1.875 MiB | 9 |
|
|
83
|
+
| the city (DRAM, this core's share) | unlimited | 2.2 |
|
|
84
|
+
|
|
85
|
+
The gas lanes are the tiles (1,024 multiply-adds per cycle) and the vector units (128 integer ops per cycle).
|
|
86
|
+
|
|
87
|
+
**Scale.** A 16×16 tensor fits on the sorting desk, so nothing travels. A real truck-load is millions of letters and sits in the city. As the AIM model does, the scale dial keeps this tensor's histogram and multiplies the letters (0 is the tensor as it is; 100 is eight billion letters).
|
|
88
|
+
|
|
89
|
+
**Placement.** Items are placed nearest-first by visits per byte: the operands of the handoff (the token's values and the running totals) are pinned to the desk; then every house and every letter in order of how often it is visited, filling each ring before the next one out.
|
|
90
|
+
|
|
91
|
+
**Two ways to deliver the truck-load.**
|
|
92
|
+
|
|
93
|
+
1. *Stream every letter* (road time). Each letter carries its full 16-bit value and is read in order, so a 64-byte truck carries 32 letters. One multiply-add per letter on the tiles.
|
|
94
|
+
2. *The mix* (road time plus gas). The `n` most frequent values become flyers: the value is kept on the sorting desk and delivered to its positions; the rest of the letters are streamed as in (1). A flyer delivery reads the value off the desk, takes a shift and an add on the vector units, and burns **gas per delivery**: a number of ops you set, exactly as the AIM model leaves it a dial. Each flyer then takes one multiply per row at the end, on the tiles.
|
|
95
|
+
|
|
96
|
+
Every lane's time is its load divided by its road (bytes) or its rate (ops). The time of the pass is the time of the **fullest lane**.
|
|
97
|
+
</cell>
|
|
98
|
+
|
|
99
|
+
<cell type="js" lane="math" id="aim-town" in="tensor" out="town">
|
|
100
|
+
const t = inputs.tensor;
|
|
101
|
+
const CRATE = 64; // bytes one truck brings back
|
|
102
|
+
const RINGS = [
|
|
103
|
+
{ id: 'desk', name: 'sorting desk', room: 10240, road: 64 },
|
|
104
|
+
{ id: 'l1', name: 'mail room (L1)', room: 49152, road: 128 },
|
|
105
|
+
{ id: 'l2', name: 'the building (L2)', room: 2097152, road: 64 },
|
|
106
|
+
{ id: 'l3', name: 'the block (L3)', room: 1966080, road: 9 },
|
|
107
|
+
{ id: 'dram', name: 'the city (DRAM)', room: Infinity, road: 2.2 },
|
|
108
|
+
];
|
|
109
|
+
const GAS = [
|
|
110
|
+
{ id: 'tiles', name: 'tiles (multiply-adds)', rate: 1024 },
|
|
111
|
+
{ id: 'vec', name: 'vector units', rate: 128 },
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
// Letters per truck-load at a scale setting 0..100 (the AIM model's scale dial).
|
|
115
|
+
const lettersAt = (scale) => Math.round(t.N * Math.pow(8e9 / t.N, scale / 100));
|
|
116
|
+
|
|
117
|
+
// Place items nearest-first: pinned items first, then by visits per byte.
|
|
118
|
+
function place(items) {
|
|
119
|
+
const sorted = items.filter((it) => it.bytes > 0 && it.visits > 0)
|
|
120
|
+
.map((it) => ({ ...it, density: it.visits / it.bytes }))
|
|
121
|
+
.sort((a, b) => (b.pinned ? 1 : 0) - (a.pinned ? 1 : 0) || b.density - a.density);
|
|
122
|
+
const left = RINGS.map((r) => r.room);
|
|
123
|
+
for (const it of sorted) {
|
|
124
|
+
it.where = RINGS.map(() => 0);
|
|
125
|
+
let rem = it.bytes;
|
|
126
|
+
for (let r = 0; r < RINGS.length && rem > 0; r++) { const take = Math.min(rem, left[r]); it.where[r] += take; left[r] -= take; rem -= take; }
|
|
127
|
+
}
|
|
128
|
+
return sorted;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Bytes one visit moves on ring r: a letter read in order moves its own bytes (the truck
|
|
132
|
+
// fills); a lookup brings a whole truck, except on the desk; the operands state their own.
|
|
133
|
+
const bytesPerVisit = (r, it) => it.perVisit != null ? it.perVisit : (it.lookup ? (r === 0 ? it.size : CRATE) : it.size);
|
|
134
|
+
|
|
135
|
+
// One pass of a truck-load. n = how many of the most frequent values go as flyers.
|
|
136
|
+
function pass({ scale, n, gasPerDelivery }) {
|
|
137
|
+
const L = lettersAt(scale), sc = L / t.N;
|
|
138
|
+
const R = Math.max(t.ROWS, Math.round(Math.sqrt(L))), C = Math.max(t.COLS, Math.round(L / R));
|
|
139
|
+
const flyers = t.book.slice(0, n);
|
|
140
|
+
const byFlyer = flyers.reduce((a, b) => a + b.count, 0) * sc; // positions delivered as flyers
|
|
141
|
+
const streamed = L - byFlyer; // letters over the roads
|
|
142
|
+
const items = [
|
|
143
|
+
{ name: 'letters (full 16-bit values)', bytes: streamed * 2, visits: streamed, size: 2 },
|
|
144
|
+
...flyers.map((b) => ({ name: 'flyer ' + b.value, bytes: 2, visits: 1, size: 2, lookup: true })),
|
|
145
|
+
// operands of the handoff, pinned: read once per 16 letters in order, once per flyer delivery
|
|
146
|
+
{ name: "the token's values", bytes: C, visits: L, pinned: true, perVisit: (streamed / 16 + byFlyer) / L },
|
|
147
|
+
{ name: 'running totals', bytes: R * 4, visits: L, pinned: true, perVisit: 4 * (streamed / 16 + byFlyer) / L },
|
|
148
|
+
];
|
|
149
|
+
const placed = place(items);
|
|
150
|
+
const bytes = RINGS.map(() => 0);
|
|
151
|
+
for (const it of placed) it.where.forEach((b, r) => { if (b > 0) bytes[r] += it.visits * (b / it.bytes) * bytesPerVisit(r, it); });
|
|
152
|
+
bytes[0] += byFlyer * 2; // each delivery reads its flyer off the desk
|
|
153
|
+
const tilesOps = streamed + R * n; // multiply-add per letter; one multiply per row per flyer
|
|
154
|
+
const vecOps = byFlyer * gasPerDelivery + byFlyer * 2; // gas per delivery, plus a shift and an add
|
|
155
|
+
const lanes = [
|
|
156
|
+
...RINGS.map((r, i) => ({ name: r.name, load: bytes[i], unit: 'B', time: bytes[i] / r.road })),
|
|
157
|
+
{ name: GAS[0].name, load: tilesOps, unit: 'ops', time: tilesOps / GAS[0].rate },
|
|
158
|
+
{ name: GAS[1].name, load: vecOps, unit: 'ops', time: vecOps / GAS[1].rate },
|
|
159
|
+
];
|
|
160
|
+
const fullest = lanes.reduce((a, b) => (b.time > a.time ? b : a), lanes[0]);
|
|
161
|
+
return { letters: L, flyers: n, byFlyer, streamed, lanes, time: fullest.time, fullest };
|
|
162
|
+
}
|
|
163
|
+
const roadOnly = (o) => pass({ ...o, n: 0 });
|
|
164
|
+
|
|
165
|
+
const fmt = (x) => x >= 1e6 ? (x / 1e6).toFixed(2) + 'M' : x >= 1e3 ? (x / 1e3).toFixed(1) + 'k' : x.toFixed(2);
|
|
166
|
+
for (const n of [0, 8, t.book.length]) {
|
|
167
|
+
const p = pass({ scale: 60, n, gasPerDelivery: 24 });
|
|
168
|
+
console.log(`scale 60 (${fmt(p.letters)} letters), ${String(n).padStart(2)} flyers, 24 ops per delivery: ${p.time.toFixed(2)} cycles per truck-load; fullest lane ${p.fullest.name}`);
|
|
169
|
+
}
|
|
170
|
+
return { town: { RINGS, GAS, CRATE, lettersAt, pass, roadOnly } };
|
|
171
|
+
</cell>
|
|
172
|
+
|
|
173
|
+
<cell type="markdown">
|
|
174
|
+
## The three numbers, and the dial
|
|
175
|
+
|
|
176
|
+
Move the **frequent values** slider to choose how many of the busiest houses go as flyers, and watch the three numbers: the time to stream every letter, the time of the mix, and which lane is the fullest (the one that sets the mix's time). The gas each delivery burns and the scale are dials too. Every lane is drawn as a share of the fullest one: the lanes short of 100% are budget the pass paid for and did not use.
|
|
177
|
+
</cell>
|
|
178
|
+
|
|
179
|
+
<cell type="js" lane="math" id="aim-dial" in="tensor, town">
|
|
180
|
+
const { display } = caps;
|
|
181
|
+
const t = inputs.tensor, town = inputs.town;
|
|
182
|
+
const fmt = (x) => x >= 1e6 ? (x / 1e6).toFixed(2) + 'M' : x >= 1e3 ? (x / 1e3).toFixed(1) + 'k' : x.toFixed(2);
|
|
183
|
+
const count = (x) => x >= 1e3 ? fmt(x) : String(Math.round(x)); // letters, bytes, ops: whole numbers
|
|
184
|
+
|
|
185
|
+
const el = (tag, css, text) => { const e = document.createElement(tag); if (css) e.style.cssText = css; if (text != null) e.textContent = text; return e; };
|
|
186
|
+
const wrap = el('div', 'font:0.82rem/1.35 system-ui,sans-serif;color:#ddd;max-width:900px;margin:2px 0;');
|
|
187
|
+
const dials = el('div', 'display:grid;grid-template-columns:repeat(3,1fr);gap:12px;');
|
|
188
|
+
wrap.appendChild(dials);
|
|
189
|
+
function slider(label, min, max, step, value) {
|
|
190
|
+
const row = el('label', 'display:grid;grid-template-columns:1fr 34px;gap:2px 6px;align-items:center;');
|
|
191
|
+
const input = el('input'); input.type = 'range'; input.min = min; input.max = max; input.step = step; input.value = value;
|
|
192
|
+
const out = el('span', 'font-family:ui-monospace,monospace;color:#fff;text-align:right;');
|
|
193
|
+
row.append(el('span', 'grid-column:1 / 3;color:#aab;', label), input, out);
|
|
194
|
+
dials.appendChild(row);
|
|
195
|
+
return { input, out };
|
|
196
|
+
}
|
|
197
|
+
const sN = slider('frequent values as flyers', 0, t.book.length, 1, 8);
|
|
198
|
+
const sG = slider('gas per delivery (ops)', 1, 200, 1, 24);
|
|
199
|
+
const sS = slider('scale (0 = this tensor)', 0, 100, 1, 60);
|
|
200
|
+
const scaleNote = el('div', 'color:#999;font-size:0.78rem;margin:4px 0 0;');
|
|
201
|
+
wrap.appendChild(scaleNote);
|
|
202
|
+
|
|
203
|
+
const cards = el('div', 'display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:6px 0;');
|
|
204
|
+
const card = (label) => { const c = el('div', 'background:#16181c;border:1px solid #2c2f36;border-radius:6px;padding:5px 10px;'); const big = el('div', 'font:600 1.15rem/1.2 ui-monospace,monospace;color:#fff;'); const sub = el('div', 'color:#9aa;font-size:0.75rem;margin-top:2px;'); c.append(el('div', 'color:#9aa;font-size:0.75rem;text-transform:uppercase;letter-spacing:.05em;', label), big, sub); cards.appendChild(c); return { big, sub }; };
|
|
205
|
+
const cRoad = card('road only: stream every letter'), cMix = card('the mix: flyers + stream'), cFull = card('the fullest lane (sets the mix)');
|
|
206
|
+
wrap.appendChild(cards);
|
|
207
|
+
const lanesBox = el('div', 'display:grid;grid-template-columns:1fr 1fr;gap:14px;');
|
|
208
|
+
wrap.appendChild(lanesBox);
|
|
209
|
+
|
|
210
|
+
function laneChart(title, p) {
|
|
211
|
+
const box = el('div');
|
|
212
|
+
box.appendChild(el('div', 'font-weight:600;color:#fff;margin-bottom:2px;', title));
|
|
213
|
+
for (const l of p.lanes) {
|
|
214
|
+
const u = p.time > 0 ? l.time / p.time : 0;
|
|
215
|
+
const row = el('div', 'display:grid;grid-template-columns:140px 1fr 40px;gap:6px;align-items:center;font-size:0.74rem;line-height:1.15;margin:1px 0;');
|
|
216
|
+
const track = el('div', 'background:#1d1f24;height:9px;border-radius:3px;overflow:hidden;');
|
|
217
|
+
track.appendChild(el('div', `height:100%;width:${(100 * u).toFixed(1)}%;background:${l === p.fullest ? '#e0a040' : '#4f9fc0'};`));
|
|
218
|
+
row.append(el('span', null, l.name), track, el('span', 'text-align:right;font-family:ui-monospace,monospace;', (100 * u).toFixed(0) + '%'));
|
|
219
|
+
box.appendChild(row);
|
|
220
|
+
}
|
|
221
|
+
return box;
|
|
222
|
+
}
|
|
223
|
+
function update() {
|
|
224
|
+
const o = { scale: +sS.input.value, n: +sN.input.value, gasPerDelivery: +sG.input.value };
|
|
225
|
+
sN.out.textContent = o.n; sG.out.textContent = o.gasPerDelivery; sS.out.textContent = o.scale;
|
|
226
|
+
const road = town.roadOnly(o), mix = town.pass(o);
|
|
227
|
+
scaleNote.textContent = `${count(road.letters)} letters per truck-load; the ${o.n} most frequent values cover ${(100 * mix.byFlyer / mix.letters).toFixed(0)}% of them`;
|
|
228
|
+
cRoad.big.textContent = fmt(road.time) + ' cyc'; cRoad.sub.textContent = `fullest lane: ${road.fullest.name}`;
|
|
229
|
+
cMix.big.textContent = fmt(mix.time) + ' cyc';
|
|
230
|
+
const x = road.time / mix.time;
|
|
231
|
+
cMix.sub.innerHTML = `<span style="color:${x >= 1 ? '#7ee2a8' : '#ff8a8a'}">${x.toFixed(2)}× the road-only speed</span>`;
|
|
232
|
+
cFull.big.textContent = mix.fullest.name; cFull.sub.textContent = `${count(mix.fullest.load)} ${mix.fullest.unit} = ${fmt(mix.time)} cycles`;
|
|
233
|
+
lanesBox.innerHTML = '';
|
|
234
|
+
lanesBox.append(laneChart('Road only', road), laneChart(`The mix (${o.n} flyers)`, mix));
|
|
235
|
+
}
|
|
236
|
+
for (const s of [sN, sG, sS]) s.input.addEventListener('input', update);
|
|
237
|
+
update();
|
|
238
|
+
display(wrap);
|
|
239
|
+
</cell>
|
|
240
|
+
|
|
241
|
+
<cell type="markdown">
|
|
242
|
+
## What to look for
|
|
243
|
+
|
|
244
|
+
- At scale 0 the whole tensor sits on the sorting desk; there is no road to save, and flyers only add gas. The road-only plan wins.
|
|
245
|
+
- At scale 60 the letters sit in the city, the city road is the fullest lane, and each frequent value taken off the road as a flyer shortens it. Past some count the vector units become the fullest lane instead, and more flyers make the pass slower: the best mix is where the road and the gas lanes finish closest together.
|
|
246
|
+
- Raise the gas per delivery and that balance point moves toward fewer flyers; lower it and more of the mail goes as flyers.
|
|
247
|
+
|
|
248
|
+
The flyer is a value kept on the desk and delivered to its positions; this notebook counts the gas of a delivery as a number you set and says nothing about what those ops are. That number, the size of the truck-load, and the budget of the whole socket are where **the AIM model** takes over: it runs this same accounting on measured weight slices, on every lane of a full server socket, with seven delivery plans, the dollar budget of each lane, and the client devices. It remains the model of record; this notebook is its accounting, small enough to read whole.
|
|
249
|
+
|
|
250
|
+
For the property that makes moving work between lanes safe at all (the same bits in any order, on any device), see **Deterministic and out of order: the same bits in any order** (`doo-same-bits-any-order`).
|
|
251
|
+
</cell>
|
|
252
|
+
|
|
253
|
+
</frqtl-notebook>
|