Skip to content

feat(attention): validate draft direction and record resume semantics - #960

Merged
maocheng23 merged 1 commit into
mainfrom
codex/pr942-04-attention-semantics
Oct 22, 2026
Merged

maocheng23 merged 1 commit into
mainfrom
codex/pr942-04-attention-semantics

Conversation

@jiapingW

@jiapingW jiapingW commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Validate nullable is_causal, record explicit attention overrides in resume metadata, and reject bidirectional sliding-window exports in the SGLang normalization gate until that serving path is validated.

Reuse main's shared training/inference masks and per-layer direction defaults. Sliding windows bound both context and draft tokens, including when is_causal is unset. The older duplicate mask builders and inference-mask implementation are removed from this PR. Tests cover direction/window visibility, gradient isolation, cached inference, DSpark, configuration round-trips, and resume/export contracts.

Stack: main → #960 → #961 → #963 → #965. One attention-only commit on current main.

Validation on H20 (Python 3.12, PyTorch 2.14.1+cu130): 115 tests passed, 1 FlashAttention 2 test skipped on this layer. Full-stack validation on H20 (Python 3.12, PyTorch 2.14.1+cu130, Liger 0.8.5): 285 tests passed, 3 skipped (FlashAttention 2 unavailable and two Blackwell-only tests). Black 24.10.0, isort 5.13.2, and git diff --check passed. No full-model training or end-to-end benchmark was run.

@jiapingW jiapingW changed the title [4/11] feat(attention): configure draft range and direction independently [4/10] feat(attention): configure draft range and direction independently Oct 14, 2026
yushengsu-thu added a commit to yushengsu-thu/SpecForge that referenced this pull request Oct 15, 2026
…yers 1-7 of the sgl-project#942 split), matching the dense-1/8 branch

The combined PR sgl-project#942 merge was reverted in the previous commit; this takes the split stack instead
(sgl-project#957 streaming-read fixes, sgl-project#958 DDP sync once per accumulation window, sgl-project#959 no implicit qwen3-instruct
system prompt, sgl-project#960 is_causal, sgl-project#961 fused DFlash head, sgl-project#962 selective checkpoint contexts, sgl-project#963 shared
flatten_vocab_projection / cache_vocab_projection), so the MoE arm carries exactly the same upstream code
as the dense-1/8 arm. Conflicts in specforge/training/backend.py and controller.py resolved in the stack's
favour.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@jiapingW

Copy link
Copy Markdown
Collaborator Author

The current PR is related to #960. Compatibility needs to be considered. @maocheng23

@maocheng23

Copy link
Copy Markdown
Collaborator

The current PR is related to #960. Compatibility needs to be considered. @maocheng23

This is PR 960 right?

def resolve_dflash_causal_block(config) -> Optional[bool]:
"""Read the direction override; None preserves the legacy per-layout defaults."""

value = getattr(config, "is_causal", None)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.is_causal = False
self.causal_block = resolve_dflash_causal_block(config)
kwargs["is_causal"] = False

If they are all the same, shall we just use the same param?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, shall we move the mask related code to common/dflash_family_model, so other draft models can work as well

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can be also used in eagle class models. So I think it's need to be designed in a DraftModelConfig class.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of simplicity, I will handle the configuration and masks in a separate PR.

@jiapingW

Copy link
Copy Markdown
Collaborator Author

The current PR is related to #960. Compatibility needs to be considered. @maocheng23

Sorry, this is a misunderstanding.

Base automatically changed from codex/pr942-03-qwen3-template to main October 22, 2026 03:18
@jiapingW
jiapingW force-pushed the codex/pr942-04-attention-semantics branch from afcacbe to 4a3802c Compare October 22, 2026 06:03
@jiapingW jiapingW changed the title [4/10] feat(attention): configure draft range and direction independently feat(attention): validate draft direction and record resume semantics Oct 22, 2026

@maocheng23 maocheng23 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo: Move the mask code later

@maocheng23
maocheng23 merged commit f586b1e into main Oct 22, 2026
7 of 8 checks passed
@maocheng23
maocheng23 deleted the codex/pr942-04-attention-semantics branch October 22, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants