Fix Flax LMSDiscreteScheduler sigma indexing and align LMS prediction_type with PyTorch#13556
Open
HaoyuLi-Nova wants to merge 1 commit intohuggingface:mainfrom
Open
Fix Flax LMSDiscreteScheduler sigma indexing and align LMS prediction_type with PyTorch#13556HaoyuLi-Nova wants to merge 1 commit intohuggingface:mainfrom
HaoyuLi-Nova wants to merge 1 commit intohuggingface:mainfrom
Conversation
…improve documentation - Updated the `FlaxLMSDiscreteScheduler` and `LMSDiscreteScheduler` classes to include 'sample' as a valid option for `prediction_type`. - Improved docstrings for clarity, specifying the expected types and values for various parameters. - Added a new test case to validate the full loop functionality with the 'sample' prediction type. This change ensures better flexibility in prediction methods and enhances code documentation for future reference.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
FlaxLMSDiscreteSchedulerpipelines pass timestep values fromstate.timesteps(training-time indices), whilestate.sigmasafterset_timestepsis indexed by inference step (lengthnum_inference_steps + 1). The previousstepimplementation indexedsigmaswith that timestep value directly, which is inconsistent withFlaxEulerDiscreteSchedulerand can yield wrong sigma values or out-of-bounds behavior. This PR resolves the step index viajnp.where(state.timesteps == timestep, size=1)before readingsigmaand before LMS coefficient integration.Additional alignment with PyTorch
LMSDiscreteScheduler:prediction_type="sample", validateprediction_typein__init__, clarify docs (beta_schedule,get_lms_coefficient,steptimestep semantics), fix comment typo (“settable”).ValueErrormessage instepso it listsepsilon,sample, andv_prediction(behavior already supportedsample).Tests: extend
test_prediction_typewith"sample", addtest_full_loop_with_sample_prediction, and addtests/schedulers/test_scheduler_lms_flax.py(@require_flax, lazy JAX import).Fixes # (N/A — no linked issue)
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
cc @yiyixuxu (schedulers) @pcuenca (JAX/Flax)