Repository navigation
Walk every sub-config when deciding whether a config carries remote code - #11555
Conversation
The check looked at text_config, vision_config and audio_config only. A composite that names its children differently (thinker_config, llm_config, sound_config) or nests them two levels down read as native and put the compiler back on code it cannot trace. Use the class's own sub_configs and walk a dict config in full.
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 |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
unsloth/unsloth/models/loader.py
Lines 261 to 262 in 1db622e
When a config object contains a composite child, this loop checks only that immediate child's auto_map and never walks the child's own sub_configs. For example, the supported shape Sam3Config -> vision_config -> backbone_config can place remotely loaded model code at the second level; this predicate then returns False, so a trust_remote_code=True load enables the compiler for code it cannot safely trace. Use the same cycle-protected worklist for object-valued and mixed dict/object sub-configs instead of stopping after one level.
ℹ️ 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".
|
Confirmed the predicate only checked text, vision and audio sub-configs, so composites like Qwen-Omni and nested dict configs were misread as native. Will get this reviewed. |
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
…ash the walk transformers 4.57 declares sub_configs as a property on backbone configs (VitMatte, DPT, UperNet and 22 more); reading it off the class returned the property object and iterating it raised TypeError.
|
pre-commit.ci run |
|
@codex review |
1 similar comment
|
@codex review |
|
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". |
|
pre-commit.ci autofix |
…ode (unslothai#11555) * Walk every sub-config when deciding whether a config carries remote code The check looked at text_config, vision_config and audio_config only. A composite that names its children differently (thinker_config, llm_config, sound_config) or nests them two levels down read as native and put the compiler back on code it cannot trace. Use the class's own sub_configs and walk a dict config in full. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Walk nested object sub-configs when deciding whether a config carries remote code * Walk config objects held inside dict-shaped configs too * Answer remote past the sub-config depth bound instead of native * Trim comments in the sub-config walk * Read sub_configs off the instance so property-declared ones do not crash the walk transformers 4.57 declares sub_configs as a property on backbone configs (VitMatte, DPT, UperNet and 22 more); reading it off the class returned the property object and iterating it raised TypeError. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
What this fixes
_config_uses_remote_codedecides whether the compiler stays on for atrust_remote_code = Trueload. It looked attext_config,vision_configandaudio_configonly. A composite whose children carry other names (Qwen-Omni'sthinker_config,talker_config,token2wav_config; Nemotron-3-Nano-Omni'sllm_configandsound_config), or a dict config that nests a child two levels down (omnivinci putsaudio_configunder itsllm_config), read as native. That put the compiler back on remote code it cannot trace, which is the one direction this predicate must never get wrong.The check now walks the class's own
sub_configson top of the three usual names, and walks dict configs and config objects nested inside them, down to a depth of 8.Tests
tests/test_trust_remote_code_native_compile.pygains cases for asub_configs-declared child, a nested dict child and a child under a name the old list did not know. All 13 pass on transformers 5.17; on 4.57.6, 12 pass and the Gemma-4 load test skips because that release has no Gemma-4.Follow-up to
#11516, which added the predicate.