Skip to content

Walk every sub-config when deciding whether a config carries remote code - #11555

Merged
shimmyshimmer merged 7 commits into
mainfrom
remote-code-subconfig-walk
Sep 25, 2026
Merged

shimmyshimmer merged 7 commits into
mainfrom
remote-code-subconfig-walk

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

What this fixes

_config_uses_remote_code decides whether the compiler stays on for a trust_remote_code = True load. It looked at text_config, vision_config and audio_config only. A composite whose children carry other names (Qwen-Omni's thinker_config, talker_config, token2wav_config; Nemotron-3-Nano-Omni's llm_config and sound_config), or a dict config that nests a child two levels down (omnivinci puts audio_config under its llm_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_configs on 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.py gains cases for a sub_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.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 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-09-25T15:00:39.299788Z ad6642b 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.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 22, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

if cfg is not None and _remote(cfg):
return True

P1 Badge Traverse nested object sub-configs recursively

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

@danielhanchen

Copy link
Copy Markdown
Member Author

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.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 5175896cfa

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

@danielhanchen danielhanchen self-assigned this Sep 25, 2026
…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.
@shimmyshimmer

Copy link
Copy Markdown
Member

pre-commit.ci run

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@unslothai unslothai deleted a comment from danielhanchen Sep 25, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@shimmyshimmer

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: ad6642b31f

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

@shimmyshimmer

Copy link
Copy Markdown
Member

pre-commit.ci autofix

@shimmyshimmer
shimmyshimmer merged commit 42a23e8 into main Sep 25, 2026
52 of 55 checks passed
@shimmyshimmer
shimmyshimmer deleted the remote-code-subconfig-walk branch September 25, 2026 17:11
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…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>
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.

2 participants