Repository navigation
[1/6] refactor(draft): move draft layer components under modeling/draft/layers - #1025
Open
maocheng23 wants to merge 2 commits into
Open
maocheng23 wants to merge 2 commits into
maocheng23 wants to merge 2 commits into
Conversation
Pure relocation, no behavior change. Split from #1023. - specforge/layers/{embedding,linear,lm_head,ring} -> specforge/modeling/draft/layers/ - modeling/draft/{flex_attention,flex_attention_backend}.py -> layers/attention/backends/ - generate_eagle3_mask -> modeling/draft/eagle3_mask.py - modeling/draft/llama3_eagle.py -> modeling/draft/eagle3.py - LlamaMLP -> layers/ffn/dense.py:GatedMLP (re-exported from eagle3 as LlamaMLP) - tests/test_layers -> tests/test_modeling/test_layers (test_decoder.py -> test_ring_attention.py) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
specforge.layers, modeling/draft/{llama3_eagle,flex_attention,flex_attention_backend}
now resolve to the relocated modules (same module objects, so registries and
class identity are preserved) and emit a DeprecationWarning. This commit can
be dropped if a clean break is preferred.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
maocheng23
requested review from
FlamingoPg,
FrankLeeeee,
shuaills and
sleepcoo
as code owners
October 27, 2026 20:42
This was referenced Oct 27, 2026
yushengsu-thu
added a commit
to yushengsu-thu/SpecForge
that referenced
this pull request
Oct 31, 2026
The five commits before this one carry sgl-project#1025 to sgl-project#1028 (draft layers moved, GQA/MLA attention components with the layer factory, residual kinds, visibility). This commit reconnects the MoE FFN to them: - layers/factory.py: build_ffn takes the layer index and delegates to the MoE package's switch, so moe_preset and ffn_layer_types work again. - layers/decoder.py: DecoderLayer.forward takes moe_token_mask and hands it to an MoELayer as its second argument; dense MLPs keep one argument. - dflash.py: pass the layer index and the mask; DFlash2 already calls _ffn. The one test that used the old build_ffn signature is updated. Temporary until sgl-project#1025 to sgl-project#1028 land on main; then this stack rebases onto them and only this commit is replayed.
yushengsu-thu
added a commit
to yushengsu-thu/SpecForge
that referenced
this pull request
Nov 4, 2026
The five commits before this one carry sgl-project#1025 to sgl-project#1028 (draft layers moved, GQA/MLA attention components with the layer factory, residual kinds, visibility). This commit reconnects the MoE FFN to them: - layers/factory.py: build_ffn takes the layer index and delegates to the MoE package's switch, so moe_preset and ffn_layer_types work again. - layers/decoder.py: DecoderLayer.forward takes moe_token_mask and hands it to an MoELayer as its second argument; dense MLPs keep one argument. - dflash.py: pass the layer index and the mask; DFlash2 already calls _ffn. The one test that used the old build_ffn signature is updated. Temporary until sgl-project#1025 to sgl-project#1028 land on main; then this stack rebases onto them and only this commit is replayed.
This branch has not been deployed
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
The first step in splitting #1023. This PR only moves files, so reviewing it means checking renames and import paths.
Modifications
specforge/layers/{embedding,linear,lm_head,ring}→specforge/modeling/draft/layers/modeling/draft/{flex_attention,flex_attention_backend}.py→modeling/draft/layers/attention/backends/generate_eagle3_mask→modeling/draft/eagle3_mask.pymodeling/draft/llama3_eagle.py→modeling/draft/eagle3.pyLlamaMLP→layers/ffn/dense.py:GatedMLP, still importable aseagle3.LlamaMLPtests/test_layers→tests/test_modeling/test_layers(test_decoder.py→test_ring_attention.py, since it tests ring attention)A second, separable commit keeps the old import paths working for one release.
specforge.layers.*,draft.llama3_eagleanddraft.flex_attention_backendresolve to the same module objects as the new paths, so registries, class identity andmock.patchtargets are unchanged.draft.flex_attentionre-exports the helpers andgenerate_eagle3_mask. All of them emit aDeprecationWarning. Drop commit 2 if a clean break is preferred.Accuracy Test
No numerical change.
git diff -M origin/mainshows renames plus import edits only.tests/test_modelingon CPU (torch 2.14, transformers 5.12): 158 tests, 23 skipped, 4 errors. The 4 errors are the moved TP/ring tests failing to importsglang/yunchang, which aren't installed in that environment; they import those at module level, both before and after the move.test_moved_import_paths.pycovers the shims.Stack
This is part of a split of #1023 (by @jiapingW) into reviewable layers. Each PR targets the branch of the previous one, and only its own commits show in the diff.
The code is @jiapingW's from #1023 (commits are authored by them). The split adds a parity test, legacy import shims, and two fixes in the visibility PR, each noted in the PR it belongs to.
🤖 Generated with Claude Code