dhndhn commited on
Commit
6d49a85
·
verified ·
1 Parent(s): d4b379a

Loom package for OsaurusAI/Raptor-0.7-4B-GGUF (Q4_K_M, loom-next port)

Browse files
README.md ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: OsaurusAI/Raptor-0.7-4B-GGUF
3
+ license: apache-2.0
4
+ tags:
5
+ - loom
6
+ - loom-serve
7
+ - gguf
8
+ - strix-halo
9
+ - radeon-r9700
10
+ ---
11
+
12
+ # Raptor-0.7-4B (Q4_K_M) for AMD Loom
13
+
14
+ A [Loom](https://github.com/ROCm/hrx-system) package (`.loom` programs and a `model.json` card) for the unmodified GGUF checkpoint [OsaurusAI/Raptor-0.7-4B-GGUF](https://huggingface.co/OsaurusAI/Raptor-0.7-4B-GGUF) (`Raptor-0.7-4B-Q4_K_M.gguf`), for the AMD Ryzen AI Max+ 395 "Strix Halo" and AMD Radeon AI PRO R9700 GPUs, generated with [loom-next](https://github.com/loom-fun/loom-next) (the generator alone, no LLM in the loop). Learn more on the [Loom ecosystem website](https://loom-fun.github.io/loom-dev/).
15
+
16
+ ## Quick start
17
+
18
+ Open your GPU and copy its commands.
19
+
20
+ <details>
21
+ <summary>AMD Ryzen AI Max+ 395 "Strix Halo" (gfx1151)</summary>
22
+
23
+ ```bash
24
+ pipx install "hrx-loom[hf]==0.2.0"
25
+ loom-fetch huggingface:loom-draft/OsaurusAI-Raptor-0.7-4B-loom:chat --materialize=copy --output=raptor-0.7-4b
26
+ loom-serve --model=raptor-0.7-4b '--device=amdgpu://?completion_spin_ns=4294967295' --pool_backing=fixed --parameter_mode=preload
27
+ ```
28
+
29
+ - `--materialize=copy` puts copies of the fetched package files in the output directory.
30
+ - `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.
31
+ - `--pool_backing=fixed` commits the preset's memory pool up front instead of growing elastic backing.
32
+ - `--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.
33
+
34
+ </details>
35
+
36
+ <details>
37
+ <summary>AMD Radeon AI PRO R9700 (gfx1201, 32 GB)</summary>
38
+
39
+ ```bash
40
+ pipx install "hrx-loom[hf]==0.2.0"
41
+ loom-fetch huggingface:loom-draft/OsaurusAI-Raptor-0.7-4B-loom:chat-r9700 --materialize=copy --output=raptor-0.7-4b
42
+ loom-serve --model=raptor-0.7-4b '--device=amdgpu://?completion_spin_ns=4294967295' --pool_backing=fixed --parameter_mode=preload
43
+ ```
44
+
45
+ - `--materialize=copy` puts copies of the fetched package files in the output directory.
46
+ - `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.
47
+ - `--pool_backing=fixed` commits the preset's memory pool up front instead of growing elastic backing.
48
+ - `--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.
49
+
50
+ </details>
51
+
52
+ ## Send a request
53
+
54
+ In another terminal (optional thinking is turned off):
55
+
56
+ ```bash
57
+ curl http://127.0.0.1:8080/v1/chat/completions \
58
+ -H 'Content-Type: application/json' \
59
+ -d '{"model": "raptor-0.7-4b", "messages": [{"role": "user", "content": "Hello"}], "chat_template_kwargs": {"enable_thinking": false}}'
60
+ ```
61
+
62
+ ## Performance vs llama.cpp
63
+
64
+ ### Strix Halo (gfx1151)
65
+
66
+ AMD Ryzen AI Max+ 395 "Strix Halo" (gfx1151): the results for this package are not yet re-measured.
67
+
68
+ ### Radeon AI PRO R9700 (gfx1201, 32 GB)
69
+
70
+ AMD Radeon AI PRO R9700 (gfx1201, 32 GB): the results for this package are not yet re-measured.
71
+
72
+ ## Features
73
+
74
+ | feature | status | detail |
75
+ |---|---|---|
76
+ | API | ✅ | OpenAI-style `/v1/chat/completions` |
77
+ | tool calling | ✅ | OpenAI-style `tools` and `tool_calls` |
78
+ | reasoning / thinking | ✅ | on by default; `chat_template_kwargs: {"enable_thinking": false}` turns it off |
79
+ | reasoning effort | ✅ | `reasoning_effort`: low, high (default high) |
80
+ | speculative decoding | — | not applicable |
81
+ | image input | ? | not determined |
82
+ | audio input / output | ? | not determined |
83
+ | sampling | ? | not determined |
84
+ | context size | ✅ | 262,144 tokens per request |
85
+ | concurrency | ✅ | 4 concurrent requests |
86
+ | max output tokens | ✅ | 4,096 (preset `max_tokens`) |
87
+
88
+ ## Correctness
89
+
90
+ | gate | description | Strix Halo | Radeon AI PRO R9700 |
91
+ |---|---|---|---|
92
+ | `kernel_tests` | Unit tests of the generated kernels against reference implementations | — not yet re-measured | — not yet re-measured |
93
+ | `golden` | llama.cpp reference recorded on the same GGUF: greedy tokens and top-5 log-probs, short prompts and 1k-32k documents | — not yet re-measured | — not yet re-measured |
94
+ | `compare` | Greedy output vs the llama.cpp reference, token by token; every divergence is a near-tie | — not yet re-measured | — not yet re-measured |
95
+ | `vision` | Image input vs llama.cpp with the same projector: identical prompt tokens, replies equal up to near-ties | — not yet re-measured | — not yet re-measured |
96
+ | `consistency` | Concurrent requests give the same output as the same requests run alone | — not yet re-measured | — not yet re-measured |
97
+ | `spec` | Speculative decoding on gives exactly the output of speculative decoding off | — not yet re-measured | — not yet re-measured |
98
+ | `agent` | Multi-turn tool-calling loop: exact prompt rendering, history reuse, valid tool calls, output vs llama.cpp | — not yet re-measured | — not yet re-measured |
99
+ | `agent_think_off` | The tool-calling loop with thinking off | — not yet re-measured | — not yet re-measured |
100
+ | `sampling` | temperature, top_k and seed behave as specified; first-token distribution matches llama.cpp | — not yet re-measured | — not yet re-measured |
101
+ | `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 | — not yet re-measured | — not yet re-measured |
102
+ | `decision` | Decision answers (choice, score, noul probabilities) vs llama.cpp on the same prompts | — not yet re-measured | — not yet re-measured |
103
+
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 `0.2.0` (install fingerprint `20d79282b0f3d72a`); card generator `fdd785e`.
116
+
117
+ Source files, fetched by `loom-fetch` from their own repositories:
118
+
119
+ - checkpoint: [OsaurusAI/Raptor-0.7-4B-GGUF](https://huggingface.co/OsaurusAI/Raptor-0.7-4B-GGUF) @ `f562cb0`, `Raptor-0.7-4B-Q4_K_M.gguf`
REPORT.md ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Raptor-0.7-4B 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 `0.2.0` (install fingerprint `20d79282b0f3d72a`).
8
+ - Checkpoint: [OsaurusAI/Raptor-0.7-4B-GGUF](https://huggingface.co/OsaurusAI/Raptor-0.7-4B-GGUF) @ `f562cb0288f6385a9e34d214d1e19be5a1cec3de`, `Raptor-0.7-4B-Q4_K_M.gguf`, sha256 `1d55935c7e7cc8e4d7b69d12f5ff7d0db83e2ce03879b73ee0979243a947c97c`.
9
+ - Programs measured: the sha256 below is card_lib.programs_sha256, over `program/*.loom` without each file's first-line generator comment.
10
+
11
+ ## Method
12
+
13
+ - `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 mean of the runs.
14
+ - `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.
15
+ - 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`.
16
+ - 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.
17
+ - Drafted tokens accepted is the `spec` gate's count: accepted over proposed draft tokens across its requests.
18
+ - Gates are loom-benchmark's `gates.sh` at the LEVEL shown; DevLab runs are the nightly-gates workflow on AMD DevLab Dispatch.
19
+ - 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.
20
+
21
+ ## AMD Ryzen AI Max+ 395 "Strix Halo" (gfx1151)
22
+
23
+ AMD Ryzen AI Max+ 395 "Strix Halo" (gfx1151): the results for this package are not yet re-measured.
24
+
25
+ ## AMD Radeon AI PRO R9700 (gfx1201, 32 GB)
26
+
27
+ AMD Radeon AI PRO R9700 (gfx1201, 32 GB): the results for this package are not yet re-measured.
gen/flash2.loom ADDED
The diff for this file is too large to render. See raw diff
 
info.json ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "low",
45
+ "high"
46
+ ]
47
+ }
48
+ },
49
+ "sampling": {
50
+ "status": "unknown",
51
+ "value": null
52
+ },
53
+ "speculative_decoding": {
54
+ "status": "n/a",
55
+ "value": null
56
+ },
57
+ "thinking": {
58
+ "status": "yes",
59
+ "value": {
60
+ "default": true,
61
+ "mode": "toggle"
62
+ }
63
+ },
64
+ "tool_calling": {
65
+ "status": "yes",
66
+ "value": null
67
+ }
68
+ },
69
+ "license": "apache-2.0"
70
+ },
71
+ "devices": {
72
+ "radeon-r9700": {
73
+ "state": "not_measured"
74
+ },
75
+ "strix-halo": {
76
+ "state": "not_measured"
77
+ }
78
+ },
79
+ "repo": "loom-draft/OsaurusAI-Raptor-0.7-4B-loom",
80
+ "report": "generated",
81
+ "schema": "loom-card/3",
82
+ "sources": {},
83
+ "versions": {
84
+ "card_generator": "fdd785e5"
85
+ }
86
+ }
llm_config.json ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "Raptor 0.7 4B",
3
+ "arch": "spark2_5",
4
+ "gguf": "Raptor-0.7-4B-Q4_K_M.gguf",
5
+ "hidden": 2560,
6
+ "layers": 36,
7
+ "heads": 16,
8
+ "kv_heads": 4,
9
+ "head_dim": 256,
10
+ "ffn": 10240,
11
+ "vocab": 131072,
12
+ "context_length": 1048576,
13
+ "rms_eps": 9.999999974752427e-07,
14
+ "rope_theta": 5000000.0,
15
+ "rope_type": "neox",
16
+ "qk_norm": false,
17
+ "attn_gate": "per_head",
18
+ "post_norms": false,
19
+ "embed_norm": false,
20
+ "embed_scale": null,
21
+ "sliding_window": 512,
22
+ "sliding_layers": [
23
+ 0,
24
+ 1,
25
+ 2,
26
+ 4,
27
+ 5,
28
+ 6,
29
+ 8,
30
+ 9,
31
+ 10,
32
+ 12,
33
+ 13,
34
+ 14,
35
+ 16,
36
+ 17,
37
+ 18,
38
+ 20,
39
+ 21,
40
+ 22,
41
+ 24,
42
+ 25,
43
+ 26,
44
+ 28,
45
+ 29,
46
+ 30,
47
+ 32,
48
+ 33,
49
+ 34
50
+ ],
51
+ "nope_layers": [],
52
+ "tied_embeddings": true,
53
+ "eos_id": 1,
54
+ "extra_eos_ids": [],
55
+ "bos_id": null,
56
+ "chat": {
57
+ "bos": "",
58
+ "system_prefix": "<\uff5cstart\u2581of\u2581sentence\uff5c><|System|>\n",
59
+ "suffix": "<\uff5cend\u2581of\u2581sentence\uff5c>",
60
+ "user_prefix": "<\uff5cstart\u2581of\u2581sentence\uff5c><|User|>",
61
+ "assistant_prefix": "<\uff5cstart\u2581of\u2581sentence\uff5c><|Bot|>",
62
+ "default_system": "",
63
+ "system_lead": "you are a helpful assistant.",
64
+ "system_lead_separator": "\n\n",
65
+ "reasoning_instructions": {
66
+ "low": "\n`thinking_effort` guides on how much to think in your thinking channel (not including the response channel), supported values include `low` and `high`.\nNow the system is invoked with `thinking_effort=low`.",
67
+ "high": "\n`thinking_effort` guides on how much to think in your thinking channel (not including the response channel), supported values include `low` and `high`.\nNow the system is invoked with `thinking_effort=high`."
68
+ },
69
+ "reasoning_separator": "",
70
+ "reasoning_after_lead": true,
71
+ "reasoning_effort_default": "high",
72
+ "trim_content": false,
73
+ "think_open": "<think>",
74
+ "think_close": "</think>",
75
+ "history_think": "close",
76
+ "history_think_scope": "all",
77
+ "generation_prompt": "<\uff5cstart\u2581of\u2581sentence\uff5c><|Bot|><think>",
78
+ "generation_prompt_plain": "<\uff5cstart\u2581of\u2581sentence\uff5c><|Bot|></think>",
79
+ "thinking": "toggle",
80
+ "thinking_default": true,
81
+ "starts_in_reasoning": true,
82
+ "think_end": "</think>",
83
+ "tools_function_only": true,
84
+ "tools_compact": true,
85
+ "tool_line_prefix": "\n",
86
+ "tool_separator": "",
87
+ "tools_after_system": false,
88
+ "tools_prefix": "\n\n## Tools\nYou have access to the following functions:\n<tools>",
89
+ "tools_system_separator": "\n\n",
90
+ "tools_suffix": "\n</tools>",
91
+ "call_format": "glm",
92
+ "calls_open": "",
93
+ "calls_close": "",
94
+ "call_end": "",
95
+ "call_marker": "<tool_call>",
96
+ "content_call_separator": "",
97
+ "call_separator": "",
98
+ "tool_turn_prefix": "<\uff5cstart\u2581of\u2581sentence\uff5c><|Tool|>",
99
+ "tool_item_prefix": "<tool_response>",
100
+ "tool_item_suffix": "</tool_response>",
101
+ "tool_turn_suffix": "<\uff5cend\u2581of\u2581sentence\uff5c>",
102
+ "terminal": "<\uff5cend\u2581of\u2581sentence\uff5c>"
103
+ },
104
+ "rope_dims": 64,
105
+ "rope_theta_swa": 10000.0,
106
+ "rope_dims_swa": 256,
107
+ "ffn_act": "gelu",
108
+ "attn_qkv": true,
109
+ "attn_sinks": false,
110
+ "model_id": "raptor-0.7-4b",
111
+ "draft": null,
112
+ "generator": {
113
+ "commit": "f74d5f3aadeadf06a26463c2cef97e211411274a",
114
+ "dirty": false,
115
+ "overlay": null,
116
+ "modified": false,
117
+ "hrx_loom": {
118
+ "hrx_loom": "0.2.0",
119
+ "fingerprint": "20d79282b0f3d72a",
120
+ "verified": false
121
+ }
122
+ },
123
+ "sdk": {
124
+ "hrx_loom": "0.2.0",
125
+ "source": "pypi",
126
+ "wheel_sha256": "5148f9e3a264af400ec4bae38bd7b06bf551d28cc33b7a61d67f7bcefa590438",
127
+ "hrx_system_sha": "0cd370f2baaa0cfef47cc23007f1a109906f8a52"
128
+ },
129
+ "resolved": {
130
+ "scopes": [
131
+ "arch/llm/dense/spark2_5",
132
+ "facet/sliding-window",
133
+ "facet/wide-head"
134
+ ],
135
+ "choices": {},
136
+ "devices": [
137
+ "rdna3",
138
+ "rdna4"
139
+ ],
140
+ "facets": [
141
+ "gated-attn",
142
+ "sliding-window",
143
+ "wide-head"
144
+ ],
145
+ "env": {}
146
+ }
147
+ }
model.json ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 1,
3
+ "model": {
4
+ "id": "raptor-0.7-4b",
5
+ "name": "Raptor 0.7 4B (Loom port, GGUF)"
6
+ },
7
+ "programs": {
8
+ "source": {
9
+ "inputs": [
10
+ {
11
+ "path": "program/prepare.loom",
12
+ "data": [
13
+ "weights.loom",
14
+ "llm_config.json"
15
+ ]
16
+ },
17
+ "program/control.loom",
18
+ "program/storage.loom",
19
+ "program/service.loom"
20
+ ],
21
+ "libraries": [
22
+ "program/llm.loom"
23
+ ]
24
+ }
25
+ },
26
+ "services": {
27
+ "chat": {
28
+ "kind": "text",
29
+ "version": 1
30
+ }
31
+ },
32
+ "variants": {
33
+ "gguf": {
34
+ "services": {
35
+ "chat": {
36
+ "programs": [
37
+ "source"
38
+ ],
39
+ "config": {
40
+ "llm.card": true,
41
+ "llm.logits": false
42
+ },
43
+ "parameters": {
44
+ "model": {
45
+ "files": [
46
+ {
47
+ "path": "parameter/Raptor-0.7-4B-Q4_K_M.gguf",
48
+ "format": "gguf",
49
+ "origin": "@checkpoint/Raptor-0.7-4B-Q4_K_M.gguf"
50
+ }
51
+ ]
52
+ }
53
+ },
54
+ "tokenizers": {
55
+ "text": "tokenizer.json"
56
+ }
57
+ }
58
+ }
59
+ }
60
+ },
61
+ "presets": {
62
+ "chat": {
63
+ "service": "chat",
64
+ "variant": "gguf",
65
+ "programs": "source",
66
+ "execution": {
67
+ "rows": 4,
68
+ "context_capacity": 262144,
69
+ "prefill_capacity": 1024,
70
+ "max_tokens": 4096
71
+ }
72
+ },
73
+ "chat-r9700": {
74
+ "service": "chat",
75
+ "variant": "gguf",
76
+ "programs": "source",
77
+ "execution": {
78
+ "rows": 4,
79
+ "context_capacity": 194560,
80
+ "prefill_capacity": 1024,
81
+ "max_tokens": 4096
82
+ }
83
+ }
84
+ },
85
+ "origins": {
86
+ "checkpoint": {
87
+ "kind": "hf",
88
+ "repository": "OsaurusAI/Raptor-0.7-4B-GGUF",
89
+ "revision": "f562cb0288f6385a9e34d214d1e19be5a1cec3de"
90
+ }
91
+ }
92
+ }
model.json.lock ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 2,
3
+ "scope": "assets",
4
+ "origins": {
5
+ "checkpoint": {
6
+ "requested": {
7
+ "kind": "hf",
8
+ "repository": "OsaurusAI/Raptor-0.7-4B-GGUF",
9
+ "revision": "f562cb0288f6385a9e34d214d1e19be5a1cec3de"
10
+ },
11
+ "resolved": {
12
+ "revision": "f562cb0288f6385a9e34d214d1e19be5a1cec3de"
13
+ }
14
+ }
15
+ },
16
+ "files": [
17
+ {
18
+ "origin": "@checkpoint/Raptor-0.7-4B-Q4_K_M.gguf",
19
+ "size": 2772657632,
20
+ "sha256": "1d55935c7e7cc8e4d7b69d12f5ff7d0db83e2ce03879b73ee0979243a947c97c"
21
+ },
22
+ {
23
+ "origin": "tokenizer.json",
24
+ "size": 5401522,
25
+ "sha256": "bd7882663af9e21dc134ee02a289770fca356ef4817dd31721a23c42b340cd65"
26
+ }
27
+ ]
28
+ }
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,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ // "weights.loom"
43
+ global.rodata.def @policy = bytes("776569676874732e6c6f6f6d")
44
+
45
+ // "<|end▁of▁sentence|>" is the service terminal marker.
46
+ global.rodata.def @terminal = bytes("3cefbd9c656e64e296816f66e2968173656e74656e6365efbd9c3e")
47
+
48
+ global.rodata.def @empty = bytes("")
49
+
50
+ // "llm requires pooled epochs without MTP, at most 128 shapes and a context of at most 262144"
51
+ global.rodata.def @unsupported = bytes("6c6c6d20726571756972657320706f6f6c65642065706f63687320776974686f7574204d54502c206174206d6f7374203132382073686170657320616e64206120636f6e74657874206f66206174206d6f737420323632313434")
52
+
53
+ func.decl @llm_storage(%maximum: i64, %span_capacity: i64, %context: i64, %pool: i64, %rows: i64, %pins: i64) -> (buffer, buffer, buffer, buffer, buffer)
54
+
55
+ // Control state layout: [0, 8) unused, [8, 88) two transfer records,
56
+ // [88, 128) layout recipe, [128, 640) stage per packing shape, then a 16-byte
57
+ // sampling record per resident row.
58
+ 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) {
59
+ %c0_source = scalar.constant 0 : i32
60
+ %origin = index.constant 0 : offset
61
+ %c0 = index.constant 0 : index
62
+ %c1 = index.constant 1 : index
63
+ %c0_i32 = scalar.constant 0 : i32
64
+ %c0_i64 = scalar.constant 0 : i64
65
+ %c64_i64 = scalar.constant 128 : i64
66
+ %c4096_i64 = scalar.constant 262144 : i64
67
+ %pooled = scalar.cmpi ne, %pool, %c0_i64 : i64
68
+ %packed = scalar.cmpi ne, %shape_count, %c0_i64 : i64
69
+ %few_shapes = scalar.cmpi ule, %shape_count, %c64_i64 : i64
70
+ %short_context = scalar.cmpi ule, %context, %c4096_i64 : i64
71
+ %no_draft = scalar.cmpi eq, %draft_depth, %c0_i32 : i32
72
+ %has_epochs = scalar.andi %pooled, %packed : i1
73
+ %mode_ok = scalar.andi %has_epochs, %no_draft : i1
74
+ %limits_ok = scalar.andi %few_shapes, %short_context : i1
75
+ %supported = scalar.andi %mode_ok, %limits_ok : i1
76
+ %supported32 = scalar.extui %supported : i1 to i32
77
+ %error = global.load @unsupported : buffer
78
+ func.call @require(%supported32, %error) : (i32, buffer)
79
+ %empty = global.load @empty : buffer
80
+ %policy = global.load @policy : buffer
81
+ %card = config.get @llm.card : i1
82
+ %checkpoint = scf.if %card -> (i32) {
83
+ %scope = global.load @model_scope : buffer
84
+ %scoped = func.call @source_scope(%scope) : (buffer) -> (i32)
85
+ scf.yield %scoped : i32
86
+ } else {
87
+ %direct = func.call @source(%empty, %weights) : (buffer, buffer) -> (i32)
88
+ scf.yield %direct : i32
89
+ }
90
+ %bounded_count = scalar.assume %shape_count [range(%shape_count, 1, 128)] : i64
91
+ %count = index.cast %bounded_count : i64 to index
92
+ %c4_off = index.constant 4 : offset
93
+ %stage_slots = index.constant 128 : index
94
+ %stage_bytes = index.scale %stage_slots, %c4_off : index, offset -> offset
95
+ %header_bytes = index.constant 128 : offset
96
+ %control_bytes = index.add %header_bytes, %stage_bytes : offset
97
+ // Then one 16-byte sampling record per resident row (control.loom @bind_request).
98
+ %bounded_rows = scalar.assume %rows [range(%rows, 1, 1048576)] : i64
99
+ %row_count = index.cast %bounded_rows : i64 to index
100
+ %record_bytes = index.constant 16 : offset
101
+ %sampling_bytes = index.scale %row_count, %record_bytes : index, offset -> offset
102
+ %state_bytes = index.add %control_bytes, %sampling_bytes : offset
103
+ %state = buffer.alloca<private> align(8) %state_bytes : buffer
104
+ buffer.fill %c0_i32, %state[%origin], %state_bytes : i32
105
+ %stage_view = buffer.view %state[%header_bytes] : buffer -> view<[%count]xi32>
106
+ %root = global.load @root : buffer
107
+ %context_key = global.load @context_key : buffer
108
+ %spans_key = global.load @spans_key : buffer
109
+ %tokens_key = global.load @tokens_key : buffer
110
+ %pool_key = global.load @pool_key : buffer
111
+ // logits:begin
112
+ %logits_cfg = config.get @llm.logits : i1
113
+ %logit_slots_key = global.load @logit_slots_key : buffer
114
+ // logits:end
115
+ %shape_view = buffer.view %shapes[%origin] : buffer -> view<[%count]x2xi64>
116
+ %maximum, %span_capacity = scf.for %i = [%c0 to %count step %c1](%previous = %c0_i64 : i64, %previous_spans = %c0_i64 : i64) -> (i64, i64) {
117
+ %tokens = view.load %shape_view[%i, 0] : view<[%count]x2xi64> -> i64
118
+ %spans = view.load %shape_view[%i, 1] : view<[%count]x2xi64> -> i64
119
+ %tag = index.cast %i : index to i64
120
+ %stage = func.call @stage(%root, %tag) : (buffer, i64) -> (i32)
121
+ func.call @config_i64(%stage, %context_key, %context) : (i32, buffer, i64)
122
+ func.call @config_i64(%stage, %pool_key, %pool) : (i32, buffer, i64)
123
+ func.call @config_i64(%stage, %tokens_key, %tokens) : (i32, buffer, i64)
124
+ func.call @config_i64(%stage, %spans_key, %spans) : (i32, buffer, i64)
125
+ // logits:begin
126
+ scf.if %logits_cfg {
127
+ %logit_slots = scalar.minsi %spans, %rows : i64
128
+ func.call @config_i64(%stage, %logit_slots_key, %logit_slots) : (i32, buffer, i64)
129
+ }
130
+ // logits:end
131
+ func.call @parameter(%stage, %c0_i32, %c0_source, %checkpoint, %policy) : (i32, i32, i32, i32, buffer)
132
+ view.store %stage, %stage_view[%i] : i32, view<[%count]xi32>
133
+ %larger = scalar.cmpi ugt, %tokens, %previous : i64
134
+ %next = scf.select %larger, %tokens, %previous : i64
135
+ %more_spans = scalar.cmpi ugt, %spans, %previous_spans : i64
136
+ %next_spans = scf.select %more_spans, %spans, %previous_spans : i64
137
+ scf.yield %next, %next_spans : i64, i64
138
+ }
139
+ %smaller = scalar.cmpi ult, %maximum, %prefill : i64
140
+ %effective = scf.select %smaller, %maximum, %prefill : i64
141
+ %layout_origin = index.constant 88 : offset
142
+ %layout = buffer.view %state[%layout_origin] : buffer -> view<5xi64>
143
+ view.store %maximum, %layout[0] : i64, view<5xi64>
144
+ view.store %span_capacity, %layout[1] : i64, view<5xi64>
145
+ view.store %context, %layout[2] : i64, view<5xi64>
146
+ view.store %pool, %layout[3] : i64, view<5xi64>
147
+ view.store %pins, %layout[4] : i64, view<5xi64>
148
+ %stage_count32 = index.cast %count : index to i32
149
+ %allocations, %views, %origins, %draft, %geometry = func.call @llm_storage(%maximum, %span_capacity, %context, %pool, %rows, %pins) : (i64, i64, i64, i64, i64, i64) -> (buffer, buffer, buffer, buffer, buffer)
150
+ %terminal = global.load @terminal : buffer
151
+ func.return %effective, %stage_count32, %state, %terminal, %allocations, %views, %origins, %empty, %geometry : i64, i32, buffer, buffer, buffer, buffer, buffer, buffer, buffer
152
+ }
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,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // KV geometry: 72 planes (K and V per attention layer) of pool x 2048 bytes (F16 KV heads x head_dim).
2
+ // Recurrent slots: 4 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) -> (buffer, buffer, buffer, buffer, buffer) {
21
+ %origin = index.constant 0 : offset
22
+ %c0 = index.constant 0 : index
23
+ %c1 = index.constant 1 : index
24
+ %c0_i32 = scalar.constant 0 : i32
25
+ %c0_i64 = scalar.constant 0 : i64
26
+ %c1_i64 = scalar.constant 1 : i64
27
+ %c4_i64 = scalar.constant 4 : i64
28
+ %bounded_rows = scalar.assume %rows [range(%rows, 1, 2147483647)] : i64
29
+ %row_count = index.cast %bounded_rows : i64 to index
30
+ %slot_stride = scalar.constant 256 : i64
31
+ %token_bytes = scalar.muli %maximum, %c4_i64 : i64
32
+ %alignment_bias = scalar.constant 255 : i64
33
+ %biased_token_bytes = scalar.addi %token_bytes, %alignment_bias : i64
34
+ %token_slots = scalar.divui %biased_token_bytes, %slot_stride : i64
35
+ %padded_token_bytes = scalar.muli %token_slots, %slot_stride : i64
36
+ %progress_offset = scalar.addi %slot_stride, %padded_token_bytes : i64
37
+ %recurrent_offset = scalar.addi %progress_offset, %slot_stride : i64
38
+ %recurrent_bytes = scalar.constant 4 : i64
39
+ %recurrent_padded = scalar.addi %recurrent_bytes, %alignment_bias : i64
40
+ %recurrent_pages = scalar.divui %recurrent_padded, %slot_stride : i64
41
+ %recurrent_region = scalar.muli %recurrent_pages, %slot_stride : i64
42
+ %row_stride = scalar.addi %recurrent_offset, %recurrent_region : i64
43
+ %pinned = scalar.cmpi ne, %pins, %c0_i64 : i64
44
+ %twice_rows = scalar.addi %rows, %rows : i64
45
+ %fork_slots = scalar.addi %twice_rows, %pins : i64
46
+ %slots = scf.select %pinned, %fork_slots, %rows : i64
47
+ %private_bytes = scalar.muli %slots, %row_stride : i64
48
+ %kv_position_bytes = scalar.constant 2048 : i64
49
+ %plane_count = scalar.constant 72 : i64
50
+ %plane_bytes = scalar.muli %pool, %kv_position_bytes : i64
51
+ %pool_bytes = scalar.muli %plane_bytes, %plane_count : i64
52
+ %biased_pool = scalar.addi %pool_bytes, %alignment_bias : i64
53
+ %pool_slots = scalar.divui %biased_pool, %slot_stride : i64
54
+ %private_origin = scalar.muli %pool_slots, %slot_stride : i64
55
+ %recurrent_origin = scalar.addi %private_origin, %recurrent_offset : i64
56
+ %arena_bytes = scalar.addi %private_origin, %private_bytes : i64
57
+ %c3_i64 = scalar.constant 3 : i64
58
+ %c15_i64 = scalar.constant 15 : i64
59
+ %c16_i64 = scalar.constant 16 : i64
60
+ %padded = scalar.addi %context, %c15_i64 : i64
61
+ %blocks = scalar.divui %padded, %c16_i64 : i64
62
+ %map_entries = scalar.muli %rows, %blocks : i64
63
+ %map_bytes = scalar.muli %map_entries, %c4_i64 : i64
64
+ %origin_stride = scalar.constant 40 : i64
65
+ %map_origin = scalar.muli %bounded_rows, %origin_stride : i64
66
+ %table_bytes = scalar.addi %map_origin, %map_bytes : i64
67
+ %allocation_bytes = index.constant 264 : offset
68
+ %allocations = buffer.alloca<private> align(8) %allocation_bytes : buffer
69
+ %allocation_count = index.constant 11 : index
70
+ scf.for %i = [%c0 to %allocation_count step %c1] {
71
+ func.call @allocation(%allocations, %i, %c0_i64, %c0_i64) : (buffer, index, i64, i64)
72
+ }
73
+ %residual_bytes = scalar.muli %span_capacity, %c4_i64 : i64
74
+ %header_bytes = scalar.constant 16 : i64
75
+ %record_bytes = scalar.constant 36 : i64
76
+ %plan_bytes = scalar.muli %span_capacity, %record_bytes : i64
77
+ %metadata_bytes = scalar.addi %header_bytes, %plan_bytes : i64
78
+ %c2 = index.constant 2 : index
79
+ %c3 = index.constant 3 : index
80
+ %c4 = index.constant 4 : index
81
+ %c5 = index.constant 5 : index
82
+ func.call @allocation(%allocations, %c0, %residual_bytes, %c0_i64) : (buffer, index, i64, i64)
83
+ func.call @allocation(%allocations, %c1, %arena_bytes, %c0_i64) : (buffer, index, i64, i64)
84
+ func.call @allocation(%allocations, %c2, %metadata_bytes, %c0_i64) : (buffer, index, i64, i64)
85
+ func.call @allocation(%allocations, %c3, %table_bytes, %c0_i64) : (buffer, index, i64, i64)
86
+ func.call @allocation(%allocations, %c4, %token_bytes, %c0_i64) : (buffer, index, i64, i64)
87
+ func.call @allocation(%allocations, %c5, %residual_bytes, %c0_i64) : (buffer, index, i64, i64)
88
+
89
+ // logits:begin
90
+ // Opt-in logits readback (card config llm.logits, default off; gen_llm.py g_logits_export): the outputs allocation also holds
91
+ // 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).
92
+ %logits_on = config.get @llm.logits : i1
93
+ scf.if %logits_on {
94
+ %logit_region = scalar.constant 32768 : i64
95
+ %logit_row = scalar.constant 524288 : i64
96
+ %logit_slots = scalar.minsi %span_capacity, %rows : i64
97
+ %logit_rows = scalar.muli %logit_slots, %logit_row : i64
98
+ %logit_total = scalar.addi %logit_region, %logit_rows : i64
99
+ func.call @allocation(%allocations, %c5, %logit_total, %c0_i64) : (buffer, index, i64, i64)
100
+ }
101
+ // logits:end
102
+
103
+ %view_stride = index.constant 64 : offset
104
+ %view_bytes = index.scale %row_count, %view_stride : index, offset -> offset
105
+ %views = buffer.alloca<private> align(8) %view_bytes : buffer
106
+ %view_records = buffer.view %views[%origin] : buffer -> view<[%row_count]x4x2xi64>
107
+ %origin_bytes = index.cast %map_origin : i64 to offset
108
+ %origins = buffer.alloca<private> align(8) %origin_bytes : buffer
109
+ buffer.fill %c0_i32, %origins[%origin], %origin_bytes : i32
110
+ %origin_records = buffer.view %origins[%origin] : buffer -> view<[%row_count]x5xi64>
111
+ %control_bytes = scalar.constant 12 : i64
112
+ %progress_bytes = scalar.constant 32 : i64
113
+ scf.for %row = [%c0 to %row_count step %c1] {
114
+ %row64 = index.cast %row : index to i64
115
+ %relative = scalar.muli %row64, %row_stride : i64
116
+ %base = scalar.addi %private_origin, %relative : i64
117
+ %tokens = scalar.addi %base, %slot_stride : i64
118
+ %progress = scalar.addi %base, %progress_offset : i64
119
+ view.store %base, %view_records[%row, 0, 0] : i64, view<[%row_count]x4x2xi64>
120
+ view.store %control_bytes, %view_records[%row, 0, 1] : i64, view<[%row_count]x4x2xi64>
121
+ view.store %c0_i64, %view_records[%row, 1, 0] : i64, view<[%row_count]x4x2xi64>
122
+ view.store %c0_i64, %view_records[%row, 1, 1] : i64, view<[%row_count]x4x2xi64>
123
+ view.store %tokens, %view_records[%row, 2, 0] : i64, view<[%row_count]x4x2xi64>
124
+ view.store %token_bytes, %view_records[%row, 2, 1] : i64, view<[%row_count]x4x2xi64>
125
+ view.store %progress, %view_records[%row, 3, 0] : i64, view<[%row_count]x4x2xi64>
126
+ view.store %progress_bytes, %view_records[%row, 3, 1] : i64, view<[%row_count]x4x2xi64>
127
+ view.store %c0_i64, %origin_records[%row, 2] : i64, view<[%row_count]x5xi64>
128
+ %map_stride = scalar.muli %blocks, %c4_i64 : i64
129
+ %map_offset = scalar.muli %row64, %map_stride : i64
130
+ %map_base = scalar.addi %map_origin, %map_offset : i64
131
+ view.store %map_base, %origin_records[%row, 4] : i64, view<[%row_count]x5xi64>
132
+ }
133
+ %geometry_bytes = index.constant 104 : offset
134
+ %geometry = buffer.alloca<private> align(8) %geometry_bytes : buffer
135
+ %geometry_view = buffer.view %geometry[%origin] : buffer -> view<13xi64>
136
+ view.store %c16_i64, %geometry_view[0] : i64, view<13xi64>
137
+ view.store %map_origin, %geometry_view[1] : i64, view<13xi64>
138
+ view.store %c0_i64, %geometry_view[2] : i64, view<13xi64>
139
+ view.store %c4_i64, %geometry_view[3] : i64, view<13xi64>
140
+ view.store %recurrent_origin, %geometry_view[4] : i64, view<13xi64>
141
+ view.store %row_stride, %geometry_view[5] : i64, view<13xi64>
142
+ view.store %recurrent_bytes, %geometry_view[6] : i64, view<13xi64>
143
+ view.store %slots, %geometry_view[7] : i64, view<13xi64>
144
+ view.store %c1_i64, %geometry_view[8] : i64, view<13xi64>
145
+ view.store %c0_i64, %geometry_view[9] : i64, view<13xi64>
146
+ view.store %plane_count, %geometry_view[10] : i64, view<13xi64>
147
+ view.store %plane_bytes, %geometry_view[11] : i64, view<13xi64>
148
+ %block_bytes = scalar.constant 32768 : i64
149
+ view.store %block_bytes, %geometry_view[12] : i64, view<13xi64>
150
+ %empty_bytes = index.constant 0 : offset
151
+ %empty = buffer.alloca<private> align(1) %empty_bytes : buffer
152
+ func.return %allocations, %views, %origins, %empty, %geometry : buffer, buffer, buffer, buffer, buffer
153
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
weights.loom ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ func.def public @prepare_weight(%key: buffer) -> (i64) {
2
+ %bytes = scalar.constant 0 : i64
3
+ func.return %bytes : i64
4
+ }