From 05737188cabfe511cde12ae5f755af765a62ff4e Mon Sep 17 00:00:00 2001 From: Qayad-Ali Date: Fri, 3 Jul 2026 00:23:56 +0530 Subject: [PATCH] fix:gaurd torch.compile in get_smol so first index doesnt crash in windows --- src/gurrt/core/models.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gurrt/core/models.py b/src/gurrt/core/models.py index 84cb94e..ec6a4c6 100644 --- a/src/gurrt/core/models.py +++ b/src/gurrt/core/models.py @@ -1,4 +1,5 @@ import torch +import sys from transformers import ( CLIPProcessor, CLIPModel, @@ -79,7 +80,15 @@ def get_smol(self, flag:bool): self._smol = SmolVLMForConditionalGeneration.from_pretrained(path, local_files_only= True) - self._smol = torch.compile(self._smol, mode="reduce-overhead") + ## torch.compile works with Triton, which is not on Windows, so this one + # line crashes the very first index. Only run it when we're on a CUDA GPU + # and not on Windows — and if the compile still chokes, just skip it instead + # of taking whole run down with it. + if self.device == "cuda" and sys.platform != "win32": + try: + self._smol = torch.compile(self._smol, mode="reduce-overhead") + except Exception as e: + ui.warn(f"torch.compile unavailable -- continuing without it ({e})") return self._to_device(self._smol), self._smol_processor def release_smol(self): @@ -149,4 +158,4 @@ def download_models(cache_dir): snapshot_download( repo_id="Systran/faster-distil-whisper-large-v2", local_dir=str(cache_dir / "whisper_model"), - ) \ No newline at end of file + )