Repository navigation
OpenVINO export: trust remote code only for a remote-code model, and decode the bounds probe as UTF-8 - #12012
Merged
Merged
Conversation
…decode the bounds probe as UTF-8 #11907 passed --trust-remote-code to optimum-cli when either the model or the tokenizer had been loaded through remote code. The flag covers both loads, so an approved custom tokenizer let the reload run a built-in-loaded model's unvetted auto_map code, which test_compressed_and_gguf_lora_paths_drop_auto_map_trust forbids. The flag now follows the model, as the GGUF-LoRA converter does, and a tokenizer-only case warns instead. The optimum-intel bounds probe decoded its output in the locale encoding, which test_save_subprocess_text_calls_declare_utf8_encoding forbids (#2660); it now pins utf-8.
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
shaojun
pushed a commit
to shaojun/unsloth
that referenced
this pull request
Sep 29, 2026
…decode the bounds probe as UTF-8 (unslothai#12012) unslothai#11907 passed --trust-remote-code to optimum-cli when either the model or the tokenizer had been loaded through remote code. The flag covers both loads, so an approved custom tokenizer let the reload run a built-in-loaded model's unvetted auto_map code, which test_compressed_and_gguf_lora_paths_drop_auto_map_trust forbids. The flag now follows the model, as the GGUF-LoRA converter does, and a tokenizer-only case warns instead. The optimum-intel bounds probe decoded its output in the locale encoding, which test_save_subprocess_text_calls_declare_utf8_encoding forbids (unslothai#2660); it now pins utf-8.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two tests in
Repo tests (CPU, rest)fail on main since #11907 (OpenVINO export). The job never ran on that PR before it merged; the org queue is backed up, so main has not run it either. Reproduced locally on0657c177e, and both pass on the parent of #11907:Which side is wrong
Both tests are right; the new code breaks invariants they were written to hold.
_unsloth_save_openvinopassed--trust-remote-codetooptimum-cli export openvinowhen either the model or the tokenizer had been loaded through remote code. That one flag governs both the model and the tokenizer loads in the child. So an approved custom tokenizer switched on remote code for a model that loaded with built-in classes, and a checkpoint whose config carries anauto_mapwould then run that unvetted code during the reload. That is exactly the case the consent tests exist to stop; the torchao and compressed exports keep the two decisions separate for this reason.subprocess.run(..., text = True)withoutencoding, so on Windows its output is decoded as cp1252 ([Bug]UnicodeDecodeErroron Windows due to missing encoding="utf-8" in open() call #2660). The probe's failures are swallowed, so there it would silently skip the bounds check rather than crash, but it is the pattern the drift check bans.Fix
--trust-remote-codenow follows the model's approved load decision, the same rule the GGUF-LoRA converter uses for its single flag. When only the tokenizer came from remote code, the export runs without the flag and warns that optimum may skip converting the tokenizer. An explicittrust_remote_codepassed by the caller is still honored.encoding = "utf-8", errors = "replace", like the other text-mode calls insave.py.test_a_custom_tokenizer_alone_does_not_trust_the_modelintests/saving/test_openvino_export.py: a remote-code tokenizer with a built-in model gets no--trust-remote-codeand one warning. The existing case (remote-code model gets the flag) is unchanged.Verification
tests/saving/test_openvino_export.py,test_torchao_remote_code_consent.py,test_save_subprocess_utf8_encoding.py,test_export_api_surface.py: 40 passed, 1 skipped on this branch.save.py, the two consent/encoding guards and the new test fail (3 failed).0657c177evse7edce154(18 commits earlier),tests/outsidetests/studio: these two are the only failures that main has and the older tree does not, apart from an untrackedunsloth_compiled_cachefile the exec-literal lint picked up locally.