Repository navigation
Commit 9ebe5bd
Make the compiler memory headroom a preparation setting
Forward compilation and kernel tuning size their worker pools against host
memory and always leave a fixed 8 GiB free. On a unified-memory GPU such as
DGX Spark (GB10), the model's weights already occupy most of that memory: a
DeepSeek V4.1 Flash TP3 rank has about 13 GiB left after loading, and with
the fixed floor the sizing rule (4 GiB per compiler, 512 MiB per Inductor
thread) allows one forward compiler with two Inductor threads per rank, so
"Compile model forwards" runs mostly serially. The right floor depends on
the host and the model, so it should be a setting rather than a constant.
Lowering it keeps the existing safety rule: on unified-memory GPUs, sizing
still leaves the greater of this floor and the preparation headroom that
protects KV capacity and later processes.
Before this change the floor was the private constant `_HEADROOM_BYTES` in
`ignition/preparation/host_memory.py`. It is now `COMPILE_HEADROOM_BYTES`
(still 8 GiB) used as the default of a `compile_headroom_bytes` argument in
`worker_limit`, `compile_threads`, `tuning_limits`,
`candidate_scratch_limit` and `CompilePool`. The value comes from the new
`[preparation] compile_headroom` setting (a size string such as "6G",
default "8G") or the advanced `--compile-headroom SIZE` flag of `export`,
`debug-serve` and `bench`, which overrides the file. It is carried as
`Plan.compile_headroom_bytes`, passed through every recipe's
`PreparationConfig` to the tuning session, `ForwardCache` and `CompilePool`,
and sent from rank zero to multi-host peers, as `compile_workers` is. The
plan dictionary, the "Select GPUs." line, the tuning report and the bench
result record it. Negative, empty and unparsable values are usage errors.
The low-memory threshold in `release_unused` keeps 8 GiB. When a pool has no
room for one worker, its MemoryError now also reports the headroom and
per-worker bytes. docs/cli-design.md and docs/model-preparation.md document
the setting and flag. With the default, pool sizing is unchanged.
Measured result: with a cold forward cache and restored tuning on three DGX
Spark GB10 hosts (DeepSeek V4.1 Flash TP3), "Compile model forwards" took
507.7 s with `--compile-headroom 6G` and 511.2 s with `[preparation]
compile_headroom = "6G"`, against 905.7 s with the default. By the sizing
rule, at 13 GiB available a 6 GiB floor gives each rank one compiler with
six Inductor threads instead of two; the export logs do not record the
thread count. This is a component result for one model and host type,
measured once per setting with this change applied to main at `ca1f960e`,
184 commits before `d2b5c5f3`; those commits change how `ForwardCache`
releases memory, so the timing may differ on `d2b5c5f3`. Kernel tuning was
restored from cache, so tuning pools and candidate scratch sized with a
lower headroom were not exercised on hardware. A host with less memory left
after loading can exhaust host memory with a low value.
Evidence: the plans of those three exports recorded 8 GiB, 6 GiB and 6 GiB.
With 6 GiB the lowest MemAvailable on any host during the phase was 9 GiB,
with no OOM. The 6 GiB package served with decode speed and 262k-token
prefill time in line with two earlier exports of the same checkpoint and
recipe with the default headroom, and answered a 262k-token prompt that asks
for 16 values placed through the context with all 16 correct. On `d2b5c5f3`
plus this commit, the CPU suites tests/cli, tests/preparation,
tests/recipes/test_declarations.py, tests/recipes/test_minimax_m3.py and
tests/recipes/muse_spark (CUDA hidden, environment from uv.lock) gave 2063
passed, 65 failed and 222 skipped; `d2b5c5f3` alone fails the same 65 tests
in the same environment (2016 passed, 222 skipped). Those failures come from
a locally built extension without `validate_prepared_contract`,
chat-template fixtures that were not prepared, a missing Kimi K3 checkpoint,
and CLI and multi-host routing expectations that also fail on `d2b5c5f3`.
New tests cover setting and flag parsing and validation, the plan and
startup line, every recipe's `PreparationConfig` (Kimi K3.1 Pro reuses the
Kimi K3 adapter), `worker_limit`, `compile_threads`, `tuning_limits`,
`candidate_scratch_limit`, `CompilePool` sizing and the tuning report. The
export measurement was not repeated on `d2b5c5f3`, and no GPU tests were run
on it.
Design-Signed-Off-By: Claude Opus 5.5; design-review=3ad6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Javier López <59578422+javieratomic@users.noreply.github.com>1 parent d2b5c5f commit 9ebe5bd
47 files changed
Lines changed: 398 additions & 63 deletions
File tree
- docs
- ignition
- cli
- preparation
- recipes
- deepseek41
- deepseek4
- gemma4
- glm53
- kimi3
- mimo_v2
- minimax_m3
- muse_spark
- nemotron_h
- qwen38_dense
- qwen38
- step5
- tests
- cli
- preparation
- recipes
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
| 422 | + | |
422 | 423 | | |
423 | 424 | | |
424 | 425 | | |
| |||
1192 | 1193 | | |
1193 | 1194 | | |
1194 | 1195 | | |
| 1196 | + | |
1195 | 1197 | | |
1196 | 1198 | | |
1197 | 1199 | | |
| |||
1280 | 1282 | | |
1281 | 1283 | | |
1282 | 1284 | | |
| 1285 | + | |
1283 | 1286 | | |
1284 | 1287 | | |
1285 | 1288 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
248 | 257 | | |
249 | 258 | | |
250 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
235 | 238 | | |
236 | 239 | | |
237 | 240 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| 228 | + | |
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| |||
182 | 184 | | |
183 | 185 | | |
184 | 186 | | |
| 187 | + | |
| 188 | + | |
185 | 189 | | |
186 | 190 | | |
187 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
105 | 114 | | |
106 | 115 | | |
107 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
205 | 206 | | |
206 | 207 | | |
207 | 208 | | |
| |||
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
273 | | - | |
| 274 | + | |
274 | 275 | | |
275 | 276 | | |
276 | 277 | | |
| |||
304 | 305 | | |
305 | 306 | | |
306 | 307 | | |
| 308 | + | |
307 | 309 | | |
308 | 310 | | |
309 | 311 | | |
| |||
464 | 466 | | |
465 | 467 | | |
466 | 468 | | |
| 469 | + | |
467 | 470 | | |
468 | 471 | | |
469 | 472 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
| 189 | + | |
| 190 | + | |
188 | 191 | | |
189 | 192 | | |
190 | 193 | | |
| |||
369 | 372 | | |
370 | 373 | | |
371 | 374 | | |
| 375 | + | |
372 | 376 | | |
373 | 377 | | |
374 | 378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
569 | | - | |
| 569 | + | |
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
| |||
575 | 575 | | |
576 | 576 | | |
577 | 577 | | |
| 578 | + | |
578 | 579 | | |
579 | 580 | | |
580 | 581 | | |
| |||
710 | 711 | | |
711 | 712 | | |
712 | 713 | | |
713 | | - | |
| 714 | + | |
| 715 | + | |
714 | 716 | | |
715 | 717 | | |
716 | 718 | | |
| |||
799 | 801 | | |
800 | 802 | | |
801 | 803 | | |
802 | | - | |
| 804 | + | |
| 805 | + | |
803 | 806 | | |
804 | 807 | | |
805 | 808 | | |
| |||
0 commit comments