Skip to content

Commit 202f464

Browse files
committed
Make DFlash multi-slot shared drafting opt-in
1 parent 4b1a944 commit 202f464

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

docs/beellama-args.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ DFlash diagnostic environment variables:
530530
| `GGML_DFLASH_VERBOSE_CONTRACT=1` | Logs extra drafter/target contract details during DFlash setup. |
531531
| `GGML_DFLASH_FORCE_CPU_CROSS=1` | Force the CPU hidden-state cross path even when the GPU ring is available. |
532532
| `GGML_DFLASH_VERIFY_PAD=1` | Re-enable diagnostic verifier padding to the active draft depth. Default is off because padded rows consume target verify time but are not sampled or accepted. |
533+
| `GGML_DFLASH_SHARED_DRAFT_BATCH=1` | Opt into the experimental shared multi-slot DFlash drafter graph. The default keeps per-slot cached drafting because the shared graph pays the full multi-slot cross-attention window and disables the drafter K/V projection cache. |
533534
| `GGML_DFLASH_GPU_RING=0` | Disable the GPU cross-attention ring and force the CPU ring path. |
534535
| `GGML_DFLASH_MULTI_GPU_TAPE=0` | Disable default-on multi-GPU DFlash GPU ring, hidden capture, tape, and replay. Use to force the CPU/eval-callback fallback for split target placement. |
535536
| `GGML_DFLASH_ALLOW_MULTI_GPU_TAPE=0` | Compatibility spelling for the same multi-GPU DFlash kill switch. |

docs/beellama-features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ BeeLlama's practical advantage is combination. Public llama.cpp has the main run
4242
| Draft top-k for DFlash tree | No | No | `--draft-topk` | `--spec-draft-top-k` |
4343
| Adaptive DFlash depth | No | No | Speculative-code adaptive tracking | Server-side `profit` and `fringe` controllers with `--spec-dm-*` CLI |
4444
| Sampled DFlash CLI | No | No | No checked CLI surface for draft temperature | `--spec-draft-temp 0`, positive value, or `auto` |
45-
| Multi-slot DFlash | No | No | Shared DFlash slot machinery | Shared drafter context, slot cap, and flat batched drafting |
45+
| Multi-slot DFlash | No | No | Shared DFlash slot machinery | Shared drafter context, slot cap, and per-slot cached drafting by default; experimental flat batched drafting behind `GGML_DFLASH_SHARED_DRAFT_BATCH=1` |
4646
| Multimodal with speculation | Upstream rules | Upstream rules | Speculative decoding disabled under multimodal | Flat DFlash allowed; tree and non-DFlash spec disabled |
4747
| CopySpec | No checked match | No checked match | Yes | Yes as explicit `--spec-type copyspec` |
4848
| Suffix/recycle speculation | No checked match | No checked match | Yes | Yes |

tests/test-dflash-plumbing.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,21 @@ int main(int argc, char ** argv) {
207207
ok &= expect(server_context.find("mark_mtp_draft_context_seq_rm_supported") == std::string::npos,
208208
"server must not keep the stale MTP seq_rm helper now that upstream probes ctx_dft directly");
209209

210+
{
211+
const size_t shared_gate = server_context.find("bool dflash_shared_drafter_batch_allowed");
212+
const size_t opt_in_env = server_context.find("GGML_DFLASH_SHARED_DRAFT_BATCH");
213+
const size_t opt_in_check = server_context.find("dflash_shared_drafter_batch_enabled()", shared_gate);
214+
const size_t draft_batch_call = server_context.find("common_speculative_draft_batch", shared_gate);
215+
216+
ok &= expect(shared_gate != std::string::npos &&
217+
opt_in_env != std::string::npos &&
218+
opt_in_check != std::string::npos &&
219+
draft_batch_call != std::string::npos &&
220+
shared_gate < opt_in_check &&
221+
opt_in_check < draft_batch_call,
222+
"flat DFlash shared drafter batching must be explicit opt-in because the multi-slot graph disables the single-slot K/V cache");
223+
}
224+
210225
const size_t pretranspose = qwen35moe.find("\"qkv_mixed_pretranspose\"");
211226
const size_t transpose = qwen35moe.find("qkv_mixed = ggml_transpose(ctx0, qkv_mixed)");
212227
const size_t transposed = qwen35moe.find("cb(qkv_mixed, \"qkv_mixed_transposed\", il)");

tools/server/server-context.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ static bool dflash_verify_padding_enabled() {
6868
return enabled;
6969
}
7070

71+
static bool dflash_shared_drafter_batch_enabled() {
72+
static const bool enabled = [] {
73+
const char * env = getenv("GGML_DFLASH_SHARED_DRAFT_BATCH");
74+
return env && env[0] != '\0' && strcmp(env, "0") != 0;
75+
}();
76+
return enabled;
77+
}
78+
7179
static bool server_model_is_dflash_drafter(const llama_model * model) {
7280
return model &&
7381
llama_model_dflash_block_size(model) > 1 &&
@@ -1981,6 +1989,9 @@ struct server_context_impl {
19811989
}
19821990

19831991
bool dflash_shared_drafter_batch_allowed(int n_drafting) {
1992+
if (!dflash_shared_drafter_batch_enabled()) {
1993+
return false;
1994+
}
19841995
if (n_drafting < 2) {
19851996
return false;
19861997
}

0 commit comments

Comments
 (0)