huggingface/candle · error
prediction_type not implemented yet: sample
Error message
prediction_type not implemented yet: sample
What it means
EulerAncestralDiscreteScheduler::step computes the original sample from the model output, but only Epsilon and VPrediction prediction types are implemented; PredictionType::Sample is explicitly rejected with this bail. It is a declared unsupported-path guard rather than a computational failure.
Source
Thrown at candle-transformers/src/models/stable_diffusion/euler_ancestral_discrete.rs:191
/// Performs a backward step during inference.
fn step(&mut self, model_output: &Tensor, timestep: usize, sample: &Tensor) -> Result<Tensor> {
let step_index = self
.timesteps
.iter()
.position(|&p| p == timestep)
.ok_or_else(|| Error::Msg("timestep out of this schedulers bounds".to_string()))?;
let sigma_from = &self.sigmas[step_index];
let sigma_to = &self.sigmas[step_index + 1];
// 1. compute predicted original sample (x_0) from sigma-scaled predicted noise
let pred_original_sample = match self.config.prediction_type {
PredictionType::Epsilon => (sample - (model_output * *sigma_from))?,
PredictionType::VPrediction => {
((model_output * (-sigma_from / (sigma_from.powi(2) + 1.0).sqrt()))?
+ (sample / (sigma_from.powi(2) + 1.0))?)?
}
PredictionType::Sample => bail!("prediction_type not implemented yet: sample"),
};
let sigma_up = (sigma_to.powi(2) * (sigma_from.powi(2) - sigma_to.powi(2))
/ sigma_from.powi(2))
.sqrt();
let sigma_down = (sigma_to.powi(2) - sigma_up.powi(2)).sqrt();
// 2. convert to a ODE derivative
let derivative = ((sample - pred_original_sample)? / *sigma_from)?;
let dt = sigma_down - *sigma_from;
let prev_sample = (sample + derivative * dt)?;
let noise = prev_sample.randn_like(0.0, 1.0)?;
prev_sample + noise * sigma_up
}
fn add_noise(&self, original: &Tensor, noise: Tensor, timestep: usize) -> Result<Tensor> {View on GitHub (pinned to d5fee525bf)
Solutions
- Set prediction_type to PredictionType::Epsilon (most SD checkpoints) or PredictionType::VPrediction in the scheduler config
- Use a different scheduler implementation in candle that supports Sample prediction if your model requires it
- Check the model's config for prediction_type and align it with what candle supports
Example fix
// before
let cfg = EulerAncestralDiscreteSchedulerConfig { prediction_type: PredictionType::Sample, .. };
// after
let cfg = EulerAncestralDiscreteSchedulerConfig { prediction_type: PredictionType::Epsilon, .. }; Defensive patterns
Strategy: validation
Validate before calling
match config.prediction_type {
PredictionType::Epsilon | PredictionType::VPrediction => {},
other => return Err(anyhow::anyhow!("prediction_type {:?} unsupported by euler_ancestral_discrete", other)),
} Type guard
fn supports_sample_pred(p: &PredictionType) -> bool {
matches!(p, PredictionType::Epsilon | PredictionType::VPrediction)
} Try / catch
match scheduler.step(&model_out, t, &mut latents) {
Err(e) if e.to_string().contains("prediction_type not implemented") => {
anyhow::bail!("rebuild scheduler with Epsilon or VPrediction")
}
r => r?,
} Prevention
- Check the checkpoint's prediction_type before choosing a scheduler
- Default to PredictionType::Epsilon for standard SD 1.x/2.x checkpoints
- Route Sample-prediction models to a scheduler that supports them
When it happens
Trigger: Using a scheduler built with EulerAncestralDiscreteSchedulerConfig { prediction_type: PredictionType::Sample, .. } and calling step(), or loading a Stable Diffusion checkpoint/config whose prediction_type is 'sample'.
Common situations: Copied a config from another pipeline (e.g. x-prediction/sample-style models); defaulted prediction_type incorrectly when constructing the scheduler config; model card specifies 'sample' prediction which candle does not support for this scheduler.
Related errors
- timestep out of this schedulers bounds: {timestep}
- only TorchAttn is supported
- kv_cache_enabled=true is not supported
- SpectralNorm is not supported yet.
- pad-mode 'reflect' is not supported
AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02).
Data as JSON: /api/errors/80a7367c25454929.
Report an issue: GitHub.