diff --git a/qwen3_6_scripts/patch_ops.sh b/qwen3_6_scripts/patch_ops.sh index bd944641..3735d411 100755 --- a/qwen3_6_scripts/patch_ops.sh +++ b/qwen3_6_scripts/patch_ops.sh @@ -246,18 +246,15 @@ INIT_EOF """Apply ix_ops patches at vllm startup.""" import logging _logger = logging.getLogger("ix_startup_patch") +_applied = False def apply(): - import sys, os - # Skip in subprocess inspection (no GPU context → dlopen .so crashes) - try: - import torch - if not torch.cuda.is_available(): - return 0 - except Exception: + global _applied + if _applied: return 0 + _applied = True + import sys, os # Ensure ex_engine is importable - for p in ["/workspace/qwen3_6_scripts", - "/workspace"]: + for p in ["/workspace/qwen3_6_scripts", "/workspace"]: rp = os.path.realpath(p) if os.path.isdir(rp) and rp not in sys.path: sys.path.insert(0, rp) @@ -279,7 +276,8 @@ def apply(): except Exception as e: _logger.warning("ix_startup_patch: hot-path patches failed: %s", e) return n -_n_patches = apply() +# DO NOT call apply() at import time — registry subprocess would crash. +# apply() is called from qwen3_5.py model init instead. STARTUP_EOF echo "[patch_ops] deployed ix_startup_patch.py" diff --git a/qwen3_6_scripts/qwen3_5.py b/qwen3_6_scripts/qwen3_5.py index 343e904a..408d1492 100644 --- a/qwen3_6_scripts/qwen3_5.py +++ b/qwen3_6_scripts/qwen3_5.py @@ -2201,6 +2201,12 @@ class Qwen3_5ForCausalLM(nn.Module, HasInnerState, SupportsLoRA, multimodal_config: Optional[MultiModalConfig] = None, prefix: str = "", ) -> None: + # Apply ix_bridge operator patches on first model init (safe: GPU is ready) + try: + from vllm import ix_startup_patch + ix_startup_patch.apply() + except Exception: + pass _bi100_model_trace("Qwen3_5ForCausalLM initialization begin") super().__init__() self.config = config