From 0271e0830cfe6e2fab58c3b59bed319215ca43d9 Mon Sep 17 00:00:00 2001 From: vladmandic Date: Sun, 26 Oct 2025 11:48:10 -0400 Subject: [PATCH] triton split check into early and full Signed-off-by: vladmandic --- installer.py | 5 ++++- modules/devices.py | 25 ++++++++++++++++--------- modules/shared.py | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/installer.py b/installer.py index bcf6f37ba..91649c596 100644 --- a/installer.py +++ b/installer.py @@ -241,7 +241,10 @@ def setup_logging(): log.addHandler(fh) global log_rolled # pylint: disable=global-statement if not log_rolled and args.debug and not args.log: - fh.doRollover() + try: + fh.doRollover() + except Exception: + pass log_rolled = True rb = RingBuffer(100) # 100 entries default in log ring buffer diff --git a/modules/devices.py b/modules/devices.py index 2cb5ee653..62847c87d 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -65,11 +65,10 @@ def has_zluda() -> bool: return False -def has_triton() -> bool: - global triton_ok +def has_triton(early:bool=False) -> bool: if triton_ok is not None: return triton_ok - return test_triton() + return test_triton(early=early) def get_backend(shared_cmd_opts): @@ -382,25 +381,33 @@ def test_bf16(): return bf16_ok -def test_triton(): - global triton_ok +def test_triton(early: bool = False): + global triton_ok # pylint: disable=global-statement if triton_ok is not None: return triton_ok + t0 = time.time() try: from torch.utils._triton import has_triton as torch_has_triton if torch_has_triton(): + if early: + return True def test_triton_func(a,b,c): return a * b + c test_triton_func = torch.compile(test_triton_func, fullgraph=True) - test_triton_func(torch.randn(128, device=device), torch.randn(128, device=device), torch.randn(128, device=device)) + test_triton_func(torch.randn(32, device=device), torch.randn(32, device=device), torch.randn(32, device=device)) triton_ok = True else: triton_ok = False except Exception as e: - log.warning(f"Triton test fail: {e}") triton_ok = False - return triton_ok - + log.warning(f"Triton test fail: {e}") + from modules import errors + errors.display(e, 'Triton') + t1 = time.time() + fn = f'{sys._getframe(2).f_code.co_name}:{sys._getframe(1).f_code.co_name}' # pylint: disable=protected-access + log.debug(f'Triton: pass={triton_ok} fn={fn} time={t1-t0:.2f}') + if not triton_ok: + opts.sdnq_dequantize_compile = False def set_cudnn_params(): if not cuda_ok: diff --git a/modules/shared.py b/modules/shared.py index b9f290df7..0ebbd7e0c 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -205,7 +205,7 @@ options_templates.update(options_section(("quantization", "Model Quantization"), "sdnq_svd_steps": OptionInfo(8, "SVD steps", gr.Slider, {"minimum": 1, "maximum": 128, "step": 1}), "sdnq_use_svd": OptionInfo(False, "Use SVD quantization", gr.Checkbox), "sdnq_quantize_conv_layers": OptionInfo(False, "Quantize convolutional layers", gr.Checkbox), - "sdnq_dequantize_compile": OptionInfo(devices.has_triton(), "Dequantize using torch.compile", gr.Checkbox), + "sdnq_dequantize_compile": OptionInfo(devices.has_triton(early=True), "Dequantize using torch.compile", gr.Checkbox), "sdnq_use_quantized_matmul": OptionInfo(False, "Use quantized MatMul", gr.Checkbox), "sdnq_use_quantized_matmul_conv": OptionInfo(False, "Use quantized MatMul with conv", gr.Checkbox), "sdnq_quantize_with_gpu": OptionInfo(True, "Quantize using GPU", gr.Checkbox),