Fix/issue 20 - #24
Open
Dikshant-Neupane wants to merge 3 commits into
Open
Conversation
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.
Description
This PR resolves Issue #20, comprehensively addressing performance degradation, numerical instability in CFG, ODE trajectory overshoot in Turbo models, and VRAM limitations during batch processing.
Key Changes
Global Norm CFG Scaling (
pipeline.py)Low-Step Cosine Turbo Schedule (
pipeline.py)build_scheduler(): whennum_steps <= 8, base sigmas follow a smooth cosine downstep schedule instead of a massive linear drop.Dynamic VRAM Guard for
batch_cfg(pipeline.py)_build_pack_ctx()to estimate required attention memory for combined multi-image packed sequence arrays.torch.cuda.mem_get_info), the system automatically issues a warning and disables sequence duplication (batch_cfg=False), preventing silent OOM crashes on 24GB consumer GPUs.Zero-Loop Vectorized SDPA Fallback (
_attn_backend.py)for-loop iterating overflash_attn_varlen_funcslices.torch.nn.utils.rnn.pad_sequenceto transform packed arrays into grouped(B, L, H, D)blocks, utilizing a single fusedF.scaled_dot_product_attentionkernel launch.SM90+ FA4 Hardware Guard (
_attn_backend.py)torch.cuda.get_device_capability()evaluation within the FlashAttention-4 lazy resolver._resolve_fa2()on Ampere (major < 9) hardware, preventing unoptimized CuTe DSL DSL fallback compilation errors.Test Suite (
tests/test_flow_performance.py)pytestcoverage introduced to assert exact spatial equivalence in CFG, verify exact terminal boundary math in Cosine Sigmas, and assert seamless downshifting against mocked Out-Of-Memory boundaries.Related Issues