Repository navigation
Conversation
cih9088
requested review from
FlamingoPg,
FrankLeeeee,
shuaills and
sleepcoo
as code owners
September 28, 2026 08:02
This was referenced Oct 6, 2026
maocheng23
added a commit
to maocheng23/SpecForge
that referenced
this pull request
Oct 6, 2026
…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>
Collaborator
|
Thanks @cih9088 for finding and fixing this. The
One open question on #934: We'd suggest closing this PR in favor of the split once you've had a look. Feedback on the new PRs is very welcome. |
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.
Motivation
DFlash attention implementation in sglang uses
is_causalattribute to determine causal or bidirectional.https://github.com/sgl-project/sglang/blob/9d18277c2720f3a1d6e64f90259e1d1b9ba9a26a/python/sglang/srt/models/dflash.py#L46-L81
is_causalnot present: bidirectional for full-attention, causal for sliding-attentionis_causal=False: bidirectional for full-attention, sliding-attentionis_causal=True: causal for full-attention, sliding-attentionHowever, SpecForge just ignores the
is_causalattribute and always uses bidirectional for full-attention and causal for sliding-attention.Modifications
is_causalnot present: bidirectional for full-attention, causal for sliding-attention as beforeis_causal=False: bidirectional for full-attention, sliding-attentionis_causal=True: causal for full-attention, sliding-attention_prepare_attention_mask()to be used for inference (spec_generate())dflash_mask.pyso that the masking functions can be used indflash_model_family.py(training) anddflash.py(inference)Related Issues
Accuracy Test
Benchmark & Profiling
Checklist