Repository navigation
fix(export): pass trust_remote_code for checkpoint exports - #14722
Merged
danielhanchen merged 3 commits intoOct 23, 2026
Merged
danielhanchen merged 3 commits into
danielhanchen merged 3 commits into
Conversation
Fine-tuned checkpoints that were trained from a base requiring trust_remote_code (e.g. IFM/K2-Horizon-3.7B) failed to load for export with 'contains custom code which must be executed' because the UI only gated HF model sources and never forwarded trust_remote_code/approved_remote_code_fingerprint for sourceMode=checkpoint. Gate the checkpoint's base model via confirmRemoteCodeIfNeeded and forward the approved fingerprint through export-runtime-store so the worker can load it.
Scanning the listed base model pinned a fingerprint over the base alone, so a full fine-tune (which ships its own copy of the custom code) failed the export worker's gate whenever the scan flagged MEDIUM/HIGH code. Scan the checkpoint path instead, which adds its LoRA base, matching the targets the worker checks. Checkpoints no longer inherit the model-mode local trust default. [skip ci]
Member
|
@codex review |
1 similar comment
Member
|
@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. Nice work! 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". |
danielhanchen
pushed a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Oct 23, 2026
2 of 5 tasks
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.
Fixes #14688
What happened
Training a model that needs
trust_remote_code=True(e.g.IFM/K2-Horizon-3.7B) succeeds and chat works, but Export fails withThe Export page only showed the remote-code consent dialog for
sourceMode=model(HF/local) and the checkpoint path never senttrust_remote_codeto the backend, so the export worker loaded withFalse.Fix
sourceMode=checkpointviaconfirmRemoteCodeIfNeeded, scanning the checkpoint folder itself. The scan adds the LoRA base, so the approved fingerprint covers the same targets the export worker checks (scanning only the listed base model left a full fine-tune's copied code out of the fingerprint, so MEDIUM/HIGH code was refused after approval). Checkpoints start untrusted and only gettrust_remote_codethrough the dialog; a checkpoint with no custom code exports without a prompt, as before.trustRemoteCode/approvedRemoteCodeFingerprintwhenloadCheckpoint({checkpoint_path})is called for a checkpoint, soExportBackend.load_checkpoint(..., trust_remote_code=...)and the worker security gates see the approval.No backend API change; existing
LoadCheckpointRequest.trust_remote_codeis now populated for checkpoints.Before / after
Studio installed at the merge base and at this branch on an NVIDIA L4, exporting a LoRA checkpoint whose base ships custom code (merged 16-bit, through the Export page):