EDMDPMSolverMultistepScheduler and CosineDPMSolverMultistepScheduler raise UnboundLocalError for an unknown sigma_schedule

Open Beginner friendly
#15,436 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, pytorch

Research direction

Read the constructors for EDMDPMSolverMultistepScheduler and CosineDPMSolverMultistepScheduler, then compare their sigma_schedule validation with EDMEulerScheduler. Add tests for an unsupported value such as "Karras" and confirm both constructors raise ValueError with a useful message.

Written by the indexing model from the issue text.

Description

Describe the bug

EDMDPMSolverMultistepScheduler and CosineDPMSolverMultistepScheduler don't check sigma_schedule. Any value other than "karras" or "exponential" (a typo or a capitalised "Karras") skips both branches in __init__, and the constructor fails with an UnboundLocalError about sigmas instead of saying which argument is wrong. EDMEulerScheduler, which takes the same argument, already raises a ValueError for this.

I found this while reading the scheduler code, not from a failing run. I'd like to send a small PR that adds the same check to both schedulers, with tests.

Reproduction
from diffusers import CosineDPMSolverMultistepScheduler, EDMDPMSolverMultistepScheduler, EDMEulerScheduler

for cls in (EDMEulerScheduler, EDMDPMSolverMultistepScheduler, CosineDPMSolverMultistepScheduler):
    try:
        cls(sigma_schedule="Karras")
    except Exception as e:
        print(f"{cls.__name__}: {type(e).__name__}: {e}")
Logs
EDMEulerScheduler: ValueError: Wrong value for provided for `sigma_schedule='Karras'`.`
EDMDPMSolverMultistepScheduler: UnboundLocalError: cannot access local variable 'sigmas' where it is not associated with a value
CosineDPMSolverMultistepScheduler: UnboundLocalError: cannot access local variable 'sigmas' where it is not associated with a value
System Info
  • diffusers 0.44.0.dev0 (main at 08d5de30e)
  • Python 3.12.15, Linux x86_64
  • torch 2.15.0+cpu
Who can help?

@yiyixuxu

Dominant language
Python
Stars
35k
Forks
7.5k
Avg merge
2d 22h
Merged PRs (30d)
58

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from huggingface/diffusers

All issues in huggingface/diffusers

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.