anyflow: swap unconditional aliases instead of popping them - #3085
Merged
Conversation
added 2 commits
August 15, 2026 08:58
Flux keys its text conditioning on prompt_embeds, so popping the alias in _unconditional_batch crashed any run using real_score_guidance_scale > 0 with KeyError at model_predict. Replacing the alias with the negative embeds (and alias masks with the negative mask when cached) serves both families: Ideogram's proxy path reads the same negative tensor it used to fall back to, and Flux keeps the key it requires. Note: the unconditional pass still reuses the positive pooled projection for Flux since collation does not cache a negative pooled embed.
…pass Collation now carries the unconditional pooled projection as negative_add_text_embeds, prepare_batch moves it to the accelerator, and _unconditional_batch swaps it into add_text_embeds and added_cond_kwargs.text_embeds so Flux and SDXL-style conditioning no longer reuse the positive pooled embed during unconditional scoring.
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
Fixes AnyFlow's unconditional batch construction for families that key text conditioning on
prompt_embeds, and completes the negative-conditioning swap for pooled projections._unconditional_batchpopped the model-specific aliases (prompt_embeds,attention_mask,attention_masks) so swapped unconditional embeds would take effect for families that merely prefer those keys (Ideogram). But Flux requiresprompt_embedsinmodel_predict, so any Flux run withreal_score_guidance_scale > 0crashed withKeyError: 'prompt_embeds'inside_apply_real_score_guidance.Changes:
_unconditional_batchswaps aliases instead of popping:prompt_embedsgets the negative embeds; alias masks get the cached negative mask (or are dropped when none is cached, preserving prior stale-mask behaviour). Ideogram's proxy path reads the same negative tensor it previously reached via fallback.negative_add_text_embeds,prepare_batchmoves it to the accelerator, and the unconditional batch swaps it intoadd_text_embedsandadded_cond_kwargs.text_embeds— the unconditional pass no longer reuses the positive pooled embed for Flux/SDXL-style conditioning.Testing
.venv/bin/python -m unittest tests.helpers.distillation.test_anyflow_distiller -f— 57 tests pass, including alias-swap coverage, negative-mask swap, and the pooled-embed swap (verifying the original batch's added_cond_kwargs is not mutated).