页面简介
Speed up token generation on Fireworks dedicated deployments with speculative decoding using draft models, n-gram speculation, and per-request configuration.
正文摘录
Speculative decoding reduces generation latency by proposing multiple tokens and letting the target model verify them in parallel. The target model still verifies every accepted token; the drafter does not replace the target model. The benefit depends on both the cost of producing draft tokens and how often the target model accepts them. A poorly matched drafter can make generation slower, so benchmark with representative traffic before overriding Fireworks defaults. The deployment flags on this page apply to dedicated deployments. Fireworks manages the serving configuration for Serverless models. Start with the default For most supported models, a default drafter and draft-token count are already configured. A new deployment inherits those settings, so you usually do not need to pass any speculative-decoding flags.Create the deployment normally, then benchmark it before changing the drafter:firectl deployment create accounts/fireworks/models/<MODEL_ID> \ --deployment-shape default \ --wait If the base model does not define a default drafter, the deployment runs without model-based speculative decoding. To explicitly disable an inherited default when creating a comparison deployment, use: firectl deployment create accounts/fireworks/models/<MODEL_ID> \ --deployment-shape default \ --disable-speculative-decoding \ --wait Choose a method MethodBest starting pointConfigurationDefault model-based speculationGeneral chat, reasoning, and coding trafficNo flags; inherit the model’s defaultCustom draft modelA validated drafter for your model or traffic distribution--draft-model and --draft-token-countN-gram speculationRepetitive output, code editing, and structured generation where output often repeats the prompt or prior context--ngram-speculation-length and --draft-token-countPredicted OutputsThe caller already knows most of the expected response, such as regenerating a file with a small editRequest-level prediction or speculation input Predicted Outputs can be used in addition to a deployment’s model-based speculative decoding. Configuration options FlagDescription--draft-modelResource name of a Fireworks or custom draft model. If omitted, the deployment inherits the base model’s default drafter.--draft-token-countNumber of candidate tokens proposed per step. It is required with an explicitly selected draft model or N-gram speculation. Start with 4, then benchmark nearby values.--ngram-speculation-lengthLength of the previous input sequence used for N-gram matching. This does not require a separate draft model.--disable-speculative-decodingDisables inherited speculative-decoding settings when creating a deployment. --draft-model and --ngram-speculation-length are alternative deployment strategies and cannot be used together. Custom draft models For self-service configuration, use a small base model that is compatible with the target model. In practice, this means using the same model family and tokenizer. A model that is merely smaller is not necessarily a useful drafter; its acceptance rate and execution cost both matter. Fallback draft models If the target model has no default drafter, the following small base models are reasonable starting points for an experiment. A purpose-built drafter generally performs better. Draft modelUse withaccounts/fireworks/models/llama-v3p2-1b-instructAll Llama models > 3Baccounts/fireworks/models/qwen2p5-0p5b-instructAll Qwen models > 3B Fireworks also supports compatible EAGLE, DFlash, DSpark, and Medusa draft addons. These formats are architecture-specific and require a checkpoint and configuration prepared for the exact target model; they are not drop-in replacements for a small base-model drafter. Contact Fireworks to validate an existing checkpoint or discuss a drafter adapted to your traffic. Examples Draft model N-gram speculationCreate a deployment with an explicit small base-model drafter:firectl deployment create accounts/fireworks/models/llama-v3p3-70b-instruct \ --deployment-shape default \ --draft-model="accounts/fireworks/models/llama-v3p2-1b-instruct" \ --draft-token-count=4 Use N-gram speculation without a separate draft model:firectl deployment create accounts/fireworks/models/llama-v3p3-70b-instruct \ --deployment-shape default \ --ngram-speculation-length=3 \ --draft-token-count=4 You can change the explicit drafter and draft-token count on an existing deployment: firectl deployment update <DEPLOYMENT_ID> \ --draft-model="accounts/<ACCOUNT_ID>/models/<DRAFT_MODEL_ID>" \ --draft-token-count=4 Benchmark and tune Compare at least three configurations on the same target model and deployment shape: The inherited Fireworks default. Your candidate drafter or N-gram settings. A deployment created with --disable-speculative-decoding. Use production-like prompts, output lengths, sampling parameters, and concurrency. Measure time to first token, inter-token latency, p50/p95 request latency, and maximum sustainable throughput. A high acceptance rate alone does not guarantee a speedup because the drafter also consumes compute. To inspect per-request metrics, set perf_metrics_in_response to true in the completion request. For dedicated deployments, the final response or final streaming chunk includes: speculation-generated-tokens: number of tokens generated through speculation speculation-acceptance: acceptance rate by proposed-token position Acceptance normally falls at later positions. Increase --draft-token-count only while the additional accepted tokens outweigh the extra drafting and verification work. Re-run the benchmark when the traffic mix, prompt format, model, quantization, or deployment shape changes.Was this page helpful?YesNo⌘I