Flux.2 Untwist RoPE
Stop Flux.2 from photocopying your reference image
- model
- reference_latent
- model
Flux.2 (especially Klein) already does style and multi-reference conditioning natively - up to ten reference images, no LoRA. The problem is that "style transfer" is one blunt lever: point it at a reference photo and the model can slavishly copy the composition, pose, and layout instead of absorbing the look. Flux.2 Untwist RoPE is the fine control that nobody else shipped. It scales only the reference image's keys in single-stream attention, by RoPE frequency band, so you can turn down spatial copying and turn up global style pull - mid-sampling, no retraining.
It's a ComfyUI translation of the "Untwisting RoPE" paper (arXiv 2602.05013). You may have seen the original ComfyUI implementation from BigStationW that went around r/StableDiffusion in May 2026 - that one was Z-Image-only, monkey-patched Flux internals directly, and dragged along a whole RF-inversion subsystem. This pack is a clean rewrite for the Flux.2 family: zero new dependencies, and it rides Flux's native ref_latents path instead of reconstructing one.
How it works
RoPE (rotary position embeddings) isn't a single scale. It decomposes into frequency bands with different jobs: high-frequency components are what make attention clamp onto exact positions - which is why a strong reference drags your output into the reference's layout. Low-frequency components carry the broad, global "this is what the style is" signal.
The node appends your reference latent as real Flux.2 reference tokens, then hooks every single-stream attention block via ComfyUI's attn1_patch API. There it builds a per-channel scale vector across the RoPE spectrum - smoothly interpolated from the high scale to the low scale with a beta exponent - and multiplies it into only the reference keys. Target keys, text keys, every query, and all values are left untouched. The scales are also lerped across denoising progress, so the reference can be aggressive early and back off when late-stage texture detail matters.
The design choice that keeps this maintainable: it never touches Flux block classes. If there's no reference token range to act on, the patch returns the tensors unchanged and the node is a no-op. That's the safety net the monkey-patching approach never had.
The inputs that matter
You feed it a model and get a patched model back, which goes straight into your guider/sampler. Of all the knobs, a beginner actually sets four:
high_scale_start/high_scale_end(default 0.25 → 0.75) - scale for the highest-frequency reference keys. Below 1 = less positional copying. This is the anti-photocopy dial.low_scale_start/low_scale_end(default 1.0 → 1.4) - scale for the lowest-frequency bands. Above 1 = more global style/reference pull.beta(2.0) - how sharply the scale interpolates between high and low frequency. Paper default; you'll rarely touch it.reference_latent(optional LATENT) - your encoded reference image from the Flux.2 VAE. Leave it unplugged only if your conditioning already suppliesref_latents.
Also real, later: start_percent/end_percent define the active denoising window, start_single_block/end_single_block limit which single-stream blocks get patched, reference_latents_method picks how reference tokens are positioned (index keeps the spatial grid aligned - leave it), and qk_adain_strength is a StyleAligned-style AdaIN experiment that's off by default for good reason.
Install
No Python dependencies beyond ComfyUI and PyTorch - I checked, there's no requirements.txt to fight with. ComfyUI Manager: search "Flux2 Untwisting RoPE", install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/xmarre/ComfyUI-Flux.2-Untwisting-RoPE
Restart ComfyUI. Then: load your Flux.2 or Klein checkpoint → encode the reference image with the Flux.2 VAE → wire the LATENT into reference_latent → drop this node between the model loader and the guider/sampler.
Where people get burned
- It's a modifier on top of native Flux.2 conditioning, not a replacement. If your style transfer was already fine, this can hurt edit/identity fidelity. The README is honest about that. A/B at a fixed seed before you adopt it.
- VRAM grows with the reference. Appended reference tokens extend attention context, and token count scales with resolution - at 2–4MP the cost is real. Don't feed it a 4K reference you don't need.
- Too much copying → lower
high_scale_start/high_scale_end. Style too weak → raiselow_scale_endfirst. Late-stage texture weak → nudgehigh_scale_end, nothigh_scale_start. The full tuning ladder is in the README. - Silent no-op. If ComfyUI changes the
attn1_patch/img_slicehook contract, the node degrades to a no-op instead of crashing - checkverboseoutput if your reference is doing nothing.
One honest caveat: this pack is brand new and niche - essentially zero impressions right now. The concept is real and it got traction on r/StableDiffusion in its original Z-Image form; this Flux.2 port is the cleaner architecture. Start with the README's suggested settings and treat everything as a tuning knob rather than a recipe.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| high_scale_start | FLOAT | 0.25-4–8 | Scale for highest-frequency reference-key RoPE channels at the start of the active window. <1 reduces positional copying. |
| high_scale_end | FLOAT | 0.75-4–8 | Scale for highest-frequency reference-key RoPE channels at the end of the active window. |
| low_scale_start | FLOAT | 1.00-4–8 | Scale for lowest-frequency reference-key RoPE channels at the start of the active window. |
| low_scale_end | FLOAT | 1.40-4–8 | Scale for lowest-frequency reference-key RoPE channels at the end of the active window. >1 increases global style/reference pull. |
| beta | FLOAT | 2.000.01–32 | Polynomial interpolation exponent from high-frequency to low-frequency scales. Paper default is 2. |
| start_percent | FLOAT | 0.000–1 | — |
| end_percent | FLOAT | 1.000–1 | — |
| start_single_block | INT | 00–999 | — |
| end_single_block | INT | 9990–999 | — |
| reference_latents_method | COMBO | index | How Flux positions appended reference latent tokens. index keeps the spatial grid aligned and differs only by image index; offset/uxo use spatial offsets. |
| qk_adain_strength | FLOAT | 0.000–1 | Optional StyleAligned-style AdaIN on target image Q/K statistics. 0 preserves native Flux.2 behavior. |
| verbose | BOOLEAN | false | — |
| reference_latentopt | LATENT | Encoded reference image latent. You may leave this unconnected if your conditioning already supplies ref_latents. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| model | MODEL | — |