[3/3] perf(dflash): compiled create_block_mask / flex_attention wrappers - #24
Closed
maocheng23 wants to merge 1 commit into
Closed
maocheng23 wants to merge 1 commit into
maocheng23 wants to merge 1 commit into
Conversation
…led wrappers create_dflash_block_mask now goes through SpecForge's compile_friendly_create_block_mask (which forwards BLOCK_SIZE via **kwargs), and DFlash attention uses SpecForge's compile_friendly_flex_attention instead of the transformers copy. The compiled wrapper is imported lazily inside create_dflash_block_mask: importing it at module scope pulls in torch._dynamo, and tests that build stubs under patch.dict(sys.modules) then purge it and hit a duplicate TORCH_LIBRARY registration on re-import (test_dflash_losses run alone). Note: importing specforge.modeling.draft.flex_attention sets torch._dynamo.config.recompile_limit = 64 process-wide. Split out of sgl-project#905. Co-authored-by: Inhyuk Cho <ihcho@lgresearch.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
maocheng23
force-pushed
the
dflash-inference-masks
branch
from
October 6, 2026 02:48
9c404db to
e0db52f
Compare
maocheng23
force-pushed
the
dflash-compiled-block-mask
branch
from
October 6, 2026 02:48
c336279 to
a8c526d
Compare
Owner
Author
|
Superseded by sgl-project#936. |
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.
Split of sgl-project#905, part 3 of 3. Stacked on #23. Needs a GPU throughput A/B before it goes upstream.
Changes
create_dflash_block_maskuses SpecForge'scompile_friendly_create_block_mask(now forwarding**kwargs, soBLOCK_SIZEstill works).compile_friendly_flex_attentioninstead of the transformers copy. On torch ≥ 2.7 both are plaintorch.compile(flex_attention).create_dflash_block_mask. In Fix DFlash attention masking sgl-project/SpecForge#905, the module-level import pulledtorch._dynamoin undertest_dflash_losses'spatch.dict(sys.modules). That made the file fail 28/28 when run alone (reproduced on Fix DFlash attention masking sgl-project/SpecForge#905's head7ccc036), which CI's single discover run hides. With this PR it passes 28/28 alone.Open questions
S,N) change every step. On CPU,test_dflash_mask.pygoes from 0.1s to 17s because each new shape compiles. GPU training needs a samples/s comparison against [2/3] feat(dflash): share DFlash masks with inference, default masks for spec_generate #23, for example a 200-step Qwen3.8 DFlash2 flex run.specforge.modeling.draft.flex_attentionsetstorch._dynamo.config.recompile_limit = 64for the whole process. It is now imported by every DFlash user, not only Eagle3/PEagle.Co-authored with @cih9088 (original sgl-project#905).
🤖 Generated with Claude Code