Skip to content

Fix Euler velocity coefficients for discrete training timesteps - #15491

Open
mertkayacs wants to merge 1 commit into
huggingface:mainfrom
mertkayacs:fix/euler-get-velocity-alphas
Open

mertkayacs wants to merge 1 commit into
huggingface:mainfrom
mertkayacs:fix/euler-get-velocity-alphas

Conversation

@mertkayacs

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #15461

EulerDiscreteScheduler.get_velocity indexes alphas_cumprod by the timestep's position in the descending schedule, so timestep 999 reads alphas_cumprod[0]. The SDXL T2I-Adapter example uses this as its v_prediction loss target.

I now index by the timestep value when it is an integer inside the training range. Fractional timesteps (Karras, exponential, beta sigmas) keep the schedule-position lookup, and continuous v_prediction timesteps are left unchanged. The issue repro now matches DDIMScheduler exactly.

New tests: DDIM parity for the default and a custom schedule, a fractional timestep (2.5), and a continuous timestep equal to 0.0.

Verification

  • With the scheduler change reverted: SUBFAILED(schedule='training'), SUBFAILED(schedule='custom'), 2 failed, 3 passed, 36 deselected (max abs diff 1.471 and 2.902).
  • With the fix, pytest tests/schedulers/test_scheduler_euler.py: 39 passed, 2 subtests passed.
  • ruff check and ruff format --check (0.9.10) on both files, utils/check_copies.py, utils/check_dummies.py: clean.

Self-review notes

I used Codex for the patch and tests and ran the self-review skill. Final round: no blocking findings. Left as is: #15300 touches the same coefficient reads for dtype handling; whichever lands second needs a small rebase. No maintainer acknowledgment on the issue yet.

Before submitting

Who can review?

Scheduler maintainers.

@mertkayacs

Copy link
Copy Markdown
Contributor Author

@yiyixuxu could you review this when you have time?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EulerDiscreteScheduler returns incorrect v-prediction targets for discrete timesteps

1 participant