Skip to content

Saving routing tests: stub the NF4 dequant cache release - #18367

Merged
danielhanchen merged 1 commit into
mainfrom
ci/save-routing-stub-nf4-cache-release
Nov 18, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci/save-routing-stub-nf4-cache-release

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Six tests in tests/saving/test_save_method_lora_routing.py fail on main in every Core job (HF default, 4.57.6 and latest):

NameError: name '_release_nf4_dequant_cache' is not defined
FAILED test_unsloth_save_model_guards_a_respelled_merged_4bit[merged-4bit]   (and 2 more params)
FAILED test_the_adapter_save_forwards_a_real_safe_serialization
FAILED test_an_adapter_push_survives_a_transformers_that_dropped_the_keywords
FAILED test_an_adapter_push_still_passes_every_keyword_a_transformers_4_accepts

Seen on the staging runs for #17742 and #18256, both on current main.

Cause

#18285 has unsloth_save_model call _release_nf4_dequant_cache() first, so a merge gets back the memory the training-time NF4 dequant cache held. That is correct. The helper is deliberately module-level, because unsloth_save_model forwards its own locals().

This test does not import unsloth/save.py. It execs the named functions into a namespace that _load() builds, pre-stubbing the helpers every save path calls (_unmerge_flags_on_error, lora_relative_to_original_base, and so on). The new helper was not in that namespace.

Fix

Add _release_nf4_dequant_cache as a no-op default in _load(), next to the other always-called save helpers. None of these fixtures has a dequant cache to free.

Verification

tests/saving/ without the model-loading test_unsloth_save.py:

Tree Result
main 7 failed (the 6 above plus test_torchao_remote_code_consent.py::test_compressed_and_gguf_lora_paths_drop_auto_map_trust)
this branch 1 failed (the same torchao test)

The torchao test fails identically on both sides on this host and does not fail in CI, so it is unrelated. test_save_method_lora_routing.py passes 80 out of 80. ruff is clean.

#18285 has unsloth_save_model call _release_nf4_dequant_cache() first
to free the training-time NF4 dequant cache before a merge. The routing
harness execs unsloth_save_model into its own namespace, which lacked
the helper, so 6 tests fail on main with NameError. Add a no-op default
next to the harness's other always-called save helpers.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 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-18T17:19:08.441880Z 3afc351 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 3afc351663

ℹ️ 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 128b925 into main Nov 18, 2026
@danielhanchen
danielhanchen deleted the ci/save-routing-stub-nf4-cache-release branch November 18, 2026 17:20
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