patches/nunchaku_patch.py line 9 does import torch at module level.
This file is loaded during ComfyUI's prestartup phase (via prestartup_script.py),
which causes the guard at main.py:225 to fire:
WARNING: Potential Error in code: Torch already imported, torch should never be imported before this point.
Fix: move import torch inside the functions that need it, and use
from __future__ import annotations so type hints don't require torch at
module load time.
patches/nunchaku_patch.pyline 9 doesimport torchat module level.This file is loaded during ComfyUI's prestartup phase (via
prestartup_script.py),which causes the guard at
main.py:225to fire:Fix: move
import torchinside the functions that need it, and usefrom __future__ import annotationsso type hints don't require torch atmodule load time.