Skip to content

tests: anchor the gguf ordering assertion on the branch that owns the marker - #7443

Merged
danielhanchen merged 1 commit into
mainfrom
fix-gguf-order-assertion
Jul 25, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix-gguf-order-assertion

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

test_load_marker_precedes_hub_guard_and_unload fails on main, which turns Repo tests (CPU) and the Python 3.10 through 3.13 backend jobs red on every branch.

What happens

The assertion added in #7251 is:

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

_load_model_impl contains more than one if config.is_gguf:, and str.index returns the first match in the file. That first match belongs to an earlier check, not to the branch the assertion is reasoning about:

landmark line offset
earlier if config.is_gguf: 4508 185014
= _resolve_inherited_extra_args( 4543 186995
if config.is_gguf: holding the load marker 4567 187973

So the comparison reads 186995 < 185014 and fails, even though the ordering it means to check is satisfied: the inheritance call at 4543 does precede the branch at 4567.

The fix

Locate the branch from the load marker itself, which is the landmark the rest of the test already relies on, then compare against that. The slice the following assertions use is anchored the same way, which tightens them as well: they previously searched from the earlier branch to end of file.

The invariant from #7251 is unchanged, and still has teeth. Moving the inheritance call after the branch makes the assertion fail.

Verification

python -m pytest tests/test_gguf_load_cache_reuse.py in studio/backend: 33 passed, against 1 failed / 32 passed on main.

… marker

_load_model_impl contains more than one `if config.is_gguf:`, so
source.index() returned the earlier one, which belongs to a different check
than the branch the assertion is reasoning about. The inheritance call sits at
line 4543, the earlier branch at 4508 and the branch holding the load marker at
4567, so the comparison read 186995 < 185014 and failed on main.

The branch is now located from the load marker itself, which is the landmark
the rest of the test already relies on, so the assertion compares the
inheritance call against the branch that actually guards it. The slice used by
the following assertions is anchored the same way, which also tightens them:
they previously searched from the earlier branch to end of file.

The invariant is unchanged and still has teeth: moving the inheritance call
after the branch makes the assertion fail.
@danielhanchen
danielhanchen merged commit 85f6231 into main Jul 25, 2026
21 of 38 checks passed
@danielhanchen
danielhanchen deleted the fix-gguf-order-assertion branch July 25, 2026 11:42
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.

2 participants