Fix StableDiffusion3Pipeline.skip_guidance_layers raising AttributeError - #14731
Open
yupengtang wants to merge 1 commit into
Open
Fix StableDiffusion3Pipeline.skip_guidance_layers raising AttributeError#14731yupengtang wants to merge 1 commit into
yupengtang wants to merge 1 commit into
Conversation
`__call__` stores the other guidance knobs on `self` so the matching
properties can read them back:
self._guidance_scale = guidance_scale
self._skip_layer_guidance_scale = skip_layer_guidance_scale
self._clip_skip = clip_skip
...
`skip_guidance_layers` was left out, but the property that reads
`self._skip_guidance_layers` exists, so `pipe.skip_guidance_layers` raises
`AttributeError` whether or not a call has run. Nothing in `src/diffusers`
assigns that name.
The existing `test_skip_guidance_layers` now checks the property alongside
the outputs it already compares.
Contributor
|
Hi @yupengtang, thanks for the PR! It does not appear to link an issue it fixes. If this PR addresses an existing issue, please add a closing keyword (e.g. Please note that PRs without a linked issue are likely to be automatically closed 10 days after this notice. Once the PR links an issue (or gets the |
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?
StableDiffusion3Pipeline.skip_guidance_layersraisesAttributeError, before or after a call:__call__stores the other guidance knobs onselfso their properties can read them back, butskip_guidance_layerswas left out of that block:grep -rn "_skip_guidance_layers = " src/returns nothing, so the name is never assigned anywhere in the library.skip_guidance_layersstays a local in__call__and does reach the transformer, so skip layer guidance itself works. Only the property is broken.Adding the missing assignment is the whole change.
StableDiffusion3Pipeline.__call__is not a# Copied fromsource for any other pipeline, so nothing else moves.Testing
tests/pipelines/stable_diffusion_3/test_pipeline_stable_diffusion_3.py::TestStableDiffusion3Pipeline::test_skip_guidance_layersalready runs the feature both ways, so it now also reads the property back. Two assertions, no new fixture.main: fails withAttributeError: 'StableDiffusion3Pipeline' object has no attribute 'skip_guidance_layers'. With this branch: passes. The message names the property rather than the missing underscore attribute, because the getter'sAttributeErrorfalls through tonn.Module.__getattr__, which probably helped this go unnoticed.mainand this branch. The failure istest_inference, which compares against a hardcoded expected slice atatol=1e-3and misses on my CPU box onmaintoo.ruff checkandruff format --checkon both changed files with the 0.9.10 pinned insetup.py: clean.make fix-copiesis unaffected, since nothing copies from__call__.Ran on Python 3.13, torch 2.11.0, Linux, CPU.
Self-review
Against
.ai/references/review-rules.md:__call__is not a# Copied fromsource before editing it.testing.md.skip_guidance_layersis documented as a__call__argument in the docstring, which is accurate and unchanged. Nothing underdocs/mentions the property._skip_layer_guidance_scaleis the mirror image of this, assigned in__call__but with no property, whileskip_layer_guidance_startandskip_layer_guidance_stophave neither. If the intent is for every guidance knob to be readable back, those are the remaining gaps. I left them alone since only the missing assignment causes a failure today.