Skip to content

Add regression tests for FlowMatchEuler, DDIM guard, and LoRA state dict utils#6

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/regression-test-coverage-e4b2
Draft

Add regression tests for FlowMatchEuler, DDIM guard, and LoRA state dict utils#6
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/regression-test-coverage-e4b2

Conversation

@cursor

@cursor cursor Bot commented Jun 22, 2026

Copy link
Copy Markdown

Risky behavior now covered

FlowMatchEulerDiscreteScheduler

The default scheduler for SD3, Flux, Wan, Qwen-Image, and many other pipelines had no dedicated scheduler test file. Pipeline tests only smoke-test it as a black box. New contract tests lock down:

  • Mutually exclusive sigma schedule config validation
  • Dynamic shifting requiring mu
  • Custom sigmas/timesteps length validation
  • Integer timestep index rejection in step() (a common pipeline footgun)
  • Stochastic sampling branch

DDIMScheduler set_timesteps guard

An eval branch demonstrated that inverting the num_inference_steps > num_train_timesteps comparison silently breaks all valid inference schedules. New tests assert the guard rejects over-limit steps and accepts the boundary value.

LoRA state dict conversion (state_dict_utils)

Every LoRA load path goes through convert_state_dict_to_peft / convert_state_dict_to_diffusers / convert_unet_state_dict_to_peft, but these had zero direct unit tests. New tests verify key remapping for diffusers-old, PEFT, and UNet formats, plus error paths for unrecognized state dicts.

Test files added/updated

  • Added tests/schedulers/test_scheduler_flow_match_euler_discrete.py (11 tests)
  • Updated tests/schedulers/test_scheduler_ddim.py (2 tests)
  • Added tests/others/test_state_dict_utils.py (6 tests)

Why these tests materially reduce regression risk

  1. High blast radius: FlowMatchEuler and LoRA conversion are shared infrastructure used by dozens of pipelines.
  2. Silent failure modes: Inverted comparison guards and incorrect LoRA key remapping produce wrong results without raising errors.
  3. Validation logic: The new tests target explicit ValueError paths that are easy to break during refactors but invisible to pipeline smoke tests.

Validation

All 19 new tests pass locally:

python3 -m pytest tests/schedulers/test_scheduler_flow_match_euler_discrete.py \
  tests/schedulers/test_scheduler_ddim.py::DDIMSchedulerTest::test_set_timesteps_num_inference_steps_exceeds_train_timesteps_raises \
  tests/schedulers/test_scheduler_ddim.py::DDIMSchedulerTest::test_set_timesteps_num_inference_steps_at_limit_succeeds \
  tests/others/test_state_dict_utils.py -v
Open in Web View Automation 

…ict utils

- FlowMatchEulerDiscreteScheduler: contract tests for validation, dynamic
  shifting, integer-timestep rejection, and stochastic sampling
- DDIMScheduler: lock down set_timesteps guard against inverted comparison
- state_dict_utils: unit tests for LoRA key remapping and error paths

Co-authored-by: Simon Lynch <srlynch1@users.noreply.github.com>
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.

1 participant