Comfy-Org/ComfyUI · error · ValueError

solver_type must be 'phi_1' or 'phi_2'

Error message

solver_type must be 'phi_1' or 'phi_2'

What it means

Raised by sample_seeds_2 (SEEDS-2 stochastic explicit exponential derivative-free solver) when solver_type is not one of its two implemented variants 'phi_1' or 'phi_2', which select different exponential-integrator basis functions. Exact string membership test at function entry.

Source

Thrown at comfy/k_diffusion/sampling.py:1597

                    # Stage 3
                    s_u = torch.sum((lambda_pos - er_lambda_s) / scaled_pos) * lambda_step_size
                    denoised_u = (denoised_d - old_denoised_d) / ((er_lambda_s - er_lambdas[i - 2]) / 2)
                    x = x + alpha_t * ((dt ** 2) / 2 + s_u * noise_scaler(er_lambda_t)) * denoised_u
                old_denoised_d = denoised_d

            if s_noise > 0:
                x = x + alpha_t * noise_sampler(sigmas[i], sigmas[i + 1]) * s_noise * (er_lambda_t ** 2 - er_lambda_s ** 2 * r ** 2).sqrt().nan_to_num(nan=0.0)
        old_denoised = denoised
    return x


@torch.no_grad()
def sample_seeds_2(model, x, sigmas, extra_args=None, callback=None, disable=None, eta=1., s_noise=1., noise_sampler=None, r=0.5, solver_type="phi_1"):
    """SEEDS-2 - Stochastic Explicit Exponential Derivative-free Solvers (VP Data Prediction) stage 2.
    arXiv: https://arxiv.org/abs/2305.14267 (NeurIPS 2023)
    """
    if solver_type not in {"phi_1", "phi_2"}:
        raise ValueError("solver_type must be 'phi_1' or 'phi_2'")

    extra_args = {} if extra_args is None else extra_args
    seed = extra_args.get("seed", None)
    noise_sampler = default_noise_sampler(x, seed=seed) if noise_sampler is None else noise_sampler
    s_in = x.new_ones([x.shape[0]])

    model_sampling = model.inner_model.model_patcher.get_model_object('model_sampling')
    s_noise = s_noise * getattr(model_sampling, "noise_scale", 1.0)
    inject_noise = eta > 0 and s_noise > 0
    sigma_fn = partial(half_log_snr_to_sigma, model_sampling=model_sampling)
    lambda_fn = partial(sigma_to_half_log_snr, model_sampling=model_sampling)
    sigmas = offset_first_sigma_for_snr(sigmas, model_sampling)

    fac = 1 / (2 * r)

    for i in trange(len(sigmas) - 1, disable=disable):
        denoised = model(x, sigmas[i] * s_in, **extra_args)
        if callback is not None:

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Pass solver_type='phi_1' (default) or 'phi_2'
  2. Keep per-sampler option lists separate instead of one shared combo
  3. Validate/normalize solver strings (lowercase, strip) before dispatch

Example fix

# before
sample_seeds_2(model, x, sigmas, solver_type='phi1')
# after
sample_seeds_2(model, x, sigmas, solver_type='phi_1')
Defensive patterns

Strategy: validation

Validate before calling

solver_type = solver_type.strip().lower()
assert solver_type in {'phi_1', 'phi_2'}, "solver_type must be 'phi_1' or 'phi_2'"

Type guard

def is_valid_seeds_solver(s: str) -> bool:
    return s in {'phi_1', 'phi_2'}

Prevention

When it happens

Trigger: Calling sample_seeds_2(..., solver_type='phi1') (missing underscore), 'PHI_1' (case), or a DPM++ value like 'midpoint' copy-pasted from another sampler's options.

Common situations: Custom sampler option lists shared across samplers; hand-edited workflow JSON; scripts forwarding one generic solver_type setting to many samplers.

Related errors


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