{"record":{"id":"80a7367c25454929","repo":"huggingface/candle","slug":"prediction-type-not-implemented-yet-sample","errorCode":null,"errorMessage":"prediction_type not implemented yet: sample","messagePattern":"prediction_type not implemented yet: sample","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-transformers/src/models/stable_diffusion/euler_ancestral_discrete.rs","lineNumber":191,"sourceCode":"    /// Performs a backward step during inference.\n    fn step(&mut self, model_output: &Tensor, timestep: usize, sample: &Tensor) -> Result<Tensor> {\n        let step_index = self\n            .timesteps\n            .iter()\n            .position(|&p| p == timestep)\n            .ok_or_else(|| Error::Msg(\"timestep out of this schedulers bounds\".to_string()))?;\n\n        let sigma_from = &self.sigmas[step_index];\n        let sigma_to = &self.sigmas[step_index + 1];\n\n        // 1. compute predicted original sample (x_0) from sigma-scaled predicted noise\n        let pred_original_sample = match self.config.prediction_type {\n            PredictionType::Epsilon => (sample - (model_output * *sigma_from))?,\n            PredictionType::VPrediction => {\n                ((model_output * (-sigma_from / (sigma_from.powi(2) + 1.0).sqrt()))?\n                    + (sample / (sigma_from.powi(2) + 1.0))?)?\n            }\n            PredictionType::Sample => bail!(\"prediction_type not implemented yet: sample\"),\n        };\n\n        let sigma_up = (sigma_to.powi(2) * (sigma_from.powi(2) - sigma_to.powi(2))\n            / sigma_from.powi(2))\n        .sqrt();\n        let sigma_down = (sigma_to.powi(2) - sigma_up.powi(2)).sqrt();\n\n        // 2. convert to a ODE derivative\n        let derivative = ((sample - pred_original_sample)? / *sigma_from)?;\n        let dt = sigma_down - *sigma_from;\n        let prev_sample = (sample + derivative * dt)?;\n\n        let noise = prev_sample.randn_like(0.0, 1.0)?;\n\n        prev_sample + noise * sigma_up\n    }\n\n    fn add_noise(&self, original: &Tensor, noise: Tensor, timestep: usize) -> Result<Tensor> {","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-transformers/src/models/stable_diffusion/euler_ancestral_discrete.rs#L173-L209","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","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"],"exampleFix":"// before\nlet cfg = EulerAncestralDiscreteSchedulerConfig { prediction_type: PredictionType::Sample, .. };\n// after\nlet cfg = EulerAncestralDiscreteSchedulerConfig { prediction_type: PredictionType::Epsilon, .. };","handlingStrategy":"validation","validationCode":"match config.prediction_type {\n    PredictionType::Epsilon | PredictionType::VPrediction => {},\n    other => return Err(anyhow::anyhow!(\"prediction_type {:?} unsupported by euler_ancestral_discrete\", other)),\n}","typeGuard":"fn supports_sample_pred(p: &PredictionType) -> bool {\n    matches!(p, PredictionType::Epsilon | PredictionType::VPrediction)\n}","tryCatchPattern":"match scheduler.step(&model_out, t, &mut latents) {\n    Err(e) if e.to_string().contains(\"prediction_type not implemented\") => {\n        anyhow::bail!(\"rebuild scheduler with Epsilon or VPrediction\")\n    }\n    r => r?,\n}","preventionTips":["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"],"tags":["rust","candle","stable-diffusion","scheduler","unsupported-feature"],"backgroundTag":"unsupported-prediction-type","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}