Eagle3: compact supervised positions before vocabulary projection - #85
Open
julyanghar wants to merge 2 commits into
Open
Eagle3: compact supervised positions before vocabulary projection#85julyanghar wants to merge 2 commits into
julyanghar wants to merge 2 commits into
Conversation
Author
|
Hi @Hannibal046, could you please take a look when you have time? This PR only compacts EAGLE3's vocabulary-side supervised rows. The teacher LM-head projection and every TTT backbone/QKV/attention step remain full-length. It includes:
I'm happy to adjust the API or split the benchmark/tests if a smaller PR is preferred. |
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.
Summary
This PR ports SpecForge's A-level Eagle3 loss-position compaction into DeepSpec's cached-teacher training path.
local_mean = batch_size * sequence_lengthdenominator;model.trim_loss_positions=falseby default.The implementation builds exact per-step draft/teacher row maps and computes one shared compact teacher-probability table. Indexed Triton kernels for metrics and soft cross-entropy read target rows directly from that table, so no per-step
[N_t, V]target tensor is materialized in forward or backward. Empty local steps execute one zero-masked dummy row so FSDP ranks retain aligned module execution.Correctness and scope
dlogitswith an explicitly materialized reference. A test-only dispatch counter observes teacher-tableindex_selectin the reference and zero such materializations in the candidate; shifted indices are detected as a negative control.q_projcalls remain length 16, the teacher LM-head remains length 16, only draft LM-head rows become[5, 4, 4], and DynamicCache grows[16, 32, 48].max_parameter_diff=0) and parameters remain rank-consistent.Performance
Synthetic values with real Qwen3-8B draft shapes, BF16, one Eagle3 layer, sequence length 4096, TTT length 7, contiguous-tail supervision, RTX 6000 Ada. Timing covers one Eagle3 forward + backward, excluding model construction, data generation, optimizer, I/O, and profiler. Each result uses 3 alternating warm-up pairs and 7 alternating measured pairs.
The direct-index path removes the previous dense-supervision crossover as well: at 90% supervision it now reduces peak allocated memory by 7.948 GiB and improves forward+backward time by 6.2%.
Usage
Tests