Skip to content

Save routing harness: define what the GGUF-packed save paths read, and guard every global the generic save loads (red on main since #20022) - #20075

Merged
danielhanchen merged 1 commit into
mainfrom
ci-save-routing-harness
Nov 28, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-save-routing-harness

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

tests/saving/test_save_method_lora_routing.py has 18 failures on main since #20022 (Train LoRA on packed GGUF weights), in every Core job (HF 4.57.6 + TRL<1 and HF latest + TRL latest). The most recent staging example is #20071, which does not touch saving:

NameError: name 'ExitStack' is not defined
AssertionError: unsloth_generic_save calls ['_shard_bytes'] from save.py, which the routing harness neither loads nor stubs

The routing harness execs unsloth_generic_save from save.py source into a namespace it builds by hand. #20022 wrapped the merge in an ExitStack (a module-level import) and added a GGUF-packed branch that calls _shard_bytes and reads _GGUF_PACKED_STATE_DICT_REFUSAL. The harness defines none of these, so every routing test that reaches the merge dies with a NameError before asserting anything. #20022 is correct, and the harness is behind it.

Changes

  • The harness now defines:
    • ExitStack;
    • _shard_bytes and the refusal constant;
    • sys;
    • save_inkling2_merged_16bit, as an overridable default that tests replace when they exercise the Inkling 2 writer.
  • unsloth.models.gguf_packed, which the save imports lazily, is stubbed in sys.modules for each routing test, the same way unsloth_zoo.saving_utils already is. No fixture is GGUF-packed:
  • _shard_bytes is listed as a stubbed helper, so the existing helper coverage check passes for the right reason.
  • New guard test_every_global_the_generic_save_reads_is_in_the_harness. The existing helper check only sees calls to save.py's own functions, so it could not see a module-level import like ExitStack. The new guard walks the bytecode of the exec'd unsloth_generic_save (nested code objects included) for every LOAD_GLOBAL, and fails if the harness namespace or builtins do not define one. A future import or constant added to the save then fails one test that names it, instead of a wall of NameErrors.

Verification

  • On main, 18 tests fail. With this change the file passes: 112 passed, on both transformers 5.18 and 4.57.6.
  • Sabotage check: removing ExitStack from the harness fails the new guard with unsloth_generic_save reads ['ExitStack'], which the routing harness does not define.
  • Only the test file changes. unsloth/save.py is untouched.

…d guard every global the generic save loads
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T23:59:25.309912Z f7837fd Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: f7837fd9cd

ℹ️ 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 29688d1 into main Nov 28, 2026
1 of 17 checks passed
@danielhanchen
danielhanchen deleted the ci-save-routing-harness branch November 28, 2026 00:01
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