Comfy-Org/ComfyUI · warning · NotImplementedError

comfy_kitchen does not support stochastic FP8 rounding

Error message

comfy_kitchen does not support stochastic FP8 rounding

What it means

Logged (logging.warning) at import time of comfy/float.py when the installed comfy_kitchen package either is missing or lacks the stochastic_rounding_fp8 attribute. The module then installs a stub that raises NotImplementedError('comfy_kitchen does not support stochastic FP8 rounding') if any code path attempts stochastic FP8 rounding. It is an environment/version signal, not a runtime exception at import.

Source

Thrown at comfy/float.py:15

import logging

import torch

_CK_STOCHASTIC_ROUNDING_AVAILABLE = False
try:
    import comfy_kitchen as ck
    _ck_stochastic_rounding_fp8 = ck.stochastic_rounding_fp8
    _CK_STOCHASTIC_ROUNDING_AVAILABLE = True
except (AttributeError, ImportError):
    logging.warning("comfy_kitchen does not support stochastic FP8 rounding, please update comfy_kitchen.")

if not _CK_STOCHASTIC_ROUNDING_AVAILABLE:
    def _ck_stochastic_rounding_fp8(value, rng, dtype):
        raise NotImplementedError("comfy_kitchen does not support stochastic FP8 rounding")


def calc_mantissa(abs_x, exponent, normal_mask, MANTISSA_BITS, EXPONENT_BIAS, generator=None):
    mantissa_scaled = torch.where(
        normal_mask,
        (abs_x / (2.0 ** (exponent - EXPONENT_BIAS)) - 1.0) * (2**MANTISSA_BITS),
        (abs_x / (2.0 ** (-EXPONENT_BIAS + 1 - MANTISSA_BITS)))
    )

    mantissa_scaled += torch.rand(mantissa_scaled.size(), dtype=mantissa_scaled.dtype, layout=mantissa_scaled.layout, device=mantissa_scaled.device, generator=generator)
    return mantissa_scaled.floor() / (2**MANTISSA_BITS)

#Not 100% sure about this
def manual_stochastic_round_to_float8(x, dtype, generator=None):
    if dtype == torch.float8_e4m3fn:
        EXPONENT_BITS, MANTISSA_BITS, EXPONENT_BIAS = 4, 3, 7
    elif dtype == torch.float8_e5m2:
        EXPONENT_BITS, MANTISSA_BITS, EXPONENT_BIAS = 5, 2, 15

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Update comfy_kitchen: pip install -U comfy_kitchen (or update ComfyUI which manages the pinned requirement)
  2. If using a portable release, re-run its update script so the embedded packages match the repo commit
  3. If the warning appears but you never use stochastic FP8 rounding, it can be safely ignored

Example fix

# before (stale env)
pip show comfy_kitchen   # old version, no stochastic_rounding_fp8
# after
pip install --upgrade comfy_kitchen
Defensive patterns

Strategy: validation

Validate before calling

import comfy_kitchen as ck
if not hasattr(ck, 'stochastic_rounding_fp8'):
    raise RuntimeError('Update comfy_kitchen: pip install -U comfy_kitchen')

Try / catch

try:
    from comfy.float import _ck_stochastic_rounding_fp8
except NotImplementedError:
    log.warning('stochastic FP8 rounding unavailable; update comfy_kitchen')
    use_deterministic_rounding = True

Prevention

When it happens

Trigger: Importing comfy.float with an old comfy_kitchen (or none installed, though core normally pins it) that predates the stochastic_rounding_fp8 API. The later NotImplementedError fires only when a code path calls _ck_stochastic_rounding_fp8 (FP8 training/quantization paths that use stochastic rounding).

Common situations: Downgrading or skipping comfy_kitchen during a partial ComfyUI update; a custom environment with a manually installed older comfy_kitchen wheel; portable installs where the embedded python libraries got out of sync with the ComfyUI frontend/repo version.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/35914f866afbd525. Report an issue: GitHub.