Skip to content

Restore the inheritance-before-guard ordering assertion in the gguf order test - #7251

Merged
danielhanchen merged 1 commit into
mainfrom
fix/gguf-order-test-inheritance
Jul 25, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/gguf-order-test-inheritance

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Jul 19, 2026 •

Copy link
Copy Markdown
Member

What

Restores the ordering assertion that the gguf order fix on main dropped: _resolve_inherited_extra_args must run before the GGUF branch, because the inherited llama_extra_args (a carried --no-mmproj) shapes the hub guard's require_mmproj. Without it a future reorder could reject a load over an mmproj download the inherited arguments would disable.

How

  • Anchored on the call form = _resolve_inherited_extra_args( so the assertion pins the endpoint's call site; the bare name would match the function definition, which always precedes the endpoint, making the check vacuous.
  • Corrected the comment that misattributed the inheritance site to _guard_chat_load_against_training.

Full file passes: 32 tests. This PR was rebased onto current main; it now contains only this restoration.

@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: 011c6e8249

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


# Pass-through inheritance runs before the GGUF branch, so a carried
# --no-mmproj shapes the hub guard's companion requirement.
assert source.index("_resolve_inherited_extra_args(") < source.index("if config.is_gguf:")

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 Assert the inheritance call rather than its function definition

str.index("_resolve_inherited_extra_args(") resolves to the helper's definition (currently at routes/inference.py:4056), which is necessarily before the GGUF branch even if the actual invocation is moved after it or removed. Thus this updated test will pass while the ordering property described in its comment is broken; constrain the search to the invocation in the load handler (for example, start searching after that handler begins or distinguish the call from def).

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, the bare name matched the function definition at line 4056, which always precedes the endpoint, so the check was vacuous. Fixed in fd32e62: the anchor is now "= _resolve_inherited_extra_args(", which pins the first call site inside the load endpoint (line 4505), the statement the test is meant to order against the GGUF branch. 32 tests pass.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates a test in test_gguf_load_cache_reuse.py to verify that _resolve_inherited_extra_args is executed before the GGUF branch. The reviewer noted that the added assertion matches the function definition rather than its actual call, making the test trivially true, and provided a code suggestion to target the assignment call instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.


# Pass-through inheritance runs before the GGUF branch, so a carried
# --no-mmproj shapes the hub guard's companion requirement.
assert source.index("_resolve_inherited_extra_args(") < source.index("if config.is_gguf:")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The assertion source.index("_resolve_inherited_extra_args(") matches the function definition of _resolve_inherited_extra_args (at line 4056 in inference.py) rather than the actual call to it (at line 4505). Since the definition is naturally placed before the GGUF branch, this assertion is trivially true and does not verify that the pass-through inheritance call runs before the GGUF branch.

To make the test robust and verify the actual execution order, assert the index of the assignment/call instead.

Suggested change
assert source.index("_resolve_inherited_extra_args(") < source.index("if config.is_gguf:")
assert source.index("extra_llama_args = _resolve_inherited_extra_args(") < source.index("if config.is_gguf:")

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.

Same catch as the Codex comment above, and correct. Fixed in fd32e62 by anchoring on the call form "= _resolve_inherited_extra_args(" so the assertion orders the endpoint's call site, not the definition.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: fd32e62480

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

The gguf order fix that landed on main dropped the only assertion
covering the prerequisite that llama_extra_args inheritance runs before
the GGUF branch: the inherited value (a carried --no-mmproj) shapes the
hub guard's require_mmproj, so a future reorder could reject a load
over an mmproj download the inherited arguments would disable. The
comment also misattributed the inheritance site to
_guard_chat_load_against_training.

The assertion is restored anchored on the call form
"= _resolve_inherited_extra_args(", which pins the endpoint's call site
(the bare name would match the function definition, which always
precedes the endpoint, making the check vacuous), and the comment now
names the real inheritance site. 32 tests pass.
@danielhanchen danielhanchen changed the title Fix the gguf load-order source check after the extra-args inheritance move Restore the inheritance-before-guard ordering assertion in the gguf order test Jul 20, 2026
@danielhanchen
danielhanchen force-pushed the fix/gguf-order-test-inheritance branch from fd32e62 to 16e6bca Compare July 20, 2026 06:06
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 16e6bca247

ℹ️ 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 95f42bc into main Jul 25, 2026
39 checks passed
@danielhanchen
danielhanchen deleted the fix/gguf-order-test-inheritance branch July 25, 2026 05:34
danielhanchen added a commit that referenced this pull request Jul 26, 2026
… structlog stub order-independent (#7442)

* studio: fix Backend CI red on main from an ambiguous ordering anchor

test_load_marker_precedes_hub_guard_and_unload fails on main, so every
open PR against the repo inherits the failure.

Root cause. #7239 (a7761e1) reworked the GGUF GPU-pool validation in
_load_model_impl from "if config.is_gguf and effective_gpu_ids is not
None:" to a bare "if config.is_gguf:", placed earlier in the function
than the GGUF load branch. The test anchors on
source.index("if config.is_gguf:"), a first-match search, so it silently
re-anchored onto the GPU-pool statement. #7251 (95f42bc) then restored
the assertion "= _resolve_inherited_extra_args(" before
"if config.is_gguf:" against a tree where that anchor already pointed at
the wrong statement, and main went red. Checking out 95f42bc and
running the suite reproduces the same single failure.

The code is correct. _resolve_inherited_extra_args still runs before the
GGUF load branch and before the hub-download guard that consumes
extra_llama_args for require_mmproj, so the guarantee #7251 protects is
intact; only the assertion is wrong.

Fix. Assert that guarantee behaviourally instead of by source offsets.
The new test drives _load_model_impl over a vision GGUF with a stored
--no-mmproj from a previous same-model load and captures the
require_mmproj the hub guard is called with: inherited --no-mmproj gives
False, nothing to inherit gives True, and an explicit request list wins
over the stored one both ways. Moving the resolution call after the
guard makes the inherited case report True and the test fails, so it
detects the reorder the old assertion was meant to catch, without
depending on how many "if config.is_gguf:" statements the endpoint has.

The surviving marker-before-guard-before-unload assertion had the same
ambiguous anchor for its slice start, silently widening the slice past
the GPU-pool block. It now slices from the "if config.is_gguf:" nearest
above the in-flight marker, which pins the load branch.

The structlog test stub gains a get_logger factory so routes/inference.py
is importable when structlog is absent.

34 pass in tests/test_gguf_load_cache_reuse.py (was 32 pass, 1 fail);
350 pass across it plus test_llama_cpp_mmproj_fallback.py and
test_llama_cpp_mtp_detection.py. A full backend run before and after is
identical apart from this test going from fail to pass.

* studio/tests: repair a pre-existing bare structlog stub before importing routes

* studio/tests: tighten the comments on the new load-ordering coverage

* Tighten comments on the load-ordering coverage for PR #7442
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