> For the complete documentation index, see [llms.txt](https://seekspeed.gitbook.io/seekspeed-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://seekspeed.gitbook.io/seekspeed-docs/spec-lab/deepspec.md).

# DeepSpec Integration

DeepSpec is the reference toolkit for speculative decoding with DeepSeek models. SeekSpeed's Spec Lab uses it via two contact points: vLLM's OpenAI-compatible serving surface and Prometheus-format `/metrics`.

## Serving stack

The canonical DeepSpec serving recipe (paraphrased from the repo's README):

```bash
# 1. Pull the DeepSpec draft + target checkpoints
huggingface-cli download deepseek-ai/DeepSeek-V3
huggingface-cli download deepseek-ai/DeepSpec-Draft-V3

# 2. Launch vLLM with speculative decoding wired up
python -m vllm.entrypoints.openai.api_server \
  --model deepseek-ai/DeepSeek-V3 \
  --speculative-model deepseek-ai/DeepSpec-Draft-V3 \
  --num-speculative-tokens 5 \
  --use-v2-block-manager \
  --tensor-parallel-size 8 \
  --port 8000
```

You can also follow the `examples/serve.py` pattern from the DeepSpec repo, which wraps the above with DSpark's dynamic-*k* controller.

## What SeekSpeed reads

Once the server is up, add it as a Spec Lab endpoint with adapter `vllm`. The probe step hits `/metrics` and parses:

```
vllm:spec_decode_num_draft_tokens_total
vllm:spec_decode_num_accepted_tokens_total
vllm:spec_decode_num_emitted_tokens_total
```

From these, the adapter computes:

```ts
acceptanceRate = accepted / drafted;
tokensPerStep  = emitted  / accepted;   // average tokens emitted per target step
```

Both flow into the [Bottleneck Analysis panel](/seekspeed-docs/spec-lab/bottlenecks.md).

## Two-endpoint A/B

A meaningful "DeepSpec speedup" measurement requires *two* endpoints — one with speculative decoding on (`endpoint`) and one without (`baselineEndpoint`). The Spec Lab refuses to claim a speedup if you only provide one:

```ts
// src/lib/spec-lab.functions.ts
if (!data.baselineEndpoint) {
  log("warn", "No baseline endpoint — speedup will not be measurable. Running spec endpoint only.");
}
```

Run the *same* DeepSeek-V3 target on both endpoints, with DeepSpec drafting enabled on one and disabled on the other. SeekSpeed then drives identical prompts through both, computes per-iteration latency distributions, and runs a Welch's *t*-test on the totals.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://seekspeed.gitbook.io/seekspeed-docs/spec-lab/deepspec.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
