Skip to content

Let a remote GGUF estimate be priced without its compute reserve - #8641

Merged
danielhanchen merged 1 commit into
mainfrom
fix-remote-gguf-estimate-tests
Aug 13, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix-remote-gguf-estimate-tests

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Backend CI is red on main, and has been since #8524.

That PR gave a non-diffusion remote estimate a default ubatch and changed the output-buffer slot count from n_parallel - 1 to max(1, n_parallel), so every single-slot remote estimate now carries about 0.58 GB of compute reserve. Ten tests in studio/backend/tests/test_chat_load_during_training.py patch _estimate_gguf_kv_gb to 0.0 and then assert an exact GB total, and they were not updated with it:

AssertionError: 4.575732421875 != 4.0 within 6 places (0.5757324218750002 difference)

with the same 0.5757 offset at 10, 12 and 14 GB.

The estimator is right and the tests are stale, so the arithmetic is untouched here. The remote compute reserve moves into _remote_gguf_compute_reserve_gb, a pure extraction from _estimate_gguf_required_gb, and the tests hold it at zero the way they already hold _estimate_gguf_kv_gb at zero. Anything pricing something other than the model itself, a drafter for instance, can now do the same.

studio/backend/tests/test_chat_load_during_training.py: 118 passed, was 8 failed / 110 passed.

Backend CI is red on main. #8524 gave a non-diffusion remote estimate a
default ubatch and changed the output-buffer slot count from n_parallel-1
to max(1, n_parallel), so every single-slot remote estimate now carries
about 0.58 GB of compute reserve. Ten tests that patch _estimate_gguf_kv_gb
to zero and then assert an exact GB total were not updated with it, and
have been failing ever since with 4.575732421875 != 4.0 and the same
offset at 10, 12 and 14 GB.

The estimator is right and the tests are stale, so the arithmetic is
untouched: the reserve moves into _remote_gguf_compute_reserve_gb, a pure
extraction, and the tests hold it at zero the way they already hold
_estimate_gguf_kv_gb at zero. Anything pricing something other than the
model itself, a drafter for instance, can now do the same.

tests/test_chat_load_during_training.py: 118 passed, was 8 failed.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: bf5ef602af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member Author

CI status, since the red checks here are not this PRs.

The four Backend CI jobs and Chat UI Tests fail with ValueError: Responses event type is missing, in tests/test_gemini_provider.py and tests/test_external_provider_usage_chunk.py. I reproduced both on a clean checkout of main at 22cb12e, with nothing from this branch applied. The Responses reader drops every event: line and then asks for a type the payload need not carry, so event: response.completed with data: {} aborts a stream it should have completed.

That one is #8608, which is open and already carries the fix.

The two are red on each other: #8608 fails the eight VRAM assertions this PR fixes (4.575732421875 != 4.0 and the same 0.5757 offset at 10, 12, 13 and 14 GB), and this PR fails the SSE assertions #8608 fixes. Either order works, and main is green once both are in.

The earlier pip scan-packages :: studio failure was a runner shutdown, exit 143 mid-download, and passed on a re-run.

@danielhanchen
danielhanchen merged commit d4139d6 into main Aug 13, 2026
56 of 62 checks passed
@danielhanchen
danielhanchen deleted the fix-remote-gguf-estimate-tests branch August 13, 2026 06:37
danielhanchen added a commit that referenced this pull request Aug 13, 2026
…them

#8524 changed the remote output-buffer slot count from n_parallel - 1 to
max(1, n_parallel), so every single-slot uncached estimate gained about 0.58 GB.
#8641 then extracted the reserve and held it at zero in the drafter tests, which
turned Backend CI green without settling whether the charge is right.

It is not. The local branch, which reads the header and is fitted to measured
allocations, charges act_scratch + output_buffer * (slots - 1) for a chat model:
{1:36, 2:492, 4:1388, 8:3220} MiB, so one slot reserves the scratch and no output
buffer. The remote branch stands in for that same computation on a model whose
header is not readable yet, and the two are supposed to agree: an existing comment
in the same function calls out the case where "the same model 409s while remote and
loads once cached" as the thing to avoid. Charging the first slot made every
uncached chat load read 0.58 GB heavier than the identical cached one, on an
estimator whose only consumer refuses the load when it does not fit.

So the slot count goes back to matching the local branch, and the activation
scratch it was standing in for is charged explicitly, at a ceiling the way the
vocab already is. Without that a one-slot remote load would carry the KQ mask
alone, which is the same divergence pointing the other way.

Measured against _estimate_compute_buffer_bytes for a 152k-vocab, 5120-wide chat
model at the default micro-batch, remote now sits just above cached rather than
half a gigabyte above it:

  1 slot   cached 0.0449 GiB   remote 0.0726 GiB   (+0.028)
  2 slots  cached 0.3782 GiB   remote 0.6476 GiB   (+0.269)

Known residual: a remote EMBEDDING GGUF now reads low, by 0.31 GB at one slot for
a 152k vocab, because that branch charges an output buffer at every slot and this
one cannot tell an embedding repo from a chat repo before the header is readable.
#8524's own comment records that there is no reliable pre-load probe for it. The
under-charge is bounded by the model's real vocab and those repos are small, which
is the same small-half trade the activation scratch used to be, against half a
gigabyte of headroom taken from every chat load.
danielhanchen added a commit that referenced this pull request Aug 13, 2026
* tests: pin the remote GGUF compute reserve

#8524 changed the output-buffer slot count from max(0, n_parallel - 1) to max(1, n_parallel) and
gave a non-diffusion remote estimate a default micro-batch, which is right: llama-server
allocates an output buffer for the one slot it runs, and the old count reserved nothing for it.
Ten tests caught the change only as an unexplained 0.58 GB and were red on main until #8641.

#8641 resolved that by extracting the term so those tests can hold it at zero, the way they
already hold _estimate_gguf_kv_gb at zero. That is the right call for them, but it leaves the
arithmetic with nothing asserting it: all fifteen references to _remote_gguf_compute_reserve_gb
in the suite patch it, and a grep for the constants it is built from finds no test at all. It
decides whether a load is refused, so it should not be free to drift.

Two cases, shape rather than magnitude: the single-slot floor, and diffusion charging nothing.
The single-slot total is spelled out because the reserve is linear in the slot count, so any two
samples are one buffer apart under the old formula and the new one alike, and only an absolute
anchor sees the floor. Constants come from the module, so retuning a safety factor moves the test
with the code while dropping a term still fails it.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* tests: drop llama batch env overrides in the compute reserve helper

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* tests: tighten comments in the compute reserve tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Trim redundant sentence in compute reserve test docstring

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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