Repository navigation
Put the smart offload planner back behind its flag - #9862
Merged
Merged
Conversation
This was referenced Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the default in #9861.
What
UNSLOTH_SMART_OFFLOADgoes 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.pyis 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 intoPlan.predicted_gen_penalty_ms, and that field is read only by tests. The planner never asks whether spilling beats letting--fit onplace the model.Two things follow, and both are independent of how the benchmark was shaped:
rank()inoffload_cost_model.pyscores prefill plus generation, andprefill_penalty_ms_per_tokenis 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.--fit onkept 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=0is 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)atllama_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 atoffload_planner.py:658working as designed, not a gap.Tests
test_the_planner_is_on_by_defaultbecomestest_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.