Skip to content

Put the smart offload planner back behind its flag - #9862

Merged
danielhanchen merged 1 commit into
mainfrom
smart-offload-back-to-opt-in
Aug 27, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
smart-offload-back-to-opt-in

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

Addresses the default in #9861.

What

UNSLOTH_SMART_OFFLOAD goes back to opt-in.

Why

Reading the planner to check #9861's report turned up something larger than the report claims: the cost model does not gate the decision at all.

Every abstain in offload_planner.py is a feasibility abstain -- layout incomplete (:385), unified memory (:390), no creditable VRAM (:393), no usable context (:399), per-device shortfall (:699, :740), multi-device partial spill (:677). There is no cost-based abstain anywhere. If a spill covers the deficit, it is taken. _spill_penalty_ms (:198) is computed once at :838 into Plan.predicted_gen_penalty_ms, and that field is read only by tests. The planner never asks whether spilling beats letting --fit on place the model.

Two things follow, and both are independent of how the benchmark was shaped:

  1. rank() in offload_cost_model.py scores prefill plus generation, and prefill_penalty_ms_per_token is implemented and calibrated. Neither has a caller. Prefill is unpriced, which is why Smart offload planner is slower than --fit on in 40 of 43 measured cells on a 6-core desktop #9861 measured it slower in 43 of 43 planned cells with no exception.
  2. Because it spills whenever it can rather than when it should, it spills in cells where --fit on kept the model fully resident. Smart offload planner is slower than --fit on in 40 of 43 measured cells on a 6-core desktop #9861 found two.

A gate that never consults its own cost model should not be on by default.

What I am NOT resting this on

The report's generation column shows 40 of 43 cells slower, and I quoted that in an earlier version of this description. The reporter has since disclosed the limitation themselves: the cache is allocated at 32768 but only about 2.2K tokens are ever live, so those cells are measured "where the planner pays in full and collects almost nothing", and they ask that the number be read as the short-sequence end of the range. That is fair and I am not leaning on it.

It cuts at our own evidence too, which is the part worth saying out loud. The Colab matrix behind #9779 ran at ctx=4096, npred=16, depth=0 (temp/cloudrun/nb/offload_bench*.ipynb). depth=0 is an empty KV cache. So the thing this planner exists to protect -- a live cache -- was not really measured on either side of the argument. A depth sweep is the next piece of work.

What this does not change

The planner still works when asked for. Every path that would have consulted it falls through to --fit on, which #9861 measured at 0.93x to 1.16x across all 33 cells where the planner declined, so the fallback is neutral there.

For the record, two of the report's other observations: the host thread count IS already wired (HostProfile(threads = os.cpu_count() or 1) at llama_cpp.py:25105, about 3.9x generation multiplier at 12 threads), so the model mispredicts with information it has rather than for lack of it; and the two-GPU result, 0 plans in 13 cells, is the deliberate partial-spill abstain at offload_planner.py:658 working as designed, not a gap.

Tests

test_the_planner_is_on_by_default becomes test_the_planner_is_off_by_default, and asserts against a load that WOULD spill rather than only a roomy one, so the default cannot flip back unnoticed behind a load that plans nothing either way. It also checks the same tight load still plans when the flag is set explicitly, so this moved the default and nothing else.

508 offload tests pass.

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.

1 participant