Skip to content

perf(qwen36): add SpecLA factor-capture speculative decoding - #606

Open
Graffioh wants to merge 5 commits into
Luce-Org:mainfrom
Graffioh:codex/qwen35-specla-current-main
Open

perf(qwen36): add SpecLA factor-capture speculative decoding#606
Graffioh wants to merge 5 commits into
Luce-Org:mainfrom
Graffioh:codex/qwen35-specla-current-main

Conversation

@Graffioh

@Graffioh Graffioh commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Current gain over main

Qwen3.6-27B Q4_K_M target, Q8_0 DFlash draft, DDTree budget 22, top-k 4, tau=6, ten HumanEval-style prompts, and 128 generated tokens:

Configuration Mean decode throughput
Current main 25.14 tok/s
SpecLA 27.19 tok/s

SpecLA gain over current main: +8.2%.

Paper: https://arxiv.org/abs/2607.16673

CLI

The normal entry point is one flag:

dflash_server TARGET.gguf --draft DRAFT.gguf --specla

--specla enables speculative linear-attention verification when the loaded target and placement support it. SpecLA is the verification/state-management mode; it is not an alias for a particular proposal algorithm.

For the Qwen3.5/Qwen3.6 dense path implemented in this PR, the runtime currently:

  • selects DDTree as the compatible proposal adapter;
  • enables fast rollback;
  • uses DDTree budget 22;
  • uses confidence-pruning margin tau=6;
  • uses draft-tree top-k 4.

This separation is intentional. A future Qwen3.8 DSpark implementation can provide candidates and parent topology behind the same --specla flag without changing the user-facing CLI. That DSpark adapter and its target-specific recurrence/factor capture are not part of this PR.

Supported and permitted combinations

The path in this PR is supported for a monolithic Qwen3.5/Qwen3.6 dense target on one local device. It has been built and parity-tested on HIP.

The current Qwen adapter requires:

  • --draft DRAFT.gguf;
  • fast rollback, which --specla enables automatically;
  • a non-split, single-device target placement.

Setup-dependent overrides remain available:

Option Constraint Default with --specla Purpose
--ddtree-budget N positive integer 22 Maximum DDTree proposal nodes
--ddtree-tau T finite, non-negative number 6 Cumulative log-probability pruning margin
--specla-top-k K positive integer 4 Draft-tree expansion width
--draft-swa N positive window when needed checkpoint metadata Override draft sliding-window metadata for older checkpoints

The environment variables DFLASH_SPECLA=1 and DFLASH_SPECLA_TOPK=K remain compatibility controls for non-CLI harnesses. DFLASH_SPECLA_CONDITIONAL_DRAFT=1 and DFLASH_SPECLA_FUSED_COMMIT=0 are advanced experiment/debug controls, not normal launch requirements.

Rejected or unavailable combinations

  • --specla --no-fast-rollback is rejected because SpecLA requires the rollback/state path.
  • --specla-top-k without --specla is rejected.
  • The test_dflash harness rejects --specla --seq-verify; sequential verification cannot exercise the SpecLA tree path.
  • The current Qwen adapter rejects a missing --draft.
  • Multi-device or layer-split SpecLA is not implemented by this PR.
  • --kvflash <tokens|auto> cannot use SpecLA factor migration. The server warns, reports SpecLA off, and falls back to ordinary DDTree verification.
  • Paged-attention autoregressive mode cannot be combined with the current draft/DDTree speculative path.
  • On an architecture or placement without a SpecLA adapter, the server prints a warning and uses that architecture’s normal decode path. An independently requested --ddtree mode remains independent.

Paper mapping

The paper requires scored speculative candidates and parent topology, not DDTree specifically. A chain is a degenerate tree. DDTree is simply the proposal adapter connected for Qwen3.6 today; DSpark can be connected later if it supplies the required candidate/topology contract and the target has a compatible SpecLA recurrence and factor-capture implementation.

@Graffioh
Graffioh force-pushed the codex/qwen35-specla-current-main branch from 27417ca to 5f38668 Compare August 13, 2026 10:55
@Graffioh

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@Graffioh I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 33 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="server/src/qwen35/qwen35_dflash_target.cpp">

<violation number="1" location="server/src/qwen35/qwen35_dflash_target.cpp:609">
P2: The SpecLA bank-rotation / `specla_compact_fused` / `specla_flush_raw_fused` logic is copied nearly verbatim between this file and `server/test/test_dflash.cpp`. `rollback_to_tree` (walked_sibling compaction + `current_bank`/`old_pending_bank` rotation + `pending_count` update), `finish_speculative_state` (bank selection via `specla_pending_bank` + `specla_flush_raw_fused`), and `rollback_to_specla` (bank toggle + count) each have a hand-maintained mirror in the bench harness. These are the two most state-sensitive routines in the PR; any divergence between the production target and the harness (e.g. the `ne` bounds, channel mapping, or bank-toggle logic) silently changes acceptance behavior. Pull the shared commit/flush helpers into a common function (e.g. in `specla_commit_cuda.h/.cu`) and have both call sites invoke it.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/deps/llama.cpp/ggml/src/ggml.c
Comment thread server/src/common/dflash_target.h
Comment thread server/src/qwen35/qwen35_target_graph.cpp
Comment thread server/src/common/specla_commit_cuda.h Outdated
Comment thread server/src/common/ddtree.cpp
Comment thread server/test/test_dflash.cpp
Comment thread server/test/test_delta_net_specla.cpp
Comment thread server/test/test_delta_net_specla.cpp Outdated
Comment thread server/src/common/ddtree.cpp Outdated
Comment thread server/deps/llama.cpp/ggml/src/ggml.c Outdated
@Graffioh
Graffioh force-pushed the codex/qwen35-specla-current-main branch 2 times, most recently from e7dc8f0 to c775f9e Compare August 15, 2026 07:16
@Graffioh

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@Graffioh I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 36 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/src/qwen35/qwen35_target_graph.cpp Outdated
Comment thread server/src/qwen35/qwen35_target_graph.cpp Outdated
Comment thread server/deps/llama.cpp/ggml/src/ggml.c Outdated
Comment thread server/deps/llama.cpp/ggml/src/ggml.c Outdated
Comment thread server/deps/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu Outdated
Comment thread server/src/qwen35/qwen35_target_graph.cpp Outdated
Comment thread server/docs/SPECLA.md Outdated
Comment thread server/src/qwen35/qwen35_dflash_target.cpp Outdated
Comment thread server/src/common/ddtree.cpp
@Graffioh
Graffioh force-pushed the codex/qwen35-specla-current-main branch from c775f9e to 7ec0e54 Compare August 17, 2026 06:45
@Graffioh Graffioh changed the title perf(qwen35): add SpecLA factor-capture speculative decoding perf(qwen36): add SpecLA factor-capture speculative decoding Aug 17, 2026
@Graffioh
Graffioh force-pushed the codex/qwen35-specla-current-main branch from 7ec0e54 to 8d9c77a Compare August 17, 2026 18:57
@Graffioh
Graffioh force-pushed the codex/qwen35-specla-current-main branch from 8d9c77a to 3db9829 Compare August 17, 2026 19:08
@Graffioh
Graffioh marked this pull request as ready for review August 18, 2026 06:51

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 36 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/src/qwen35/qwen35_backend.cpp Outdated
Comment thread server/deps/llama.cpp/ggml/src/ggml.c
Comment thread server/deps/llama.cpp/ggml/src/ggml.c
Comment thread server/src/qwen35/qwen35_target_graph.cpp
Comment thread server/src/qwen35/qwen35_target_graph.cpp
Comment thread server/src/server/server_main.cpp Outdated
Comment thread server/test/test_delta_net_specla.cpp
Comment thread server/src/common/ddtree.cpp
@Graffioh
Graffioh force-pushed the codex/qwen35-specla-current-main branch from 3db9829 to c8889ab Compare August 18, 2026 08:09
@Graffioh
Graffioh marked this pull request as draft August 18, 2026 08:12
@Graffioh
Graffioh force-pushed the codex/qwen35-specla-current-main branch from c8889ab to 5da798e Compare August 18, 2026 08:29
@Graffioh
Graffioh marked this pull request as ready for review August 18, 2026 09:21

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 37 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/src/server/server_main.cpp
Comment thread server/test/test_dflash.cpp
@Graffioh
Graffioh force-pushed the codex/qwen35-specla-current-main branch from 5da798e to 7824c6b Compare August 18, 2026 09:38
@Graffioh
Graffioh force-pushed the codex/qwen35-specla-current-main branch from 7824c6b to 2782286 Compare August 18, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant