Skip to content

feat(spec): add draft sampling (--spec-draft-sampling) and the draft micro-batch (--spec-draft-n-ubatch) - #281

Merged
tmac1973 merged 1 commit into
mainfrom
feat/spec-draft-sampling-ubatch
Oct 15, 2026
Merged

tmac1973 merged 1 commit into
mainfrom
feat/spec-draft-sampling-ubatch

Conversation

@tmac1973

Copy link
Copy Markdown
Owner

Background

Two speculative-decoding options added in llama.cpp:

--spec-draft-sampling {greedy,probabilistic}

--spec-draft-n-ubatch N

  • Added in b11630 (common : add --spec-draft-n-ubatch ggml-org/llama.cpp#30459).
  • It sets the micro-batch of the drafter's own context. The drafter never processes more than the tokens it drafts, so a small value shrinks its compute buffer and leaves VRAM for the model.
  • 0 (the default) follows --ubatch-size.
  • Every draft method has a draft context, MTP included, so it applies to all of them.

Changes

Config

  • New DraftSampling and DraftUBatchSize settings in the config form's draft section.
  • Sampling is shown only for Draft Model and MTP.
  • Each setting shows a note when the active build is too old for it.

Launch

  • Both options are written to the command line and the preset only for builds that have them (versionDraftSampling, versionDraftUBatch).
  • Sampling is written only for draft and draft-mtp.

VRAM estimate

  • The draft compute term uses the draft micro-batch when one is set.

Benchmarks

  • draft_sampling is a parameter of draft and draft-mtp in the spec-value encoding.
  • draft_ubatch is a setting of every draft method, like draft_cache.
  • Invalid values are rejected when the value is parsed.

Autotune

  • The draft-settings stage also measures each Draft Model or MTP finalist with draft_sampling=probabilistic, at the finalist's own settings.
  • It's skipped when the profile's temperature is 0. There, probabilistic and greedy drafting pick the same tokens.
  • Autotune doesn't vary the draft micro-batch. It saves memory rather than time.

Tests

  • TestDraftSamplingAndUBatchFlags covers version gating, and that a DFlash head gets the micro-batch but no sampling mode.
  • TestDraftUBatchLowersTheEstimate.
  • Spec-value parse cases in sweep_test.go, valid and rejected.
  • The probabilistic cell in TestPlanSpecParamsStage, and that it is absent at temperature 0.
  • go test ./... and go vet ./... pass.

Follow-up worth considering

Autoconfigure's fit planner could set a small draft micro-batch (e.g. 16–32) whenever a draft method is on. That would give the freed memory to the context or the KV cache. Upstream says that's the point of the option; it isn't done here.

…micro-batch (--spec-draft-n-ubatch)

--spec-draft-sampling (b11368, ggml-org/llama.cpp#27694) samples the
draft and verifies it by rejection, for a draft model and MTP.
--spec-draft-n-ubatch (b11630, #30459) gives the drafter's context a
micro-batch of its own, shrinking its compute buffer. Both are model
settings written only for builds that have them, spec-value settings
for benchmark sweeps, and counted where they matter: the estimate uses
the draft micro-batch for the draft compute buffer, and Autotune's
draft-settings stage measures probabilistic drafting on each draft or
MTP finalist when the profile samples above temperature 0.
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