Loom package for bartowski/Qwen2.5-Math-7B-Instruct-GGUF (Q4_K_M, loom-next port)
Browse files- README.md +119 -0
- REPORT.md +27 -0
- gen/flash2.loom +0 -0
- info.json +77 -0
- llm_config.json +105 -0
- model.json +81 -0
- model.json.lock +28 -0
- program/control.loom +0 -0
- program/llm.loom +0 -0
- program/prepare.loom +152 -0
- program/service.loom +316 -0
- program/storage.loom +153 -0
- tokenizer.json +0 -0
- weights.loom +4 -0
README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: bartowski/Qwen2.5-Math-7B-Instruct-GGUF
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
tags:
|
| 5 |
+
- loom
|
| 6 |
+
- loom-serve
|
| 7 |
+
- gguf
|
| 8 |
+
- strix-halo
|
| 9 |
+
- radeon-r9700
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Qwen2.5-Math-7B-Instruct (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 [bartowski/Qwen2.5-Math-7B-Instruct-GGUF](https://huggingface.co/bartowski/Qwen2.5-Math-7B-Instruct-GGUF) (`Qwen2.5-Math-7B-Instruct-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/bartowski-Qwen2.5-Math-7B-Instruct-loom:chat --materialize=copy --output=qwen2.5-math-7b-instruct
|
| 26 |
+
loom-serve --model=qwen2.5-math-7b-instruct '--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/bartowski-Qwen2.5-Math-7B-Instruct-loom:chat --materialize=copy --output=qwen2.5-math-7b-instruct
|
| 42 |
+
loom-serve --model=qwen2.5-math-7b-instruct '--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:
|
| 55 |
+
|
| 56 |
+
```bash
|
| 57 |
+
curl http://127.0.0.1:8080/v1/chat/completions \
|
| 58 |
+
-H 'Content-Type: application/json' \
|
| 59 |
+
-d '{"model": "qwen2.5-math-7b-instruct", "messages": [{"role": "user", "content": "Hello"}]}'
|
| 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 | — | not applicable |
|
| 79 |
+
| reasoning effort | — | not applicable |
|
| 80 |
+
| speculative decoding | — | not applicable |
|
| 81 |
+
| image input | — | not applicable |
|
| 82 |
+
| audio input / output | — | not applicable |
|
| 83 |
+
| sampling | ? | not determined |
|
| 84 |
+
| context size | ✅ | 4,096 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: [bartowski/Qwen2.5-Math-7B-Instruct-GGUF](https://huggingface.co/bartowski/Qwen2.5-Math-7B-Instruct-GGUF) @ `22e2c9c`, `Qwen2.5-Math-7B-Instruct-Q4_K_M.gguf`
|
REPORT.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Qwen2.5-Math-7B-Instruct 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: [bartowski/Qwen2.5-Math-7B-Instruct-GGUF](https://huggingface.co/bartowski/Qwen2.5-Math-7B-Instruct-GGUF) @ `22e2c9c42470193b2b643636564765c84bcb06cb`, `Qwen2.5-Math-7B-Instruct-Q4_K_M.gguf`, sha256 `7e03cee8c65b9ebf9ca14ddb010aca27b6b18e6c70f2779e94e7451d9529c091`.
|
| 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,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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": "n/a",
|
| 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": 4096,
|
| 26 |
+
"tokens": 4096
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
"image_input": {
|
| 30 |
+
"status": "n/a",
|
| 31 |
+
"value": null
|
| 32 |
+
},
|
| 33 |
+
"max_output_tokens": {
|
| 34 |
+
"status": "yes",
|
| 35 |
+
"value": {
|
| 36 |
+
"max_tokens": 4096
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"reasoning_effort": {
|
| 40 |
+
"status": "n/a",
|
| 41 |
+
"value": null
|
| 42 |
+
},
|
| 43 |
+
"sampling": {
|
| 44 |
+
"status": "unknown",
|
| 45 |
+
"value": null
|
| 46 |
+
},
|
| 47 |
+
"speculative_decoding": {
|
| 48 |
+
"status": "n/a",
|
| 49 |
+
"value": null
|
| 50 |
+
},
|
| 51 |
+
"thinking": {
|
| 52 |
+
"status": "n/a",
|
| 53 |
+
"value": null
|
| 54 |
+
},
|
| 55 |
+
"tool_calling": {
|
| 56 |
+
"status": "yes",
|
| 57 |
+
"value": null
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
"license": "apache-2.0"
|
| 61 |
+
},
|
| 62 |
+
"devices": {
|
| 63 |
+
"radeon-r9700": {
|
| 64 |
+
"state": "not_measured"
|
| 65 |
+
},
|
| 66 |
+
"strix-halo": {
|
| 67 |
+
"state": "not_measured"
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
"repo": "loom-draft/bartowski-Qwen2.5-Math-7B-Instruct-loom",
|
| 71 |
+
"report": "generated",
|
| 72 |
+
"schema": "loom-card/3",
|
| 73 |
+
"sources": {},
|
| 74 |
+
"versions": {
|
| 75 |
+
"card_generator": "fdd785e5"
|
| 76 |
+
}
|
| 77 |
+
}
|
llm_config.json
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "Qwen2.5 Math 7B Instruct",
|
| 3 |
+
"arch": "qwen2",
|
| 4 |
+
"gguf": "Qwen2.5-Math-7B-Instruct-Q4_K_M.gguf",
|
| 5 |
+
"hidden": 3584,
|
| 6 |
+
"layers": 28,
|
| 7 |
+
"heads": 28,
|
| 8 |
+
"kv_heads": 4,
|
| 9 |
+
"head_dim": 128,
|
| 10 |
+
"ffn": 18944,
|
| 11 |
+
"vocab": 152064,
|
| 12 |
+
"context_length": 4096,
|
| 13 |
+
"rms_eps": 9.999999974752427e-07,
|
| 14 |
+
"rope_theta": 10000.0,
|
| 15 |
+
"rope_type": "neox",
|
| 16 |
+
"qk_norm": false,
|
| 17 |
+
"attn_gate": false,
|
| 18 |
+
"post_norms": false,
|
| 19 |
+
"embed_norm": false,
|
| 20 |
+
"embed_scale": null,
|
| 21 |
+
"sliding_window": 0,
|
| 22 |
+
"sliding_layers": [],
|
| 23 |
+
"nope_layers": [],
|
| 24 |
+
"tied_embeddings": false,
|
| 25 |
+
"eos_id": 151645,
|
| 26 |
+
"extra_eos_ids": [
|
| 27 |
+
151643
|
| 28 |
+
],
|
| 29 |
+
"bos_id": null,
|
| 30 |
+
"chat": {
|
| 31 |
+
"bos": "",
|
| 32 |
+
"system_prefix": "<|im_start|>system\n",
|
| 33 |
+
"suffix": "<|im_end|>\n",
|
| 34 |
+
"user_prefix": "<|im_start|>user\n",
|
| 35 |
+
"assistant_prefix": "<|im_start|>assistant\n",
|
| 36 |
+
"default_system": "Please reason step by step, and put your final answer within \\boxed{}.",
|
| 37 |
+
"trim_content": false,
|
| 38 |
+
"think_open": "",
|
| 39 |
+
"think_close": "",
|
| 40 |
+
"history_think": "nonempty",
|
| 41 |
+
"history_think_scope": "after_last_query",
|
| 42 |
+
"generation_prompt": "<|im_start|>assistant\n",
|
| 43 |
+
"generation_prompt_plain": "<|im_start|>assistant\n",
|
| 44 |
+
"thinking": "never",
|
| 45 |
+
"thinking_default": false,
|
| 46 |
+
"starts_in_reasoning": false,
|
| 47 |
+
"think_end": "</think>",
|
| 48 |
+
"tools_function_only": false,
|
| 49 |
+
"tool_line_prefix": "\n",
|
| 50 |
+
"tool_separator": "",
|
| 51 |
+
"tools_after_system": true,
|
| 52 |
+
"tools_system_separator": "\n\n",
|
| 53 |
+
"tools_prefix": "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>",
|
| 54 |
+
"tools_suffix": "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call>",
|
| 55 |
+
"call_format": "hermes",
|
| 56 |
+
"calls_open": "",
|
| 57 |
+
"calls_close": "",
|
| 58 |
+
"call_end": "",
|
| 59 |
+
"call_marker": "<tool_call>",
|
| 60 |
+
"content_call_separator": "\n",
|
| 61 |
+
"call_separator": "\n",
|
| 62 |
+
"tool_turn_prefix": "<|im_start|>user",
|
| 63 |
+
"tool_item_prefix": "\n<tool_response>\n",
|
| 64 |
+
"tool_item_suffix": "\n</tool_response>",
|
| 65 |
+
"tool_turn_suffix": "<|im_end|>\n",
|
| 66 |
+
"terminal": "<|im_end|>"
|
| 67 |
+
},
|
| 68 |
+
"attn_bias": [
|
| 69 |
+
"q",
|
| 70 |
+
"k",
|
| 71 |
+
"v"
|
| 72 |
+
],
|
| 73 |
+
"attn_sinks": false,
|
| 74 |
+
"model_id": "qwen2.5-math-7b-instruct",
|
| 75 |
+
"draft": null,
|
| 76 |
+
"generator": {
|
| 77 |
+
"commit": "f74d5f3aadeadf06a26463c2cef97e211411274a",
|
| 78 |
+
"dirty": false,
|
| 79 |
+
"overlay": null,
|
| 80 |
+
"modified": false,
|
| 81 |
+
"hrx_loom": {
|
| 82 |
+
"hrx_loom": "0.2.0",
|
| 83 |
+
"fingerprint": "20d79282b0f3d72a",
|
| 84 |
+
"verified": false
|
| 85 |
+
}
|
| 86 |
+
},
|
| 87 |
+
"sdk": {
|
| 88 |
+
"hrx_loom": "0.2.0",
|
| 89 |
+
"source": "pypi",
|
| 90 |
+
"wheel_sha256": "5148f9e3a264af400ec4bae38bd7b06bf551d28cc33b7a61d67f7bcefa590438",
|
| 91 |
+
"hrx_system_sha": "0cd370f2baaa0cfef47cc23007f1a109906f8a52"
|
| 92 |
+
},
|
| 93 |
+
"resolved": {
|
| 94 |
+
"scopes": [
|
| 95 |
+
"arch/llm/dense/qwen2"
|
| 96 |
+
],
|
| 97 |
+
"choices": {},
|
| 98 |
+
"devices": [
|
| 99 |
+
"rdna3",
|
| 100 |
+
"rdna4"
|
| 101 |
+
],
|
| 102 |
+
"facets": [],
|
| 103 |
+
"env": {}
|
| 104 |
+
}
|
| 105 |
+
}
|
model.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema_version": 1,
|
| 3 |
+
"model": {
|
| 4 |
+
"id": "qwen2.5-math-7b-instruct",
|
| 5 |
+
"name": "Qwen2.5 Math 7B Instruct (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/Qwen2.5-Math-7B-Instruct-Q4_K_M.gguf",
|
| 48 |
+
"format": "gguf",
|
| 49 |
+
"origin": "@checkpoint/Qwen2.5-Math-7B-Instruct-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": 4096,
|
| 69 |
+
"prefill_capacity": 1024,
|
| 70 |
+
"max_tokens": 4096
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
"origins": {
|
| 75 |
+
"checkpoint": {
|
| 76 |
+
"kind": "hf",
|
| 77 |
+
"repository": "bartowski/Qwen2.5-Math-7B-Instruct-GGUF",
|
| 78 |
+
"revision": "22e2c9c42470193b2b643636564765c84bcb06cb"
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
}
|
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": "bartowski/Qwen2.5-Math-7B-Instruct-GGUF",
|
| 9 |
+
"revision": "22e2c9c42470193b2b643636564765c84bcb06cb"
|
| 10 |
+
},
|
| 11 |
+
"resolved": {
|
| 12 |
+
"revision": "22e2c9c42470193b2b643636564765c84bcb06cb"
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
},
|
| 16 |
+
"files": [
|
| 17 |
+
{
|
| 18 |
+
"origin": "@checkpoint/Qwen2.5-Math-7B-Instruct-Q4_K_M.gguf",
|
| 19 |
+
"size": 4683074272,
|
| 20 |
+
"sha256": "7e03cee8c65b9ebf9ca14ddb010aca27b6b18e6c70f2779e94e7451d9529c091"
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"origin": "tokenizer.json",
|
| 24 |
+
"size": 5212067,
|
| 25 |
+
"sha256": "20f3f185bfd9a4f9f69c9e605911d6c4d9b004c9993ac29c1bc7c666d1b33877"
|
| 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 |
+
// "<|im_end|>" is the service terminal marker.
|
| 46 |
+
global.rodata.def @terminal = bytes("3c7c696d5f656e647c3e")
|
| 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 4096"
|
| 51 |
+
global.rodata.def @unsupported = bytes("6c6c6d20726571756972657320706f6f6c65642065706f63687320776974686f7574204d54502c206174206d6f7374203132382073686170657320616e64206120636f6e74657874206f66206174206d6f73742034303936")
|
| 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 4096 : 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: 56 planes (K and V per attention layer) of pool x 1024 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 1024 : i64
|
| 49 |
+
%plane_count = scalar.constant 56 : 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 608256 : 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 16384 : 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 |
+
}
|