Lazy import of qtorch.float_quantize. qtorch triggers a JIT C++ extension build on import, which blocks ComfyUI startup. Defer it until the first call site that needs it (only the online fp8 weight-quant path uses float_quantize).
()
| 3 | |
| 4 | |
| 5 | def _load_float_quantize(): |
| 6 | """Lazy import of qtorch.float_quantize. |
| 7 | |
| 8 | qtorch triggers a JIT C++ extension build on import, which blocks |
| 9 | ComfyUI startup. Defer it until the first call site that needs it |
| 10 | (only the online fp8 weight-quant path uses float_quantize). |
| 11 | """ |
| 12 | global float_quantize |
| 13 | if float_quantize is _UNLOADED: |
| 14 | try: |
| 15 | from qtorch.quant import float_quantize as _fq |
| 16 | |
| 17 | float_quantize = _fq |
| 18 | except Exception: |
| 19 | logger.warning("qtorch not found, please install qtorch (pip install qtorch).") |
| 20 | float_quantize = None |
| 21 | return float_quantize |
| 22 | |
| 23 | |
| 24 | _UNLOADED = object() |