Skip to content

fix: require explicit opt-in for embedder remote code - #1620

Open
original4422 wants to merge 1 commit into
FlagOpen:masterfrom
original4422:fix/explicit-embedder-remote-code-trust
Open

original4422 wants to merge 1 commit into
FlagOpen:masterfrom
original4422:fix/explicit-embedder-remote-code-trust

Conversation

@original4422

Copy link
Copy Markdown

Summary

 if trust_remote_code is None:
-    trust_remote_code = model_config.trust_remote_code
+    trust_remote_code = False

Require explicit opt-in for custom code in FlagAutoModel.from_finetuned, including Hub namespaces, local paths, and checkpoint-parent aliases that match a registry basename. Warn when a recognized model is configured for custom code, and document the compatibility change. Explicit True/False and model-class, pooling, and query-format selection are preserved.

Fixes #1579.

Evidence

  • Before: new tests against the original public dispatcher: 12 failed, 15 passed; failures captured omitted trust becoming True at the selected model constructor.
  • After: 32 passed (27 new dispatcher cases and 5 existing import tests), covering all seven current True registry entries, path aliases, explicit flags, and selection/forwarding controls.
  • Tests intercept only the downstream model constructor. The dispatcher and registry use the original package; zero outbound network attempts, model loads, or remote model-code executions.
  • Scoped Python compilation, package wheel build, and git diff --check pass. Reused the original declared editable-install dependencies with Python 3.13.14, Torch 2.15.0, and Transformers 5.22.1.
  • Full model/GPU/provider integration tests and the full Sphinx site were not run.

Merge Danger

Door: two-way

Models requiring custom code now need trust_remote_code=True explicitly, after reviewing that code. This is an intentional compatibility change.

Blast Radius: embedder-loading

Prepared with AI assistance.

This branch has not been deployed

No deployments
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.

Silent trust_remote_code=True enable in FlagAutoModel.from_finetuned via basename-only registry lookup

1 participant