From 3400654afc95a26dee687b35e15ea229aa16a10d Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Mon, 6 Apr 2026 18:20:08 +0000 Subject: [PATCH] restrict trust_remote_code auto-enable to Nemotron models only --- studio/backend/core/inference/worker.py | 13 +++++-------- studio/backend/core/training/worker.py | 20 +++++++------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/studio/backend/core/inference/worker.py b/studio/backend/core/inference/worker.py index 3c5363cb77..1010e56dac 100644 --- a/studio/backend/core/inference/worker.py +++ b/studio/backend/core/inference/worker.py @@ -322,19 +322,16 @@ def _handle_load(backend, config: dict, resp_queue: Any) -> None: except Exception as e: logger.warning("Could not read adapter_config.json: %s", e) - # Auto-enable trust_remote_code for unsloth/* transformers 5.x models - # (matches the training worker logic in core/training/worker.py) + # Auto-enable trust_remote_code for Nemotron models only. + # NemotronH has config parsing bugs requiring trust_remote_code=True. + # Other transformers 5.x models are native and do NOT need it. trust_remote_code = config.get("trust_remote_code", False) if not trust_remote_code: - from utils.transformers_version import needs_transformers_5 - model_name = config["model_name"] - if needs_transformers_5(model_name) and model_name.lower().startswith( - "unsloth/" - ): + if "nemotron" in model_name.lower(): trust_remote_code = True logger.info( - "Auto-enabled trust_remote_code for unsloth/* transformers 5.x model: %s", + "Auto-enabled trust_remote_code for Nemotron model: %s", model_name, ) diff --git a/studio/backend/core/training/worker.py b/studio/backend/core/training/worker.py index 9815e9d7b7..b412a05cc9 100644 --- a/studio/backend/core/training/worker.py +++ b/studio/backend/core/training/worker.py @@ -399,25 +399,19 @@ def run_training_process( ) return - # ── 1a. Auto-enable trust_remote_code for unsloth/* transformers 5.x models ── - # Some newer architectures (e.g. NemotronH) have config parsing bugs in - # transformers that require trust_remote_code=True as a workaround. - # Only auto-enable for models that genuinely need it (set in YAML defaults). - # Native transformers 5.x models (Qwen3.5, Gemma 4, etc.) do NOT need it - # and enabling it can bypass the compiler (disabling fused CE). - from utils.transformers_version import get_transformers_tier - + # ── 1a. Auto-enable trust_remote_code for Nemotron models ── + # NemotronH has config parsing bugs in transformers that require + # trust_remote_code=True as a workaround. Other transformers 5.x models + # (Qwen3.5, Gemma 4, etc.) are native and do NOT need it — enabling it + # bypasses the compiler (disabling fused CE). _lowered = model_name.lower() - _tier = get_transformers_tier(model_name) if ( - _tier != "default" - and _lowered.startswith("unsloth/") - and _tier not in ("530", "550") # Native t5 models don't need trust_remote_code + "nemotron" in _lowered and not config.get("trust_remote_code", False) ): config["trust_remote_code"] = True logger.info( - "Auto-enabled trust_remote_code for unsloth/* transformers 5.x model: %s", + "Auto-enabled trust_remote_code for Nemotron model: %s", model_name, )