{"record":{"id":"6b8b046a95273c1d","repo":"microsoft/VibeVoice","slug":"cannot-use-timesteps-with-config-use-karras-sig","errorCode":null,"errorMessage":"Cannot use `timesteps` with `config.use_karras_sigmas = True`","messagePattern":"Cannot use `timesteps` with `config\\.use_karras_sigmas = True`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vibevoice/schedule/dpm_solver.py","lineNumber":345,"sourceCode":"        \"\"\"\n        Sets the discrete timesteps used for the diffusion chain (to be run before inference).\n\n        Args:\n            num_inference_steps (`int`):\n                The number of diffusion steps used when generating samples with a pre-trained model.\n            device (`str` or `torch.device`, *optional*):\n                The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.\n            timesteps (`List[int]`, *optional*):\n                Custom timesteps used to support arbitrary timesteps schedule. If `None`, timesteps will be generated\n                based on the `timestep_spacing` attribute. If `timesteps` is passed, `num_inference_steps` and `sigmas`\n                must be `None`, and `timestep_spacing` attribute will be ignored.\n        \"\"\"\n        if num_inference_steps is None and timesteps is None:\n            raise ValueError(\"Must pass exactly one of `num_inference_steps` or `timesteps`.\")\n        if num_inference_steps is not None and timesteps is not None:\n            raise ValueError(\"Can only pass one of `num_inference_steps` or `custom_timesteps`.\")\n        if timesteps is not None and self.config.use_karras_sigmas:\n            raise ValueError(\"Cannot use `timesteps` with `config.use_karras_sigmas = True`\")\n        if timesteps is not None and self.config.use_lu_lambdas:\n            raise ValueError(\"Cannot use `timesteps` with `config.use_lu_lambdas = True`\")\n\n        if timesteps is not None:\n            timesteps = np.array(timesteps).astype(np.int64)\n        else:\n            # Clipping the minimum of all lambda(t) for numerical stability.\n            # This is critical for cosine (squaredcos_cap_v2) noise schedule.\n            clipped_idx = torch.searchsorted(torch.flip(self.lambda_t, [0]), self.config.lambda_min_clipped)\n            last_timestep = ((self.config.num_train_timesteps - clipped_idx).numpy()).item()\n\n            # \"linspace\", \"leading\", \"trailing\" corresponds to annotation of Table 2. of https://arxiv.org/abs/2305.08891\n            if self.config.timestep_spacing == \"linspace\":\n                timesteps = (\n                    np.linspace(0, last_timestep - 1, num_inference_steps + 1)\n                    .round()[::-1][:-1]\n                    .copy()\n                    .astype(np.int64)","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/microsoft/VibeVoice/blob/94da20d98b2fa7688e9cbfaf7692ddb4954f7600/vibevoice/schedule/dpm_solver.py#L327-L363","documentation":"Custom `timesteps` and the Karras sigma schedule (`use_karras_sigmas=True` in the scheduler config) are mutually exclusive: Karras sigmas are generated from the trained sigma schedule and then mapped back to timesteps, so a user-supplied timestep list would be overwritten/inconsistent. `set_timesteps` rejects the combination with this ValueError.","triggerScenarios":"`DPMSolverMultistepScheduler(..., use_karras_sigmas=True)` later followed by `scheduler.set_timesteps(timesteps=[...])`.","commonSituations":"SDEdit/img2img flows that specify timesteps while the scheduler was built with karras sigmas for quality; reusing one scheduler config across pipelines with different calling conventions.","solutions":["Construct the scheduler with `use_karras_sigmas=False` if you need custom timesteps.","Or keep Karras sigmas and pass `num_inference_steps` instead of `timesteps`.","If you need both (custom grid + Karras spacing), compute the Karras sigmas yourself and set `scheduler.sigmas`/`timesteps` manually after set_timesteps."],"exampleFix":"# before\nsched = DPMSolverMultistepScheduler(..., use_karras_sigmas=True)\nsched.set_timesteps(timesteps=[900, 700, 400, 100])\n\n# after\nsched = DPMSolverMultistepScheduler(..., use_karras_sigmas=False)\nsched.set_timesteps(timesteps=[900, 700, 400, 100])","handlingStrategy":"validation","validationCode":"if timesteps is not None and scheduler.config.use_karras_sigmas:\n    raise ValueError(\"Custom timesteps require a scheduler built with use_karras_sigmas=False\")\nscheduler.set_timesteps(num_inference_steps=n, timesteps=timesteps)","typeGuard":"def can_use_custom_timesteps(scheduler) -> bool:\n    return not (scheduler.config.use_karras_sigmas or scheduler.config.use_lu_lambdas)","tryCatchPattern":null,"preventionTips":["Decide the sigma strategy (karras/lu/standard) at scheduler construction and keep the set_timesteps call style consistent with it.","Check scheduler.config.use_karras_sigmas before passing timesteps.","Use num_inference_steps when you just want fewer steps with Karras spacing."],"tags":["python","diffusion","scheduler","config","karras","timesteps"],"backgroundTag":null,"analyzedSha":"94da20d98b2fa7688e9cbfaf7692ddb4954f7600","analyzedAt":"2026-08-15T04:12:07.418Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}