Skip to content

mem_admit: flint's 14 full-attention layers are priced at the context (Fixes #1425) - #1440

Closed
bong-water-water-bong wants to merge 2 commits into
mainfrom
1bit/mem-admit-flint
Closed

bong-water-water-bong wants to merge 2 commits into
mainfrom
1bit/mem-admit-flint

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

What was wrong

app/mem_admit.h prices the share of full-attention layers from a per-architecture table ("one layer in N") and falls
back to 0 for an architecture it does not know — documented as a lower bound. flint is not on the list, and its
split is not any 1/N either: 49 layers, 35 windowed and 14 full. So all 49 were priced at
min(n_ctx, swa·n_seq + 512), and the estimate stopped depending on the context at all — the lemonade#45 row measured
the same 24.07 GiB at ctx 4096, 8192 and 262144, with KV/state at 0.24 GiB in every case. That is a lower bound
that admits a model the reservation cannot then hold (the GTT-ceiling overrun the refusal line cites as engine #680).

The change

flint gets its own entry, as the ratio 14/49, with a comment saying why it is a fraction rather than a 1/N and
that a pack with a different split needs its own entry — unless its GGUF carries attention.sliding_window_pattern,
which already wins over the table (unchanged).

Rows (tests/mem_admit_test.cpp, a 49-layer flint header with a 4096 window)

row result
at ctx 8192 1,078.0000 MiB (14/49 at 8192 + 35/49 at 4096+512) — exact against the formula
at ctx 262144 14,966.0000 MiB — exact, i.e. the 14 full layers really are priced at the context
grows with the context 262144 > 3 × 8192 — the row that would have caught the defect, since the estimate used to be constant

ctest -R mem_admit → 2/2 (mem_admit and mem_admit_route), tools/copyright.py --check rc 0.

What is still unconfirmed, and says so

The issue's author could not find a local flint GGUF, so the window size (and therefore the exact GiB a real flint
reserves) is still unmeasured — the rows above verify the pricing rule against a header of the documented shape, not
against a real pack. If the window turns out to be different, only the 4608 in the test changes; the table entry does
not.

Fixes #1425.

pi-npufeat added 2 commits November 8, 2026 00:26
…ing too (#1311/TQVL)

Qwen3-VL's config declares the rotary variant under rope_scaling ({mrope_interleaved: true, mrope_section:
[24,20,20]}); our reader only looked inside rope_parameters (the FastFlowLM/OGA and Qwen3.5 spelling). So a
Qwen3-VL container loaded with mrope=0 -- plain RoPE -- and nothing said so.

For a text-only prompt that is exactly right: with pos_t = pos_h = pos_w the interleaved MRoPE angle vector equals
plain RoPE's bit for bit (checked over positions 0..262143 at theta 5e6, and the rotated 128-dim heads are
identical). With image tokens the position ids differ per axis and the two differ by ~0.29 rad on the rotary
block, so the flag is what a route, a plan field or a refusal can act on -- it has to be seen.

tests/q4nx_mrope_test.c pins both spellings and the controls that keep this honest: a rope_scaling block without
mrope_interleaved (yarn, linear, dynamic) is NOT mrope, and mrope_interleaved:false stays plain. Verified on the
real container: the load line now reads mrope=1.

Also carries the converter's acceptance of the HF VL layout (model.language_model.* beside model.visual.*), which
is what let the Qwen3-VL text half be packed at all.
…, so the estimate grows again (Fixes #1425)

app/mem_admit.h prices the share of full-attention layers from a per-architecture table ('one layer in N') and
falls back to 0 for an architecture it does not know -- a lower bound that does not grow with the context. flint
is 49 layers, 35 windowed and 14 full, so its split is not any 1/N and it was priced as 49 windowed layers: the
lemonade#45 row measured the same 24.07 GiB at ctx 4096, 8192 and 262144, with KV/state at 0.24 GiB in every case,
which would admit the model at its own 262144 context and then exceed the reservation.

flint gets its own entry, as the ratio 14/49 (a pattern array in the GGUF still wins, as before).

Rows in tests/mem_admit_test.cpp, on a 49-layer flint header:
  at ctx 8192: 1,078.0000 MiB (14/49 at 8192 + 35/49 at 4096+512) -- exact
  at ctx 262144: 14,966.0000 MiB -- exact, and > 3x the 8192 figure, which is the row that would have caught
  this (the estimate used to be constant)

ctest mem_admit: 2/2.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#1440 ready for review at 0a5c4a46 — flint priced as the ratio 14/49 (its split is not a 1/N), with the rows that would have caught it: 1,078.00 MiB at ctx 8192 and 14,966.00 MiB at 262144, and the estimate now grows with the context (it was constant, which is how the same 24.07 GiB at 4096/8192/262144 got through). ctest -R mem_admit 2/2, copyright.py rc 0. Unmeasured and said so in the body: no flint GGUF exists on this box, so the window size (and the real GiB) is still open — only the pricing rule is verified.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: CHANGES at 0a5c4a4631fdac8d4efbedf21ac5cfa395589da0

This is the third open fix for #1425 (I filed it), and it fixes a symptom of the root cause the other two already fix. Its stated premise is also false on main.

1. "a GGUF that carries attention.sliding_window_pattern … already wins over the table (unchanged)" isn't true on main for flint.

  • gguf-py's add_sliding_window_pattern(Sequence[bool]) writes the per-layer pattern as ARRAY of BOOL (type 7).
  • read_gguf_header's is_int is t <= 5 || t == 10 || t == 11, so the array is skipped and the "file wins" branch never runs for flint (or for command-r, exaone, zaya and the others that emit bools).
  • Measured with a gguf-py-written flint header against main's app/mem_admit.h: pattern NOT PARSED, KV a flat 0.431 GiB from 8K to 256K.
  • That root cause is what #1433 (READY) and #1429 (READY, a superset with the lower-bound flag) fix, by reading bool arrays.

2. A hard-coded 14/49 is the wrong layer for this.

  • llama.cpp gives flint no fixed interval: src/models/flint.cpp reads the pattern from the pack with get_arr(…, required=true). So a flint pack with a different split would be priced wrong by this entry, and the PR's own comment admits as much ("a pack with a different split needs its own entry").
  • Once #1433 or #1429 lands, the file's pattern wins and this entry only runs for a flint pack with no pattern, which llama.cpp itself refuses to load. It becomes dead code with a misleading number.

3. Merge mechanics:

  • git merge-tree against #1433 conflicts.
  • The branch also carries a6be23a, a pre-squash copy of #1415. Its patch-id 8a02eb4a equals main's 8e66309, so the merge with main is a clean no-op, but it puts q4nx_semantics.c, q4nx_mrope_test.c, safetensors_to_q4nx.py and a CMake block in this PR's file list, where they don't belong. Rebasing onto main drops it.

Suggested resolution:

  • close this one in favour of #1429 (or #1433), which fix the reader all three are working around;
  • or, if you want a test row that the estimate grows with context at a 14/49 split, add it to whichever lands, written with a bool pattern array, so the test exercises the path real packs take.

What I ran: the patch-id comparison of a6be23a against 8e66309; git merge-tree against main (clean) and #1433 (conflict); and, earlier, the gguf-py bool-array probe against main's reader (in my #1429 and #1433 reviews).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Superseded by #1433 (merged 3a799f8f), closing. That PR found the better root cause and it is not the one I fixed: mem_admit did not read bool arrays (GGUF type 7), so a GGUF's attention.sliding_window_pattern — which flint's loader requires — was never counted. With the array read, flint takes its own pattern from the file, which is data-driven and does not need a hardcoded ratio. Mine hardcoded 14/49 from the catalog row, which would go stale on any repack.

For the record, my rows were exact for the rule I implemented (1,078.00 MiB at ctx 8192, 14,966.00 MiB at 262144, and the 'grows with the context' check that the defect would have failed), and #1433's fix makes that row pass without the table entry. Closing rather than rebasing a redundant branch — the owner's pile-up is not helped by two PRs for one defect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mem_admit: flint is not in model_need()'s sliding-window list, so its KV estimate stays a lower bound at any context

1 participant