Repository navigation
tools: repair q3pp model and source derivation - #1072
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: the new slot check refuses valid runs whose context limits the allocated batch rows.
Must fix
1. Apply the slot limit to the allocated rows (kind A)
tools/ref/q3pp.py:300 rejects expert_used_count=16, P=512, --ctx 768 with the default batch of 4096. The engine allocates min(u, ctx) rows (crates/gpu/src/arch/qwen3moe/ubatch.rs:357): this run needs 768 × 16 = 12,288 slots [derived], within 40,960. The planner exits 64 before a valid profiling run.
Fix this now so the new tests do not establish the wrong accepted range. Replace the batch/context check with:
ctx = int(opt(argv, "--ctx", 0)) or None
U = int(opt(argv, "--ubatch", c["ubatch_planned"]))
rows = U if ctx is None else min(U, ctx)
if not 1 <= U <= c["ubatch_planned"] or rows > ubatch_max:
refuse(f"[derive] a ubatch of {U} tokens allocates {rows} rows at {n_used} experts per token "
f"(the arena takes 1..={ubatch_max} rows); set --ubatch within that limit", 64)Append this case to test_model_dependent_slot_limit; also check the context boundary at 2560 versus 2561 rows:
p = self.plan(used=16, tokens=512, extra=("--ctx", "768"))
self.assertEqual((p["ubatch"], p["t"], p["p0"]), ("4096", "512", "0"))The replacement preserves all 11 plan cases from the four existing tests. It accepts contexts of 768 and 2560 rows and rejects 2561 rows with the default batch and 16 experts per token.
Checked
Duplicates: one finding; no duplicate findings or inline suggestions.
Complexity: no Rust file changed; the changed functions are offline tooling.
Silent failure: missing scope, invalid expert count and rejected batches have named refusal paths before plan output.
Tests: replayed all 11 existing plan cases with model and plan I/O in memory against current code and the replacement. The short-context case fails with the current guard and passes with the replacement; the context boundary and invalid batch checks hold.
Gates: no numeric gate pin moved.
Escape catalog: no C1–C4 pattern matched.
Notes
Dryer and crapper did not run because no Rust file changed.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
…min(ubatch, ctx), against the arena's expert slots
There was a problem hiding this comment.
Since the last review: must-fix 1 is fixed at tools/ref/q3pp.py:301. The slot limit now applies to allocated rows, with context-boundary regressions.
Verdict: CLEAN: the revised check matches the engine's allocation and preserves the batch-size bounds.
Checked
Duplicates: 0 new functions, types or constants in the incremental diff; no dryer pairs.
Complexity: only offline planner logic changed; no Rust functions or hot paths changed.
Silent failure: 3 sites followed: context default, allocated-row calculation and refusal. Invalid batches and slot overflows exit 64 before plan output; insufficient context is also refused.
Tests: replayed the four self-tests with model and plan I/O in memory; all 16 plan calls pass. Six mutants at tools/ref/q3pp.py:301–302 turn the suite red: ignore context, use max, reject the exact slot boundary, drop either batch bound, or drop the slot check.
Gates: no numeric pin, tolerance or gate removed or moved.
Escape catalog: no C1–C4 pattern matched.
Notes
Dryer and crapper did not run because no Rust file changed.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
@wsj040303 Thanks for the contribution. The review is done, so I'm merging this. |
|
환영합니다!!! |
What and why
The q3pp plan command exits 3 on current main because it looks for the removed N_USED constant and a literal UBATCH declaration. Read the expert count from GGUF metadata, follow UBATCH to its placement owner, and bound requested batches by the model's slots per token. The engine's default remains unchanged; an oversized default requires an explicit smaller --ubatch.
The current attention call moved through the shared head-128 path, and the kernel file now contains several attention bodies. Update those source checks and count the four MMA sites only inside prefill_128_walk. Register source-tree plan regressions with the existing tool self-tests.
Fixes #1056. Fixes #1061.
Release notes: Fixed — q3pp profiling plans derive batch limits from the model header and current source owners.
Code shape
Duplication found or removed: none.
What I ran
Linux x86_64, Ryzen 5 7500F, Python 3.14, Rust 1.99.1; GNU coreutils and NumPy/Pillow for the repository's shell/Python self-tests.
No GPU timing or counter measurement is claimed; this change repairs offline plan generation and its source checks.