Fix python -O and BatchedBrownianTree w0 handling #9884
Merged
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.
Currently it's not possible to run ComfyUI with
python -O
because asserts only run when optimization is disabled and there are a couple places where ComfyUI actually depends on assert raising an exception for correct handling.It's possible there are places I missed when I looking through the source code for similar structures but with these changes I can verify that ACE-Steps, Chroma Radiance and SDXL work when the Python interpreter is running with optimization enabled.
In the process of fixing that problem, I also noticed that
BatchedBrownianTree
doesn't correctly handle the case wherew0
is passed in kwargs. I don't think this happens in practice anywhere but ifw0
does get passed, it'll be included in the kwargs passed totorchsde.BrownianTree
which doesn't support that argument. The simple fix is to just pop it with a default instead.If necessary I can revert the changes that aren't strictly necessary: This pull also includes a bit of cleanup/refactoring for
BatchedBrownianTree
. The current implementation will movet0
andt1
to CPU (in cpu tree mode) for every tree which isn't necessary. It also always creates an emptyw0
tensor whether it's needed or not. Because of the bug mentioned above, if it ever wasn't needed we would crash so not much real-world impact since apparently no one has ever tried passingw0
to theBatchedBrownianTree
constructor.