Repository navigation
feat(spec): add draft sampling (--spec-draft-sampling) and the draft micro-batch (--spec-draft-n-ubatch) - #281
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Two speculative-decoding options added in llama.cpp:
--spec-draft-sampling {greedy,probabilistic}probabilisticsamples the draft and has the model verify it by rejection sampling. It accepts more of the draft when replies are sampled above temperature 0.draft-simpleanddraft-mtp(common/speculative.cpp).--spec-draft-n-ubatch N--ubatch-size.Changes
Config
DraftSamplingandDraftUBatchSizesettings in the config form's draft section.Launch
versionDraftSampling,versionDraftUBatch).draftanddraft-mtp.VRAM estimate
Benchmarks
draft_samplingis a parameter ofdraftanddraft-mtpin the spec-value encoding.draft_ubatchis a setting of every draft method, likedraft_cache.Autotune
draft_sampling=probabilistic, at the finalist's own settings.Tests
TestDraftSamplingAndUBatchFlagscovers version gating, and that a DFlash head gets the micro-batch but no sampling mode.TestDraftUBatchLowersTheEstimate.sweep_test.go, valid and rejected.TestPlanSpecParamsStage, and that it is absent at temperature 0.go test ./...andgo 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.