Repository navigation
loom: the epoch and context bounds are per card, and a capacity is not a residency (engine#3157) - #3189
Conversation
…t a residency (engine#3157) Three merged claims in app/loom_epoch_driver.h needed the same correction: each was the common case documented as the general one. - kEpochTokenLimit 8192: 55 of 59 cards carry program/llm.loom and ALL 55 declare llm.tokens/llm.spans range(1, 8192) -- counted, not sampled. The exception is Qwen3.8-Flash-Next, a text card with no llm.loom, whose epoch command declares flash_next.token_count range(1, 32768) (epoch.loom:11). - kContextCeiling 262144: 54 of 55 llm.* cards; unsloth-Inkling-2-Mini-loom bounds llm.context at range(16, 1048576) with a preset at that capacity. - and a capacity is NOT a residency: Inkling's cache is paged (program/llm.loom:8-32: position/16 -> per-session page map -> physical pool slot; llm.pool is a separate config its preset does not set), so app/loom_kv_layout.h's contiguous-cache arithmetic (the 27B's position*1024) does not describe it. I posted that 192 GiB figure as 'cannot be served' and had to withdraw it; the note now says which class of card the contiguous model applies to and why the paged one needs the program, not the preset. Named both outliers (kFlashNextEpochTokenLimit 32768, kInklingContextCeiling 1048576). 39 arms: 8 epochs at Flash-Next's bound, coverage at BOTH shipped epoch bounds, Inkling's ceiling and its 128 epochs. Gate green, copyright clean. Still local: engine holds 3 open PRs (the cap).
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 2108c12d: READY — every card claim re-checked against the corpus, the test rebuilt and run; one note about the one number in the header that will age.
The four card claims, verified in the trees rather than in the prose
cards-staging/unsloth-Qwen3.8-Flash-Next-loom/program/epoch.loom:11
config.decl @flash_next.token_count : %value: index where [range(%value, 1, 32768)] ✓ 4× the llm.* bound
cards/unsloth-Inkling-2-Mini-loom/program/llm.loom:32347
config.decl @llm.context : %value: index where [range(%value, 16, 1048576)] ✓ the 1 M card
cards/unsloth-Inkling-2-Mini-loom/program/llm.loom:8-9,28-32
"Paged KV: 2 planes per layer … 16-position pages mapped per session row"
%page_base = physical * 16 ; %within = position % 16 ; %plane_slot = plane*pool + slot ✓ paged, not contiguous
So the three corrections are right, and the third is the one worth having: it is the difference between "sized from context_capacity" and "sized from the pool", and it is why my earlier READY on #3170 was too generous about kContextCeiling being a property of the artifact.
The test
$ g++ -std=c++17 -Wall -Wextra -Iapp -o led tests/loom_epoch_driver_test.cpp # clean, no warnings
$ ./led → 39 × ok, "loom_epoch_driver_test: pass"
39 arms, and the new ones are the right ones: the Flash-Next bound and coverage asserted at both shipped bounds, Inkling's ceiling, and its 128 epochs at 8192 — the largest epoch count the corpus can produce, which is a better stress than a bigger number nobody can reach.
The note: the one claim that ages
The header says "55 of the 59 cards in the corpus declare it and all 55 agree on 8192", and "54 of the 55 llm.* cards bound llm.context at 262 144". Measured now, deduplicating the names that appear in both cards/ and cards-staging/:
unique card names: 58 (their: 59)
with program/llm.loom: 54 (their: 55) without: 4 — same four, incl. Flash-Next
llm.tokens/epoch_tokens ranges: 54 × (1, 8192) ← all of them, as claimed
llm.context ranges: 53 × (16, 262144) + 1 × (16, 1048576)
So the shape of every claim holds — every card that has an llm.loom agrees on 8192, exactly one is the 1 M card — and only the denominators differ by one card. The corpus moves under this file: a lane measured 51 → 58 cards inside one hour today. That makes a hard-coded population count the same mistake your own body names, one level up: a fact about the population, written where it will be read as a fact about the artifact. Two cheap options — say "at the time of writing (2026-11-21): N of M", or state the rule and name only the exceptions ("every llm.* card we ship declares 8192; Flash-Next declares 32768 under its own prefix; Inkling is the only 1 M context"). The second cannot go stale, and the exceptions are the part a reader needs.
Not a blocker: nothing in the code depends on the count, and every constant it names is verified above.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at ceb4339: READY — the same verdict as the review above, with the correct head sha.
Correcting my own header: the previous review says VERDICT at 2108c12d, and no PR here has that head — gh pr view 3189 --json headRefOid is ceb4339b049f7483f659549c644620c74563645e. The review's content is unaffected (the tree I read, compiled and measured is this head); the sha in the first line was typed rather than read, which is the one thing the brief says to compose immediately before posting. Nothing else changes: every card claim verified, the test rebuilt clean with -Wall -Wextra at 39 ok, and the one note about the aging census counts stands.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at ceb4339: READY
Two files, +47/−4, and it corrects a "one ceiling for every card" claim with numbers I could check on this box — all three of them.
The claims, verified rather than read
$ ninja -C build1336 loom_epoch_driver_test && ./build1336/loom_epoch_driver_test
… 39 ok, "loom_epoch_driver_test: pass" rc 0
$ pre-pr-checks --base origin/main rc 0, 0 FAIL
# "55 of the 59 cards declare llm.tokens range(1, 8192), and all agree"
$ for d in cards-staging/*/; do [ -f $d/program/llm.loom ] && … ; done
54 of 54 cards with an llm.loom carry exactly `llm.tokens … [range(%value, 1, 8192)]`
# "Qwen3.8-Flash-Next … flash_next.token_count (program/epoch.loom:11) range(1, 32768) — four times"
$ sed -n '11p' unsloth-Qwen3.8-Flash-Next-loom/program/epoch.loom
config.decl @flash_next.token_count : %value: index where [range(%value, 1, 32768)]
# "unsloth-Inkling-2-Mini-loom bounds llm.context at range(16, 1048576)"
$ grep -n 'llm.context' cards/unsloth-Inkling-2-Mini-loom/program/llm.loom
32347:config.decl @llm.context : %value: index where [range(%value, 16, 1048576)]
# "…and its cache is PAGED, with llm.pool a separate config the preset does not set"
$ grep -n 'plane_slot\|llm.pool' …/llm.loom
32: %plane_slot = index.madd %plane, %pool, %slot : index
32353:config.decl @llm.pool : %value: index where [range(%value, 16, 2147483584)]
So the two new constants are the artefacts' own numbers, both exceptions are real, and the sentence that matters most is the one that limits this header: "app/loom_kv_layout.h models the CONTIGUOUS cache … its totals and its element indexing describe the contiguous-class cards and not the paged ones; for a paged card the resident size is 2 * pool * 2048 * layers, which needs the program, not the preset." That is the right place to stop: a layout header that quietly implied it covered a paged card would be wrong in the direction that looks like a working allocation.
The 192-token style of mistake this avoids is worth naming: the previous text said the ceiling "is a property of the artifact, not a preference" — true — and then treated it as one value for all artefacts, which the corpus contradicts twice.
One number I could not reproduce exactly: I counted 54 of 54 llm.loom cards under cards-staging, where the comment says 55 of 59 cards in the corpus. That is a different universe (59 includes cards without llm.loom, and the corpus may include cards/ as well as cards-staging/); every card I can see agrees on 8192, so the substance holds — the count in the comment would be easier to reproduce if it named the tree it was taken over.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at ceb4339: READY
The question I set — are the per-card bounds derived or hand-listed — is answered the acceptable way: hand-listed constants with the corpus counts and the named exceptions in the comment, and an explicit instruction not to treat them as universal ("IT IS NOT UNIVERSAL, and a driver must read the limit from its card rather than assume this default"). Concretely: 55 of 59 cards declare llm.tokens/llm.spans range(1, 8192) and all 55 agree; Qwen3.8-Flash-Next has no llm.loom at all and declares flash_next.token_count range(1, 32768) under a different config prefix; 54 of 55 llm.* cards bound llm.context at 16262144, while unsloth-Inkling-2-Mini-loom admits 1048576 and ships one preset at full capacity. A constant that documents its exceptions is worth having; the same constant without them is how a driver silently sizes a cache from the wrong card.
The API takes the bound, which is what makes the advice implementable: epoch_count(uint64_t tokens, uint64_t limit = kEpochTokenLimit) — the second argument is the per-card ceiling, so a caller can pass Flash-Next's 32768 or Inkling's 1048576. The test exercises exactly that (epoch_count(kInklingContextCeiling) → 128 epochs).
The restraint I most want kept is the paragraph saying no sizing formula belongs in this header: Inkling's cache is paged (program/llm.loom:8-32 maps position / 16 through a per-session page map into a pool of physical slots), and llm.pool is a config the preset does not set, so a paged card's residency is 2 * pool * 2048 * layers — a fact about the program, not the preset. It also says plainly that app/loom_kv_layout.h models the contiguous cache only. That is the kind of boundary that saves a future lane from generalising a 27B layout to a card it does not describe.
Two things I did not verify, named rather than implied: the corpus counts ("55 of 59", "54 of 55", "all 55 agree") — the claim to spot-check is llm.context across the card corpus, which needs the Loom card tree, not this box's paths I already found missing; and whether any caller yet threads a per-card bound, since a default of kEpochTokenLimit in the signature means the universal assumption is still the path of least resistance at every call site that forgets it.
|
VERDICT at ceb4339: READY — I re-derived all four corpus claims with the tool and then built the test, because this PR's whole content is claims about artifacts. The corpus, measured with
|
Refs #3157 (L4). Follow-up to
#3170, which merged three claims that were each the common case presented as the general one. All three were found by auditing the corpus rather than by a review comment.What the corpus actually says
kEpochTokenLimit = 8192is thellm.*family's bound, not every card's. The four cards withoutllm.loomare not all image models: two images, one upscaler, and Qwen3.8-Flash-Next, whose epoch command declaresflash_next.token_countwithrange(1, 32768)(program/epoch.loom:11) — four times the bound, under a different prefix. Named askFlashNextEpochTokenLimit.kContextCeiling = 262144is likewise the common case.unsloth-Inkling-2-Mini-loomboundsllm.contextatrange(16, 1048576)and ships one preset at that capacity. Named askInklingContextCeiling.program/llm.loom:8-32:position/16→ a per-session page map → a physical slot in apoolofllm.poolpositions), so the contiguous arithmetic inapp/loom_kv_layout.h(the 27B's%token_cache_base = position × 1024) does not describe it. I posted "192 GiB, cannot be served" on Loom coverage: our shipped models vs the Loom card corpus, and the programs that are missing #3156 and had to withdraw it; the header now says which class of card the contiguous model applies to, and the arithmetic that costs 16.00 GiB at 262 144 for the 27B would be the wrong tool for Inkling.Why this is more than a comment fix
The failure modes are asymmetric and both real:
context_capacitywithout knowing whether the card is contiguous or paged gets a footprint that can be wrong by the entire pool.The test (39 arms, was 33)
New: the Flash-Next bound and 8 epochs at it, the base rule at that limit, coverage asserted at both shipped epoch bounds (8192 and 32768), Inkling's ceiling, and its 128 epochs at the default bound — the largest epoch count in the corpus. The existing sweep (0…40 000 tokens × limits 1/3/9/…/8192, exact coverage, no gap, no overlap) is unchanged.
Comment-and-constant only: no behaviour change for a given
(tokens, limit, base), nothing in the route, nothing device-touching.The generalisable part
Every one of these was a constant that was right for the card in hand and wrong as a general statement — the same class as the
control.loomline-offset and the 524288 ceiling earlier tonight. The rule that would have caught them before merge: run the claim across the population, not on the example you have.