Skip to content

tests: pin the remote GGUF compute reserve - #8660

Merged
danielhanchen merged 7 commits into
mainfrom
tests/cover-the-remote-gguf-compute-reserve
Aug 13, 2026
Merged

danielhanchen merged 7 commits into
mainfrom
tests/cover-the-remote-gguf-compute-reserve

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

_remote_gguf_compute_reserve_gb decides how much headroom a remote GGUF estimate reserves, and therefore whether a load is refused. Nothing asserts it.

All fifteen references to it in test_chat_load_during_training.py are patch(..., return_value = 0.0), and grepping the suite for the constants it is built from (_ASSUMED_MAX_VOCAB, out_buffer, output_slots) returns nothing.

How it got that way

#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. That is correct: 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 4.575732421875 != 4.0 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, and it is why this PR adds coverage rather than changing anything.

Changes

Two cases in a new TestRemoteGgufComputeReserve, pinning shape rather than magnitude:

  • The single-slot floor. The total is spelled out rather than compared against a neighbouring call, because the reserve is linear in the slot count: any two samples are one buffer apart under the old formula and the new one alike, so only an absolute anchor sees the floor. Verified by reverting _out_slots to max(0, n_parallel - 1), where this test fails and the difference-based version I wrote first still passed.
  • Diffusion reserves nothing, since the default micro-batch is a llama-server notion and charging one would refuse loads that fit.

Constants come from the module, so retuning a safety factor moves the test with the code while dropping a term still fails it.

Validation

tests/test_chat_load_during_training.py: 120 passed. Ruff clean. No production code touched.

#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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd42ee02e9

ℹ️ 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".

cls.route = _load_inference_route()

def _reserve(self, **kwargs):
return self.route._remote_gguf_compute_reserve_gb(max_seq_length = 4096, **kwargs)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear llama batch overrides before asserting defaults

When the test suite runs with LLAMA_ARG_BATCH or LLAMA_ARG_UBATCH set, this helper leaves n_batch and n_ubatch unspecified, so _remote_gguf_compute_reserve_gb obtains a non-default effective micro-batch from os.environ via _extra_args_n_ubatch. The assertions nevertheless calculate their expected values from _DEFAULT_N_UBATCH, producing a false failure unrelated to the slot-count behavior under test; clear these variables or pass explicit batch and micro-batch values.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, fixed in 67971e8. _extra_args_n_ubatch reads LLAMA_ARG_BATCH and LLAMA_ARG_UBATCH off os.environ, so either one exported on the runner moves the effective micro-batch away from _DEFAULT_N_UBATCH and the assertions fail for a reason unrelated to the slot count. The helper now drops both for the duration of the call. Confirmed by running the class with LLAMA_ARG_UBATCH=1024 set: it failed before the change and passes after.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 84047894e4

ℹ️ 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
danielhanchen merged commit 965f7b4 into main Aug 13, 2026
38 of 41 checks passed
@danielhanchen
danielhanchen deleted the tests/cover-the-remote-gguf-compute-reserve branch August 13, 2026 10:10
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