Skip to content

Stop the slot re-fit tests encoding the fit floor as a literal - #9845

Merged
danielhanchen merged 2 commits into
mainfrom
robustify-slot-refit-fit-floor-tests
Aug 27, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
robustify-slot-refit-fit-floor-tests

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Why

These three files pin placement outcomes that are arithmetic against _FIT_MIN_CTX, so moving the floor re-edits the tests - and the re-edit is indistinguishable from noticing that placement changed. #9492 already moved it once. test_weights_that_fit_nowhere_still_offload reads _AUTO_OFFLOAD_CTX for exactly this reason; this extends that treatment to its neighbours.

This is not a fix for a red test on main - all 91 pass today. It is groundwork so the next floor change reports its cause instead of its symptom. #9822 is the live example: it raises _FIT_MIN_CTX 4096 -> 8192 and turns 51 of these red, most of them opaquely.

No production code changes.

What

  • test_the_reduction_still_pins_without_a_native_context spelled the floor as 4096 and pinned the surviving slot count. Now reads the constant, and asserts that a reduction happened rather than which number it landed on.
  • The _AUTO_OFFLOAD_CTX sweeps were literals including values below a raised floor, so they drove the planner through a state the product never reaches - _AUTO_OFFLOAD_CTX is documented to sit at or above _FIT_MIN_CTX. Now multiples of the floor: identical values today (4096 x [1,2,4,8]), still the intended sweep after a move.
  • The checkpoint reserve test asserted the reserve is paid in context. There are three ways to pay - context, a slot, or residency - and at 16 and 32 checkpoints this fixture already offloads, where the old assertion held only because the offload fallback happens to be shorter than the resident plan. I found this by writing the two-way version first and watching it fail. All three are now named, so "nothing was charged" stays distinguishable from "a different axis paid".
  • The platform matrix shares one fixture across nine cells, and whether it reaches the re-fit at all depends on the floor. A floor change turns all nine red with assert 0 > 0, which reads like the re-fit was deleted when the block is untouched and only the fixture went stale. Added an anti-vacuity test that names the fixture, the floor and the plan the planner actually returned:
the shared fixture (10200 MiB of weights on a 12288 MiB card, asking 4 slots) no
longer produces a reducible plan at _FIT_MIN_CTX=8192. The planner returned
{'ctx': 8192, 'slots': 4, 'fit': 'on', ...}. Resize the fixture into the
reducible band -- the nine cells below are about WHICH hosts may re-fit, and
cannot answer that question from a fixture where nobody can.

What this deliberately does not do

Simulating #9822's bump locally, the RESCUED band still fails after these changes:

test_a_load_the_reduction_can_rescue_never_offloads
  AssertionError: a placeable load was handed to --fit offload

That is correct and I have left it. Those rows are the --fit off bands #9492/#6718 exist to protect, and the failure is the ~3x decode collapse being reported, not a stale expectation. Robustifying a test must not mean sanding off the part that objects. Raised separately on #9822.

Verification

pytest studio/backend/tests/test_slot_reduction_context_refit.py test_slot_refit_platform_matrix.py test_slot_refit_ctx_checkpoints.py test_auto_offload_ctx_fit_floor_coupling.py -> 91 passed (90 before, +1 anti-vacuity test).

Also re-ran with _FIT_MIN_CTX locally forced to 8192 to confirm the new diagnostics fire and read correctly, then restored it. llama_cpp.py is untouched in this PR.

These three files pin placement outcomes that are arithmetic against
_FIT_MIN_CTX, so moving the floor re-edits the tests and the re-edit is
indistinguishable from noticing that placement changed. #9492 already moved it
once; test_weights_that_fit_nowhere_still_offload reads _AUTO_OFFLOAD_CTX for
exactly this reason, and this extends that treatment.

- test_the_reduction_still_pins_without_a_native_context read the floor as 4096
  and pinned the surviving slot count. Read the constant, and assert a reduction
  happened rather than which number it landed on.
- The _AUTO_OFFLOAD_CTX sweeps were literals including values below a raised
  floor, so they drove the planner through a state the product never reaches
  (_AUTO_OFFLOAD_CTX is documented to sit at or above _FIT_MIN_CTX). Expressed
  as multiples of the floor: identical values today, still intended after a move.
- The checkpoint reserve test asserted the reserve is paid in context. There are
  three ways to pay -- context, a slot, or residency -- and at 16 and 32
  checkpoints this fixture already offloads, where the old assertion held only
  because the offload fallback happens to be shorter. Name all three so 'nothing
  was charged' stays distinguishable from 'a different axis paid'.
- The platform matrix shares one fixture across nine cells, and whether it
  reaches the re-fit at all depends on the floor. A floor change turned all nine
  red with 'assert 0 > 0', which reads like the re-fit was deleted when the block
  is untouched. Added an anti-vacuity test that names the fixture, the floor and
  the plan the planner actually returned, and pointed the cells at it.

No production change: these pass at the current floor and report the cause
rather than the symptom at any other.
@danielhanchen
danielhanchen merged commit 5517565 into main Aug 27, 2026
31 of 33 checks passed
@danielhanchen
danielhanchen deleted the robustify-slot-refit-fit-floor-tests branch August 27, 2026 09:35
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.

2 participants