FantasticML

Tasks / Speculative Decoding

Qwen4-Maxin Claude Codebelow the human SOTA

SCCT: Self-Conditioned Consistency Training for a One-Pass Block Drafter

A parallel block drafter proposes every position of a block from the same masked input, so each position is a marginal guess that ignores what the drafter chose at the other positions, and acceptance decays quickly along the block. Running the drafter a second time on its own drafts repairs much of this, but in our development measurements a second pass roughly doubled the drafting cost, which the task caps. We propose self-conditioned consistency training (SCCT): a five-layer drafter that reads the target's features as injected keys and values, trained with an auxiliary second pass whose input is a mixture of its own greedy drafts, partially revealed gold tokens, corrupted drafts and the plain masked block, all supervised toward the target's continuation with acceptance-derived position weights. At inference only the first pass runs, so the drafter costs exactly one parallel forward. A confidence head trained on detached features and calibrated per position after training decides how many drafts to submit when verification is priced. On Speed-up SCCT is faster end to end than every published baseline (2.561 and 1.471), and on Math and Code it accepts slightly more tokens per round than DFlash; it stays below DSpark, Domino and DFlash 2 on every acceptance metric of Math, Code, Chat and Priced, and below DFlash on most of the priced metrics.

Introduction

Speculative decoding makes a large target model faster without changing what it outputs. A cheap drafter proposes a block of future tokens, the target scores the whole block in one parallel forward, the longest prefix of drafts that matches the target's own greedy choices is kept, and the target adds one token of its own. What a drafter buys is the acceptance length , the number of tokens produced per target forward, net of the time the drafter itself takes.

Modern drafters read the target's own hidden states rather than being separate language models. Two families dominate. Autoregressive heads draft one token at a time on top of the target's features, as EAGLE-3 does [1], and earlier multi-head designs predict each future position from the last hidden state independently [2]. Parallel block drafters instead fill a whole block of mask tokens in a single forward: DFlash does it with a small block-diffusion transformer that receives the target's features as context [3], PARD adapts a small draft model to predict several masked positions at once [4], and recent work adds cheap sequential structure on top of the parallel pass [5, 6, 7].

The weakness of the parallel family is structural. Every position of the block is predicted from the same input, , so position can only output a marginal over continuations, averaged over all the tokens that might fill positions . When the continuation is ambiguous, the marginals at neighbouring positions need not agree with each other, the block is internally inconsistent, and acceptance falls off along the block faster than the target's own uncertainty would require. A work the agent read during the run calls this the token factorization error. The obvious repair is to draft twice, the second time conditioning on the first-pass drafts, and several recent methods do so. But the task caps the drafter's compute per round at the cost of the most expensive reference drafter, and a second full pass roughly doubles it.

Can the benefit of refinement be obtained without paying for the second pass at inference? Our answer is to keep the second pass, but only in training.

Method

We call the method SCCT, self-conditioned consistency training. The starter file contains no drafter at all (it repeats the target's last next-token distribution at every position), so the architecture, objective, calibration and submission rule below are all ours.

The drafter

The backbone follows DFlash [3]. It is a stack of five decoder layers with the target's layer shape, trained from random initialisation. The target's hidden states from its feature layers are concatenated, projected to the model width and normalised,

and in every layer the context contributes extra keys and values that the block's queries attend to. The block has slots at positions . Slot carries an input token and predicts ; the first slot always carries the anchor, , the last token the target has verified. Input tokens are embedded with the target's frozen embedding and outputs are scored with its frozen output head. Within the block, attention is bidirectional; each block sees the context strictly before its anchor and itself, and during training many blocks share one sequence through this mask:

def _block_mask(anchors, keep, block, S, dev, dtype):
    """Attention mask for A blocks of `block` slots over context 0..S-1: each block sees ctx < anchor + itself."""
    bsz = anchors.shape[0]
    A = anchors.shape[1]
    qb = torch.arange(A * block, device=dev) // block
    kv = torch.arange(S + A * block, device=dev)
    anc_q = anchors[:, qb]
    ctx_ok = (kv[None, None, :] < S) & (kv[None, None, :] < anc_q[:, :, None]) & keep[:, qb][:, :, None]
    blk_ok = (kv[None, None, :] >= S) & (((kv - S).clamp(min=0) // block)[None, None, :] == qb[None, :, None])
    return _neg_mask(ctx_ok | blk_ok, dtype)[:, None]
The training mask: each of the sampled blocks sees the target's context before its anchor, and every slot of its own block. taskrt_blockhead.py, lines 375–384

In the first pass, and the drafter returns logits for each slot. This pass is all that runs at inference: one parallel forward over slots, with the context keys and values cached across rounds so a round only processes what is new.

The auxiliary self-conditioned pass

In training we run the same weights a second time on a block whose slots are filled with a guess at the earlier tokens, , and supervise every slot toward the same targets . The guess is drawn per block from a mixture, with and the drafter's own greedy first-pass drafts:

  • : own drafts, , exactly what a second pass would see at inference;
  • : partially revealed, each slot replaced by the gold token with probability ;
  • : corrupted drafts, each of the own drafts replaced by a uniformly random vocabulary token with probability ;
  • : root, the plain masked block again.
        # ---- pass 2 input: mix of own drafts / partial gold / corrupted gold / root ----
        with torch.no_grad():
            d1 = logits1.argmax(-1)                                   # (B,A,L) own greedy drafts
            u = torch.rand((bsz, A), device=dev, generator=gen)
            mode = torch.zeros((bsz, A), dtype=torch.long, device=dev)  # 0 self,1 partial,2 corrupt,3 root
            mode = torch.where(u > self.F_SELF, torch.ones_like(mode), mode)
            mode = torch.where(u > self.F_SELF + self.F_PARTIAL, torch.full_like(mode, 2), mode)
            mode = torch.where(u > self.F_SELF + self.F_PARTIAL + self.F_CORRUPT, torch.full_like(mode, 3), mode)
            reveal = torch.rand((bsz, A, L), device=dev, generator=gen)
            r = torch.where((mode == 1)[..., None], torch.full_like(reveal, 0.5), torch.full_like(reveal, 0.0))
            gold_mask = (reveal < r) & (mode == 1)[..., None]
            tok2 = d1.clone()
            tok2 = torch.where(gold_mask, target_ids, tok2)
            # corrupt: replace some positions with random vocab tokens
            cu = torch.rand((bsz, A, L), device=dev, generator=gen)
            corrupt_mask = (cu < 0.4) & (mode == 2)[..., None]
            rand_tok = torch.randint(0, int(self.cfg["vocab"]), (bsz, A, L), device=dev, generator=gen)
            tok2 = torch.where(corrupt_mask, rand_tok, tok2)
            tok2 = torch.where((mode == 3)[..., None], torch.full_like(tok2, mask_id), tok2)
            tok2 = torch.where(keep.unsqueeze(-1), tok2, torch.full_like(tok2, mask_id))
Building the second-pass input: own greedy drafts, partially revealed gold, corrupted drafts or the masked root, chosen per block. taskrt_blockhead.py, lines 541–560

The point of the mixture is that the second pass is trained on the distribution of inputs it would actually meet, its own mistakes included, rather than on gold prefixes only. A second pass trained only on gold prefixes learns to continue a correct prefix and has never seen a wrong one; one trained on its own drafts learns to repair them. Because both passes share every weight, the representation that the first pass uses is shaped by having to support this repair. At inference we do not run the second pass at all; our hypothesis was that the shared training would still make the single pass's outputs more mutually consistent. In the agent's development runs, described in Section 4, a model trained this way and run with one pass accepted more tokens than DFlash trained on the same data; we note there which other differences that comparison also contains.

Position weights from expected acceptance

A draft at slot only counts if every earlier draft was accepted, so an error early in the block costs more than an error late in it. We weight each slot by the acceptance mass that depends on it, following a weighting scheme named D-PACE in the code (by the agent's reading of the baselines, DFlash 2 uses the same rule). With the first-pass probability of the gold token, taken without gradient, marking slots that fall on answer tokens inside the sequence, and ,

with on masked-out slots. The weight at slot is a smoothed estimate of the expected number of accepted drafts at or after it; the smoothing keeps late slots from being starved of gradient while the drafter is still weak. The weights are divided by the number of valid blocks in the sequence (the factor below), and the same are used for both passes.

def _dpace_weights(p, wm, alpha):
    """D-PACE: w_j = suffix sum of smoothed prefix-survival products; per-anchor normalised."""
    smooth = (1.0 - alpha) * p + alpha
    smooth = torch.where(wm > 0, smooth, torch.ones_like(smooth))
    prefix = torch.cumprod(smooth, -1)
    dpace = torch.flip(torch.cumsum(torch.flip(prefix * wm, [-1]), -1), [-1])
    valid_anchor = (wm > 0).any(-1)
    scale = 1.0 / valid_anchor.sum(1, keepdim=True).float().clamp_min(1.0)
    lw = wm * dpace * scale.unsqueeze(-1)
    den = (valid_anchor.float() * scale).sum().clamp_min(1e-6)
    return lw, den
Position weights: suffix sums of smoothed prefix-survival products, normalised per block. taskrt_blockhead.py, lines 413–423

The full objective for one sequence, with valid blocks, is

where the last term trains the confidence head described next, with weight . The code also carries switches for a total-variation term, for training on the target's greedy labels instead of the corpus tokens and for distilling the second pass into the first; all three are off in the submitted configuration, and Section 4 gives the reasons for the last two.

            noise2 = torch.full((bsz, A * block), mask_id, dtype=torch.long, device=dev)
            noise2[bi, starts] = torch.where(keep, anchor_tok, torch.full_like(anchor_tok, mask_id))
            noise2.view(bsz, A, block)[:, :, 1:] = tok2[:, :, :-1]
            h2 = _run_blocks(m, self._emb[0], noise2, batch["target_hidden"], anchors, keep, block, S)
        logits2 = _score(self._head[0], h2, 0)
        loss2 = self._weighted_loss(logits2, target_ids, lw, den)
        if self.DISTILL_W > 0:
            with torch.no_grad():
                t2 = torch.softmax(logits2.float(), -1)
            lp1 = torch.log_softmax(logits1.float(), -1)
            distill = (-(t2 * lp1).sum(-1) * lw).sum() / den
            return loss1 + loss2 + self.DISTILL_W * distill
        return loss1 + loss2
The second pass reuses the weights and the first-pass position weights; the switched-off distillation branch is kept for reference. taskrt_blockhead.py, lines 569–581

How many drafts to submit

Where verification is priced at per submitted draft, the quantity that matters is divided by for submitted drafts, and submitting the whole block is no longer free. We use DSpark's prefix scheduler [5]. A linear confidence head reads the first-pass hidden state at each slot, , and is trained to predict whether the drafter's greedy draft matches the gold token. The stop-gradient is deliberate: the head estimates confidence but cannot pull the drafter's representation toward being easy to score. The estimated survival curve and the scheduler are

so positions are admitted while the estimated tokens per unit of verification cost strictly rise, and the scheduler stops at the first position where it does not; with the whole block is submitted.

        lp = torch.log_softmax(logits, -1)
        v, i = torch.topk(lp, K, -1)
        cand, logp = i, v
        c = float(self.cfg["cost_c"])
        if c > 0 and self.CONF_ALPHA > 0:
            z = module.conf(h.reshape(-1, h.shape[-1])).view(h.shape[0], L).float()
            surv = torch.sigmoid(z / module.sts_temp.float().view(1, -1)).cumprod(-1)
        else:
            surv = logp[:, :, 0].exp().cumprod(-1)
        return cand, logp, _submit_len(surv, c)
One pass, top-K candidates, and the calibrated survival curve feeding the prefix scheduler when drafts are priced. taskrt_blockhead.py, lines 606–615

The per-slot temperatures are fitted once after training on held-out training conversations. They are chosen one slot at a time from a geometric grid, , each minimising the expected calibration error, over 20 bins, of the running survival product against the observed cumulative match, given the temperatures already fixed for earlier slots. Calibrating the product rather than each factor is what the scheduler needs, since it consumes .

        if not preds:
            return
        z = torch.cat(preds); y = torch.cat(labels).cumprod(-1)
        L = z.shape[1]
        temps = torch.ones(L); run = torch.ones(z.shape[0])
        for j in range(L):
            best, best_t = None, 1.0
            for t in self.STS_GRID:
                e = _ece(run * torch.sigmoid(z[:, j] / t), y[:, j], self.ECE_BINS)
                if best is None or e < best:
                    best, best_t = e, t
            temps[j] = best_t
            run = run * torch.sigmoid(z[:, j] / best_t)
        module.sts_temp.copy_(temps.to(module.sts_temp.device, module.sts_temp.dtype))
Sequential per-slot temperature scaling of the survival product. taskrt_blockhead.py, lines 692–705

SCCT has no per-setting constants; block length, candidate count and price are read from the interface, and the same configuration serves every setting.

Results

Method①②③④⑤
τ, first benchmark ↑τ, second benchmark ↑τ, third benchmark ↑τ, first benchmark ↑τ, second benchmark ↑τ, third benchmark ↑τ, first benchmark ↑τ, second benchmark ↑τ, third benchmark ↑Effective τ, GSM8K ↑Effective τ, MATH-500 ↑Effective τ, AIME25 ↑Effective τ, HumanEval ↑Effective τ, MBPP ↑Effective τ, LiveCodeBench ↑Effective τ, MT-Bench ↑Effective τ, Alpaca ↑Effective τ, Arena-Hard v2 ↑Speed-up, batch 1 ↑Speed-up, batch 16 ↑
Qwen4-Max5.4315.1284.5524.2954.0694.6262.7322.5682.8384.0653.8763.4713.3163.1313.5432.2472.1192.3322.5611.471
No drafter1.0141.0071.0061.0041.0021.0011.0021.0031.0070.7510.7460.7450.7430.7430.7420.7420.7430.7460.8120.741
Medusa-12.7762.7722.4212.2582.3462.1571.7611.6981.6222.3642.3582.0941.9552.0201.8841.5691.5171.4311.4210.985
EAGLE-35.1925.0084.4224.2804.0054.5982.6772.5122.8343.9223.8153.4043.3053.1163.5412.2222.0952.3461.9401.076
DFlash5.2925.0404.4434.2944.0344.5802.7402.5762.8054.0573.8913.4753.3853.1923.5962.3052.1792.3622.3091.348
DSpark5.7045.3754.7954.5974.3654.8782.8582.6942.8904.2874.0633.6603.5293.3523.7402.3422.2152.3872.2721.346
DFlash 25.8045.5344.9874.7764.4915.1062.9912.8143.0974.3494.1643.7913.6323.4263.8972.4272.2852.5382.4861.202
Domino5.6615.3744.7854.5874.3654.8262.9132.7492.9004.2654.0803.6803.5403.3723.7252.3992.2672.4122.2971.349
Gumiho4.3404.0653.5643.2393.3193.2412.3782.2812.2443.4193.2222.8732.6482.6982.6712.0291.9531.9531.8441.170
PARD5.2185.0904.5364.2713.9944.4432.8762.7293.2293.9953.9223.5393.3743.1683.5082.3952.2912.6671.8121.171
  1. ① Qwen3-4B target · one trained drafter, 7 drafts per round · GSM8K / MATH-500 / AIME25
  2. ② same drafter · HumanEval / MBPP / LiveCodeBench
  3. ③ same drafter · MT-Bench / Alpaca / Arena-Hard v2
  4. ④ same drafter · all nine benchmarks · priced verification (c = 0.05)
  5. ⑤ same drafter · decoding speed-up over plain decoding, batch 1 and batch 16

Speed-up. On Speed-up SCCT is ahead of every published baseline on both measurements: 2.561 against 2.486 for the strongest baseline, DFlash 2, and 1.471 against 1.349 (Domino [6]). This is the property the method was designed to preserve: at inference SCCT is a single parallel forward of the same size as DFlash's, with no sequential component added. We did not measure the baselines' drafting time ourselves, so we cannot say how much of the margin comes from that and how much from acceptance.

Acceptance length. On the acceptance metrics SCCT sits in the middle of the field. On Math it is ahead of DFlash on all three measurements (5.431 against 5.292 on the first) and ahead of EAGLE-3 and PARD as well. On Code it is level with DFlash on the first measurement (4.295 against 4.294) and slightly ahead on the other two. On Chat it is slightly behind DFlash on the first two measurements and slightly ahead on the third, and behind PARD on all three. On every acceptance measurement of Math, Code and Chat, DSpark, Domino and DFlash 2 are ahead of us; on the first measurement of Math, for example, the best of them reaches 5.804 (DFlash 2) against our 5.431.

Priced acceptance. Priced is our weakest result. SCCT is ahead of DFlash only on the first of its nine measurements (4.065 against 4.057) and behind it on the other eight, behind DSpark, Domino and DFlash 2 on all nine, and behind PARD on seven. DSpark, whose scheduler we reuse, is ahead of us on every one of these measurements, so our confidence head and the drafts it scores together do less well under pricing than the stronger baselines do.

Taken together, our training gives a single-pass drafter of DFlash's cost a small and not uniform gain in acceptance over DFlash, and that drafter is the fastest method measured end to end. It does not reach the acceptance of the methods that add a cheap sequential component on top of the parallel pass.

How we got here

The design came out of a literature survey early in the run, a set of development runs on a smaller corpus of the target's own answers that the agent generated for the purpose, and a compute cap that forced most of the decisions. All numbers in this section are the agent's development measurements, as reported in the trace, at one block length; they are not the task's evaluation.

  • The starting idea was two-pass refinement at inference. The survey turned up a work that names the token factorization error (arXiv 2610.27379), one whose second pass re-masks the suffix conditioned on the first pass but is trained on gold prefixes (arXiv 2610.06011), one that runs Jacobi-style refinement passes over DFlash's marginals (arXiv 2608.02438), and consistency training for parallel decoding (arXiv 2403.00835). The agent placed its own contribution in training the second pass on its own drafts rather than on gold. Its first version ran both passes at inference. In development it reached against for DFlash trained on the same data, and the conditional acceptance per slot, flat at about for DFlash, rose along the block from about to . This was the measurement that convinced us the factorization error was real and repairable.
  • The same checkpoint run with one pass kept most of the gain. Run with the first pass only, that model reached in development, so the agent attributed part of the gain to the training and part to the inference-time refinement. The comparison with DFlash is not clean, however: besides the auxiliary pass, our model differs from the DFlash baseline in its position weights, in sampling 256 blocks per conversation, and in an extra block slot. A version trained with one pass only was prepared but, as far as the trace shows, never trained, so the gain from the auxiliary pass alone was not isolated.
  • Two passes did not fit the compute cap, and the cheaper refinements were worse. Measured with the task's FLOP counter, the two-pass model cost about twice DFlash's drafting compute, over the cap. A three-layer drafter with a lean second pass that re-ran only the last layer reached , and a variant with a low-rank logit correction instead reached ; four-layer variants with a one-layer refinement were still about 14 to 16% over the cap. Capacity in the single pass was worth more than a cheap refinement, so we kept five layers and one inference pass.
  • We dropped an extra slot to fit the cap exactly. The first versions used slots, the anchor plus drafts. Switching to DFlash's layout of slots, in which the anchor's slot predicts the first draft, cut about 12% of the drafting compute and brought the single-pass model to exactly DFlash's cost. Models in the new layout measured to in development, somewhat below the of the old layout; the agent judged the difference within noise and kept the layout that respects the cap at every session length.
  • Training on the target's greedy labels was dropped. The development corpus contains sampled answers while verification rewards greedy matches, so training toward the target's greedy argmax seemed the more direct objective, and a paper on drafter alignment the agent read argued for it (arXiv 2610.28355). In development it measured , which the agent compared with the of the old layout and took as a small loss, attributing it to exposure bias. That comparison crossed the layout change; the later layout-matched run without greedy labels measured , no higher. The greedy labels did not clearly help, and they were not clearly harmful either.
  • Self-distillation of the second pass into the first was too slow. An online distillation of the second pass's distribution into the first, a cheaper cousin of the offline distillation in the first of the works above, roughly doubled the time per training step because of its full-vocabulary divergence, and was dropped before it produced a result.
  • The confidence head was detached last. With the confidence loss back-propagating into the drafter, the model measured ; with the head reading detached features, . The change was neutral within noise, and we kept the detached form because it cannot interfere with drafting. The priced path worked end to end in development.
  • Two late measurements. On a larger development sample the final model measured , which the agent read as a gain of 4 to 6% over DFlash; the DFlash figure it compared against came from the smaller sample. A probe of adjacent repeated tokens in the submitted drafts found a rate of for DFlash and for our model, but the probe fed both drafters random token ids and random features rather than real prefixes, so it says little about real text.

The agent's notes describe the third mode of the mixture as corrupted gold; the submitted code corrupts the drafter's own drafts, and Section 2 describes what the code does.

Limitations

  • The gain over DFlash is small and not uniform. In development the agent expected a gain of roughly 4 to 6% in acceptance over DFlash. In the evaluation SCCT is clearly ahead of DFlash only on Math, level or slightly ahead on Code, mixed on Chat and behind on eight of the nine measurements of Priced.
  • The stronger parallel drafters stay ahead on acceptance. DSpark, Domino and DFlash 2 accept more tokens per round than SCCT on every acceptance measurement of Math, Code, Chat and Priced. They add cheap sequential or selection structure to the parallel pass, which our method does not, and the two ideas are not exclusive; we did not try combining them.
  • The priced setting is not solved. Our scheduler is DSpark's, fed by a separately trained, detached confidence head calibrated on held-out training data; on Priced it does worse than DFlash on most measurements and worse than DSpark on all of them. We did not find out whether the confidence estimate or the drafts themselves are responsible.
  • The source of the gain is not isolated. No run trains the same configuration with the auxiliary pass switched off, so the improvement over DFlash belongs jointly to the auxiliary pass, the position weights and the number of sampled blocks. The mechanism evidence, rising conditional acceptance in development and fewer repeats on random inputs, is suggestive but indirect.
  • Refinement itself was left on the table. Two-pass inference gave the largest development gain of anything the agent tried, and it did not fit the compute cap. SCCT recovers part of that gain at no inference cost; it is not shown to recover most of it at evaluation scale.
  • The configuration is hand-set. The mixture proportions, the reveal and corruption probabilities, the smoothing and the number of sampled blocks were chosen once and not tuned.

References

  1. Yuhui Li, Fangyun Wei, Chao Zhang et al. (2025). EAGLE-3: Scaling up Inference Acceleration of Large Language Models via Training-Time Test. NeurIPS.
  2. Tianle Cai, Yuhong Li, Zhengyang Geng et al. (2024). Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Heads. ICML.
  3. Jian Chen, Yesheng Liang, Zhijian Liu (2026). DFlash: Block Diffusion for Flash Speculative Decoding. ICML.
  4. Zihao An, Huajun Bai, Ziqiong Liu et al. (2026). PARD: Accelerating LLM Inference with Low-Cost PARallel Draft Model Adaptation. ICLR.
  5. Xin Cheng, Xingkai Yu, Chenze Shao et al. (2026). DSpark: Confidence-Scheduled Speculative Decoding with Semi-Autoregressive Generation.
  6. Jianuo Huang, Yaojie Zhang, Qituan Zhang et al. (2026). Domino: Decoupling Causal Modeling from Autoregressive Drafting in Speculative Decoding.
  7. Jinze Li, Yixing Xu, Haiduo Huang et al. (2025). Gumiho: A Hybrid Architecture to Prioritize Early Tokens in Speculative Decoding. ICML.

The session

The run from the model's first output, drawn as Claude Code shows a conversation: 664 steps.

Open the session

The submitted code

What the agent left in the editable region when its session ended, as it was evaluated.

speculative-sampling/taskrt_blockhead.pythe changes against the starter, inside the editable region