Repository navigation
mem_admit: flint's 14 full-attention layers are priced at the context (Fixes #1425) - #1440
bong-water-water-bong wants to merge 2 commits into
Conversation
…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.
|
#1440 ready for review at |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
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'sis_intist <= 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.cppreads the pattern from the pack withget_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-treeagainst #1433 conflicts.- The branch also carries
a6be23a, a pre-squash copy of #1415. Its patch-id8a02eb4aequals main's8e66309, so the merge with main is a clean no-op, but it putsq4nx_semantics.c,q4nx_mrope_test.c,safetensors_to_q4nx.pyand 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).
|
Superseded by #1433 (merged For the record, my rows were exact for the rule I implemented ( |
What was wrong
app/mem_admit.hprices the share of full-attention layers from a per-architecture table ("one layer in N") and fallsback to 0 for an architecture it does not know — documented as a lower bound.
flintis not on the list, and itssplit 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 measuredthe 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
flintgets its own entry, as the ratio 14/49, with a comment saying why it is a fraction rather than a 1/N andthat 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)262144 > 3 × 8192— the row that would have caught the defect, since the estimate used to be constantctest -R mem_admit→ 2/2 (mem_admitandmem_admit_route),tools/copyright.py --checkrc 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
4608in the test changes; the table entry doesnot.
Fixes #1425.