mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #366] [CLOSED] [RFC] EXPERIMENTAL Investigate DFlash2 support for Qwen3.8-Flash-Next #2601
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2601
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/366
Author: @j-luwierski
Created: 10/1/2026
Status: ❌ Closed
Base:
main← Head:dflash2-qwen3.8-flash-next📝 Commits (10+)
2575cb1C-3: the prompt path's GDN short conv tiled over tokensdf6980dE-2: prefetch the i-quant expert rows ahead of the AVX-512 decode; an opt-in gather decodecf68b00D-5: the prompt path's expert stream is issued by its own host threadcb91f2aserve: keep image parts in tool/assistant messages456011eLayer split limits: docs/MULTI_GPU.md and bench/results/2026-09-29-layer-split-limitsf0bbe97E-4 (prompt side): the draft layer's pass over a prompt chunk without a host sync per groupefddd74E-6: a verify layer whose routed experts are all in VRAM needs nothing from the host66f4341D-2: the prompt path's GDN recurrence split over value columns, the output norm in its own kernel0abcd5bE-6: the device plan opt-in (STRATA_VERIFY_DEVICE_PLAN=1)57fa1fdserve: routing traces from the live server (--dump-routing under --serve)📄 Description
Summary
Related to #347.
This draft PR proposes an investigation into DFlash2 support for Qwen3.8-Flash-Next in Strata.
The goal is to determine whether a compatible DFlash2 drafter can be integrated with Strata’s execution model and provide a measurable improvement over the existing MTP path, while preserving the target model’s decoding semantics.
This is initially a planning and feasibility PR. It does not claim that a compatible Flash-Next checkpoint is available, that an implementation is complete, or that DFlash2 will be faster on Strata’s supported hardware.
I would like to use this PR as a place to discuss the approach, record findings, and keep the investigation reproducible. A documented limitation or negative result would also be a useful outcome.
Current status and open assumptions
The initial investigation separates three questions:
The publicly documented DFlash2 checkpoint for Qwen3.8-27B should not be treated as a compatible checkpoint for Qwen3.8-Flash-Next. Compatibility needs to be established explicitly.
Likewise, Flash-Next’s existing MTP weights are not automatically DFlash2 weights. Reusing parts of the current speculative decoding infrastructure may be possible, but this does not remove the need for a compatible trained drafter.
Any statement below describing planned behavior is a proposal, not a completed implementation.
1. Model-side requirements
This workstream covers the artifacts and architectural contracts required from the target–drafter pair.
Compatible drafter weights
Before implementing the full runtime, establish:
A matching tokenizer or similar model name is not sufficient evidence of compatibility.
If no compatible checkpoint is available, this becomes a separate training or distillation dependency. The PR should then document the missing requirements rather than present runtime integration alone as working model support.
Target feature contract
Document exactly what the drafter expects from the target:
Layer indices and tensor layouts should come from the checkpoint and reference implementation, rather than being guessed or copied from the 27B integration.
Token and vocabulary compatibility
Verify:
Any mismatch should produce an explicit compatibility error.
If training is required
Prepare a separate feasibility note covering:
Training a useful drafter should be treated as an independent milestone. It should not be hidden inside the runtime implementation estimate.
2. Strata-side changes
The runtime work should begin with an audit of existing functionality, especially the MTP verification path, before deciding which components need to change.
Drafter loading and validation
Introduce a clearly defined configuration and loading path for the selected DFlash2 checkpoint.
Validation should cover the target identity, architecture, tensor shapes, vocabulary contract, and supported block sizes. Unsupported combinations should fail with actionable diagnostics.
The initial implementation should remain experimental and opt-in.
Target feature extraction
Expose the required target features during prefill and decoding.
The implementation needs to establish:
Where possible, features should stay on the device that consumes them. Any host transfers should be measured explicitly.
DFlash2 execution
Implement the operations required by the selected reference architecture, including:
The implementation should preserve the reference architecture’s semantics before introducing optimizations.
A simpler mock or partial drafter may be useful for testing infrastructure, but it should be clearly identified as such and not reported as DFlash2.
Verification and state management
Audit whether the existing verifier can accept proposals independently of the MTP implementation.
Correctness must cover:
The initial focus should be a linear candidate sequence. More complex verification structures are outside the first milestone unless required by the reference algorithm.
Sampling semantics
Start with greedy decoding to reduce the number of moving parts.
Support for nonzero-temperature sampling should be a separate milestone. It requires the correct proposal probabilities and acceptance/correction procedure for the selected DFlash2 implementation.
Matching output for one seed is not sufficient evidence of distribution-preserving sampling. Likewise, a deterministic greedy prototype should not be described as supporting general lossless sampling.
Memory budgeting
Account for the complete incremental footprint:
This is particularly important for Strata because allocating VRAM to a new drafter may reduce the memory available for cached experts. A faster drafting method can still make the complete system slower if it increases CPU work or transfers.
3. First small experiment: verifier and rollback correctness
The first proposed experiment does not require a trained Flash-Next DFlash2 checkpoint.
Its purpose is to establish whether the existing target execution path can safely support an alternative source of draft proposals.
Setup
Use three fixed prompts covering code, prose, and a short reasoning task, generating up to 128 tokens per prompt.
Procedure
The deliberately incorrect token should differ from the reference token and avoid unrelated EOS or special-token behavior.
Numerical controls
Strata’s numerical execution path may depend on token grouping. The experiment must first establish the expected relationship between single-token and multi-token execution under the chosen configuration.
Use a controlled kernel configuration where supported. Record tolerances and compare finite logits on identical prefixes before interpreting a later sequence divergence.
If the baseline itself is not stable, investigate that first rather than attributing the difference to DFlash2.
Pass criteria
Record verification time, rollback time, and additional memory usage, but do not interpret these measurements as DFlash2 performance.
This experiment validates integration infrastructure, not drafter quality or DFlash2 speedup.
4. First experiment with a real drafter
Once a compatible checkpoint and reference implementation are available:
Start with one supported block size from the checkpoint’s configuration. Any later block-size sweep must distinguish between total block length, number of proposed tokens, and verifier-produced tokens.
If the checkpoint is unavailable, this milestone remains blocked; successful mock-proposal tests do not satisfy it.
5. Performance evaluation
Compare three explicit configurations:
Use the same target weights, quantization, prompts, output limits, and sampling settings.
Run repeated measurements after warm-up, and report variability rather than only the fastest run. Keep correctness measurements separate from performance measurements if they require different execution settings.
Metrics
Record:
Accepted draft tokens and total emitted tokens must be reported separately so that a verifier-generated token does not inflate the acceptance metric.
Fair memory comparison
The primary comparison should use the same total hardware memory budget and document the resulting expert-cache allocation for each method.
An additional diagnostic comparison with a fixed expert-cache allocation may help isolate runtime costs, if it fits in memory.
Improvement over target-only decoding is not enough to justify replacing MTP. The useful result is a repeatable improvement over the existing Strata configuration on the tested workload and hardware.
6. Documentation and reproducibility
Proposed structure:
Document responsibilities
Large tensor dumps and model weights should remain outside the repository, with checksums and retrieval instructions where appropriate.
Run manifest
Each run should identify:
Findings should distinguish observed facts, hypotheses, and decisions. Failed experiments should include enough information to reproduce the failure.
7. Initial non-goals
The first implementation milestone does not include:
These can be considered after the smallest correct configuration has been demonstrated.
8. Proposed milestones
The feasibility milestone can conclude with a documented blocker or a negative performance result. Full support should only be claimed after a compatible checkpoint, correct runtime behavior, and reproducible measurements are available.
Feedback requested
Before expanding the implementation, feedback would be particularly useful on:
References
- Tracking issue #347
- DFlash reference repository
- DFlash2 architecture and release notes
- Published Qwen3.8-27B DFlash2 checkpoint — reference only, not established Flash-Next compatibility
- Strata implementation and performance details
<html><head></head>Training plan if no compatible Flash-Next DFlash2 checkpoint exists
This is intended as a concrete follow-up to the “If training is required” section above, rather than a replacement for the existing runtime/integration plan.
The current PR already covers verifier/rollback correctness, runtime integration, sampling semantics, memory accounting, benchmarking against MTP, and reproducibility. I do not want to duplicate those parts here.
The goal of this additional workstream is narrower:
Why SpecForge looks like the best starting point
SpecForge currently has explicit DFlash2 training support.
In particular:
DFlash2 remains under
training.strategy: dflash;the draft architecture is selected through an explicit
DFlash2DraftModelconfiguration;offline training from precomputed hidden-state checkpoints is supported through
data.hidden_states_path;the target model does not need to remain loaded during offline training;
DFlash2 includes grouped dynamic convolution and a learned top-k path selector;
selector loss, warmup, ramp-up, and selector-specific metrics are already implemented.
This means the intention would not be to reimplement the DFlash2 training algorithm.
The main work would instead be adapting the Flash-Next target feature path and producing data that satisfies SpecForge's DFlash training contract.
Relevant SpecForge documentation:
https://github.com/sgl-project/SpecForge/blob/main/docs/sections/basic_usage/training.md
1. First establish the Flash-Next feature contract
This should happen before collecting a meaningful dataset.
The central question is:
For every proposed capture point, document:
target layer/block index;
exact location inside the block;
whether the tensor is before or after normalization;
whether it is before or after residual merging;
actual tensor shape and dtype;
token-to-feature alignment;
whether the same representation is available during prefill and autoregressive decode;
whether any projection or transformation is required before the drafter consumes it.
hidden_size = 2560alone is not enough to assume that every useful internal Flash-Next tensor is simply[tokens, 2560].Any reduction, concatenation, projection, or layout conversion must become an explicit part of the target–drafter contract. It should not be introduced silently in the data exporter.
For the first training experiment I would start with three target feature taps, approximately covering early, middle, and late parts of the network.
The exact layer indices should only be chosen after inspecting the Flash-Next execution graph.
Deliverable
A small compatibility note containing the selected capture points, shapes, alignment rules, and one captured short sequence.
2. Add a training-feature export path to Strata
The normal generation API does not expose the features required for DFlash2 training, so Strata will need an internal capture path.
A training sample should contain at least the equivalent of:
The exact serialization format should be chosen to minimize conversion work when feeding the data into SpecForge.
The important requirement is that sequence boundaries and token positions remain completely unambiguous.
3. Prefer a two-pass data-generation path
My preferred first implementation would separate response generation from feature capture.
Pass A — generate sequences
Run the exact Flash-Next target configuration that we eventually want to accelerate.
Store the exact token IDs generated by the target, rather than only decoded text.
Pass B — replay and capture
Replay the complete stored sequence through Flash-Next and capture the selected hidden states during prefill.
This could make large-scale feature collection significantly cheaper than dumping activations during the autoregressive generation loop.
However, this optimization must be validated first.
For the same short sequence, compare the selected target features from:
against:
at matching token positions.
If those representations are not equivalent under the selected Strata execution path, the exporter must use the representation that actually exists during inference.
A one-token feature alignment error could still allow the training loss to decrease while producing a useless drafter.
4. Keep the initial target configuration fixed
The first drafter should target exactly one Flash-Next configuration.
For example:
Initially avoid mixing:
different quantizations;
modified Flash-Next checkpoints;
steering/control vectors;
speed projection;
Coder/Swift variants;
other experimental weight changes.
Training against activations produced by the same quantized target used in Strata is a reasonable experiment, because this is the environment in which the drafter would actually run.
However, transfer to another target quantization or modified model should not be assumed.
5. Start with a deliberately small target-generated dataset
The training data should preferably contain responses generated by the exact target model being accelerated.
An initial mixture could include:
C++ code;
Python code;
debugging;
technical explanations;
normal English conversation;
normal Polish conversation;
short reasoning tasks.
Suggested progression:
These values are starting hypotheses, not a proposed final architecture.
Before any real training run:
instantiate the complete draft model;
count trainable and frozen parameters;
run a full
forward -> backward -> optimizer.step;record peak VRAM;
only then increase sequence length or sampled anchors.
The large vocabulary projection may be one of the dominant memory costs, so this should be measured rather than estimated away.
8. Make tiny-dataset overfitting the first training gate
Before collecting millions of tokens, deliberately overfit approximately 16–32 short sequences.
The goal is not generalization.
The goal is to prove that:
features are aligned correctly;
loss masks are correct;
gradients reach the projection, draft layers, convolution, and selector;
correct future tokens can be learned;
selector candidate coverage improves;
checkpoint save/load preserves the result.
Track at least:
If the drafter cannot strongly fit this tiny dataset, do not scale the dataset.
Investigate:
first.
9. Add an explicit future-information leakage test
Offline training from complete sequences makes accidental future-token leakage a particularly important failure mode.
When the drafter predicts future positions, it must not receive target features containing information that would not exist at that point during real speculative decoding.
A simple regression test should:
keep a valid prefix fixed;
change tokens after the draft anchor;
rebuild the training input;
verify that drafter inputs that should depend only on the prefix remain unchanged.
If changing future tokens changes a supposedly prefix-only target feature, the capture/training contract is invalid.
This should be checked before interpreting any impressive training accuracy.
10. Use the existing DFlash2 selector schedule before experimenting with new objectives
For the first working baseline, use the existing SpecForge DFlash2 objective rather than introducing custom training losses.
Conceptually:
The selector should initially have either a warmup period or a gradual ramp, using the existing SpecForge controls:
The reason is that the selector cannot recover a correct token that is not already present in its unary top-k candidate set.
Therefore candidate coverage should be monitored before aggressively tuning the selector.
In particular, track SpecForge's unary top-k recall metric.
D-PACE or more aggressive objective changes can be tested later, after a plain DFlash2 baseline works.
11. Evaluate draft quality using accepted-prefix length
Token accuracy alone is not a sufficient speculative-decoding metric.
For example:
The final
Dbeing correct provides no speculative-decoding benefit once the prefix has already failed atX.The most useful offline metrics should therefore include:
accuracy by future-token position;
Recall@K;
selector accuracy conditioned on a valid previous prefix;
simulated accepted-prefix length;
distribution of accepted-prefix lengths.
SpecForge already exposes DFlash-family per-position diagnostics and an offline
simulated_acc_lenevaluation metric, which makes it useful for this stage.These metrics are still only training diagnostics.
The real acceptance and end-to-end speed measurements remain the runtime milestones already described elsewhere in this PR.
12. Define a training-side go/no-go gate
Before moving from the pilot to a larger dataset, I would require:
If those conditions fail, the next step should be to investigate the cause rather than scaling training.
A negative result here would still answer an important feasibility question for this PR.
13. First concrete training milestone
I would define the first training milestone as:
This milestone should produce three artifacts:
1. Strata feature exporter
Responsible for:
2. Flash-Next / SpecForge adapter
Responsible for:
3. Minimal trained checkpoint
A small experimental DFlash2 checkpoint which successfully fits the tiny dataset and can be loaded independently.
Only after this succeeds would I move to approximately 1M target tokens.
Proposed training milestones
At that point the existing “First experiment with a real drafter” section of this PR can take over:
That keeps training feasibility and runtime feasibility as two separate milestones, while avoiding duplication between them.
</html>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.