[core] Add DyPE for training-free high-resolution generation - #28
Draft
smellslikeml wants to merge 2 commits into
Draft
[core] Add DyPE for training-free high-resolution generation#28smellslikeml wants to merge 2 commits into
smellslikeml wants to merge 2 commits into
Conversation
Adapted from https://github.com/guyyariv/DyPE (MIT). Co-Authored-By: remyx-ai[bot] <289541483+remyx-ai[bot]@users.noreply.github.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Aug 17, 2026
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?
Adds DyPE (Dynamic Position Extrapolation) as a
hooksutility for training-free ultra-high-resolution generation on RoPE DiTs such asFluxTransformer2DModel— no fine-tuning and no extra sampling cost.apply_dype(pipe.transformer)swaps the positional embedding for a timestep-aware YaRN / NTK-by-parts schedule (κ = t²) that engages only above the trained resolution (1024² for Flux) and is otherwise a bit-for-bit no-op.Notes
muwith the image sequence length, which collapses the sigma schedule at 4K (the sampler never leaves the noise regime). Pinningbase_shift == max_shiftholdsmuconstant. This is a pipeline-level setting and is intentionally kept out of the hook's scope.register_forward_pre_hook, so it keeps working when the transformer'sforwardis re-wrapped byenable_model_cpu_offload.Validation
Reproduces the reference implementation (
guyyariv/DyPE, MIT) on FLUX.1-Krea-dev at 4096² (guidance 4.5, 28 steps); the positional-embedding output matches the reference toΔ = 0. Unit tests cover the schedule helpers, the no-op-at-trained-resolution guarantee, the timestep schedule, and the hook lifecycle.The schedule is adapted from https://github.com/guyyariv/DyPE (MIT-licensed).
🤖 Generated with Claude Code