Skip to content

fix(export): pass trust_remote_code for checkpoint exports - #14722

Merged
danielhanchen merged 3 commits into
unslothai:mainfrom
ryder777777:fix/export-checkpoint-trust-remote-code-14688
Oct 23, 2026
Merged

danielhanchen merged 3 commits into
unslothai:mainfrom
ryder777777:fix/export-checkpoint-trust-remote-code-14688

Conversation

@ryder777777

@ryder777777 ryder777777 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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 with

Failed to load checkpoint: The repository IFM/K2-Horizon-3.7B contains custom code ... Please pass the argument trust_remote_code=True ...

The Export page only showed the remote-code consent dialog for sourceMode=model (HF/local) and the checkpoint path never sent trust_remote_code to the backend, so the export worker loaded with False.

Fix

  • frontend/export-page.tsx + lib/remote-code-consent.ts: also gate sourceMode=checkpoint via confirmRemoteCodeIfNeeded, 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 get trust_remote_code through the dialog; a checkpoint with no custom code exports without a prompt, as before.
  • frontend/stores/export-runtime-store.ts: forward trustRemoteCode / approvedRemoteCodeFingerprint when loadCheckpoint({checkpoint_path}) is called for a checkpoint, so ExportBackend.load_checkpoint(..., trust_remote_code=...) and the worker security gates see the approval.

No backend API change; existing LoadCheckpointRequest.trust_remote_code is 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):

Export of a remote-code checkpoint, before and after

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]
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T05:42:26.205546Z ab87462 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. Nice work!

Reviewed commit: ab87462ddf

ℹ️ 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Models with remote code can't be exported from UI

2 participants