feat(flux2): add regional prompting for FLUX.2 Klein#9255
Draft
Pfannkuchensack wants to merge 1 commit into
Draft
feat(flux2): add regional prompting for FLUX.2 Klein#9255Pfannkuchensack wants to merge 1 commit into
Pfannkuchensack wants to merge 1 commit into
Conversation
FLUX.2 Klein's diffusers transformer already accepts an attention mask through joint_attention_kwargs, and its unified attention sequence [txt, img] matches FLUX 1, so regional prompting works without a forward override — we just build a restricted mask and pass it down. Backend: - Flux2RegionalPromptingExtension builds a restricted [txt, img] mask from per-conditioning Qwen3 embeddings + image masks (FLUX 1 logic, no CLIP pooled). Unlike FLUX 1 the same mask is applied to every block (no per-block alternation, since we use the diffusers forward). - flux2 denoise() threads pos_joint_attention_kwargs to all positive transformer forwards; negative passes stay unmasked. - flux2_denoise invocation accepts list[FluxConditioningField] and skips masking when reference images extend the image stream. Frontend: - buildFLUXGraph wires posCondCollect + addRegions for the FLUX.2 path. - addRegions clones flux2_klein_text_encoder edges (qwen3_encoder, max_seq_len, mask) for each regional prompt. - validators surface unsupported features (regional negative, auto-neg, reference images) so FLUX.2 regions are filtered consistently with FLUX 1. - schema.ts regenerated to reflect the list-or-single union.
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.
Summary
FLUX.2 Klein's diffusers transformer already accepts an attention mask through
joint_attention_kwargs, and its unified attention sequence[txt, img]matches FLUX 1, so regional prompting works without a forward override — we just build a restricted mask and pass it down.Backend:
Flux2RegionalPromptingExtensionbuilds a restricted[txt, img]mask from per-conditioning Qwen3 embeddings + image masks (FLUX 1 logic, no CLIP pooled). Unlike FLUX 1 the same mask is applied to every block (no per-block alternation, since we use the diffusers forward).flux2denoise()threadspos_joint_attention_kwargsto all positive transformer forwards; negative passes stay unmasked.flux2_denoiseinvocation acceptslist[FluxConditioningField]and skips masking when reference images extend the image stream.Frontend:
buildFLUXGraphwiresposCondCollect+addRegionsfor the FLUX.2 path.addRegionsclonesflux2_klein_text_encoderedges (qwen3_encoder,max_seq_len,mask) for each regional prompt.validatorssurface unsupported features (regional negative, auto-neg, reference images) so FLUX.2 regions are filtered consistently with FLUX 1.schema.tsregenerated to reflect the list-or-single union.Related Issues / Discussions
n/a
QA Instructions
None).Merge Plan
Standard merge. No DB/schema migration.
schema.tsis regenerated and committed.Checklist
What's Newcopy (if doing a release after this PR)