1bit-MONSTER commited on
Commit
35a1fab
·
1 Parent(s): 1bd923d

Inkling-2-Mini UD-Q4_K_XL on Loom (gfx1151): native NVFP4 experts + MXFP8 layers 20-23, DFlash depth 3

Browse files

prefill 1984 tok/s @2k , decode 60.4 tok/s; kernel_tests 39/39; consistency failed (near-tie)

.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
BUILD.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "kernels": {
3
+ "repository": "1bit-MONSTER/loom-kernels (private)",
4
+ "commit": "bb04f2f7bd9d1ecf96ba8cacfea68e94f31c0638",
5
+ "dir": "inkling2/"
6
+ },
7
+ "base_card": "loom-fun/unsloth-Inkling-2-Mini-loom@a8354e77",
8
+ "steps": [
9
+ "splice_armA.py",
10
+ "gen_nvfp4_dense.py + gen_nvfp4_gemm.py",
11
+ "splice_armB.py",
12
+ "package_cards.py"
13
+ ]
14
+ }
README.md ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: unsloth/Inkling-2-Mini-GGUF
3
+ license: mit
4
+ tags:
5
+ - loom
6
+ - loom-serve
7
+ - gguf
8
+ - strix-halo
9
+ - speculative-decoding
10
+ - dflash
11
+ ---
12
+
13
+ # Inkling-2-Mini (UD-Q4_K_XL) for AMD Loom
14
+
15
+ A [Loom](https://github.com/ROCm/hrx-system) package (`.loom` programs and a `model.json` card) for the unmodified GGUF checkpoint [unsloth/Inkling-2-Mini-GGUF](https://huggingface.co/unsloth/Inkling-2-Mini-GGUF) (`Inkling-2-Mini-UD-Q4_K_XL.gguf`), generated on an AMD Ryzen AI Max+ 395 "Strix Halo" with the [loom-skills](https://github.com/loom-fun/loom-skills) workflow. Learn more on the [Loom ecosystem website](https://loom-fun.github.io/loom-dev/).
16
+
17
+ ## Quick start
18
+
19
+ ```bash
20
+ pipx install "hrx-loom[hf]==0.2.0"
21
+ loom-fetch huggingface:1bit-MONSTER/Inkling-2-Mini-loom-native:chat --materialize=copy --output=Inkling-2-Mini-loom-native
22
+ loom-serve --model=Inkling-2-Mini-loom-native '--device=amdgpu://?completion_spin_ns=4294967295' --pool_backing=fixed --parameter_mode=preload
23
+ ```
24
+
25
+ - `--materialize=copy` puts copies of the fetched package files in the output directory.
26
+ - `completion_spin_ns=4294967295` enables active waiting for GPU completions (uses CPU while GPU work is in flight); the card's performance measurements use this setting.
27
+ - `--pool_backing=fixed` commits the preset's memory pool up front instead of growing elastic backing.
28
+ - `--parameter_mode=preload` only changes how the weights are loaded on the host, so the performance rows were measured without it unless their job served with it.
29
+
30
+ ## Send a request
31
+
32
+ In another terminal (optional thinking is turned off):
33
+
34
+ ```bash
35
+ curl http://127.0.0.1:8080/v1/chat/completions \
36
+ -H 'Content-Type: application/json' \
37
+ -d '{"model": "1bit-MONSTER/Inkling-2-Mini-loom-native", "messages": [{"role": "user", "content": "Hello"}], "chat_template_kwargs": {"enable_thinking": false}}'
38
+ ```
39
+
40
+ ## Performance vs llama.cpp
41
+
42
+ | metric | llama.cpp | Loom | margin vs best llama.cpp | roofline | Loom % of roofline |
43
+ |---|---|---|---|---|---|
44
+ | decode tok/s, short prompt | — | 60.4 | — | 98.5 | 61 % |
45
+ | decode tok/s, 2k context | — | 59.9 | — | 93.8 | 64 % |
46
+ | decode tok/s, 32k context | — | 47.8 | — | 78.0 | 61 % |
47
+ | prefill tok/s, 1k document | — | 1785.9 | — | 9583.4 | 19 % |
48
+ | prefill tok/s, 2k document | — | 1984.3 | — | 9283.9 | 21 % |
49
+ | prefill tok/s, 8k document | — | 2014.8 | — | 8991.6 | 22 % |
50
+ | prefill tok/s, 16k document | — | 1960.8 | — | 8642.8 | 23 % |
51
+ | prefill tok/s, 32k document | — | 1764.0 | — | 8020.5 | 22 % |
52
+ | 4 streams, aggregate decode tok/s | — | — | — | 379.1 | — |
53
+ | speculative decoding, drafted tokens accepted | — | — | — | n/a | n/a |
54
+
55
+ **Methodology**
56
+
57
+ - Compared: Loom against llama.cpp ROCm (build not recorded); the same GGUF, the same machine and session, the same prompts; Loom served with the active wait. Values are the median of 2–4 sessions (4 streams: median of not recorded); Loom is timed by the client, llama.cpp by its server.
58
+ - Out of the box on both engines: Loom serves the preset shipped in this package; llama.cpp runs its build defaults plus only the server arguments listed below (offload, context and slots). No tuning sweep on either engine.
59
+ - Drafting, 1-stream rows (decode, decode_2k, decode_32k, prefill): Loom DFlash depth 3; llama.cpp ROCm no drafting (NOT the same choice on both engines). Each engine is loaded once for all these rows.
60
+ - 4 streams: both engines loaded with drafting off, 4 parallel requests, aggregate tokens per second.
61
+ - Rows: decode = short-context decode; decode_2k / decode_32k = decode after a ~2k / ~32k-token context; prefill_Nk = prompt processing of an N k-token prompt; streams4 = 4-stream aggregate decode. A margin within +-3 % (the measured same-runner noise) is a tie.
62
+ - llama.cpp ROCm server arguments: not recorded.
63
+ - Measured on AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, AMD Radeon 8060S Graphics, Puppy 26.04, a named machine (this GPU has no DevLab runner); both engines ran on it.
64
+ - Margin vs best llama.cpp: (Loom / max(ROCm, Vulkan) - 1) × 100 %, using the available measured tokens/s for each row on this GPU. With only one valid backend, that backend is used; with neither, the margin is not measured. Raw backend values and their measurement sources are retained below and in the table.
65
+ - Measured 2026-11-25; device AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, AMD Radeon 8060S Graphics, Puppy 26.04; hrx-loom unknown; source: named-machine run.
66
+ - Drafted tokens accepted: the share of the drafter's proposed tokens the model accepted during the `spec` gate's requests.
67
+ - Roofline: the hardware ceiling for this GGUF on AMD Ryzen AI Max+ 395 "Strix Halo" (gfx1151) at 228 GB/s and 44 TFLOP/s sustained at 85 W (spec 59), from loom-roofline `roofline.py` (loom-skills unknown commit); single-pass ceiling (no acceptance measured on this package) for decode, decode at 2k, decode at 32k; 4 streams run without drafting, so its ceiling is single-pass; the 4-stream ceiling of this mixture-of-experts model assumes the four streams route to the same experts (the bound a run may not exceed).
68
+ - — not measured; n/a not applicable.
69
+
70
+ ## Features
71
+
72
+ | feature | status | detail |
73
+ |---|---|---|
74
+ | API | ✅ | OpenAI-style `/v1/chat/completions` |
75
+ | tool calling | ✅ | OpenAI-style `tools` and `tool_calls` |
76
+ | reasoning / thinking | ✅ | on by default; `chat_template_kwargs: {"enable_thinking": false}` turns it off |
77
+ | reasoning effort | ✅ | `reasoning_effort`: none, minimal, low, medium, high, xhigh, max (default high) |
78
+ | speculative decoding | ✅ | DFlash, depth 3, on by default; drafter [unsloth/Inkling-2-Mini-GGUF](https://huggingface.co/unsloth/Inkling-2-Mini-GGUF) |
79
+ | image input | ? | not determined |
80
+ | audio input / output | ? | not determined |
81
+ | sampling | ✅ | `temperature`, `top_p`, `top_k`, `seed` |
82
+ | context size | ✅ | 262,144 tokens per request |
83
+ | concurrency | ✅ | 4 concurrent requests |
84
+ | max output tokens | ✅ | 4,096 (preset `max_tokens`) |
85
+
86
+ ## Correctness
87
+
88
+ | gate | description | result |
89
+ |---|---|---|
90
+ | `kernel_tests` | Unit tests of the generated kernels against reference implementations | ✅ pass (39/39) ¹ |
91
+ | `golden` | llama.cpp reference recorded on the same GGUF: greedy tokens and top-5 log-probs, short prompts and 1k-32k documents | ❌ no evidence |
92
+ | `compare` | Greedy output vs the llama.cpp reference, token by token; every divergence is a near-tie | ❌ no evidence |
93
+ | `vision` | Image input vs llama.cpp with the same projector: identical prompt tokens, replies equal up to near-ties | — not applicable |
94
+ | `consistency` | Concurrent requests give the same output as the same requests run alone | ❌ fail ² |
95
+ | `spec` | Speculative decoding on gives exactly the output of speculative decoding off | ✅ pass ² |
96
+ | `agent` | Multi-turn tool-calling loop: exact prompt rendering, history reuse, valid tool calls, output vs llama.cpp | ✅ pass ² |
97
+ | `agent_think_off` | The tool-calling loop with thinking off | ✅ pass ² |
98
+ | `sampling` | temperature, top_k and seed behave as specified; first-token distribution matches llama.cpp | ✅ pass ² |
99
+ | `logits` | Host logits readback (llm.logits on): at T=0 every returned row's argmax is the device's token, the top-k matches llama.cpp, greedy text is unchanged | ❌ no evidence |
100
+ | `decision` | Decision answers (choice, score, noul probabilities) vs llama.cpp on the same prompts | — not applicable |
101
+
102
+ - ¹ local run, 2026-11-26; device AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, AMD Radeon 8060S Graphics, Puppy 26.04; hrx-loom unknown.
103
+ - ² local run, LEVEL=full, 2026-11-26; device AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, AMD Radeon 8060S Graphics, Puppy 26.04; hrx-loom unknown.
104
+ - Gates are the loom-benchmark correctness gates (`gates.sh`); a gate without a recorded run shows no evidence.
105
+
106
+ ## Files
107
+
108
+ - `model.json` / `model.json.lock`: the card and the pinned source files (sha256 checked by `loom-fetch`).
109
+ - `program/*.loom`, `weights.loom`: the generated Loom programs.
110
+ - `tokenizer.json`: the tokenizer.
111
+ - `llm_config.json`: the configuration the programs were generated from.
112
+ - `info.json`: the measurements, gate evidence and versions this card shows; everything else comes from the files above.
113
+ - `REPORT.md`: how the values above were measured: setup, commands and the value of every run.
114
+
115
+ Versions: card schema `loom-card/3`; loom-skills unknown; hrx-loom unknown; card generator unknown.
116
+
117
+ Source files, fetched by `loom-fetch` from their own repositories:
118
+
119
+ - checkpoint: [unsloth/Inkling-2-Mini-GGUF](https://huggingface.co/unsloth/Inkling-2-Mini-GGUF) @ `ea0c79b`, `Inkling-2-Mini-UD-Q4_K_XL.gguf`
120
+ - drafter: [unsloth/Inkling-2-Mini-GGUF](https://huggingface.co/unsloth/Inkling-2-Mini-GGUF) @ `ea0c79b`, `dspark-Inkling-2-Mini-Q8_0.gguf`
REPORT.md ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inkling-2-Mini for AMD Loom: measurement report
2
+
3
+ How the values on this repository's model card were measured. Generated from `info.json` (schema `loom-card/3`) by the loom-skills card generator; the card's README.md is rendered from the same data.
4
+
5
+ ## Setup
6
+
7
+ - Package: this repository. Programs generated by loom-skills unknown with hrx-loom unknown.
8
+ - Checkpoint: [unsloth/Inkling-2-Mini-GGUF](https://huggingface.co/unsloth/Inkling-2-Mini-GGUF) @ `ea0c79b2ecd73669e774c8519b79bfabfddbc027`, `Inkling-2-Mini-UD-Q4_K_XL.gguf`, sha256 `e62d463c135ffe283df8d94b279a96ca145ac128b52ce854478613045bf4de15`.
9
+ - Drafter: [unsloth/Inkling-2-Mini-GGUF](https://huggingface.co/unsloth/Inkling-2-Mini-GGUF) @ `ea0c79b2ecd73669e774c8519b79bfabfddbc027`, `dspark-Inkling-2-Mini-Q8_0.gguf`; Loom speculative decoding on (DFlash, depth 3).
10
+ - Baseline: llama.cpp (build not recorded), server arguments not recorded (model path, host and port left out).
11
+ - Programs measured: the sha256 below is card_lib.programs_sha256, over `program/*.loom` without each file's first-line generator comment.
12
+
13
+ ## Method
14
+
15
+ - `perf.py` (loom-benchmark) sends real-text requests: a short prompt for decode, decode after 2k and 32k tokens of context, and prefill of documents of about 1k, 2k, 8k, 16k and 32k tokens. Each run gives one value per metric; the card shows the median over the sessions of each session's median sample (a session without an "aggregate" key was measured as the mean of its runs: its row says so).
16
+ - `c4_steady.py` runs 4 concurrent streams and reports the aggregate decode rate over the window in which all 4 are decoding; the card shows the median of the runs.
17
+ - One engine runs at a time on the same machine, with the same GGUF. Loom rates are timed by the client; llama.cpp rates come from its server-side `timings`.
18
+ - Every performance value comes from a `devlab-perf` job (loom-skills) on an AMD DevLab Dispatch Strix Halo runner: Loom, served with the active wait (`--device=amdgpu://?completion_spin_ns=4294967295`), and llama.cpp on the same runner, with the published programs.
19
+ - Drafted tokens accepted is the `spec` gate's count: accepted over proposed draft tokens across its requests.
20
+ - Gates are loom-benchmark's `gates.sh` at the LEVEL shown; DevLab runs are the nightly-gates workflow on AMD DevLab Dispatch.
21
+ - Roofline: per metric, the rate at the hardware limit computed from the GGUF's tensors by loom-roofline `roofline.py`: decode is memory bandwidth / bytes read per token (weights, active experts, KV cache), prefill is peak FLOP/s / flops per token, 4 streams reads the weights once for 4 tokens. With speculative decoding, decode and 4 streams are verify passes per second x (1 + acceptance x depth) tokens per pass, with the acceptance measured in the row's own session (loom-serve's drafted-token counters around perf.py's decode request, or around c4_steady.py's streams), else the `spec` gate's.
22
+
23
+ ## Session 1: named-machine run, 2026-11-25
24
+
25
+ - Device: AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, AMD Radeon 8060S Graphics, Puppy 26.04.
26
+ - Loom SDK: hrx-loom unknown.
27
+ - Programs measured: sha256 `9e281c47c320484ffd4b315520ad99f0870e104f2dd4c1c4b40e295b9dc192f5`, the same as this repository's programs.
28
+ - Values: the median over 4 sessions, a session's value being the median of its samples.
29
+
30
+ | metric | engine | runs | value |
31
+ |---|---|---|---|
32
+ | decode tok/s, short prompt | Loom | 60.4, 60.39, 61.37, 59.44 | 60.4 |
33
+ | decode tok/s, 2k context | Loom | 59.1, 60.63, 59.25, 61.54 | 59.9 |
34
+ | decode tok/s, 32k context | Loom | 49.11, 46.42 | 47.8 |
35
+ | prefill tok/s, 1k document | Loom | 1785.3, 1786.6, 1788.3, 1784.4 | 1785.9 |
36
+ | prefill tok/s, 2k document | Loom | 1971.3, 1963.6, 1999.4, 1997.3 | 1984.3 |
37
+ | prefill tok/s, 8k document | Loom | 1990.0, 2039.6 | 2014.8 |
38
+ | prefill tok/s, 16k document | Loom | 1919.4, 2002.3 | 1960.8 |
39
+ | prefill tok/s, 32k document | Loom | 1634.9, 1893.1 | 1764.0 |
40
+
41
+ ## Roofline
42
+
43
+ - Device: AMD Ryzen AI Max+ 395 "Strix Halo" (gfx1151), 228 GB/s, 44 TFLOP/s sustained at 85 W (spec 59).
44
+ - Tool: `skills/loom-roofline/roofline.py` sha256 `b6dc5d43a40f8a647563d6088cbc6f1c7d0a8e2e4cdbfc20bf0c368d230ec0a8`, loom-skills commit unknown.
45
+ - Checkpoint: `Inkling-2-Mini-UD-Q4_K_XL.gguf`.
46
+ - Speculative decoding: DFlash, depth 3; a drafted row's ceiling counts the acceptance measured in its own session on this package; a row without one shows the single-pass ceiling; 4 streams run without drafting.
47
+
48
+ | metric | ceiling | without drafting | acceptance | demonstrated efficiency |
49
+ |---|---|---|---|---|
50
+ | decode tok/s, short prompt | 98.5 | — | — | 78 % |
51
+ | decode tok/s, 2k context | 93.8 | — | — | 79 % |
52
+ | decode tok/s, 32k context | 78.0 | — | — | 81 % |
53
+ | prefill tok/s, 1k document | 9583.4 | — | — | 44 % |
54
+ | prefill tok/s, 2k document | 9283.9 | — | — | 44 % |
55
+ | prefill tok/s, 8k document | 8991.6 | — | — | 44 % |
56
+ | prefill tok/s, 16k document | 8642.8 | — | — | 44 % |
57
+ | prefill tok/s, 32k document | 8020.5 | — | — | 44 % |
58
+ | 4 streams, aggregate decode tok/s | 379.1 | — | — | 85 % |
59
+
60
+ ## Gate evidence
61
+
62
+ ### local run, 2026-11-26
63
+
64
+ - Gates: `kernel_tests` pass (39/39).
65
+ - Device: AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, AMD Radeon 8060S Graphics, Puppy 26.04.
66
+ - Loom SDK: hrx-loom unknown.
67
+ - Programs: sha256 `9e281c47c320484ffd4b315520ad99f0870e104f2dd4c1c4b40e295b9dc192f5`, the same as this repository's programs.
68
+
69
+ ### local run, LEVEL=full, 2026-11-26
70
+
71
+ - Gates: `consistency` fail, `spec` pass, `agent` pass, `agent_think_off` pass, `sampling` pass.
72
+ - Device: AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, AMD Radeon 8060S Graphics, Puppy 26.04.
73
+ - Loom SDK: hrx-loom unknown.
74
+ - Programs: sha256 `9e281c47c320484ffd4b315520ad99f0870e104f2dd4c1c4b40e295b9dc192f5`, the same as this repository's programs.
head_weights.loom ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Weight policy (the proposal head; draft/prep_weights.py): the listed tensors of the published checkpoint are staged and
2
+ // converted at load by llm_prep_<src>_<dst> (llm.loom); every other tensor keeps its file bytes. No converted
3
+ // checkpoint is written or published.
4
+
5
+ func.decl import("weights") @input(%source: i32, %key: buffer, %key_offset: i64, %key_length: i64, %offset: i64, %length: i64, %alignment: i64) -> (i64)
6
+
7
+ func.decl import("prepare") @stage(%root: buffer, %tag: i64) -> (i32)
8
+
9
+ func.decl import("prepare") @config_i64(%stage: i32, %key: buffer, %value: i64)
10
+
11
+ global.rodata.def @root0 = bytes("6c6c6d5f707265705f71385f30675f71345f3073")
12
+
13
+ global.rodata.def @split_key = bytes("6c6c6d2e707265705f73706c6974")
14
+
15
+ global.rodata.def @skip_key = bytes("6c6c6d2e707265705f736b6970")
16
+
17
+ global.rodata.def @blocks_key = bytes("6c6c6d2e707265705f626c6f636b73")
18
+
19
+ global.rodata.def @input_key = bytes("6c6c6d2e707265705f696e707574")
20
+
21
+ // "output.weight"
22
+ global.rodata.def @k0 = bytes("6f75747075742e776569676874")
23
+
24
+ func.def @same(%key: buffer, %name: buffer) -> (i1) {
25
+ %a = buffer.length %key
26
+ %b = buffer.length %name
27
+ %sized = index.cmp eq, %a, %b : offset
28
+ %result = scf.if %sized -> (i1) {
29
+ %o = index.constant 0 : offset
30
+ %order = buffer.compare %key[%o], %name[%o], %b
31
+ %z = scalar.constant 0 : i32
32
+ %same = scalar.cmpi eq, %order, %z : i32
33
+ scf.yield %same : i1
34
+ } else {
35
+ %no = scalar.constant false : i1
36
+ scf.yield %no : i1
37
+ }
38
+ func.return %result : i1
39
+ }
40
+
41
+ func.def public @prepare_weight(%key: buffer) -> (i64) {
42
+ %zero = scalar.constant 0 : i64
43
+ %blocks_0 = scalar.constant 0 : i64
44
+ %kind_0 = scalar.constant 0 : i64
45
+ %inb_0 = scalar.constant 0 : i64
46
+ %outb_0 = scalar.constant 0 : i64
47
+ %len_0 = scalar.constant 0 : i64
48
+ %split_0 = scalar.constant 0 : i64
49
+ %skip_0 = scalar.constant 0 : i64
50
+ %name0 = global.load @k0 : buffer
51
+ %is0 = func.call @same(%key, %name0) : (buffer, buffer) -> (i1)
52
+ %nb0 = scalar.constant 4718592 : i64
53
+ %nk0 = scalar.constant 0 : i64
54
+ %ni0 = scalar.constant 272 : i64
55
+ %no0 = scalar.constant 18 : i64
56
+ %blocks_1 = scf.select %is0, %nb0, %blocks_0 : i64
57
+ %kind_1 = scf.select %is0, %nk0, %kind_0 : i64
58
+ %inb_1 = scf.select %is0, %ni0, %inb_0 : i64
59
+ %outb_1 = scf.select %is0, %no0, %outb_0 : i64
60
+ %nl0 = scalar.constant 489741984 : i64
61
+ %nsp0 = scalar.constant 65536 : i64
62
+ %nsk0 = scalar.constant 72 : i64
63
+ %len_1 = scf.select %is0, %nl0, %len_0 : i64
64
+ %split_1 = scf.select %is0, %nsp0, %split_0 : i64
65
+ %skip_1 = scf.select %is0, %nsk0, %skip_0 : i64
66
+ %found = scalar.cmpi ne, %blocks_1, %zero : i64
67
+ %bytes = scf.if %found -> (i64) {
68
+ %source = scalar.constant 0 : i32
69
+ %align = scalar.constant 256 : i64
70
+ %length = scalar.addi %len_1, %zero : i64
71
+ %key_bytes = buffer.length %key
72
+ %key_length = index.cast %key_bytes : offset to i64
73
+ %first = func.call @input(%source, %key, %zero, %key_length, %zero, %length, %align) : (i32, buffer, i64, i64, i64, i64, i64) -> (i64)
74
+ %want0 = scalar.constant 0 : i64
75
+ %this0 = scalar.cmpi eq, %kind_1, %want0 : i64
76
+ scf.if %this0 {
77
+ %root0 = global.load @root0 : buffer
78
+ %stage0 = func.call @stage(%root0, %zero) : (buffer, i64) -> (i32)
79
+ %bk0 = global.load @blocks_key : buffer
80
+ %ik0 = global.load @input_key : buffer
81
+ func.call @config_i64(%stage0, %bk0, %blocks_1) : (i32, buffer, i64)
82
+ func.call @config_i64(%stage0, %ik0, %first) : (i32, buffer, i64)
83
+ %spk0 = global.load @split_key : buffer
84
+ %skk0 = global.load @skip_key : buffer
85
+ func.call @config_i64(%stage0, %spk0, %split_1) : (i32, buffer, i64)
86
+ func.call @config_i64(%stage0, %skk0, %skip_1) : (i32, buffer, i64)
87
+ }
88
+ %prepared = scalar.muli %blocks_1, %outb_1 : i64
89
+ scf.yield %prepared : i64
90
+ } else {
91
+ scf.yield %zero : i64
92
+ }
93
+ func.return %bytes : i64
94
+ }
info.json ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "card": {
3
+ "features": {
4
+ "api": {
5
+ "status": "yes",
6
+ "value": {
7
+ "endpoint": "/v1/chat/completions",
8
+ "style": "openai"
9
+ }
10
+ },
11
+ "audio": {
12
+ "status": "unknown",
13
+ "value": null
14
+ },
15
+ "concurrency": {
16
+ "status": "yes",
17
+ "value": {
18
+ "pending_requests": null,
19
+ "rows": 4
20
+ }
21
+ },
22
+ "context": {
23
+ "status": "yes",
24
+ "value": {
25
+ "native": 1048576,
26
+ "tokens": 262144
27
+ }
28
+ },
29
+ "image_input": {
30
+ "status": "unknown",
31
+ "value": null
32
+ },
33
+ "max_output_tokens": {
34
+ "status": "yes",
35
+ "value": {
36
+ "max_tokens": 4096
37
+ }
38
+ },
39
+ "reasoning_effort": {
40
+ "status": "yes",
41
+ "value": {
42
+ "default": "high",
43
+ "levels": [
44
+ "none",
45
+ "minimal",
46
+ "low",
47
+ "medium",
48
+ "high",
49
+ "xhigh",
50
+ "max"
51
+ ]
52
+ }
53
+ },
54
+ "sampling": {
55
+ "status": "yes",
56
+ "value": null
57
+ },
58
+ "speculative_decoding": {
59
+ "status": "yes",
60
+ "value": {
61
+ "depth": 3,
62
+ "drafter": "unsloth/Inkling-2-Mini-GGUF",
63
+ "method": "dflash"
64
+ }
65
+ },
66
+ "thinking": {
67
+ "status": "yes",
68
+ "value": {
69
+ "default": true,
70
+ "mode": "toggle"
71
+ }
72
+ },
73
+ "tool_calling": {
74
+ "status": "yes",
75
+ "value": null
76
+ }
77
+ },
78
+ "memory_bytes": 48000000000
79
+ },
80
+ "devices": {
81
+ "strix-halo": {
82
+ "gates": {
83
+ "agent": {
84
+ "date": "2026-11-26",
85
+ "detail": null,
86
+ "level": "full",
87
+ "programs_sha256": "9e281c47c320484ffd4b315520ad99f0870e104f2dd4c1c4b40e295b9dc192f5",
88
+ "source": "local",
89
+ "status": "pass"
90
+ },
91
+ "agent_think_off": {
92
+ "date": "2026-11-26",
93
+ "detail": null,
94
+ "level": "full",
95
+ "programs_sha256": "9e281c47c320484ffd4b315520ad99f0870e104f2dd4c1c4b40e295b9dc192f5",
96
+ "source": "local",
97
+ "status": "pass"
98
+ },
99
+ "consistency": {
100
+ "date": "2026-11-26",
101
+ "detail": null,
102
+ "level": "full",
103
+ "programs_sha256": "9e281c47c320484ffd4b315520ad99f0870e104f2dd4c1c4b40e295b9dc192f5",
104
+ "source": "local",
105
+ "status": "fail"
106
+ },
107
+ "kernel_tests": {
108
+ "date": "2026-11-26",
109
+ "detail": "39/39",
110
+ "level": null,
111
+ "programs_sha256": "9e281c47c320484ffd4b315520ad99f0870e104f2dd4c1c4b40e295b9dc192f5",
112
+ "source": "local",
113
+ "status": "pass"
114
+ },
115
+ "sampling": {
116
+ "date": "2026-11-26",
117
+ "detail": null,
118
+ "level": "full",
119
+ "programs_sha256": "9e281c47c320484ffd4b315520ad99f0870e104f2dd4c1c4b40e295b9dc192f5",
120
+ "source": "local",
121
+ "status": "pass"
122
+ },
123
+ "spec": {
124
+ "date": "2026-11-26",
125
+ "detail": null,
126
+ "level": "full",
127
+ "programs_sha256": "9e281c47c320484ffd4b315520ad99f0870e104f2dd4c1c4b40e295b9dc192f5",
128
+ "source": "local",
129
+ "status": "pass"
130
+ }
131
+ },
132
+ "performance": {
133
+ "baseline": {
134
+ "args": null,
135
+ "name": "llama.cpp",
136
+ "version": null
137
+ },
138
+ "sessions": [
139
+ {
140
+ "aggregate": "median",
141
+ "commands": [],
142
+ "date": "2026-11-25",
143
+ "metrics": {
144
+ "decode": {
145
+ "baseline": null,
146
+ "loom": 60.4,
147
+ "loom_runs": [
148
+ 60.4,
149
+ 60.39,
150
+ 61.37,
151
+ 59.44
152
+ ]
153
+ },
154
+ "decode_2k": {
155
+ "baseline": null,
156
+ "loom": 59.9,
157
+ "loom_runs": [
158
+ 59.1,
159
+ 60.63,
160
+ 59.25,
161
+ 61.54
162
+ ]
163
+ },
164
+ "decode_32k": {
165
+ "baseline": null,
166
+ "loom": 47.8,
167
+ "loom_runs": [
168
+ 49.11,
169
+ 46.42
170
+ ]
171
+ },
172
+ "prefill_16k": {
173
+ "baseline": null,
174
+ "loom": 1960.8,
175
+ "loom_runs": [
176
+ 1919.4,
177
+ 2002.3
178
+ ]
179
+ },
180
+ "prefill_1k": {
181
+ "baseline": null,
182
+ "loom": 1785.9,
183
+ "loom_runs": [
184
+ 1785.3,
185
+ 1786.6,
186
+ 1788.3,
187
+ 1784.4
188
+ ]
189
+ },
190
+ "prefill_2k": {
191
+ "baseline": null,
192
+ "loom": 1984.3,
193
+ "loom_runs": [
194
+ 1971.3,
195
+ 1963.6,
196
+ 1999.4,
197
+ 1997.3
198
+ ]
199
+ },
200
+ "prefill_32k": {
201
+ "baseline": null,
202
+ "loom": 1764.0,
203
+ "loom_runs": [
204
+ 1634.9,
205
+ 1893.1
206
+ ]
207
+ },
208
+ "prefill_8k": {
209
+ "baseline": null,
210
+ "loom": 2014.8,
211
+ "loom_runs": [
212
+ 1990.0,
213
+ 2039.6
214
+ ]
215
+ }
216
+ },
217
+ "programs_sha256": "9e281c47c320484ffd4b315520ad99f0870e104f2dd4c1c4b40e295b9dc192f5",
218
+ "runs": {
219
+ "decode_prefill": 4,
220
+ "streams4": null
221
+ },
222
+ "source": "machine"
223
+ }
224
+ ]
225
+ },
226
+ "quick_start": {
227
+ "args": [
228
+ "--pool_backing=fixed",
229
+ "--parameter_mode=preload"
230
+ ],
231
+ "device": "amdgpu://?completion_spin_ns=4294967295",
232
+ "preset": "chat"
233
+ },
234
+ "roofline": {
235
+ "checkpoint": "Inkling-2-Mini-UD-Q4_K_XL.gguf",
236
+ "device": {
237
+ "bandwidth_bytes_per_s": 228000000000.0,
238
+ "name": "AMD Ryzen AI Max+ 395 \"Strix Halo\" (gfx1151)",
239
+ "peak_flops": 43800000000000.0,
240
+ "power_mode": "85 W",
241
+ "spec_peak_flops": 59000000000000.0
242
+ },
243
+ "drafting": {
244
+ "acceptance": null,
245
+ "depth": 3,
246
+ "method": "dflash",
247
+ "tokens_per_pass": null
248
+ },
249
+ "metrics": {
250
+ "decode": {
251
+ "ceiling": 98.5,
252
+ "efficiency": 0.78
253
+ },
254
+ "decode_2k": {
255
+ "ceiling": 93.8,
256
+ "efficiency": 0.787
257
+ },
258
+ "decode_32k": {
259
+ "ceiling": 78.0,
260
+ "efficiency": 0.813
261
+ },
262
+ "prefill_16k": {
263
+ "ceiling": 8642.8,
264
+ "efficiency": 0.445
265
+ },
266
+ "prefill_1k": {
267
+ "ceiling": 9583.4,
268
+ "efficiency": 0.445
269
+ },
270
+ "prefill_2k": {
271
+ "ceiling": 9283.9,
272
+ "efficiency": 0.445
273
+ },
274
+ "prefill_32k": {
275
+ "ceiling": 8020.5,
276
+ "efficiency": 0.445
277
+ },
278
+ "prefill_8k": {
279
+ "ceiling": 8991.6,
280
+ "efficiency": 0.445
281
+ },
282
+ "streams4": {
283
+ "basis": "shared-experts",
284
+ "ceiling": 379.1,
285
+ "efficiency": 0.85
286
+ }
287
+ },
288
+ "tool": {
289
+ "script": "skills/loom-roofline/roofline.py",
290
+ "sha256": "b6dc5d43a40f8a647563d6088cbc6f1c7d0a8e2e4cdbfc20bf0c368d230ec0a8",
291
+ "skills_commit": "unknown"
292
+ }
293
+ }
294
+ }
295
+ },
296
+ "repo": "1bit-MONSTER/Inkling-2-Mini-loom-native",
297
+ "report": "generated",
298
+ "schema": "loom-card/3",
299
+ "sources": {
300
+ "local": {
301
+ "device": {
302
+ "cpu": "AMD RYZEN AI MAX+ 395 w/ Radeon 8060S",
303
+ "gpu": "AMD Radeon 8060S Graphics",
304
+ "os": "Puppy 26.04"
305
+ },
306
+ "hrx_loom": null,
307
+ "kind": "local",
308
+ "run": null,
309
+ "url": null
310
+ },
311
+ "machine": {
312
+ "device": {
313
+ "cpu": "AMD RYZEN AI MAX+ 395 w/ Radeon 8060S",
314
+ "gpu": "AMD Radeon 8060S Graphics",
315
+ "os": "Puppy 26.04"
316
+ },
317
+ "hrx_loom": null,
318
+ "kind": "machine",
319
+ "run": null,
320
+ "url": null
321
+ }
322
+ },
323
+ "versions": {
324
+ "card_generator": "unknown"
325
+ }
326
+ }
llm_config.json ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "Inkling-2-Mini",
3
+ "arch": "inkling2",
4
+ "gguf": "Inkling-2-Mini-UD-Q4_K_XL.gguf",
5
+ "hidden": 2304,
6
+ "layers": 48,
7
+ "heads": 24,
8
+ "kv_heads": 8,
9
+ "head_dim": 128,
10
+ "ffn": 1152,
11
+ "vocab": 200058,
12
+ "context_length": 1048576,
13
+ "rms_eps": 9.999999974752427e-07,
14
+ "rope_theta": 10000.0,
15
+ "rope_type": "neox",
16
+ "qk_norm": false,
17
+ "attn_gate": true,
18
+ "post_norms": false,
19
+ "embed_norm": false,
20
+ "embed_scale": null,
21
+ "sliding_window": 1024,
22
+ "sliding_layers": [
23
+ 0,
24
+ 1,
25
+ 2,
26
+ 3,
27
+ 4,
28
+ 6,
29
+ 7,
30
+ 8,
31
+ 9,
32
+ 10,
33
+ 12,
34
+ 13,
35
+ 14,
36
+ 15,
37
+ 16,
38
+ 18,
39
+ 19,
40
+ 20,
41
+ 21,
42
+ 22
43
+ ],
44
+ "nope_layers": [
45
+ 0,
46
+ 1,
47
+ 2,
48
+ 3,
49
+ 4,
50
+ 5,
51
+ 6,
52
+ 7,
53
+ 8,
54
+ 9,
55
+ 10,
56
+ 11,
57
+ 12,
58
+ 13,
59
+ 14,
60
+ 15,
61
+ 16,
62
+ 17,
63
+ 18,
64
+ 19,
65
+ 20,
66
+ 21,
67
+ 22,
68
+ 23,
69
+ 24,
70
+ 25,
71
+ 26,
72
+ 27,
73
+ 28,
74
+ 29,
75
+ 30,
76
+ 31,
77
+ 32,
78
+ 33,
79
+ 34,
80
+ 35,
81
+ 36,
82
+ 37,
83
+ 38,
84
+ 39,
85
+ 40,
86
+ 41,
87
+ 42,
88
+ 43,
89
+ 44,
90
+ 45,
91
+ 46,
92
+ 47
93
+ ],
94
+ "tied_embeddings": false,
95
+ "eos_id": 200006,
96
+ "extra_eos_ids": [
97
+ 199999
98
+ ],
99
+ "bos_id": null,
100
+ "chat": {
101
+ "bos": "",
102
+ "system_prefix": "<|message_system|><|content_text|>",
103
+ "suffix": "<|end_message|>",
104
+ "user_prefix": "<|message_user|><|content_text|>",
105
+ "assistant_prefix": "<|message_model|><|content_text|>",
106
+ "default_system": "",
107
+ "trim_content": false,
108
+ "think_open": "<|message_model|><|content_thinking|>",
109
+ "think_close": "<|end_message|>",
110
+ "history_think": "nonempty",
111
+ "history_think_scope": "all",
112
+ "generation_prompt": "",
113
+ "generation_prompt_plain": "",
114
+ "thinking": "toggle",
115
+ "thinking_default": true,
116
+ "starts_in_reasoning": false,
117
+ "think_end": "<|end_message|>",
118
+ "reasoning_instructions": {
119
+ "none": "0",
120
+ "minimal": "0.1",
121
+ "low": "0.2",
122
+ "medium": "0.7",
123
+ "high": "0.9",
124
+ "xhigh": "0.99",
125
+ "max": "0.99"
126
+ },
127
+ "reasoning_effort_default": "high",
128
+ "reasoning_separator": "",
129
+ "terminal": "<|content_model_end_sampling|>",
130
+ "nonspecial_tokens": [
131
+ "<|message_model|>",
132
+ "<|content_thinking|>",
133
+ "<|content_text|>",
134
+ "<|content_invoke_tool_json|>",
135
+ "<|end_message|>"
136
+ ],
137
+ "tools_function_only": false,
138
+ "tools_prefix": "<|message_system|>tool_declare<|content_xml|>",
139
+ "tools_suffix": "<|end_message|>",
140
+ "tools_after_system": false,
141
+ "tools_system_separator": "",
142
+ "tool_line_prefix": "",
143
+ "call_format": "inkling2",
144
+ "base_call_format": "hermes",
145
+ "tool_turn_prefix": "",
146
+ "tool_item_prefix": "<|message_tool|>",
147
+ "tool_item_suffix": "<|end_message|>",
148
+ "tool_turn_suffix": "",
149
+ "content_call_separator": "",
150
+ "call_separator": "",
151
+ "call_marker": "<|content_invoke_tool_json|>",
152
+ "_note": "Inkling-2-Mini chat format: control.loom renders the whole conversation in chat_begin (chat/inkling2.loom); generic fields are informational and configure chat_reasoning, nonspecial_tokens, and terminal."
153
+ },
154
+ "attn_sinks": false,
155
+ "kv_layers": 48,
156
+ "logit_softcap": 30.0,
157
+ "inkling2": {
158
+ "n_phys": 24,
159
+ "core_start": 6,
160
+ "core_end": 18,
161
+ "n_passes": 3,
162
+ "gate_rank": 64,
163
+ "l_cache": 4,
164
+ "attn_res_block_size": 6,
165
+ "d_rel": 16,
166
+ "rel_extent": 1024,
167
+ "qk_clip": 22.627416610717773,
168
+ "rel_clip": 8.0,
169
+ "log_scale_floor": 8192,
170
+ "log_scale_alpha": 0.10000000149011612
171
+ },
172
+ "moe": {
173
+ "experts": 128,
174
+ "used": 8,
175
+ "ffn": 1152,
176
+ "leading_dense": 0,
177
+ "gating": 2,
178
+ "norm_weights": true,
179
+ "scale": 8.0,
180
+ "probs_bias": true,
181
+ "act": "situ",
182
+ "norm_eps": 1e-20,
183
+ "situ_beta": 4.0,
184
+ "situ_linear_beta": 25.0,
185
+ "gate_up_fused": true,
186
+ "down_scale": true
187
+ },
188
+ "model_id": "1bit-MONSTER/Inkling-2-Mini-loom-native",
189
+ "draft": {
190
+ "kind": "dflash",
191
+ "depth": 3,
192
+ "gguf": "dspark-Inkling-2-Mini-Q8_0.gguf",
193
+ "layers": 3,
194
+ "kv_heads": 8,
195
+ "head_dim": 128,
196
+ "taps": 4,
197
+ "block_size": 8,
198
+ "dspark_inkling2": true,
199
+ "kv_layers": 1,
200
+ "carry_stride": 8404992,
201
+ "head_policy": "head_weights.loom"
202
+ },
203
+ "generator": {
204
+ "skills_commit": "unknown",
205
+ "dirty": null,
206
+ "kit": {
207
+ "example": null,
208
+ "modified": true
209
+ },
210
+ "hrx_loom": "unknown",
211
+ "dirty_choices": [
212
+ "moe.decode.rows_per_wg",
213
+ "prefill.gemm.m256_a32"
214
+ ]
215
+ },
216
+ "sdk": {
217
+ "hrx_loom": "0.2.0",
218
+ "source": "pypi",
219
+ "wheel_sha256": "5148f9e3a264af400ec4bae38bd7b06bf551d28cc33b7a61d67f7bcefa590438",
220
+ "hrx_system_sha": "0cd370f2baaa0cfef47cc23007f1a109906f8a52"
221
+ },
222
+ "resolved": {
223
+ "scopes": [
224
+ "facet/drafted",
225
+ "facet/moe",
226
+ "facet/sliding-window"
227
+ ],
228
+ "choices": {},
229
+ "devices": [
230
+ "rdna3",
231
+ "rdna4"
232
+ ],
233
+ "facets": [
234
+ "draft-dflash",
235
+ "drafted",
236
+ "gated-attn",
237
+ "moe",
238
+ "sliding-window"
239
+ ],
240
+ "env": {}
241
+ }
242
+ }
model.json ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 1,
3
+ "model": {
4
+ "id": "1bit-MONSTER/Inkling-2-Mini-loom-native",
5
+ "name": "Inkling-2-Mini nvfp4attn (Loom; speed variant, OPT-IN: attention + output head re-quantized BF16 -> NVFP4; vs the HF reference mean KLD 0.018259 (default 0.004583), top-1 95.07 % (97.99 %), PPL +1.1 %; decode +14 / +20 % at 0.7k / 5.6k ctx, prefill -3.9 % (engine#3333))"
6
+ },
7
+ "programs": {
8
+ "source": {
9
+ "inputs": [
10
+ {
11
+ "path": "program/prepare.loom",
12
+ "data": [
13
+ "weights.loom",
14
+ "head_weights.loom",
15
+ "llm_config.json"
16
+ ]
17
+ },
18
+ "program/control.loom",
19
+ "program/storage.loom",
20
+ "program/service.loom"
21
+ ],
22
+ "libraries": [
23
+ "program/llm.loom"
24
+ ]
25
+ }
26
+ },
27
+ "services": {
28
+ "chat": {
29
+ "kind": "text",
30
+ "version": 1
31
+ }
32
+ },
33
+ "variants": {
34
+ "gguf": {
35
+ "services": {
36
+ "chat": {
37
+ "programs": [
38
+ "source"
39
+ ],
40
+ "config": {
41
+ "llm.card": true,
42
+ "llm.logits": false
43
+ },
44
+ "parameters": {
45
+ "model": {
46
+ "files": [
47
+ {
48
+ "path": "parameter/Inkling-2-Mini-UD-Q4_K_XL.gguf",
49
+ "format": "gguf",
50
+ "origin": "@checkpoint/Inkling-2-Mini-UD-Q4_K_XL.gguf"
51
+ },
52
+ {
53
+ "path": "parameter/Inkling-2-Mini-MXFP8-experts.safetensors",
54
+ "format": "safetensors",
55
+ "origin": "@mxfp8/Inkling-2-Mini-MXFP8-experts.safetensors"
56
+ },
57
+ {
58
+ "path": "parameter/Inkling-2-Mini-nvfp4-attention.gguf",
59
+ "format": "gguf",
60
+ "origin": "@nvfp4/Inkling-2-Mini-nvfp4-attention.gguf"
61
+ }
62
+ ]
63
+ },
64
+ "draft": {
65
+ "files": [
66
+ {
67
+ "path": "parameter/dspark-Inkling-2-Mini-Q8_0.gguf",
68
+ "format": "gguf",
69
+ "origin": "@checkpoint/dspark-Inkling-2-Mini-Q8_0.gguf"
70
+ }
71
+ ]
72
+ }
73
+ },
74
+ "tokenizers": {
75
+ "text": "tokenizer.json"
76
+ }
77
+ }
78
+ }
79
+ }
80
+ },
81
+ "presets": {
82
+ "chat": {
83
+ "service": "chat",
84
+ "variant": "gguf",
85
+ "programs": "source",
86
+ "execution": {
87
+ "rows": 4,
88
+ "context_capacity": 262144,
89
+ "prefill_capacity": 4096,
90
+ "max_tokens": 4096,
91
+ "draft_depth": 3
92
+ }
93
+ },
94
+ "ab": {
95
+ "service": "chat",
96
+ "variant": "gguf",
97
+ "programs": "source",
98
+ "execution": {
99
+ "rows": 1,
100
+ "context_capacity": 32768,
101
+ "prefill_capacity": 4096,
102
+ "max_tokens": 4096,
103
+ "draft_depth": 3
104
+ }
105
+ }
106
+ },
107
+ "origins": {
108
+ "checkpoint": {
109
+ "kind": "hf",
110
+ "repository": "unsloth/Inkling-2-Mini-GGUF",
111
+ "revision": "ea0c79b2ecd73669e774c8519b79bfabfddbc027"
112
+ },
113
+ "nvfp4": {
114
+ "kind": "hf",
115
+ "repository": "1bit-MONSTER/Inkling-2-Mini-NVFP4-attention",
116
+ "revision": "0a7dbdf2ef0034cd5cee59ddffcb516f76afa9c9"
117
+ },
118
+ "mxfp8": {
119
+ "kind": "hf",
120
+ "repository": "1bit-MONSTER/Inkling-2-Mini-MXFP8-experts",
121
+ "revision": "a9955dddd10125865cbd76a720d9530c6be89ab4"
122
+ }
123
+ }
124
+ }
model.json.lock ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 2,
3
+ "scope": "assets",
4
+ "origins": {
5
+ "checkpoint": {
6
+ "requested": {
7
+ "kind": "hf",
8
+ "repository": "unsloth/Inkling-2-Mini-GGUF",
9
+ "revision": "ea0c79b2ecd73669e774c8519b79bfabfddbc027"
10
+ },
11
+ "resolved": {
12
+ "revision": "ea0c79b2ecd73669e774c8519b79bfabfddbc027"
13
+ }
14
+ },
15
+ "mxfp8": {
16
+ "requested": {
17
+ "kind": "hf",
18
+ "repository": "1bit-MONSTER/Inkling-2-Mini-MXFP8-experts",
19
+ "revision": "a9955dddd10125865cbd76a720d9530c6be89ab4"
20
+ },
21
+ "resolved": {
22
+ "revision": "a9955dddd10125865cbd76a720d9530c6be89ab4"
23
+ }
24
+ },
25
+ "nvfp4": {
26
+ "requested": {
27
+ "kind": "hf",
28
+ "repository": "1bit-MONSTER/Inkling-2-Mini-NVFP4-attention",
29
+ "revision": "0a7dbdf2ef0034cd5cee59ddffcb516f76afa9c9"
30
+ },
31
+ "resolved": {
32
+ "revision": "0a7dbdf2ef0034cd5cee59ddffcb516f76afa9c9"
33
+ }
34
+ }
35
+ },
36
+ "files": [
37
+ {
38
+ "origin": "@checkpoint/Inkling-2-Mini-UD-Q4_K_XL.gguf",
39
+ "size": 17629759456,
40
+ "sha256": "e62d463c135ffe283df8d94b279a96ca145ac128b52ce854478613045bf4de15"
41
+ },
42
+ {
43
+ "origin": "@checkpoint/dspark-Inkling-2-Mini-Q8_0.gguf",
44
+ "size": 402278560,
45
+ "sha256": "2ec78510da837e8fc3be54a14757a0c5fbd2d8d9e85a0d92853fafdf674f3773"
46
+ },
47
+ {
48
+ "origin": "@mxfp8/Inkling-2-Mini-MXFP8-experts.safetensors",
49
+ "size": 4204267656,
50
+ "sha256": "3ef844b57270b474d15377aff110778f89a69db452bf7644198250adc8688367"
51
+ },
52
+ {
53
+ "origin": "@nvfp4/Inkling-2-Mini-nvfp4-attention.gguf",
54
+ "size": 622844480,
55
+ "sha256": "028ac1cbab596e412cbcddfa6a80075ef26129337efb2c6294d1f67e3a604ff7"
56
+ },
57
+ {
58
+ "origin": "tokenizer.json",
59
+ "size": 12242935,
60
+ "sha256": "a45fdc4e7e66a035de236d2694742fed5645327051caace5f8312013a879f9b1"
61
+ }
62
+ ]
63
+ }
program/control.loom ADDED
The diff for this file is too large to render. See raw diff
 
program/llm.loom ADDED
The diff for this file is too large to render. See raw diff
 
program/prepare.loom ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ config.def @llm.card = false : i1
2
+
3
+ // logits:begin
4
+ // A declaration: the one definition (default false) is in llm.loom; a second config.def of the key links ambiguously (LINK/MATERIALIZE).
5
+ config.decl @llm.logits : i1
6
+ // logits:end
7
+
8
+ func.decl import("input") @require(%condition: i32, %diagnostic: buffer)
9
+
10
+ func.decl import("json") @members(%json: buffer) -> (buffer, i32, i64)
11
+
12
+ func.decl import("prepare") @stage(%root: buffer, %tag: i64) -> (i32)
13
+
14
+ func.decl import("prepare") @config_i64(%stage: i32, %key: buffer, %value: i64)
15
+
16
+ func.decl import("prepare") @source(%directory: buffer, %path: buffer) -> (i32)
17
+
18
+ func.decl import("prepare") @parameter(%stage: i32, %binding: i32, %input: i32, %source: i32, %policy: buffer)
19
+
20
+ func.decl import("prepare") @source_scope(%scope: buffer) -> (i32)
21
+
22
+ // "model"
23
+ global.rodata.def @model_scope = bytes("6d6f64656c")
24
+
25
+ // "llm_advance"
26
+ global.rodata.def @root = bytes("6c6c6d5f616476616e6365")
27
+
28
+ // "llm.context", "llm.spans", "llm.tokens", "llm.pool"
29
+ global.rodata.def @context_key = bytes("6c6c6d2e636f6e74657874")
30
+
31
+ global.rodata.def @spans_key = bytes("6c6c6d2e7370616e73")
32
+
33
+ global.rodata.def @tokens_key = bytes("6c6c6d2e746f6b656e73")
34
+
35
+ global.rodata.def @pool_key = bytes("6c6c6d2e706f6f6c")
36
+
37
+ // logits:begin
38
+ // "llm.logit_slots": the rows of the logits region a stage may write (min(spans, rows)), set only with the capability.
39
+ global.rodata.def @logit_slots_key = bytes("6c6c6d2e6c6f6769745f736c6f7473")
40
+ // logits:end
41
+
42
+ // "llm_verify", "llm_dflash_warm", "llm_dflash_propose", "llm.width", "llm.gated", "llm.epoch_spans", "llm.epoch_tokens"
43
+ global.rodata.def @verify_root = bytes("6c6c6d5f766572696679")
44
+
45
+ global.rodata.def @warm_root = bytes("6c6c6d5f64666c6173685f7761726d")
46
+
47
+ global.rodata.def @propose_root = bytes("6c6c6d5f64666c6173685f70726f706f7365")
48
+
49
+ global.rodata.def @width_key = bytes("6c6c6d2e7769647468")
50
+
51
+ global.rodata.def @gated_key = bytes("6c6c6d2e6761746564")
52
+
53
+ global.rodata.def @epoch_spans_key = bytes("6c6c6d2e65706f63685f7370616e73")
54
+
55
+ global.rodata.def @epoch_tokens_key = bytes("6c6c6d2e65706f63685f746f6b656e73")
56
+
57
+ // "draft"
58
+ global.rodata.def @draft_scope = bytes("6472616674")
59
+
60
+ // "head_weights.loom"
61
+ global.rodata.def @head_policy_name = bytes("686561645f776569676874732e6c6f6f6d")
62
+
63
+ // "weights.loom"
64
+ global.rodata.def @policy = bytes("776569676874732e6c6f6f6d")
65
+
66
+ // "<|content_model_end_sampling|>" is the service terminal marker.
67
+ global.rodata.def @terminal = bytes("3c7c636f6e74656e745f6d6f64656c5f656e645f73616d706c696e677c3e")
68
+
69
+ global.rodata.def @empty = bytes("")
70
+
71
+ // "llm requires pooled epochs without MTP, at most 128 shapes and a context of at most 1048576"
72
+ global.rodata.def @unsupported = bytes("6c6c6d20726571756972657320706f6f6c65642065706f63687320776974686f7574204d54502c206174206d6f7374203132382073686170657320616e64206120636f6e74657874206f66206174206d6f73742031303438353736")
73
+
74
+ func.decl @llm_storage(%maximum: i64, %span_capacity: i64, %context: i64, %pool: i64, %rows: i64, %pins: i64, %drafting: i64) -> (buffer, buffer, buffer, buffer, buffer)
75
+
76
+ // Control state layout: [0, 8) unused, [8, 88) two transfer records,
77
+ // [88, 128) layout recipe, [128, 640) stage per packing shape, then a 16-byte
78
+ // sampling record per resident row.
79
+ func.def public @prepare(%prefill: i64, %context: i64, %pool: i64, %rows: i64, %pins: i64, %draft_depth: i32, %shapes: buffer, %shape_count: i64, %weights: buffer, %options: buffer) -> (i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer) {
80
+ %c0_source = scalar.constant 0 : i32
81
+ %origin = index.constant 0 : offset
82
+ %c0 = index.constant 0 : index
83
+ %c1 = index.constant 1 : index
84
+ %c0_i32 = scalar.constant 0 : i32
85
+ %c0_i64 = scalar.constant 0 : i64
86
+ %c64_i64 = scalar.constant 128 : i64
87
+ %c4096_i64 = scalar.constant 1048576 : i64
88
+ %pooled = scalar.cmpi ne, %pool, %c0_i64 : i64
89
+ %packed = scalar.cmpi ne, %shape_count, %c0_i64 : i64
90
+ %few_shapes = scalar.cmpi ule, %shape_count, %c64_i64 : i64
91
+ %short_context = scalar.cmpi ule, %context, %c4096_i64 : i64
92
+ %no_draft = scalar.cmpi eq, %draft_depth, %c0_i32 : i32
93
+ %has_epochs = scalar.andi %pooled, %packed : i1
94
+ %c7_i32 = scalar.constant 7 : i32
95
+ %depth_ok = scalar.cmpi ule, %draft_depth, %c7_i32 : i32
96
+ %mode_ok = scalar.andi %has_epochs, %depth_ok : i1
97
+ %limits_ok = scalar.andi %few_shapes, %short_context : i1
98
+ %supported = scalar.andi %mode_ok, %limits_ok : i1
99
+ %supported32 = scalar.extui %supported : i1 to i32
100
+ %error = global.load @unsupported : buffer
101
+ func.call @require(%supported32, %error) : (i32, buffer)
102
+ %empty = global.load @empty : buffer
103
+ %policy = global.load @policy : buffer
104
+ %card = config.get @llm.card : i1
105
+ %checkpoint = scf.if %card -> (i32) {
106
+ %scope = global.load @model_scope : buffer
107
+ %scoped = func.call @source_scope(%scope) : (buffer) -> (i32)
108
+ scf.yield %scoped : i32
109
+ } else {
110
+ %direct = func.call @source(%empty, %weights) : (buffer, buffer) -> (i32)
111
+ scf.yield %direct : i32
112
+ }
113
+ %bounded_count = scalar.assume %shape_count [range(%shape_count, 1, 128)] : i64
114
+ %count = index.cast %bounded_count : i64 to index
115
+ %c4_off = index.constant 4 : offset
116
+ %stage_slots = index.constant 128 : index
117
+ %stage_bytes = index.scale %stage_slots, %c4_off : index, offset -> offset
118
+ %header_bytes = index.constant 128 : offset
119
+ %control_bytes = index.constant 2048 : offset
120
+ // Then one 16-byte sampling record per resident row (control.loom @bind_request).
121
+ %bounded_rows = scalar.assume %rows [range(%rows, 1, 1048576)] : i64
122
+ %row_count = index.cast %bounded_rows : i64 to index
123
+ %record_bytes = index.constant 16 : offset
124
+ %sampling_bytes = index.scale %row_count, %record_bytes : index, offset -> offset
125
+ %state_bytes = index.add %control_bytes, %sampling_bytes : offset
126
+ %state = buffer.alloca<private> align(8) %state_bytes : buffer
127
+ buffer.fill %c0_i32, %state[%origin], %state_bytes : i32
128
+ %stage_view = buffer.view %state[%header_bytes] : buffer -> view<[%count]xi32>
129
+ %verify_at = index.constant 640 : offset
130
+ %warm_at = index.constant 1152 : offset
131
+ %verify_view = buffer.view %state[%verify_at] : buffer -> view<[%count]xi32>
132
+ %warm_view = buffer.view %state[%warm_at] : buffer -> view<[%count]xi32>
133
+ %drafting = scalar.cmpi ne, %draft_depth, %c0_i32 : i32
134
+ %depth64 = scalar.extui %draft_depth : i32 to i64
135
+ %c1_w = scalar.constant 1 : i64
136
+ %width = scalar.addi %depth64, %c1_w : i64
137
+ %verify_root = global.load @verify_root : buffer
138
+ %warm_root = global.load @warm_root : buffer
139
+ %width_key = global.load @width_key : buffer
140
+ %gated_key = global.load @gated_key : buffer
141
+ %gated_off = scalar.constant 0 : i64
142
+ %gated_on = scalar.constant 1 : i64
143
+ %root = global.load @root : buffer
144
+ %context_key = global.load @context_key : buffer
145
+ %spans_key = global.load @spans_key : buffer
146
+ %tokens_key = global.load @tokens_key : buffer
147
+ %pool_key = global.load @pool_key : buffer
148
+ // logits:begin
149
+ %logits_cfg = config.get @llm.logits : i1
150
+ %logit_slots_key = global.load @logit_slots_key : buffer
151
+ // logits:end
152
+ %shape_view = buffer.view %shapes[%origin] : buffer -> view<[%count]x2xi64>
153
+ %maximum, %span_capacity = scf.for %i = [%c0 to %count step %c1](%previous = %c0_i64 : i64, %previous_spans = %c0_i64 : i64) -> (i64, i64) {
154
+ %tokens = view.load %shape_view[%i, 0] : view<[%count]x2xi64> -> i64
155
+ %spans = view.load %shape_view[%i, 1] : view<[%count]x2xi64> -> i64
156
+ %tag = index.cast %i : index to i64
157
+ %stage = func.call @stage(%root, %tag) : (buffer, i64) -> (i32)
158
+ func.call @config_i64(%stage, %context_key, %context) : (i32, buffer, i64)
159
+ func.call @config_i64(%stage, %pool_key, %pool) : (i32, buffer, i64)
160
+ func.call @config_i64(%stage, %tokens_key, %tokens) : (i32, buffer, i64)
161
+ func.call @config_i64(%stage, %spans_key, %spans) : (i32, buffer, i64)
162
+ // logits:begin
163
+ scf.if %logits_cfg {
164
+ %logit_slots = scalar.minsi %spans, %rows : i64
165
+ func.call @config_i64(%stage, %logit_slots_key, %logit_slots) : (i32, buffer, i64)
166
+ }
167
+ // logits:end
168
+ func.call @parameter(%stage, %c0_i32, %c0_source, %checkpoint, %policy) : (i32, i32, i32, i32, buffer)
169
+ view.store %stage, %stage_view[%i] : i32, view<[%count]xi32>
170
+ %larger = scalar.cmpi ugt, %tokens, %previous : i64
171
+ %next = scf.select %larger, %tokens, %previous : i64
172
+ %more_spans = scalar.cmpi ugt, %spans, %previous_spans : i64
173
+ %next_spans = scf.select %more_spans, %spans, %previous_spans : i64
174
+ scf.yield %next, %next_spans : i64, i64
175
+ }
176
+ // Verify and catch-up stages per shape, declared after every advance stage (the first shape_count
177
+ // stages are the shared target stages), then proposal stages for cohorts of 1, 2, 4, ... spans.
178
+ // the drafter checkpoint (card parameter scope "draft")
179
+ %draft_scope = global.load @draft_scope : buffer
180
+ %draft_source = func.call @source_scope(%draft_scope) : (buffer) -> (i32)
181
+ %head_policy = global.load @head_policy_name : buffer
182
+ scf.if %drafting {
183
+ %propose_root = global.load @propose_root : buffer
184
+ %epoch_spans_key = global.load @epoch_spans_key : buffer
185
+ %epoch_tokens_key = global.load @epoch_tokens_key : buffer
186
+ %span32 = scalar.trunci %span_capacity : i64 to i32
187
+ %one32 = scalar.constant 1 : i32
188
+ %bits32 = scalar.constant 32 : i32
189
+ %below = scalar.subi %span32, %one32 : i32
190
+ %leading = scalar.ctlzi %below : i32
191
+ %last_level = scalar.subi %bits32, %leading : i32
192
+ %levels_all = scalar.addi %last_level, %one32 : i32
193
+ %level_cap = scalar.constant 5 : i32
194
+ %levels32 = scalar.minui %levels_all, %level_cap : i32
195
+ %levels_b = scalar.assume %levels32 [range(%levels32, 1, 14)] : i32
196
+ %levels = index.cast %levels_b : i32 to index
197
+ %c1_64 = scalar.constant 1 : i64
198
+ %first_propose = scf.for %level = [%c0 to %levels step %c1](%first = %c0_i32 : i32) -> (i32) {
199
+ %shift = index.cast %level : index to i64
200
+ %cap = scalar.shli %c1_64, %shift : i64
201
+ %pstage = func.call @stage(%propose_root, %shift) : (buffer, i64) -> (i32)
202
+ func.call @config_i64(%pstage, %context_key, %context) : (i32, buffer, i64)
203
+ func.call @config_i64(%pstage, %pool_key, %pool) : (i32, buffer, i64)
204
+ // A DFlash block is [anchor, <mask> x depth] (llama.cpp's n_max + 1 tokens), capped at the trained block size:
205
+ // 4 streams at depth 3 propose 16 tokens (one int8 matvec pass per drafter weight) instead of 64 (GEMM).
206
+ %block_full = scalar.constant 8 : i64
207
+ %block_tokens = scalar.constant 8 : i64
208
+ %cap_tokens = scalar.muli %cap, %block_tokens : i64
209
+ func.call @config_i64(%pstage, %tokens_key, %cap_tokens) : (i32, buffer, i64)
210
+ func.call @config_i64(%pstage, %spans_key, %cap) : (i32, buffer, i64)
211
+ func.call @config_i64(%pstage, %width_key, %width) : (i32, buffer, i64)
212
+ func.call @config_i64(%pstage, %epoch_spans_key, %span_capacity) : (i32, buffer, i64)
213
+ func.call @config_i64(%pstage, %epoch_tokens_key, %maximum) : (i32, buffer, i64)
214
+ %pstage_b0 = scalar.constant 0 : i32
215
+ func.call @parameter(%pstage, %pstage_b0, %c0_source, %checkpoint, %policy) : (i32, i32, i32, i32, buffer)
216
+ %pstage_b1 = scalar.constant 1 : i32
217
+ func.call @parameter(%pstage, %pstage_b1, %c0_source, %draft_source, %policy) : (i32, i32, i32, i32, buffer)
218
+ %pstage_b2 = scalar.constant 2 : i32
219
+ func.call @parameter(%pstage, %pstage_b2, %c0_source, %checkpoint, %head_policy) : (i32, i32, i32, i32, buffer)
220
+
221
+ %initial = index.cmp eq, %level, %c0 : index
222
+ %next_first = scf.select %initial, %pstage, %first : i32
223
+ scf.yield %next_first : i32
224
+ }
225
+ scf.for %i = [%c0 to %count step %c1] {
226
+ %tokens = view.load %shape_view[%i, 0] : view<[%count]x2xi64> -> i64
227
+ %spans = view.load %shape_view[%i, 1] : view<[%count]x2xi64> -> i64
228
+ %tag = index.cast %i : index to i64
229
+ %vstage = func.call @stage(%verify_root, %tag) : (buffer, i64) -> (i32)
230
+ func.call @config_i64(%vstage, %context_key, %context) : (i32, buffer, i64)
231
+ func.call @config_i64(%vstage, %pool_key, %pool) : (i32, buffer, i64)
232
+ func.call @config_i64(%vstage, %tokens_key, %tokens) : (i32, buffer, i64)
233
+ func.call @config_i64(%vstage, %spans_key, %spans) : (i32, buffer, i64)
234
+ func.call @config_i64(%vstage, %width_key, %width) : (i32, buffer, i64)
235
+ func.call @config_i64(%vstage, %gated_key, %gated_off) : (i32, buffer, i64)
236
+ func.call @parameter(%vstage, %c0_i32, %c0_source, %checkpoint, %policy) : (i32, i32, i32, i32, buffer)
237
+ view.store %vstage, %verify_view[%i] : i32, view<[%count]xi32>
238
+ %wstage = func.call @stage(%warm_root, %tag) : (buffer, i64) -> (i32)
239
+ func.call @config_i64(%wstage, %context_key, %context) : (i32, buffer, i64)
240
+ func.call @config_i64(%wstage, %pool_key, %pool) : (i32, buffer, i64)
241
+ func.call @config_i64(%wstage, %tokens_key, %tokens) : (i32, buffer, i64)
242
+ func.call @config_i64(%wstage, %spans_key, %spans) : (i32, buffer, i64)
243
+ %wstage_b0 = scalar.constant 0 : i32
244
+ func.call @parameter(%wstage, %wstage_b0, %c0_source, %draft_source, %policy) : (i32, i32, i32, i32, buffer)
245
+
246
+ view.store %wstage, %warm_view[%i] : i32, view<[%count]xi32>
247
+ %same_shape = scalar.cmpi eq, %tokens, %spans : i64
248
+ %gate_slots = scalar.constant 32 : i64
249
+ %few_spans = scalar.cmpi ult, %spans, %gate_slots : i64
250
+ %gate_ok = scalar.andi %same_shape, %few_spans : i1
251
+ scf.if %gate_ok {
252
+ %gate_at = index.constant 1700 : offset
253
+ %gate_view = buffer.view %state[%gate_at] : buffer -> view<32xi32>
254
+ %gate_slot = index.cast %spans : i64 to index
255
+ %gate_i32 = index.cast %i : index to i32
256
+ %gate_one = scalar.constant 1 : i32
257
+ %gate_idx1 = scalar.addi %gate_i32, %gate_one : i32
258
+ %gtag_base = scalar.constant 256 : i64
259
+ %gtag = scalar.addi %tag, %gtag_base : i64
260
+ %gvstage = func.call @stage(%verify_root, %gtag) : (buffer, i64) -> (i32)
261
+ func.call @config_i64(%gvstage, %context_key, %context) : (i32, buffer, i64)
262
+ func.call @config_i64(%gvstage, %pool_key, %pool) : (i32, buffer, i64)
263
+ func.call @config_i64(%gvstage, %tokens_key, %tokens) : (i32, buffer, i64)
264
+ func.call @config_i64(%gvstage, %spans_key, %spans) : (i32, buffer, i64)
265
+ func.call @config_i64(%gvstage, %width_key, %width) : (i32, buffer, i64)
266
+ func.call @config_i64(%gvstage, %gated_key, %gated_on) : (i32, buffer, i64)
267
+ func.call @parameter(%gvstage, %c0_i32, %c0_source, %checkpoint, %policy) : (i32, i32, i32, i32, buffer)
268
+ %gate_shift = scalar.constant 8 : i32
269
+ %gv_high = scalar.shli %gvstage, %gate_shift : i32
270
+ %gate_tag = scalar.ori %gate_idx1, %gv_high : i32
271
+ view.store %gate_tag, %gate_view[%gate_slot] : i32, view<32xi32>
272
+ }
273
+ }
274
+ %draft_at = index.constant 1664 : offset
275
+ %draft_view = buffer.view %state[%draft_at] : buffer -> view<3xi32>
276
+ view.store %first_propose, %draft_view[0] : i32, view<3xi32>
277
+ view.store %levels32, %draft_view[1] : i32, view<3xi32>
278
+ %kind32 = scalar.constant 2 : i32
279
+ view.store %kind32, %draft_view[2] : i32, view<3xi32>
280
+ // Adaptive depth=1 fast-path stages (when draft_depth >= 2): 1-step propose + t=2 verify + t=2 warm
281
+ %c1_ad = scalar.constant 1 : i32
282
+ %adapt_ok = scalar.cmpi ugt, %draft_depth, %c1_ad : i32
283
+ scf.if %adapt_ok {
284
+ %c1_a64 = scalar.constant 1 : i64
285
+ %c2_a64 = scalar.constant 2 : i64
286
+ %ptag_d1 = scalar.constant 16 : i64
287
+ %pstage_d1 = func.call @stage(%propose_root, %ptag_d1) : (buffer, i64) -> (i32)
288
+ func.call @config_i64(%pstage_d1, %context_key, %context) : (i32, buffer, i64)
289
+ func.call @config_i64(%pstage_d1, %pool_key, %pool) : (i32, buffer, i64)
290
+ %block_d1 = scalar.constant 8 : i64
291
+ func.call @config_i64(%pstage_d1, %tokens_key, %block_d1) : (i32, buffer, i64)
292
+ func.call @config_i64(%pstage_d1, %spans_key, %c1_a64) : (i32, buffer, i64)
293
+ func.call @config_i64(%pstage_d1, %width_key, %c2_a64) : (i32, buffer, i64)
294
+ func.call @config_i64(%pstage_d1, %epoch_spans_key, %span_capacity) : (i32, buffer, i64)
295
+ func.call @config_i64(%pstage_d1, %epoch_tokens_key, %maximum) : (i32, buffer, i64)
296
+ %pstage_d1_b0 = scalar.constant 0 : i32
297
+ func.call @parameter(%pstage_d1, %pstage_d1_b0, %c0_source, %checkpoint, %policy) : (i32, i32, i32, i32, buffer)
298
+ %pstage_d1_b1 = scalar.constant 1 : i32
299
+ func.call @parameter(%pstage_d1, %pstage_d1_b1, %c0_source, %draft_source, %policy) : (i32, i32, i32, i32, buffer)
300
+ %pstage_d1_b2 = scalar.constant 2 : i32
301
+ func.call @parameter(%pstage_d1, %pstage_d1_b2, %c0_source, %checkpoint, %head_policy) : (i32, i32, i32, i32, buffer)
302
+
303
+ %vtag_d1 = scalar.constant 512 : i64
304
+ %vstage_d1 = func.call @stage(%verify_root, %vtag_d1) : (buffer, i64) -> (i32)
305
+ func.call @config_i64(%vstage_d1, %context_key, %context) : (i32, buffer, i64)
306
+ func.call @config_i64(%vstage_d1, %pool_key, %pool) : (i32, buffer, i64)
307
+ func.call @config_i64(%vstage_d1, %tokens_key, %c2_a64) : (i32, buffer, i64)
308
+ func.call @config_i64(%vstage_d1, %spans_key, %c1_a64) : (i32, buffer, i64)
309
+ func.call @config_i64(%vstage_d1, %width_key, %c2_a64) : (i32, buffer, i64)
310
+ func.call @config_i64(%vstage_d1, %gated_key, %gated_off) : (i32, buffer, i64)
311
+ func.call @parameter(%vstage_d1, %c0_i32, %c0_source, %checkpoint, %policy) : (i32, i32, i32, i32, buffer)
312
+ %wstage_d1 = func.call @stage(%warm_root, %vtag_d1) : (buffer, i64) -> (i32)
313
+ func.call @config_i64(%wstage_d1, %context_key, %context) : (i32, buffer, i64)
314
+ func.call @config_i64(%wstage_d1, %pool_key, %pool) : (i32, buffer, i64)
315
+ func.call @config_i64(%wstage_d1, %tokens_key, %c2_a64) : (i32, buffer, i64)
316
+ func.call @config_i64(%wstage_d1, %spans_key, %c1_a64) : (i32, buffer, i64)
317
+ %wstage_d1_b0 = scalar.constant 0 : i32
318
+ func.call @parameter(%wstage_d1, %wstage_d1_b0, %c0_source, %draft_source, %policy) : (i32, i32, i32, i32, buffer)
319
+
320
+ %adapt_at = index.constant 1828 : offset
321
+ %adapt_view = buffer.view %state[%adapt_at] : buffer -> view<5xi32>
322
+ view.store %c1_ad, %adapt_view[0] : i32, view<5xi32>
323
+ view.store %pstage_d1, %adapt_view[1] : i32, view<5xi32>
324
+ view.store %vstage_d1, %adapt_view[2] : i32, view<5xi32>
325
+ view.store %wstage_d1, %adapt_view[3] : i32, view<5xi32>
326
+ view.store %c0_i32, %adapt_view[4] : i32, view<5xi32>
327
+ }
328
+ }
329
+ %smaller = scalar.cmpi ult, %maximum, %prefill : i64
330
+ %effective = scf.select %smaller, %maximum, %prefill : i64
331
+ %layout_origin = index.constant 88 : offset
332
+ %layout = buffer.view %state[%layout_origin] : buffer -> view<5xi64>
333
+ view.store %maximum, %layout[0] : i64, view<5xi64>
334
+ view.store %span_capacity, %layout[1] : i64, view<5xi64>
335
+ view.store %context, %layout[2] : i64, view<5xi64>
336
+ view.store %pool, %layout[3] : i64, view<5xi64>
337
+ view.store %pins, %layout[4] : i64, view<5xi64>
338
+ %stage_count32 = index.cast %count : index to i32
339
+ %drafting64 = scalar.extui %drafting : i1 to i64
340
+ %allocations, %views, %origins, %draft, %geometry = func.call @llm_storage(%maximum, %span_capacity, %context, %pool, %rows, %pins, %drafting64) : (i64, i64, i64, i64, i64, i64, i64) -> (buffer, buffer, buffer, buffer, buffer)
341
+ %terminal = global.load @terminal : buffer
342
+ func.return %effective, %stage_count32, %state, %terminal, %allocations, %views, %origins, %draft, %geometry : i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer
343
+ }
program/service.loom ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Text service contracts share one fixture implementation. Each ABI has
2
+ // explicit exported roles, including the unversioned development contract.
3
+
4
+ func.decl @prepare(%prefill: i64, %context: i64, %pool: i64, %rows: i64, %pins: i64, %draft_depth: i32, %shapes: buffer, %shape_count: i64, %weights: buffer, %options: buffer) -> (i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer)
5
+
6
+ func.def public @text_prepare(%prefill: i64, %context: i64, %pool: i64, %rows: i64, %pins: i64, %draft_depth: i32, %shapes: buffer, %shape_count: i64, %weights: buffer, %options: buffer) -> (i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer) {
7
+ %result_0, %result_1, %result_2, %result_3, %result_4, %result_5, %result_6, %result_7, %result_8 = func.call @prepare(%prefill, %context, %pool, %rows, %pins, %draft_depth, %shapes, %shape_count, %weights, %options) : (i64, i64, i64, i64, i64, i32, buffer, i64, buffer, buffer) -> (i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer)
8
+ func.return %result_0, %result_1, %result_2, %result_3, %result_4, %result_5, %result_6, %result_7, %result_8 : i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer
9
+ }
10
+
11
+ func.def public @text_prepare_v1(%prefill: i64, %context: i64, %pool: i64, %rows: i64, %pins: i64, %draft_depth: i32, %shapes: buffer, %shape_count: i64, %weights: buffer, %options: buffer) -> (i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer) {
12
+ %result_0, %result_1, %result_2, %result_3, %result_4, %result_5, %result_6, %result_7, %result_8 = func.call @prepare(%prefill, %context, %pool, %rows, %pins, %draft_depth, %shapes, %shape_count, %weights, %options) : (i64, i64, i64, i64, i64, i32, buffer, i64, buffer, buffer) -> (i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer)
13
+ func.return %result_0, %result_1, %result_2, %result_3, %result_4, %result_5, %result_6, %result_7, %result_8 : i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer
14
+ }
15
+
16
+ func.decl @resize_state(%state: buffer, %rows: i64) -> (buffer, buffer, buffer, buffer, buffer, buffer)
17
+
18
+ func.def public @text_resize_state(%state: buffer, %rows: i64) -> (buffer, buffer, buffer, buffer, buffer, buffer) {
19
+ %control, %allocations, %views, %origins, %draft, %geometry = func.call @resize_state(%state, %rows) : (buffer, i64) -> (buffer, buffer, buffer, buffer, buffer, buffer)
20
+ func.return %control, %allocations, %views, %origins, %draft, %geometry : buffer, buffer, buffer, buffer, buffer, buffer
21
+ }
22
+
23
+ func.def public @text_resize_state_v1(%state: buffer, %rows: i64) -> (buffer, buffer, buffer, buffer, buffer, buffer) {
24
+ %control, %allocations, %views, %origins, %draft, %geometry = func.call @resize_state(%state, %rows) : (buffer, i64) -> (buffer, buffer, buffer, buffer, buffer, buffer)
25
+ func.return %control, %allocations, %views, %origins, %draft, %geometry : buffer, buffer, buffer, buffer, buffer, buffer
26
+ }
27
+
28
+ func.def public @sequence_resize_state_v1(%state: buffer, %rows: i64) -> (buffer, buffer, buffer, buffer, buffer, buffer) {
29
+ %control, %allocations, %views, %origins, %draft, %geometry = func.call @resize_state(%state, %rows) : (buffer, i64) -> (buffer, buffer, buffer, buffer, buffer, buffer)
30
+ func.return %control, %allocations, %views, %origins, %draft, %geometry : buffer, buffer, buffer, buffer, buffer, buffer
31
+ }
32
+
33
+ func.decl @model_name() -> (buffer)
34
+
35
+ func.def public @text_model_name() -> (buffer) {
36
+ %result_0 = func.call @model_name() : () -> (buffer)
37
+ func.return %result_0 : buffer
38
+ }
39
+
40
+ func.def public @text_model_name_v1() -> (buffer) {
41
+ %result_0 = func.call @model_name() : () -> (buffer)
42
+ func.return %result_0 : buffer
43
+ }
44
+
45
+ func.decl @request_defaults(%options: buffer) -> (buffer)
46
+
47
+ func.def public @text_request_defaults(%options: buffer) -> (buffer) {
48
+ %result_0 = func.call @request_defaults(%options) : (buffer) -> (buffer)
49
+ func.return %result_0 : buffer
50
+ }
51
+
52
+ func.def public @text_request_defaults_v1(%options: buffer) -> (buffer) {
53
+ %result_0 = func.call @request_defaults(%options) : (buffer) -> (buffer)
54
+ func.return %result_0 : buffer
55
+ }
56
+
57
+ func.decl @request_options(%defaults: buffer, %request: buffer, %nonce: i64) -> (buffer)
58
+
59
+ func.def public @text_request_options(%defaults: buffer, %request: buffer, %nonce: i64) -> (buffer) {
60
+ %result_0 = func.call @request_options(%defaults, %request, %nonce) : (buffer, buffer, i64) -> (buffer)
61
+ func.return %result_0 : buffer
62
+ }
63
+
64
+ func.def public @text_request_options_v1(%defaults: buffer, %request: buffer, %nonce: i64) -> (buffer) {
65
+ %result_0 = func.call @request_options(%defaults, %request, %nonce) : (buffer, buffer, i64) -> (buffer)
66
+ func.return %result_0 : buffer
67
+ }
68
+
69
+ func.decl @bind_request(%state: buffer, %row: i32, %options: buffer)
70
+
71
+ func.def public @text_bind_request(%state: buffer, %row: i32, %options: buffer) {
72
+ func.call @bind_request(%state, %row, %options) : (buffer, i32, buffer)
73
+ func.return
74
+ }
75
+
76
+ func.def public @text_bind_request_v1(%state: buffer, %row: i32, %options: buffer) {
77
+ func.call @bind_request(%state, %row, %options) : (buffer, i32, buffer)
78
+ func.return
79
+ }
80
+
81
+ func.decl @chat_reasoning() -> (i32, i32, i32)
82
+
83
+ func.def public @text_chat_reasoning() -> (i32, i32, i32) {
84
+ %enabled, %efforts, %default = func.call @chat_reasoning() : () -> (i32, i32, i32)
85
+ func.return %enabled, %efforts, %default : i32, i32, i32
86
+ }
87
+
88
+ func.def public @text_chat_reasoning_v1() -> (i32, i32, i32) {
89
+ %enabled, %efforts, %default = func.call @chat_reasoning() : () -> (i32, i32, i32)
90
+ func.return %enabled, %efforts, %default : i32, i32, i32
91
+ }
92
+
93
+ func.decl @chat_image_limits() -> (i64, i64, i64, i64, i64)
94
+
95
+ func.def public @text_chat_image_limits() -> (i64, i64, i64, i64, i64) {
96
+ %result_0, %result_1, %result_2, %result_3, %result_4 = func.call @chat_image_limits() : () -> (i64, i64, i64, i64, i64)
97
+ func.return %result_0, %result_1, %result_2, %result_3, %result_4 : i64, i64, i64, i64, i64
98
+ }
99
+
100
+ func.def public @text_chat_image_limits_v1() -> (i64, i64, i64, i64, i64) {
101
+ %result_0, %result_1, %result_2, %result_3, %result_4 = func.call @chat_image_limits() : () -> (i64, i64, i64, i64, i64)
102
+ func.return %result_0, %result_1, %result_2, %result_3, %result_4 : i64, i64, i64, i64, i64
103
+ }
104
+
105
+ func.decl @chat_begin(%request: buffer, %tools: buffer) -> (buffer, i64)
106
+
107
+ func.def public @text_chat_begin(%request: buffer, %tools: buffer) -> (buffer, i64) {
108
+ %result_0, %result_1 = func.call @chat_begin(%request, %tools) : (buffer, buffer) -> (buffer, i64)
109
+ func.return %result_0, %result_1 : buffer, i64
110
+ }
111
+
112
+ func.def public @text_chat_begin_v1(%request: buffer, %tools: buffer) -> (buffer, i64) {
113
+ %result_0, %result_1 = func.call @chat_begin(%request, %tools) : (buffer, buffer) -> (buffer, i64)
114
+ func.return %result_0, %result_1 : buffer, i64
115
+ }
116
+
117
+ func.decl @chat_message(%raw: buffer, %role: buffer, %content: buffer, %parts: buffer, %frames: buffer, %reasoning: buffer, %calls: buffer, %state: i64, %ordinal: i64, %fields: i64, %part_count: i64) -> (buffer, i64, buffer, i64)
118
+
119
+ func.def public @text_chat_message(%raw: buffer, %role: buffer, %content: buffer, %parts: buffer, %frames: buffer, %reasoning: buffer, %calls: buffer, %state: i64, %ordinal: i64, %fields: i64, %part_count: i64) -> (buffer, i64, buffer, i64) {
120
+ %result_0, %result_1, %result_2, %result_3 = func.call @chat_message(%raw, %role, %content, %parts, %frames, %reasoning, %calls, %state, %ordinal, %fields, %part_count) : (buffer, buffer, buffer, buffer, buffer, buffer, buffer, i64, i64, i64, i64) -> (buffer, i64, buffer, i64)
121
+ func.return %result_0, %result_1, %result_2, %result_3 : buffer, i64, buffer, i64
122
+ }
123
+
124
+ func.def public @text_chat_message_v1(%raw: buffer, %role: buffer, %content: buffer, %parts: buffer, %frames: buffer, %reasoning: buffer, %calls: buffer, %state: i64, %ordinal: i64, %fields: i64, %part_count: i64) -> (buffer, i64, buffer, i64) {
125
+ %result_0, %result_1, %result_2, %result_3 = func.call @chat_message(%raw, %role, %content, %parts, %frames, %reasoning, %calls, %state, %ordinal, %fields, %part_count) : (buffer, buffer, buffer, buffer, buffer, buffer, buffer, i64, i64, i64, i64) -> (buffer, i64, buffer, i64)
126
+ func.return %result_0, %result_1, %result_2, %result_3 : buffer, i64, buffer, i64
127
+ }
128
+
129
+ func.decl @chat_end(%state: i64) -> (buffer, i64)
130
+
131
+ func.def public @text_chat_end(%state: i64) -> (buffer, i64) {
132
+ %result_0, %result_1 = func.call @chat_end(%state) : (i64) -> (buffer, i64)
133
+ func.return %result_0, %result_1 : buffer, i64
134
+ }
135
+
136
+ func.def public @text_chat_end_v1(%state: i64) -> (buffer, i64) {
137
+ %result_0, %result_1 = func.call @chat_end(%state) : (i64) -> (buffer, i64)
138
+ func.return %result_0, %result_1 : buffer, i64
139
+ }
140
+
141
+ func.decl @render_tool(%name: buffer, %arguments: buffer, %ordinal: i64) -> (buffer, i64)
142
+
143
+ func.def public @text_render_tool(%name: buffer, %arguments: buffer, %ordinal: i64) -> (buffer, i64) {
144
+ %result_0, %result_1 = func.call @render_tool(%name, %arguments, %ordinal) : (buffer, buffer, i64) -> (buffer, i64)
145
+ func.return %result_0, %result_1 : buffer, i64
146
+ }
147
+
148
+ func.def public @text_render_tool_v1(%name: buffer, %arguments: buffer, %ordinal: i64) -> (buffer, i64) {
149
+ %result_0, %result_1 = func.call @render_tool(%name, %arguments, %ordinal) : (buffer, buffer, i64) -> (buffer, i64)
150
+ func.return %result_0, %result_1 : buffer, i64
151
+ }
152
+
153
+ func.decl @parse_tools(%schemas: buffer, %response: buffer, %truncated: i64) -> (buffer)
154
+
155
+ func.def public @text_parse_tools(%schemas: buffer, %response: buffer, %truncated: i64) -> (buffer) {
156
+ %result_0 = func.call @parse_tools(%schemas, %response, %truncated) : (buffer, buffer, i64) -> (buffer)
157
+ func.return %result_0 : buffer
158
+ }
159
+
160
+ func.def public @text_parse_tools_v1(%schemas: buffer, %response: buffer, %truncated: i64) -> (buffer) {
161
+ %result_0 = func.call @parse_tools(%schemas, %response, %truncated) : (buffer, buffer, i64) -> (buffer)
162
+ func.return %result_0 : buffer
163
+ }
164
+
165
+ func.decl @prepare_input(%text: buffer, %markers: buffer, %marker_count: i64, %format: i32, %boundary: i32, %capacity: i64) -> (buffer, i64, buffer)
166
+
167
+ func.def public @text_prepare_input(%text: buffer, %markers: buffer, %marker_count: i64, %format: i32, %boundary: i32, %capacity: i64) -> (buffer, i64, buffer) {
168
+ %result_0, %result_1, %result_2 = func.call @prepare_input(%text, %markers, %marker_count, %format, %boundary, %capacity) : (buffer, buffer, i64, i32, i32, i64) -> (buffer, i64, buffer)
169
+ func.return %result_0, %result_1, %result_2 : buffer, i64, buffer
170
+ }
171
+
172
+ func.def public @text_prepare_input_v1(%text: buffer, %markers: buffer, %marker_count: i64, %format: i32, %boundary: i32, %capacity: i64) -> (buffer, i64, buffer) {
173
+ %result_0, %result_1, %result_2 = func.call @prepare_input(%text, %markers, %marker_count, %format, %boundary, %capacity) : (buffer, buffer, i64, i32, i32, i64) -> (buffer, i64, buffer)
174
+ func.return %result_0, %result_1, %result_2 : buffer, i64, buffer
175
+ }
176
+
177
+ func.decl @output_next(%response: buffer, %previous: i64, %state: i64, %phase: i32) -> (i64, i64, i64, i64)
178
+
179
+ func.def public @text_output_next(%response: buffer, %previous: i64, %state: i64, %phase: i32) -> (i64, i64, i64, i64) {
180
+ %result_0, %result_1, %result_2, %result_3 = func.call @output_next(%response, %previous, %state, %phase) : (buffer, i64, i64, i32) -> (i64, i64, i64, i64)
181
+ func.return %result_0, %result_1, %result_2, %result_3 : i64, i64, i64, i64
182
+ }
183
+
184
+ func.def public @text_output_next_v1(%response: buffer, %previous: i64, %state: i64, %phase: i32) -> (i64, i64, i64, i64) {
185
+ %result_0, %result_1, %result_2, %result_3 = func.call @output_next(%response, %previous, %state, %phase) : (buffer, i64, i64, i32) -> (i64, i64, i64, i64)
186
+ func.return %result_0, %result_1, %result_2, %result_3 : i64, i64, i64, i64
187
+ }
188
+
189
+ func.decl @complete_text(%prompt: buffer, %response: buffer, %content: buffer, %reasoning: buffer, %tools: buffer, %initial_state: i64, %final_state: i64) -> (buffer, i32)
190
+
191
+ func.def public @text_complete_text(%prompt: buffer, %response: buffer, %content: buffer, %reasoning: buffer, %tools: buffer, %initial_state: i64, %final_state: i64) -> (buffer, i32) {
192
+ %result_0, %result_1 = func.call @complete_text(%prompt, %response, %content, %reasoning, %tools, %initial_state, %final_state) : (buffer, buffer, buffer, buffer, buffer, i64, i64) -> (buffer, i32)
193
+ func.return %result_0, %result_1 : buffer, i32
194
+ }
195
+
196
+ func.def public @text_complete_text_v1(%prompt: buffer, %response: buffer, %content: buffer, %reasoning: buffer, %tools: buffer, %initial_state: i64, %final_state: i64) -> (buffer, i32) {
197
+ %result_0, %result_1 = func.call @complete_text(%prompt, %response, %content, %reasoning, %tools, %initial_state, %final_state) : (buffer, buffer, buffer, buffer, buffer, i64, i64) -> (buffer, i32)
198
+ func.return %result_0, %result_1 : buffer, i32
199
+ }
200
+
201
+ func.decl @encode_state(%bindings: buffer, %count: i32, %origins: buffer)
202
+
203
+ func.def public @text_encode_state(%bindings: buffer, %count: i32, %origins: buffer) {
204
+ func.call @encode_state(%bindings, %count, %origins) : (buffer, i32, buffer)
205
+ func.return
206
+ }
207
+
208
+ func.def public @text_encode_state_v1(%bindings: buffer, %count: i32, %origins: buffer) {
209
+ func.call @encode_state(%bindings, %count, %origins) : (buffer, i32, buffer)
210
+ func.return
211
+ }
212
+
213
+ func.decl @capture_epoch(%state: buffer, %shape: i32, %count: i32, %plan: buffer) -> (buffer)
214
+
215
+ func.def public @text_capture_epoch(%state: buffer, %shape: i32, %count: i32, %plan: buffer) -> (buffer) {
216
+ %result_0 = func.call @capture_epoch(%state, %shape, %count, %plan) : (buffer, i32, i32, buffer) -> (buffer)
217
+ func.return %result_0 : buffer
218
+ }
219
+
220
+ func.def public @text_capture_epoch_v1(%state: buffer, %shape: i32, %count: i32, %plan: buffer) -> (buffer) {
221
+ %result_0 = func.call @capture_epoch(%state, %shape, %count, %plan) : (buffer, i32, i32, buffer) -> (buffer)
222
+ func.return %result_0 : buffer
223
+ }
224
+
225
+ func.decl @encode_epoch(%control_state: buffer, %plan: buffer, %inputs: buffer, %media_plan: buffer, %first_count: i32, %next_count: i32, %input_count: i32, %first_media_count: i32, %next_media_count: i32, %first_packet_capacity: i32, %next_packet_capacity: i32, %eos: i32, %metadata: buffer, %tokens: buffer) -> (i32, buffer, i64, i64)
226
+
227
+ func.def public @text_encode_epoch(%control_state: buffer, %plan: buffer, %inputs: buffer, %media_plan: buffer, %first_count: i32, %next_count: i32, %input_count: i32, %first_media_count: i32, %next_media_count: i32, %first_packet_capacity: i32, %next_packet_capacity: i32, %eos: i32, %metadata: buffer, %tokens: buffer) -> (i32, buffer, i64, i64) {
228
+ %count, %transfers, %transfer_begin, %transfer_length = func.call @encode_epoch(%control_state, %plan, %inputs, %media_plan, %first_count, %next_count, %input_count, %first_media_count, %next_media_count, %first_packet_capacity, %next_packet_capacity, %eos, %metadata, %tokens) : (buffer, buffer, buffer, buffer, i32, i32, i32, i32, i32, i32, i32, i32, buffer, buffer) -> (i32, buffer, i64, i64)
229
+ func.return %count, %transfers, %transfer_begin, %transfer_length : i32, buffer, i64, i64
230
+ }
231
+
232
+ func.def public @text_encode_epoch_v1(%control_state: buffer, %plan: buffer, %inputs: buffer, %media_plan: buffer, %first_count: i32, %next_count: i32, %input_count: i32, %first_media_count: i32, %next_media_count: i32, %first_packet_capacity: i32, %next_packet_capacity: i32, %eos: i32, %metadata: buffer, %tokens: buffer) -> (i32, buffer, i64, i64) {
233
+ %count, %transfers, %transfer_begin, %transfer_length = func.call @encode_epoch(%control_state, %plan, %inputs, %media_plan, %first_count, %next_count, %input_count, %first_media_count, %next_media_count, %first_packet_capacity, %next_packet_capacity, %eos, %metadata, %tokens) : (buffer, buffer, buffer, buffer, i32, i32, i32, i32, i32, i32, i32, i32, buffer, buffer) -> (i32, buffer, i64, i64)
234
+ func.return %count, %transfers, %transfer_begin, %transfer_length : i32, buffer, i64, i64
235
+ }
236
+
237
+ func.decl @publish_epoch(%control_state: buffer, %plan: buffer, %media_plan: buffer, %count: i32, %first_media_count: i32, %next_media_count: i32, %verified: i32, %continues: i32, %next_speculative: buffer, %ordinary: buffer, %first_results: buffer, %next_results: buffer, %progress: buffer)
238
+
239
+ func.def public @text_publish_epoch(%control_state: buffer, %plan: buffer, %media_plan: buffer, %count: i32, %first_media_count: i32, %next_media_count: i32, %verified: i32, %continues: i32, %next_speculative: buffer, %ordinary: buffer, %first_results: buffer, %next_results: buffer, %progress: buffer) {
240
+ func.call @publish_epoch(%control_state, %plan, %media_plan, %count, %first_media_count, %next_media_count, %verified, %continues, %next_speculative, %ordinary, %first_results, %next_results, %progress) : (buffer, buffer, buffer, i32, i32, i32, i32, i32, buffer, buffer, buffer, buffer, buffer)
241
+ func.return
242
+ }
243
+
244
+ func.def public @text_publish_epoch_v1(%control_state: buffer, %plan: buffer, %media_plan: buffer, %count: i32, %first_media_count: i32, %next_media_count: i32, %verified: i32, %continues: i32, %next_speculative: buffer, %ordinary: buffer, %first_results: buffer, %next_results: buffer, %progress: buffer) {
245
+ func.call @publish_epoch(%control_state, %plan, %media_plan, %count, %first_media_count, %next_media_count, %verified, %continues, %next_speculative, %ordinary, %first_results, %next_results, %progress) : (buffer, buffer, buffer, i32, i32, i32, i32, i32, buffer, buffer, buffer, buffer, buffer)
246
+ func.return
247
+ }
248
+
249
+ func.decl @step(%state: buffer, %initialize: i32, %source_position: i32, %input_count: i32, %residual: hal.buffer, %control: hal.buffer, %recurrent: hal.buffer, %attention: hal.buffer, %tokens: hal.buffer, %progress: hal.buffer) -> (i64, i32)
250
+
251
+ func.def public @text_step(%state: buffer, %initialize: i32, %source_position: i32, %input_count: i32, %residual: hal.buffer, %control: hal.buffer, %recurrent: hal.buffer, %attention: hal.buffer, %tokens: hal.buffer, %progress: hal.buffer) -> (i64, i32) {
252
+ %result_0, %result_1 = func.call @step(%state, %initialize, %source_position, %input_count, %residual, %control, %recurrent, %attention, %tokens, %progress) : (buffer, i32, i32, i32, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer) -> (i64, i32)
253
+ func.return %result_0, %result_1 : i64, i32
254
+ }
255
+
256
+ func.def public @text_step_v1(%state: buffer, %initialize: i32, %source_position: i32, %input_count: i32, %residual: hal.buffer, %control: hal.buffer, %recurrent: hal.buffer, %attention: hal.buffer, %tokens: hal.buffer, %progress: hal.buffer) -> (i64, i32) {
257
+ %result_0, %result_1 = func.call @step(%state, %initialize, %source_position, %input_count, %residual, %control, %recurrent, %attention, %tokens, %progress) : (buffer, i32, i32, i32, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer) -> (i64, i32)
258
+ func.return %result_0, %result_1 : i64, i32
259
+ }
260
+
261
+ func.decl @epoch(%control_state: buffer, %shape: i32, %proposes: i32, %verifies: i32, %span_count: i32, %output_count: i32, %epoch_count: i32, %continuation_shape: i32, %continuation_proposes: i32, %first_media_count: i32, %next_media_count: i32, %residual: hal.buffer, %metadata: hal.buffer, %origins: hal.buffer, %state: hal.buffer, %tokens: hal.buffer, %outputs: hal.buffer, %carry: hal.buffer, %committed: hal.buffer, %results: hal.buffer, %draft_cache: hal.buffer, %draft_origins: hal.buffer, %next_results: hal.buffer) -> (i64)
262
+
263
+ func.def public @text_epoch(%control_state: buffer, %shape: i32, %proposes: i32, %verifies: i32, %span_count: i32, %output_count: i32, %epoch_count: i32, %continuation_shape: i32, %continuation_proposes: i32, %first_media_count: i32, %next_media_count: i32, %residual: hal.buffer, %metadata: hal.buffer, %origins: hal.buffer, %state: hal.buffer, %tokens: hal.buffer, %outputs: hal.buffer, %carry: hal.buffer, %committed: hal.buffer, %results: hal.buffer, %draft_cache: hal.buffer, %draft_origins: hal.buffer, %next_results: hal.buffer) -> (i64) {
264
+ %result_0 = func.call @epoch(%control_state, %shape, %proposes, %verifies, %span_count, %output_count, %epoch_count, %continuation_shape, %continuation_proposes, %first_media_count, %next_media_count, %residual, %metadata, %origins, %state, %tokens, %outputs, %carry, %committed, %results, %draft_cache, %draft_origins, %next_results) : (buffer, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer) -> (i64)
265
+ func.return %result_0 : i64
266
+ }
267
+
268
+ func.def public @text_epoch_v1(%control_state: buffer, %shape: i32, %proposes: i32, %verifies: i32, %span_count: i32, %output_count: i32, %epoch_count: i32, %continuation_shape: i32, %continuation_proposes: i32, %first_media_count: i32, %next_media_count: i32, %residual: hal.buffer, %metadata: hal.buffer, %origins: hal.buffer, %state: hal.buffer, %tokens: hal.buffer, %outputs: hal.buffer, %carry: hal.buffer, %committed: hal.buffer, %results: hal.buffer, %draft_cache: hal.buffer, %draft_origins: hal.buffer, %next_results: hal.buffer) -> (i64) {
269
+ %result_0 = func.call @epoch(%control_state, %shape, %proposes, %verifies, %span_count, %output_count, %epoch_count, %continuation_shape, %continuation_proposes, %first_media_count, %next_media_count, %residual, %metadata, %origins, %state, %tokens, %outputs, %carry, %committed, %results, %draft_cache, %draft_origins, %next_results) : (buffer, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer) -> (i64)
270
+ func.return %result_0 : i64
271
+ }
272
+
273
+ func.def public @sequence_prepare_v1(%prefill: i64, %context: i64, %pool: i64, %rows: i64, %pins: i64, %draft_depth: i32, %shapes: buffer, %shape_count: i64, %weights: buffer, %options: buffer) -> (i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer) {
274
+ %result_0, %result_1, %result_2, %result_3, %result_4, %result_5, %result_6, %result_7, %result_8 = func.call @prepare(%prefill, %context, %pool, %rows, %pins, %draft_depth, %shapes, %shape_count, %weights, %options) : (i64, i64, i64, i64, i64, i32, buffer, i64, buffer, buffer) -> (i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer)
275
+ func.return %result_0, %result_1, %result_2, %result_3, %result_4, %result_5, %result_6, %result_7, %result_8 : i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer
276
+ }
277
+
278
+ func.def public @sequence_epoch_v1(%control_state: buffer, %shape: i32, %proposes: i32, %verifies: i32, %span_count: i32, %output_count: i32, %epoch_count: i32, %continuation_shape: i32, %continuation_proposes: i32, %first_media_count: i32, %next_media_count: i32, %residual: hal.buffer, %metadata: hal.buffer, %origins: hal.buffer, %state: hal.buffer, %tokens: hal.buffer, %outputs: hal.buffer, %carry: hal.buffer, %committed: hal.buffer, %results: hal.buffer, %draft_cache: hal.buffer, %draft_origins: hal.buffer, %next_results: hal.buffer) -> (i64) {
279
+ %result_0 = func.call @epoch(%control_state, %shape, %proposes, %verifies, %span_count, %output_count, %epoch_count, %continuation_shape, %continuation_proposes, %first_media_count, %next_media_count, %residual, %metadata, %origins, %state, %tokens, %outputs, %carry, %committed, %results, %draft_cache, %draft_origins, %next_results) : (buffer, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer, hal.buffer) -> (i64)
280
+ func.return %result_0 : i64
281
+ }
282
+
283
+ func.def public @sequence_encode_epoch_v1(%control_state: buffer, %plan: buffer, %inputs: buffer, %media_plan: buffer, %first_count: i32, %next_count: i32, %input_count: i32, %first_media_count: i32, %next_media_count: i32, %first_packet_capacity: i32, %next_packet_capacity: i32, %eos: i32, %metadata: buffer, %tokens: buffer) -> (i32, buffer, i64, i64) {
284
+ %count, %transfers, %transfer_begin, %transfer_length = func.call @encode_epoch(%control_state, %plan, %inputs, %media_plan, %first_count, %next_count, %input_count, %first_media_count, %next_media_count, %first_packet_capacity, %next_packet_capacity, %eos, %metadata, %tokens) : (buffer, buffer, buffer, buffer, i32, i32, i32, i32, i32, i32, i32, i32, buffer, buffer) -> (i32, buffer, i64, i64)
285
+ func.return %count, %transfers, %transfer_begin, %transfer_length : i32, buffer, i64, i64
286
+ }
287
+
288
+ func.def public @sequence_publish_epoch_v1(%control_state: buffer, %plan: buffer, %media_plan: buffer, %count: i32, %first_media_count: i32, %next_media_count: i32, %verified: i32, %continues: i32, %next_speculative: buffer, %ordinary: buffer, %first_results: buffer, %next_results: buffer, %progress: buffer) {
289
+ func.call @publish_epoch(%control_state, %plan, %media_plan, %count, %first_media_count, %next_media_count, %verified, %continues, %next_speculative, %ordinary, %first_results, %next_results, %progress) : (buffer, buffer, buffer, i32, i32, i32, i32, i32, buffer, buffer, buffer, buffer, buffer)
290
+ func.return
291
+ }
292
+
293
+ func.def public @sequence_encode_state_v1(%bindings: buffer, %count: i32, %origins: buffer) {
294
+ func.call @encode_state(%bindings, %count, %origins) : (buffer, i32, buffer)
295
+ func.return
296
+ }
297
+
298
+ func.def public @sequence_bind_request_v1(%state: buffer, %row: i32, %options: buffer) {
299
+ func.call @bind_request(%state, %row, %options) : (buffer, i32, buffer)
300
+ func.return
301
+ }
302
+
303
+ func.def public @sequence_capture_epoch_v1(%state: buffer, %shape: i32, %count: i32, %plan: buffer) -> (buffer) {
304
+ %result_0 = func.call @capture_epoch(%state, %shape, %count, %plan) : (buffer, i32, i32, buffer) -> (buffer)
305
+ func.return %result_0 : buffer
306
+ }
307
+
308
+ func.def public @sequence_request_defaults_v1(%options: buffer) -> (buffer) {
309
+ %result_0 = func.call @request_defaults(%options) : (buffer) -> (buffer)
310
+ func.return %result_0 : buffer
311
+ }
312
+
313
+ func.def public @sequence_request_options_v1(%defaults: buffer, %request: buffer, %nonce: i64) -> (buffer) {
314
+ %result_0 = func.call @request_options(%defaults, %request, %nonce) : (buffer, buffer, i64) -> (buffer)
315
+ func.return %result_0 : buffer
316
+ }
program/storage.loom ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // KV geometry: 16 planes (K and V per attention layer) of pool x 2048 bytes (F16 KV heads x head_dim).
2
+ // Recurrent slots: 174227456 bytes each (gated delta-net state of every recurrent layer; 4 = none).
3
+ // logits:begin
4
+ // A declaration: the one definition (default false) is in llm.loom; a second config.def of the key links ambiguously (LINK/MATERIALIZE).
5
+ config.decl @llm.logits : i1
6
+ // logits:end
7
+
8
+ func.def @allocation(%records: buffer, %slot: index, %bytes: i64, %clear: i64) {
9
+ %origin = index.constant 0 : offset
10
+ %bounded = index.assume %slot [range(%slot, 0, 10)] : index
11
+ %view = buffer.view %records[%origin] : buffer -> view<11x3xi64>
12
+ %alignment = scalar.constant 256 : i64
13
+ view.store %bytes, %view[%bounded, 0] : i64, view<11x3xi64>
14
+ view.store %alignment, %view[%bounded, 1] : i64, view<11x3xi64>
15
+ view.store %clear, %view[%bounded, 2] : i64, view<11x3xi64>
16
+ func.return
17
+ }
18
+
19
+ // KV is a stable prefix; private views and recurrent slots grow by appending.
20
+ func.def public @llm_storage(%maximum: i64, %span_capacity: i64, %context: i64, %pool: i64, %rows: i64, %pins: i64, %drafting: i64) -> (buffer, buffer, buffer, buffer, buffer) {
21
+ // drafting = 0 (draft_depth 0 at serve time): no drafter allocations, one cache region, no draft table.
22
+ %zero_flag = scalar.constant 0 : i64
23
+ %on = scalar.cmpi ne, %drafting, %zero_flag : i64
24
+ %origin = index.constant 0 : offset
25
+ %c0 = index.constant 0 : index
26
+ %c1 = index.constant 1 : index
27
+ %c0_i32 = scalar.constant 0 : i32
28
+ %c0_i64 = scalar.constant 0 : i64
29
+ %c1_i64 = scalar.constant 1 : i64
30
+ %c4_i64 = scalar.constant 4 : i64
31
+ %bounded_rows = scalar.assume %rows [range(%rows, 1, 2147483647)] : i64
32
+ %row_count = index.cast %bounded_rows : i64 to index
33
+ %slot_stride = scalar.constant 256 : i64
34
+ %token_bytes = scalar.muli %maximum, %c4_i64 : i64
35
+ %alignment_bias = scalar.constant 255 : i64
36
+ %biased_token_bytes = scalar.addi %token_bytes, %alignment_bias : i64
37
+ %token_slots = scalar.divui %biased_token_bytes, %slot_stride : i64
38
+ %padded_token_bytes = scalar.muli %token_slots, %slot_stride : i64
39
+ %progress_offset = scalar.addi %slot_stride, %padded_token_bytes : i64
40
+ %recurrent_offset = scalar.addi %progress_offset, %slot_stride : i64
41
+ %recurrent_bytes = scalar.constant 174227456 : i64
42
+ %recurrent_padded = scalar.addi %recurrent_bytes, %alignment_bias : i64
43
+ %recurrent_pages = scalar.divui %recurrent_padded, %slot_stride : i64
44
+ %recurrent_region = scalar.muli %recurrent_pages, %slot_stride : i64
45
+ %row_stride = scalar.addi %recurrent_offset, %recurrent_region : i64
46
+ %pinned = scalar.cmpi ne, %pins, %c0_i64 : i64
47
+ %twice_rows = scalar.addi %rows, %rows : i64
48
+ %fork_slots = scalar.addi %twice_rows, %pins : i64
49
+ %slots = scf.select %pinned, %fork_slots, %rows : i64
50
+ %private_bytes = scalar.muli %slots, %row_stride : i64
51
+ %kv_position_bytes = scalar.constant 2048 : i64
52
+ %plane_count = scalar.constant 16 : i64
53
+ %plane_bytes = scalar.muli %pool, %kv_position_bytes : i64
54
+ %pool_bytes = scalar.muli %plane_bytes, %plane_count : i64
55
+ %biased_pool = scalar.addi %pool_bytes, %alignment_bias : i64
56
+ %pool_slots = scalar.divui %biased_pool, %slot_stride : i64
57
+ %private_origin = scalar.muli %pool_slots, %slot_stride : i64
58
+ %recurrent_origin = scalar.addi %private_origin, %recurrent_offset : i64
59
+ %arena_bytes = scalar.addi %private_origin, %private_bytes : i64
60
+ %c3_i64 = scalar.constant 3 : i64
61
+ %c15_i64 = scalar.constant 15 : i64
62
+ %c16_i64 = scalar.constant 16 : i64
63
+ %padded = scalar.addi %context, %c15_i64 : i64
64
+ %blocks = scalar.divui %padded, %c16_i64 : i64
65
+ %map_entries = scalar.muli %rows, %blocks : i64
66
+ %map_bytes = scalar.muli %map_entries, %c4_i64 : i64
67
+ %origin_stride = scalar.constant 40 : i64
68
+ %map_origin = scalar.muli %bounded_rows, %origin_stride : i64
69
+ %table_bytes = scalar.addi %map_origin, %map_bytes : i64
70
+ %allocation_bytes = index.constant 264 : offset
71
+ %allocations = buffer.alloca<private> align(8) %allocation_bytes : buffer
72
+ %allocation_count = index.constant 11 : index
73
+ scf.for %i = [%c0 to %allocation_count step %c1] {
74
+ func.call @allocation(%allocations, %i, %c0_i64, %c0_i64) : (buffer, index, i64, i64)
75
+ }
76
+ // Final normalized hidden rows (the drafter's catch-up input) live in the residual allocation.
77
+ %hidden_row = scalar.constant 36864 : i64
78
+ %carry_stride = scalar.constant 8404992 : i64
79
+ %residual_bytes = scalar.muli %maximum, %hidden_row : i64
80
+ %span_floor = scalar.muli %span_capacity, %c4_i64 : i64
81
+ %feedback_bytes = scalar.maxui %residual_bytes, %span_floor : i64
82
+ %header_bytes = scalar.constant 16 : i64
83
+ %record_bytes = scalar.constant 36 : i64
84
+ %plan_bytes = scalar.muli %span_capacity, %record_bytes : i64
85
+ %metadata_bytes = scalar.addi %header_bytes, %plan_bytes : i64
86
+ %c2 = index.constant 2 : index
87
+ %c3 = index.constant 3 : index
88
+ %c4 = index.constant 4 : index
89
+ %c5 = index.constant 5 : index
90
+ func.call @allocation(%allocations, %c0, %feedback_bytes, %c0_i64) : (buffer, index, i64, i64)
91
+ func.call @allocation(%allocations, %c1, %arena_bytes, %c0_i64) : (buffer, index, i64, i64)
92
+ func.call @allocation(%allocations, %c2, %metadata_bytes, %c0_i64) : (buffer, index, i64, i64)
93
+ func.call @allocation(%allocations, %c3, %table_bytes, %c0_i64) : (buffer, index, i64, i64)
94
+ func.call @allocation(%allocations, %c4, %token_bytes, %c0_i64) : (buffer, index, i64, i64)
95
+ func.call @allocation(%allocations, %c5, %span_floor, %c0_i64) : (buffer, index, i64, i64)
96
+ // Drafter: carry (one hidden row per resident row and checkpoint), committed packet, verification
97
+ // results (first bank 40 B/span, second bank 44 B/span), draft K/V (2 planes over the pool's
98
+ // page ids), and the draft page table (same layout as the target table).
99
+ %c6 = index.constant 6 : index
100
+ %c7 = index.constant 7 : index
101
+ %c8 = index.constant 8 : index
102
+ %c9 = index.constant 9 : index
103
+ %c10 = index.constant 10 : index
104
+ %owners = scalar.addi %rows, %pins : i64
105
+ %carry_bytes = scalar.muli %owners, %carry_stride : i64
106
+ %committed_stride = scalar.constant 40 : i64
107
+ %committed_records = scalar.muli %span_capacity, %committed_stride : i64
108
+ %committed_bytes = scalar.addi %committed_records, %header_bytes : i64
109
+ %result_stride = scalar.constant 84 : i64
110
+ %results_bytes = scalar.muli %span_capacity, %result_stride : i64
111
+ %first_bank_stride = scalar.constant 40 : i64
112
+ %feedback_split = scalar.muli %span_capacity, %first_bank_stride : i64
113
+ %draft_planes = scalar.constant 2 : i64
114
+ %draft_pos_bytes = scalar.constant 2048 : i64
115
+ %draft_plane_bytes = scalar.muli %pool, %draft_pos_bytes : i64
116
+ %draft_bytes = scalar.muli %draft_plane_bytes, %draft_planes : i64
117
+ %carry_on = scf.select %on, %carry_bytes, %c0_i64 : i64
118
+ %committed_on = scf.select %on, %committed_bytes, %c0_i64 : i64
119
+ %results_on = scf.select %on, %results_bytes, %c0_i64 : i64
120
+ %draft_on = scf.select %on, %draft_bytes, %c0_i64 : i64
121
+ %table_on = scf.select %on, %table_bytes, %c0_i64 : i64
122
+ %carry_stride_on = scf.select %on, %carry_stride, %c0_i64 : i64
123
+ %split_on = scf.select %on, %feedback_split, %c4_i64 : i64
124
+ func.call @allocation(%allocations, %c6, %carry_on, %carry_on) : (buffer, index, i64, i64)
125
+ func.call @allocation(%allocations, %c7, %committed_on, %c0_i64) : (buffer, index, i64, i64)
126
+ func.call @allocation(%allocations, %c8, %results_on, %c0_i64) : (buffer, index, i64, i64)
127
+ func.call @allocation(%allocations, %c9, %draft_on, %c0_i64) : (buffer, index, i64, i64)
128
+ func.call @allocation(%allocations, %c10, %table_on, %c0_i64) : (buffer, index, i64, i64)
129
+
130
+ // logits:begin
131
+ // Opt-in logits readback (card config llm.logits, default off; gen_llm.py g_logits_export): the outputs allocation also holds
132
+ // one full-vocabulary f32 row per slot (min(span_capacity, rows)) after the 8192-span token region. Spans hold at most 8192 tokens (4 B each).
133
+ %logits_on = config.get @llm.logits : i1
134
+ scf.if %logits_on {
135
+ %logit_region = scalar.constant 32768 : i64
136
+ %logit_row = scalar.constant 800256 : i64
137
+ %logit_slots = scalar.minsi %span_capacity, %rows : i64
138
+ %logit_rows = scalar.muli %logit_slots, %logit_row : i64
139
+ %logit_total = scalar.addi %logit_region, %logit_rows : i64
140
+ func.call @allocation(%allocations, %c5, %logit_total, %c0_i64) : (buffer, index, i64, i64)
141
+ }
142
+ // logits:end
143
+
144
+ %view_stride = index.constant 64 : offset
145
+ %view_bytes = index.scale %row_count, %view_stride : index, offset -> offset
146
+ %views = buffer.alloca<private> align(8) %view_bytes : buffer
147
+ %view_records = buffer.view %views[%origin] : buffer -> view<[%row_count]x4x2xi64>
148
+ %origin_bytes = index.cast %map_origin : i64 to offset
149
+ %origins = buffer.alloca<private> align(8) %origin_bytes : buffer
150
+ buffer.fill %c0_i32, %origins[%origin], %origin_bytes : i32
151
+ %origin_records = buffer.view %origins[%origin] : buffer -> view<[%row_count]x5xi64>
152
+ %control_bytes = scalar.constant 12 : i64
153
+ %progress_bytes = scalar.constant 32 : i64
154
+ scf.for %row = [%c0 to %row_count step %c1] {
155
+ %row64 = index.cast %row : index to i64
156
+ %relative = scalar.muli %row64, %row_stride : i64
157
+ %base = scalar.addi %private_origin, %relative : i64
158
+ %tokens = scalar.addi %base, %slot_stride : i64
159
+ %progress = scalar.addi %base, %progress_offset : i64
160
+ view.store %base, %view_records[%row, 0, 0] : i64, view<[%row_count]x4x2xi64>
161
+ view.store %control_bytes, %view_records[%row, 0, 1] : i64, view<[%row_count]x4x2xi64>
162
+ view.store %c0_i64, %view_records[%row, 1, 0] : i64, view<[%row_count]x4x2xi64>
163
+ view.store %c0_i64, %view_records[%row, 1, 1] : i64, view<[%row_count]x4x2xi64>
164
+ view.store %tokens, %view_records[%row, 2, 0] : i64, view<[%row_count]x4x2xi64>
165
+ view.store %token_bytes, %view_records[%row, 2, 1] : i64, view<[%row_count]x4x2xi64>
166
+ view.store %progress, %view_records[%row, 3, 0] : i64, view<[%row_count]x4x2xi64>
167
+ view.store %progress_bytes, %view_records[%row, 3, 1] : i64, view<[%row_count]x4x2xi64>
168
+ view.store %c0_i64, %origin_records[%row, 2] : i64, view<[%row_count]x5xi64>
169
+ %map_stride = scalar.muli %blocks, %c4_i64 : i64
170
+ %map_offset = scalar.muli %row64, %map_stride : i64
171
+ %map_base = scalar.addi %map_origin, %map_offset : i64
172
+ view.store %map_base, %origin_records[%row, 4] : i64, view<[%row_count]x5xi64>
173
+ }
174
+ %geometry_one = index.constant 104 : offset
175
+ %geometry_two = index.constant 144 : offset
176
+ %geometry_bytes = scf.select %on, %geometry_two, %geometry_one : offset
177
+ %geometry = buffer.alloca<private> align(8) %geometry_bytes : buffer
178
+ %geometry_view = buffer.view %geometry[%origin] : buffer -> view<13xi64>
179
+ view.store %c16_i64, %geometry_view[0] : i64, view<13xi64>
180
+ view.store %map_origin, %geometry_view[1] : i64, view<13xi64>
181
+ view.store %carry_stride_on, %geometry_view[2] : i64, view<13xi64>
182
+ view.store %split_on, %geometry_view[3] : i64, view<13xi64>
183
+ view.store %recurrent_origin, %geometry_view[4] : i64, view<13xi64>
184
+ view.store %row_stride, %geometry_view[5] : i64, view<13xi64>
185
+ view.store %recurrent_bytes, %geometry_view[6] : i64, view<13xi64>
186
+ view.store %slots, %geometry_view[7] : i64, view<13xi64>
187
+ view.store %c1_i64, %geometry_view[8] : i64, view<13xi64>
188
+ view.store %c0_i64, %geometry_view[9] : i64, view<13xi64>
189
+ view.store %plane_count, %geometry_view[10] : i64, view<13xi64>
190
+ view.store %plane_bytes, %geometry_view[11] : i64, view<13xi64>
191
+ %block_bytes = scalar.constant 32768 : i64
192
+ view.store %block_bytes, %geometry_view[12] : i64, view<13xi64>
193
+ // second cache region: the drafter's K/V planes (allocation 9), same page geometry
194
+ %draft_origins = scf.if %on -> (buffer) {
195
+ %region_at = index.constant 104 : offset
196
+ %region = buffer.view %geometry[%region_at] : buffer -> view<5xi64>
197
+ %c9_i64 = scalar.constant 9 : i64
198
+ %draft_block_bytes = scalar.constant 32768 : i64
199
+ view.store %c9_i64, %region[0] : i64, view<5xi64>
200
+ view.store %c0_i64, %region[1] : i64, view<5xi64>
201
+ view.store %draft_planes, %region[2] : i64, view<5xi64>
202
+ view.store %draft_plane_bytes, %region[3] : i64, view<5xi64>
203
+ view.store %draft_block_bytes, %region[4] : i64, view<5xi64>
204
+ // the draft page table starts as a copy of the target's (page maps at the same offsets)
205
+ %copy = buffer.alloca<private> align(8) %origin_bytes : buffer
206
+ buffer.copy %origins[%origin], %copy[%origin], %origin_bytes
207
+ scf.yield %copy : buffer
208
+ } else {
209
+ %none_bytes = index.constant 0 : offset
210
+ %none = buffer.alloca<private> align(1) %none_bytes : buffer
211
+ scf.yield %none : buffer
212
+ }
213
+ %empty_bytes = index.constant 0 : offset
214
+ %empty = buffer.alloca<private> align(1) %empty_bytes : buffer
215
+ func.return %allocations, %views, %origins, %draft_origins, %geometry : buffer, buffer, buffer, buffer, buffer
216
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a45fdc4e7e66a035de236d2694742fed5645327051caace5f8312013a879f9b1
3
+ size 12242935
weights.loom ADDED
The diff for this file is too large to render. See raw diff