[PR #366] [CLOSED] [RFC] EXPERIMENTAL Investigate DFlash2 support for Qwen3.8-Flash-Next #2601

Closed
opened 2026-11-04 02:01:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 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+)

  • 2575cb1 C-3: the prompt path's GDN short conv tiled over tokens
  • df6980d E-2: prefetch the i-quant expert rows ahead of the AVX-512 decode; an opt-in gather decode
  • cf68b00 D-5: the prompt path's expert stream is issued by its own host thread
  • cb91f2a serve: keep image parts in tool/assistant messages
  • 456011e Layer split limits: docs/MULTI_GPU.md and bench/results/2026-09-29-layer-split-limits
  • f0bbe97 E-4 (prompt side): the draft layer's pass over a prompt chunk without a host sync per group
  • efddd74 E-6: a verify layer whose routed experts are all in VRAM needs nothing from the host
  • 66f4341 D-2: the prompt path's GDN recurrence split over value columns, the output norm in its own kernel
  • 0abcd5b E-6: the device plan opt-in (STRATA_VERIFY_DEVICE_PLAN=1)
  • 57fa1fd serve: 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:

  1. Model availability: do we have, or can we obtain, a DFlash2 drafter compatible with Qwen3.8-Flash-Next?
  2. Runtime correctness: can Strata expose the required target features and correctly verify, commit, and roll back draft blocks?
  3. Practical performance: does the resulting system improve end-to-end generation speed after accounting for drafting, verification, memory pressure, and expert-cache changes?

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:

  • Whether a DFlash2 checkpoint exists for the exact Flash-Next target.
  • Which target revision and training configuration it was built against.
  • Whether its architecture, configuration, and reference inference code are available.
  • Whether the required weights include the DFlash2 selector and dynamic convolution components.
  • What licenses apply to the checkpoint, reference implementation, and any training data used.

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:

  • Source layers and the precise extraction points within those layers.
  • Whether features are taken before or after normalization or residual operations.
  • Tensor shapes, ordering, precision, and any concatenation or projection.
  • Token-to-feature alignment, including the last accepted token and the start of each draft block.
  • Position IDs, attention masks, and context handling.
  • Whether and how target embeddings or the output head are reused.
  • Which features must be retained across successive draft–verify cycles.

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:

  • Tokenizer revision and token IDs.
  • Vocabulary size and ordering.
  • Special tokens, EOS handling, and any mask or placeholder tokens.
  • Whether the drafter uses the full vocabulary or a restricted vocabulary.
  • Whether Strata’s current MTP vocabulary handling can be reused or needs a separate path.

Any mismatch should produce an explicit compatibility error.

If training is required

Prepare a separate feasibility note covering:

  • The intended frozen target checkpoint.
  • Access to the target features required for training.
  • Availability of a DFlash2 training implementation.
  • Data sources, licenses, and train/evaluation separation.
  • Compute, storage, and memory requirements.
  • Checkpoint export and conversion requirements.
  • A small held-out evaluation for draft acceptance and numerical validation.

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:

  • Correct feature alignment after full, partial, and zero draft acceptance.
  • Ownership and lifetime of feature buffers.
  • Behavior across chunked prefill and subsequent decoding.
  • The cost of retaining or transferring those features.
  • Whether extraction changes kernel selection or adds synchronization.

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:

  • Parallel block drafting.
  • Candidate generation.
  • The learned path selector.
  • Dynamic convolution components.
  • Construction of the final proposed token sequence.

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:

  • Full acceptance, partial acceptance, and rejection at the first candidate.
  • Committing only accepted tokens and any verifier-produced continuation token.
  • Restoring attention KV state and recurrent/DeltaNet state after rejection.
  • Discarding or rebuilding speculative drafter state as required.
  • Keeping position counters and target feature buffers aligned.
  • EOS, output limits, and context boundaries.

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:

  • Drafter weights.
  • Drafter caches and intermediate buffers.
  • Retained target features.
  • Candidate and selector buffers.
  • Verification and rollback scratch space.

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

  • One pinned Strata revision.
  • One supported Flash-Next quantization.
  • One GPU and one active request.
  • Short prompts, approximately 2K tokens or less.
  • Greedy decoding.
  • No concurrent MTP or other drafting strategy.
  • Experimental speed projection disabled.
  • Fixed KV, expert-cache, and numerical execution settings.

Use three fixed prompts covering code, prose, and a short reasoning task, generating up to 128 tokens per prompt.

Procedure

  1. Generate a token-by-token reference continuation without speculation.
  2. Feed two-token candidate blocks from that continuation into a small verifier test harness.
  3. Exercise three cases:
    • Both candidates match the reference.
    • The first candidate matches and the second is deliberately incorrect.
    • The first candidate is deliberately incorrect.
  4. After each verification and rollback, continue decoding and compare against the reference.
  5. Record the next-token logits, generated token IDs, acceptance decisions, and relevant state positions.

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

  • Correct accepted-prefix lengths in all three cases.
  • No rejected candidate remains committed in model state.
  • Subsequent greedy continuation matches the controlled reference.
  • Next-token logits remain within a predefined numerical tolerance.
  • No non-finite values are introduced.
  • State positions and cache lengths remain consistent.

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:

  1. Validate one drafter forward pass using fixed target features.
  2. Compare intermediate tensors, candidate logits, and selected proposals with the reference implementation.
  3. Check token/feature alignment across successive cycles.
  4. Run a short greedy generation test against target-only decoding.
  5. Only after correctness passes, collect acceptance and timing measurements.

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:

Configuration Purpose
Target-only decoding Baseline without speculative decoding
Existing MTP Current Strata performance reference
DFlash2 Proposed integration

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:

  • Generated tokens per second.
  • End-to-end request latency and time to first token.
  • Drafting, selection, verification, and rollback time.
  • Number of proposed and accepted draft tokens.
  • Mean accepted draft tokens per cycle.
  • Mean total emitted tokens per cycle.
  • Number of target verification passes.
  • Peak VRAM and host RAM.
  • Expert-cache capacity and relevant cache/transfer statistics, where available.

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:

docs/experiments/dflash2/
  README.md
  compatibility.md
  protocol.md
  findings.md
  results.csv
  prompts/
  runs/
    <run-id>/
      manifest.json
      command.txt
      metrics.json
      output_tokens.json
      run.log

Document responsibilities

  • README.md: scope, current status, milestones, and blockers.
  • compatibility.md: target–drafter contract, checkpoint references, tensor requirements, and unresolved dependencies.
  • protocol.md: exact test procedures, comparison rules, metric definitions, and pass/fail criteria.
  • findings.md: observations, interpretation, decisions, and the next experiment.
  • results.csv: one row per run, including failed runs.
  • runs/: small reproducibility artifacts associated with each recorded result.

Large tensor dumps and model weights should remain outside the repository, with checksums and retrieval instructions where appropriate.

Run manifest

Each run should identify:

  • Strata commit and local patch status.
  • Reference implementation revision.
  • Target and drafter revisions and file checksums.
  • Conversion and quantization settings.
  • CPU, GPU, RAM, operating system, driver, and build configuration.
  • Prompt identifier and checksum.
  • Context length, KV format, and expert-cache settings.
  • Draft/block configuration.
  • Sampler parameters and seed, where applicable.
  • Warm-up policy, repetitions, and output limits.

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:

  • Automatic checkpoint training or downloads.
  • Support for unrelated models or every Flash-Next derivative.
  • Multimodal inputs.
  • Multi-GPU execution.
  • Concurrent requests.
  • Long-context performance claims.
  • Combining DFlash2 with MTP or other drafters.
  • Production setup/UI integration.
  • Changing the default decoding strategy.

These can be considered after the smallest correct configuration has been demonstrated.

8. Proposed milestones

  • Establish checkpoint availability and reference implementation.
  • Document the target–drafter compatibility contract.
  • Audit Strata’s verifier, feature access, and state rollback.
  • Add the small mock-proposal correctness experiment.
  • Record results, limitations, and any blocking issues.
  • Validate a real drafter forward pass against the reference.
  • Demonstrate correct short greedy generation.
  • Benchmark against target-only decoding and MTP.
  • Decide whether to proceed with broader integration.
  • Validate sampling and additional configurations separately.

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:

  • The preferred boundary between drafter execution and the existing verifier.
  • Existing tests or hooks that should be reused for state rollback and numerical comparisons.
  • Availability of a Flash-Next-compatible drafter or training work already in progress.
  • The hardware and workloads that should define the first performance gate.

References

<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:

If no compatible DFlash2 checkpoint exists for Qwen3.8-Flash-Next, determine whether one can realistically be trained from Flash-Next activations and produce a checkpoint suitable for the later runtime milestones already described in this PR.

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 DFlash2DraftModel configuration;

  • 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:

What exact Flash-Next representation should be supplied to DFlash2 at each draft step?

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 = 2560 alone 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:

sample_id
target_revision
target_quantization
tokenizer_revision

input_ids
loss_mask

captured_layer_ids
hidden_states

capture_layout_version

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:

normal autoregressive decoding

against:

full-sequence replay/prefill

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:

one Qwen3.8-Flash-Next revision
one quantization
one tokenizer revision
one chat template
text-only inference
fixed numerical/runtime settings

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:

Stage Approximate size Purpose
Export validation 5–10 sequences Validate tensor layout and token alignment
Tiny overfit test 16–32 short sequences Validate the complete training pipeline
First pilot ~1M target tokens First held-out acceptance experiment
Larger pilot 5–10M target tokens Only if the 1M-token pilot is promising

These values are starting hypotheses, not a proposed final architecture.

Before any real training run:

  1. instantiate the complete draft model;

  2. count trainable and frozen parameters;

  3. run a full forward -> backward -> optimizer.step;

  4. record peak VRAM;

  5. 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:

training loss
per-position token accuracy
Recall@selector_top_k
selector accuracy
simulated accepted-prefix length

If the drafter cannot strongly fit this tiny dataset, do not scale the dataset.

Investigate:

feature alignment
off-by-one token shifts
loss masks
causal masking
position IDs
feature projection
output head
selector targets
gradient flow

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:

  1. keep a valid prefix fixed;

  2. change tokens after the draft anchor;

  3. rebuild the training input;

  4. 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:

L = L_draft + alpha * L_selector

The selector should initially have either a warmup period or a gradual ramp, using the existing SpecForge controls:

training.dflash2_selector_loss_alpha
training.dflash2_selector_warmup_ratio
training.dflash2_selector_ramp_ratio

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:

target: A B C D
draft:  A B X D

The final D being correct provides no speculative-decoding benefit once the prefix has already failed at X.

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_len evaluation 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:

[ ] Target feature contract documented
[ ] Prefill/replay vs decode feature behavior understood
[ ] Tiny dataset can be strongly overfit
[ ] No future-token leakage detected
[ ] Held-out draft loss improves
[ ] Unary Recall@K is useful
[ ] Simulated accepted-prefix length > trivial baseline
[ ] Checkpoint reload reproduces outputs
[ ] Exported checkpoint contains projection/convolution/selector tensors

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:

Export correctly aligned features from three selected Flash-Next capture points for a small number of target-generated sequences, load them through an adapted SpecForge offline DFlash2 path, and demonstrate that a small DFlash2 drafter can deliberately overfit the dataset without future-information leakage.

This milestone should produce three artifacts:

1. Strata feature exporter

Responsible for:

exact target token capture
selected target features
loss masks
capture metadata
versioned/sharded output

2. Flash-Next / SpecForge adapter

Responsible for:

Flash-Next target configuration handling
offline feature loading
target-to-drafter feature mapping
DFlash2 configuration
training sample construction

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

[ ] Inspect SpecForge DFlash2 capture/training contract
[ ] Define Flash-Next feature taps and tensor semantics
[ ] Add minimal Strata feature capture
[ ] Validate replay/prefill vs decode alignment
[ ] Define sharded offline feature format
[ ] Adapt the data to SpecForge hidden_states_path training
[ ] Instantiate a small Flash-Next DFlash2 configuration
[ ] Measure one full training step and peak VRAM
[ ] Overfit 16–32 short sequences
[ ] Add future-information leakage regression test
[ ] Train a ~1M-token pilot
[ ] Evaluate held-out Recall@K and simulated accepted-prefix length
[ ] Export and reload the checkpoint

At that point the existing “First experiment with a real drafter” section of this PR can take over:

trained checkpoint
        ↓
reference forward validation
        ↓
Strata inference integration
        ↓
verifier / rollback validation
        ↓
target-only vs MTP vs DFlash2 benchmark

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.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/366 **Author:** [@j-luwierski](https://github.com/j-luwierski) **Created:** 10/1/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `dflash2-qwen3.8-flash-next` --- ### 📝 Commits (10+) - [`2575cb1`](https://github.com/Niko1221/Strata/commit/2575cb1636d906d195bf56f95b9527098a1fbd99) C-3: the prompt path's GDN short conv tiled over tokens - [`df6980d`](https://github.com/Niko1221/Strata/commit/df6980d43f1c499d2929006d89249a079920b223) E-2: prefetch the i-quant expert rows ahead of the AVX-512 decode; an opt-in gather decode - [`cf68b00`](https://github.com/Niko1221/Strata/commit/cf68b004c25f3ec60997d780422ce92e0e959f23) D-5: the prompt path's expert stream is issued by its own host thread - [`cb91f2a`](https://github.com/Niko1221/Strata/commit/cb91f2ad5039a27c4bf775d9bfe6ddfdb98bd5c1) serve: keep image parts in tool/assistant messages - [`456011e`](https://github.com/Niko1221/Strata/commit/456011edebed4b2b36d51d4b76b703c4ae687e5c) Layer split limits: docs/MULTI_GPU.md and bench/results/2026-09-29-layer-split-limits - [`f0bbe97`](https://github.com/Niko1221/Strata/commit/f0bbe978ec4fab037dda7cb7288ff8fcd604025b) E-4 (prompt side): the draft layer's pass over a prompt chunk without a host sync per group - [`efddd74`](https://github.com/Niko1221/Strata/commit/efddd7488092137c64300a22509a4c23337e33da) E-6: a verify layer whose routed experts are all in VRAM needs nothing from the host - [`66f4341`](https://github.com/Niko1221/Strata/commit/66f4341e6c50c5436037e4a1bc47f5ff9fb2cd47) D-2: the prompt path's GDN recurrence split over value columns, the output norm in its own kernel - [`0abcd5b`](https://github.com/Niko1221/Strata/commit/0abcd5b3c7652c685ea9e52636751bcf6b22a6ed) E-6: the device plan opt-in (STRATA_VERIFY_DEVICE_PLAN=1) - [`57fa1fd`](https://github.com/Niko1221/Strata/commit/57fa1fde2503d1e382abb870695d4835118c883a) serve: 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: 1. **Model availability:** do we have, or can we obtain, a DFlash2 drafter compatible with Qwen3.8-Flash-Next? 2. **Runtime correctness:** can Strata expose the required target features and correctly verify, commit, and roll back draft blocks? 3. **Practical performance:** does the resulting system improve end-to-end generation speed after accounting for drafting, verification, memory pressure, and expert-cache changes? 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: - Whether a DFlash2 checkpoint exists for the exact Flash-Next target. - Which target revision and training configuration it was built against. - Whether its architecture, configuration, and reference inference code are available. - Whether the required weights include the DFlash2 selector and dynamic convolution components. - What licenses apply to the checkpoint, reference implementation, and any training data used. 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: - Source layers and the precise extraction points within those layers. - Whether features are taken before or after normalization or residual operations. - Tensor shapes, ordering, precision, and any concatenation or projection. - Token-to-feature alignment, including the last accepted token and the start of each draft block. - Position IDs, attention masks, and context handling. - Whether and how target embeddings or the output head are reused. - Which features must be retained across successive draft–verify cycles. 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: - Tokenizer revision and token IDs. - Vocabulary size and ordering. - Special tokens, EOS handling, and any mask or placeholder tokens. - Whether the drafter uses the full vocabulary or a restricted vocabulary. - Whether Strata’s current MTP vocabulary handling can be reused or needs a separate path. Any mismatch should produce an explicit compatibility error. ### If training is required Prepare a separate feasibility note covering: - The intended frozen target checkpoint. - Access to the target features required for training. - Availability of a DFlash2 training implementation. - Data sources, licenses, and train/evaluation separation. - Compute, storage, and memory requirements. - Checkpoint export and conversion requirements. - A small held-out evaluation for draft acceptance and numerical validation. 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: - Correct feature alignment after full, partial, and zero draft acceptance. - Ownership and lifetime of feature buffers. - Behavior across chunked prefill and subsequent decoding. - The cost of retaining or transferring those features. - Whether extraction changes kernel selection or adds synchronization. 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: - Parallel block drafting. - Candidate generation. - The learned path selector. - Dynamic convolution components. - Construction of the final proposed token sequence. 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: - Full acceptance, partial acceptance, and rejection at the first candidate. - Committing only accepted tokens and any verifier-produced continuation token. - Restoring attention KV state and recurrent/DeltaNet state after rejection. - Discarding or rebuilding speculative drafter state as required. - Keeping position counters and target feature buffers aligned. - EOS, output limits, and context boundaries. 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: - Drafter weights. - Drafter caches and intermediate buffers. - Retained target features. - Candidate and selector buffers. - Verification and rollback scratch space. 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 - One pinned Strata revision. - One supported Flash-Next quantization. - One GPU and one active request. - Short prompts, approximately 2K tokens or less. - Greedy decoding. - No concurrent MTP or other drafting strategy. - Experimental speed projection disabled. - Fixed KV, expert-cache, and numerical execution settings. Use three fixed prompts covering code, prose, and a short reasoning task, generating up to 128 tokens per prompt. ### Procedure 1. Generate a token-by-token reference continuation without speculation. 2. Feed two-token candidate blocks from that continuation into a small verifier test harness. 3. Exercise three cases: - Both candidates match the reference. - The first candidate matches and the second is deliberately incorrect. - The first candidate is deliberately incorrect. 4. After each verification and rollback, continue decoding and compare against the reference. 5. Record the next-token logits, generated token IDs, acceptance decisions, and relevant state positions. 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 - Correct accepted-prefix lengths in all three cases. - No rejected candidate remains committed in model state. - Subsequent greedy continuation matches the controlled reference. - Next-token logits remain within a predefined numerical tolerance. - No non-finite values are introduced. - State positions and cache lengths remain consistent. 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: 1. Validate one drafter forward pass using fixed target features. 2. Compare intermediate tensors, candidate logits, and selected proposals with the reference implementation. 3. Check token/feature alignment across successive cycles. 4. Run a short greedy generation test against target-only decoding. 5. Only after correctness passes, collect acceptance and timing measurements. 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: | Configuration | Purpose | | --- | --- | | Target-only decoding | Baseline without speculative decoding | | Existing MTP | Current Strata performance reference | | DFlash2 | Proposed integration | 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: - Generated tokens per second. - End-to-end request latency and time to first token. - Drafting, selection, verification, and rollback time. - Number of proposed and accepted draft tokens. - Mean accepted draft tokens per cycle. - Mean total emitted tokens per cycle. - Number of target verification passes. - Peak VRAM and host RAM. - Expert-cache capacity and relevant cache/transfer statistics, where available. 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: ```text docs/experiments/dflash2/ README.md compatibility.md protocol.md findings.md results.csv prompts/ runs/ <run-id>/ manifest.json command.txt metrics.json output_tokens.json run.log ``` ### Document responsibilities - **README.md:** scope, current status, milestones, and blockers. - **compatibility.md:** target–drafter contract, checkpoint references, tensor requirements, and unresolved dependencies. - **protocol.md:** exact test procedures, comparison rules, metric definitions, and pass/fail criteria. - **findings.md:** observations, interpretation, decisions, and the next experiment. - **results.csv:** one row per run, including failed runs. - **runs/:** small reproducibility artifacts associated with each recorded result. Large tensor dumps and model weights should remain outside the repository, with checksums and retrieval instructions where appropriate. ### Run manifest Each run should identify: - Strata commit and local patch status. - Reference implementation revision. - Target and drafter revisions and file checksums. - Conversion and quantization settings. - CPU, GPU, RAM, operating system, driver, and build configuration. - Prompt identifier and checksum. - Context length, KV format, and expert-cache settings. - Draft/block configuration. - Sampler parameters and seed, where applicable. - Warm-up policy, repetitions, and output limits. 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: - Automatic checkpoint training or downloads. - Support for unrelated models or every Flash-Next derivative. - Multimodal inputs. - Multi-GPU execution. - Concurrent requests. - Long-context performance claims. - Combining DFlash2 with MTP or other drafters. - Production setup/UI integration. - Changing the default decoding strategy. These can be considered after the smallest correct configuration has been demonstrated. ## 8. Proposed milestones - [ ] Establish checkpoint availability and reference implementation. - [ ] Document the target–drafter compatibility contract. - [ ] Audit Strata’s verifier, feature access, and state rollback. - [ ] Add the small mock-proposal correctness experiment. - [ ] Record results, limitations, and any blocking issues. - [ ] Validate a real drafter forward pass against the reference. - [ ] Demonstrate correct short greedy generation. - [ ] Benchmark against target-only decoding and MTP. - [ ] Decide whether to proceed with broader integration. - [ ] Validate sampling and additional configurations separately. 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: - The preferred boundary between drafter execution and the existing verifier. - Existing tests or hooks that should be reused for state rollback and numerical comparisons. - Availability of a Flash-Next-compatible drafter or training work already in progress. - The hardware and workloads that should define the first performance gate. ## References - [Tracking issue #347](https://github.com/Niko1221/Strata/issues/347) - [DFlash reference repository](https://github.com/z-lab/dflash) - [DFlash2 architecture and release notes](https://inco.ai/blog/dflash2/) - [Published Qwen3.8-27B DFlash2 checkpoint — reference only, not established Flash-Next compatibility](https://huggingface.co/z-lab/Qwen3.8-27B-DFlash2) - [Strata implementation and performance details](https://github.com/Niko1221/Strata/blob/main/docs/DETAILS.md) <html><head></head><body><h2><span>Training plan if no compatible Flash-Next DFlash2 checkpoint exists</span></h2><p><span>This is intended as a concrete follow-up to the </span><strong><span>“If training is required”</span></strong><span> section above, rather than a replacement for the existing runtime/integration plan.</span></p><p><span>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.</span></p><p><span>The goal of this additional workstream is narrower:</span></p><blockquote><p><span>If no compatible DFlash2 checkpoint exists for Qwen3.8-Flash-Next, determine whether one can realistically be trained from Flash-Next activations and produce a checkpoint suitable for the later runtime milestones already described in this PR.</span></p></blockquote><h3><span>Why SpecForge looks like the best starting point</span></h3><p><span>SpecForge currently has explicit DFlash2 training support.</span></p><p><span>In particular:</span></p><ul><li><p><span>DFlash2 remains under </span><code><span>training.strategy: dflash</span></code><span>;</span></p></li><li><p><span>the draft architecture is selected through an explicit </span><code><span>DFlash2DraftModel</span></code><span> configuration;</span></p></li><li><p><span>offline training from precomputed hidden-state checkpoints is supported through </span><code><span>data.hidden_states_path</span></code><span>;</span></p></li><li><p><span>the target model does not need to remain loaded during offline training;</span></p></li><li><p><span>DFlash2 includes grouped dynamic convolution and a learned top-k path selector;</span></p></li><li><p><span>selector loss, warmup, ramp-up, and selector-specific metrics are already implemented.</span></p></li></ul><p><span>This means the intention would </span><strong><span>not</span></strong><span> be to reimplement the DFlash2 training algorithm.</span></p><p><span>The main work would instead be adapting the Flash-Next target feature path and producing data that satisfies SpecForge's DFlash training contract.</span></p><p><span>Relevant SpecForge documentation:</span></p><p><a href="https://github.com/sgl-project/SpecForge/blob/main/docs/sections/basic_usage/training.md"><span>https://github.com/sgl-project/SpecForge/blob/main/docs/sections/basic_usage/training.md</span></a></p><div><hr></div><h2><span>1. First establish the Flash-Next feature contract</span></h2><p><span>This should happen before collecting a meaningful dataset.</span></p><p><span>The central question is:</span></p><blockquote><p><span>What exact Flash-Next representation should be supplied to DFlash2 at each draft step?</span></p></blockquote><p><span>For every proposed capture point, document:</span></p><ul><li><p><span>target layer/block index;</span></p></li><li><p><span>exact location inside the block;</span></p></li><li><p><span>whether the tensor is before or after normalization;</span></p></li><li><p><span>whether it is before or after residual merging;</span></p></li><li><p><span>actual tensor shape and dtype;</span></p></li><li><p><span>token-to-feature alignment;</span></p></li><li><p><span>whether the same representation is available during prefill and autoregressive decode;</span></p></li><li><p><span>whether any projection or transformation is required before the drafter consumes it.</span></p></li></ul><p><code><span>hidden_size = 2560</span></code><span> alone is not enough to assume that every useful internal Flash-Next tensor is simply </span><code><span>[tokens, 2560]</span></code><span>.</span></p><p><span>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.</span></p><p><span>For the first training experiment I would start with </span><strong><span>three target feature taps</span></strong><span>, approximately covering early, middle, and late parts of the network.</span></p><p><span>The exact layer indices should only be chosen after inspecting the Flash-Next execution graph.</span></p><h3><span>Deliverable</span></h3><p><span>A small compatibility note containing the selected capture points, shapes, alignment rules, and one captured short sequence.</span></p><div><hr></div><h2><span>2. Add a training-feature export path to Strata</span></h2><p><span>The normal generation API does not expose the features required for DFlash2 training, so Strata will need an internal capture path.</span></p><p><span>A training sample should contain at least the equivalent of:</span></p><pre><code><span>sample_id target_revision target_quantization tokenizer_revision input_ids loss_mask captured_layer_ids hidden_states capture_layout_version</span></code></pre><p><span>The exact serialization format should be chosen to minimize conversion work when feeding the data into SpecForge.</span></p><p><span>The important requirement is that sequence boundaries and token positions remain completely unambiguous.</span></p><div><hr></div><h2><span>3. Prefer a two-pass data-generation path</span></h2><p><span>My preferred first implementation would separate response generation from feature capture.</span></p><h3><span>Pass A — generate sequences</span></h3><p><span>Run the exact Flash-Next target configuration that we eventually want to accelerate.</span></p><p><span>Store the </span><strong><span>exact token IDs</span></strong><span> generated by the target, rather than only decoded text.</span></p><h3><span>Pass B — replay and capture</span></h3><p><span>Replay the complete stored sequence through Flash-Next and capture the selected hidden states during prefill.</span></p><p><span>This could make large-scale feature collection significantly cheaper than dumping activations during the autoregressive generation loop.</span></p><p><span>However, this optimization must be validated first.</span></p><p><span>For the same short sequence, compare the selected target features from:</span></p><pre><code><span>normal autoregressive decoding</span></code></pre><p><span>against:</span></p><pre><code><span>full-sequence replay/prefill</span></code></pre><p><span>at matching token positions.</span></p><p><span>If those representations are not equivalent under the selected Strata execution path, the exporter must use the representation that actually exists during inference.</span></p><p><span>A one-token feature alignment error could still allow the training loss to decrease while producing a useless drafter.</span></p><div><hr></div><h2><span>4. Keep the initial target configuration fixed</span></h2><p><span>The first drafter should target exactly one Flash-Next configuration.</span></p><p><span>For example:</span></p><pre><code><span>one Qwen3.8-Flash-Next revision one quantization one tokenizer revision one chat template text-only inference fixed numerical/runtime settings</span></code></pre><p><span>Initially avoid mixing:</span></p><ul><li><p><span>different quantizations;</span></p></li><li><p><span>modified Flash-Next checkpoints;</span></p></li><li><p><span>steering/control vectors;</span></p></li><li><p><span>speed projection;</span></p></li><li><p><span>Coder/Swift variants;</span></p></li><li><p><span>other experimental weight changes.</span></p></li></ul><p><span>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.</span></p><p><span>However, transfer to another target quantization or modified model should not be assumed.</span></p><div><hr></div><h2><span>5. Start with a deliberately small target-generated dataset</span></h2><p><span>The training data should preferably contain responses generated by the exact target model being accelerated.</span></p><p><span>An initial mixture could include:</span></p><ul><li><p><span>C++ code;</span></p></li><li><p><span>Python code;</span></p></li><li><p><span>debugging;</span></p></li><li><p><span>technical explanations;</span></p></li><li><p><span>normal English conversation;</span></p></li><li><p><span>normal Polish conversation;</span></p></li><li><p><span>short reasoning tasks.</span></p></li></ul><p><span>Suggested progression:</span></p> Stage | Approximate size | Purpose -- | -- | -- Export validation | 5–10 sequences | Validate tensor layout and token alignment Tiny overfit test | 16–32 short sequences | Validate the complete training pipeline First pilot | ~1M target tokens | First held-out acceptance experiment Larger pilot | 5–10M target tokens | Only if the 1M-token pilot is promising <p><span>These values are starting hypotheses, not a proposed final architecture.</span></p><p><span>Before any real training run:</span></p><ol start="1"><li><p><span>instantiate the complete draft model;</span></p></li><li><p><span>count trainable and frozen parameters;</span></p></li><li><p><span>run a full </span><code><span>forward -&gt; backward -&gt; optimizer.step</span></code><span>;</span></p></li><li><p><span>record peak VRAM;</span></p></li><li><p><span>only then increase sequence length or sampled anchors.</span></p></li></ol><p><span>The large vocabulary projection may be one of the dominant memory costs, so this should be measured rather than estimated away.</span></p><div><hr></div><h2><span>8. Make tiny-dataset overfitting the first training gate</span></h2><p><span>Before collecting millions of tokens, deliberately overfit approximately 16–32 short sequences.</span></p><p><span>The goal is not generalization.</span></p><p><span>The goal is to prove that:</span></p><ul><li><p><span>features are aligned correctly;</span></p></li><li><p><span>loss masks are correct;</span></p></li><li><p><span>gradients reach the projection, draft layers, convolution, and selector;</span></p></li><li><p><span>correct future tokens can be learned;</span></p></li><li><p><span>selector candidate coverage improves;</span></p></li><li><p><span>checkpoint save/load preserves the result.</span></p></li></ul><p><span>Track at least:</span></p><pre><code><span>training loss per-position token accuracy Recall@selector_top_k selector accuracy simulated accepted-prefix length</span></code></pre><p><span>If the drafter cannot strongly fit this tiny dataset, do </span><strong><span>not</span></strong><span> scale the dataset.</span></p><p><span>Investigate:</span></p><pre><code><span>feature alignment off-by-one token shifts loss masks causal masking position IDs feature projection output head selector targets gradient flow</span></code></pre><p><span>first.</span></p><div><hr></div><h2><span>9. Add an explicit future-information leakage test</span></h2><p><span>Offline training from complete sequences makes accidental future-token leakage a particularly important failure mode.</span></p><p><span>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.</span></p><p><span>A simple regression test should:</span></p><ol start="1"><li><p><span>keep a valid prefix fixed;</span></p></li><li><p><span>change tokens after the draft anchor;</span></p></li><li><p><span>rebuild the training input;</span></p></li><li><p><span>verify that drafter inputs that should depend only on the prefix remain unchanged.</span></p></li></ol><p><span>If changing future tokens changes a supposedly prefix-only target feature, the capture/training contract is invalid.</span></p><p><span>This should be checked before interpreting any impressive training accuracy.</span></p><div><hr></div><h2><span>10. Use the existing DFlash2 selector schedule before experimenting with new objectives</span></h2><p><span>For the first working baseline, use the existing SpecForge DFlash2 objective rather than introducing custom training losses.</span></p><p><span>Conceptually:</span></p><pre><code><span>L = L_draft + alpha * L_selector</span></code></pre><p><span>The selector should initially have either a warmup period or a gradual ramp, using the existing SpecForge controls:</span></p><pre><code><span>training.dflash2_selector_loss_alpha training.dflash2_selector_warmup_ratio training.dflash2_selector_ramp_ratio</span></code></pre><p><span>The reason is that the selector cannot recover a correct token that is not already present in its unary top-k candidate set.</span></p><p><span>Therefore candidate coverage should be monitored before aggressively tuning the selector.</span></p><p><span>In particular, track SpecForge's unary top-k recall metric.</span></p><p><span>D-PACE or more aggressive objective changes can be tested later, after a plain DFlash2 baseline works.</span></p><div><hr></div><h2><span>11. Evaluate draft quality using accepted-prefix length</span></h2><p><span>Token accuracy alone is not a sufficient speculative-decoding metric.</span></p><p><span>For example:</span></p><pre><code><span>target: A B C D draft: A B X D</span></code></pre><p><span>The final </span><code><span>D</span></code><span> being correct provides no speculative-decoding benefit once the prefix has already failed at </span><code><span>X</span></code><span>.</span></p><p><span>The most useful offline metrics should therefore include:</span></p><ul><li><p><span>accuracy by future-token position;</span></p></li><li><p><span>Recall@K;</span></p></li><li><p><span>selector accuracy conditioned on a valid previous prefix;</span></p></li><li><p><span>simulated accepted-prefix length;</span></p></li><li><p><span>distribution of accepted-prefix lengths.</span></p></li></ul><p><span>SpecForge already exposes DFlash-family per-position diagnostics and an offline </span><code><span>simulated_acc_len</span></code><span> evaluation metric, which makes it useful for this stage.</span></p><p><span>These metrics are still only training diagnostics.</span></p><p><span>The real acceptance and end-to-end speed measurements remain the runtime milestones already described elsewhere in this PR.</span></p><div><hr></div><h2><span>12. Define a training-side go/no-go gate</span></h2><p><span>Before moving from the pilot to a larger dataset, I would require:</span></p><pre><code><span>[ ] Target feature contract documented [ ] Prefill/replay vs decode feature behavior understood [ ] Tiny dataset can be strongly overfit [ ] No future-token leakage detected [ ] Held-out draft loss improves [ ] Unary Recall@K is useful [ ] Simulated accepted-prefix length &gt; trivial baseline [ ] Checkpoint reload reproduces outputs [ ] Exported checkpoint contains projection/convolution/selector tensors</span></code></pre><p><span>If those conditions fail, the next step should be to investigate the cause rather than scaling training.</span></p><p><span>A negative result here would still answer an important feasibility question for this PR.</span></p><div><hr></div><h2><span>13. First concrete training milestone</span></h2><p><span>I would define the first training milestone as:</span></p><blockquote><p><span>Export correctly aligned features from three selected Flash-Next capture points for a small number of target-generated sequences, load them through an adapted SpecForge offline DFlash2 path, and demonstrate that a small DFlash2 drafter can deliberately overfit the dataset without future-information leakage.</span></p></blockquote><p><span>This milestone should produce three artifacts:</span></p><h3><span>1. Strata feature exporter</span></h3><p><span>Responsible for:</span></p><pre><code><span>exact target token capture selected target features loss masks capture metadata versioned/sharded output</span></code></pre><h3><span>2. Flash-Next / SpecForge adapter</span></h3><p><span>Responsible for:</span></p><pre><code><span>Flash-Next target configuration handling offline feature loading target-to-drafter feature mapping DFlash2 configuration training sample construction</span></code></pre><h3><span>3. Minimal trained checkpoint</span></h3><p><span>A small experimental DFlash2 checkpoint which successfully fits the tiny dataset and can be loaded independently.</span></p><p><span>Only after this succeeds would I move to approximately 1M target tokens.</span></p><div><hr></div><h2><span>Proposed training milestones</span></h2><pre><code><span>[ ] Inspect SpecForge DFlash2 capture/training contract [ ] Define Flash-Next feature taps and tensor semantics [ ] Add minimal Strata feature capture [ ] Validate replay/prefill vs decode alignment [ ] Define sharded offline feature format [ ] Adapt the data to SpecForge hidden_states_path training [ ] Instantiate a small Flash-Next DFlash2 configuration [ ] Measure one full training step and peak VRAM [ ] Overfit 16–32 short sequences [ ] Add future-information leakage regression test [ ] Train a ~1M-token pilot [ ] Evaluate held-out Recall@K and simulated accepted-prefix length [ ] Export and reload the checkpoint</span></code></pre><p><span>At that point the existing </span><strong><span>“First experiment with a real drafter”</span></strong><span> section of this PR can take over:</span></p><pre><code><span>trained checkpoint ↓ reference forward validation ↓ Strata inference integration ↓ verifier / rollback validation ↓ target-only vs MTP vs DFlash2 benchmark</span></code></pre><p><span>That keeps training feasibility and runtime feasibility as two separate milestones, while avoiding duplication between them.</span></p></body></html> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:01:40 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2601
No description provided.