Tiktokenizer

DeepSeek inference

DeepInfer for DeepSeek

DeepInfer is DeepSeek’s open-source inference framework for DeepSeek-V4.1-Flash. Its public release provides offline inference; a complete online service also needs cache management, stage routing and load balancing.

Accuracy note

This guide covers the public DeepInfer release reviewed on October 23, 2026. Its offline example is a starting point; a complete online service needs additional infrastructure.

Developer
DeepSeek
Supported model
DeepSeek-V4.1-Flash
Public release
Offline inference
License
Apache-2.0

Facts checked against official sources on .

What is DeepInfer?

DeepInfer is the inference framework behind DeepSeek’s large-scale production services. The public repository exposes an offline engine and examples for DeepSeek-V4.1-Flash. It is the software that runs the model; the model weights and the surrounding service are separate parts of a deployment.

Start with the deepseek-ai repository below when searching for “deepinfer deepseek.” The deployment Q&A explains the architecture, while the examples document the runnable entry points.

ResourceOfficial link
Source, build instructions and licensedeepseek-ai/DeepInfer on GitHub
Serving architecture and implementation detailsDeepSeek inference deployment Q&A
Offline inference and benchmark commandsDeepInfer examples

DeepInfer deployment requirements

Check the accelerator and software stack before building. The reviewed README lists the following targets. A benchmark’s GPU count describes that experiment; it does not establish a minimum card count for every offline configuration.

RequirementNVIDIAHuawei Ascend
AcceleratorSM100 GPUsAscend 950 NPUs
Operating systemLinuxLinux
CompilerGCC 13 or newerGCC 13 or newer
Python3.123.12
Platform toolkitCUDA 13CANN 9.2
DEEPINFER_ACCELERATORnvidiaascend

Build and run offline inference

Activate a fresh Python 3.12 environment on a supported machine with the matching toolkit already available. This NVIDIA example follows the upstream source-build workflow; it is intended for a prepared inference machine. Review the repository’s build script and record the checked-out revision for reproducibility.

bashNVIDIA offline inference
git clone --recurse-submodules https://github.com/deepseek-ai/DeepInfer.git
cd DeepInfer
git rev-parse HEAD

export DEEPINFER_ACCELERATOR=nvidia
./build.sh
python examples/offline_inference.py --help
python examples/offline_inference.py

Choose the model files and parallel configuration

The examples default to deepseek-ai/DeepSeek-V4.1-Flash-1017. On the first run, a model ID is downloaded to the Hugging Face cache. If the files are already present, point DEEPINFER_HF_MODEL_DIR at the local checkpoint directory. An explicitly supplied --model_name takes priority over that environment variable.

For Ascend, use DEEPINFER_ACCELERATOR=ascend and the corresponding toolkit. The examples document --ep, --dp and --cp configurations. Choose them for the devices and topology you actually have; the command above does not promise that one accelerator has enough memory.

bashUse an existing local checkpoint
export DEEPINFER_HF_MODEL_DIR=/absolute/path/to/DeepSeek-V4.1-Flash-1017
python examples/offline_inference.py

What is needed for an online service?

The public engine is one part of the production architecture described in DeepSeek’s deployment Q&A. The release identifies several service-level pieces that are still needed around it. Treat the offline run as an engine check before integrating those pieces.

ComponentDeployment work
KV cache systemAdd the storage and management needed to reuse cached context.
VE / prefill / decode disaggregationConnect the stages into a complete service; the README says much of the engine functionality is implemented.
Replica load balancingRoute prefill and decode work across data-parallel replicas.

DeepInfer vs vLLM and SGLang

Compare the workflow you need, the exact model revision and the supported hardware. The official documentation provides different entry points: DeepInfer’s released offline examples, vLLM’s HTTP serving guide, and SGLang’s server-and-request tutorial. Those entry points alone do not establish a speed ranking.

FrameworkDocumented starting pointWhat to check next
DeepInferDeepSeek-V4.1-Flash offline inferenceListed accelerators, parallel configuration and the additional service infrastructure.
vLLMOnline serving with an OpenAI-compatible HTTP APISupport for your exact checkpoint, hardware and required API features.
SGLangLaunch a server and send compatible API requestsThe model’s launch settings, runtime backend and request format.

Evaluate performance on your workload

DeepSeek publishes separate prefill and decode benchmarks with specific hardware and parallel settings. Keep that context attached to any reported result. The examples also explain how draft-token settings affect decode-throughput accounting; accepted output tokens and speculative work need to be distinguished.

For your own comparison, hold the checkpoint, precision, input/output lengths, concurrency and stopping conditions constant. Repeat runs with both cold and warm caches, then check output quality alongside latency. An engine that looks fast on short prompts may behave differently on your actual request mix.

MeasurementRecord alongside it
Time to first tokenPrompt length, queue time, concurrency and cache state.
Time per output tokenGenerated length and speculative decoding settings.
Accepted output tokens per secondDevice count, utilization, batch size and acceptance rate.
Memory useWeights, KV cache allocation and simultaneous sequence lengths.

Count the tokens your deployment actually sees

Use the tokenizer and conversation format for the exact deployed checkpoint. DeepSeek Recipe provides request conversion, prompt rendering and token encoding with an attached tokenizer for DeepSeek V4 and V4.1. The caller still supplies model inference and HTTP transport.

A plain-text count helps inspect the text layer. A complete request can also contain roles, tools, images and generation markers. Record the final serialized input token IDs or request-level usage when checking context limits and throughput. If two frameworks receive different serialized prompts, their performance results are not directly comparable.

Tiktokenizer’s related DeepSeek V4 and R1 pages describe their own tokenizer targets. They are useful references, but their counts are not a verified DeepSeek-V4.1-Flash-1017 request total. This guide does not run a DeepInfer server in your browser.

TaskNext step
Render a complete DeepSeek conversationDeepSeek Recipe request and tokenizer documentation
Inspect the existing V4 tokenizer workflowDeepSeek V4 token counter
Check which local model counts are supportedTokenizer support by model

Tiktokenizer Reference Sources

Tokenizer behavior and model limits change. Verify production decisions with current provider documentation:

Frequently asked questions

Is DeepInfer an official DeepSeek project?

Yes. The source is published in the deepseek-ai/DeepInfer GitHub repository under the Apache-2.0 license.

Which DeepSeek model does DeepInfer support?

The reviewed public support list names DeepSeek-V4.1-Flash. The examples default to deepseek-ai/DeepSeek-V4.1-Flash-1017; do not assume the same support for every older DeepSeek checkpoint.

Can I run DeepInfer on a laptop or an H100?

The reviewed hardware list specifies NVIDIA SM100 GPUs and Huawei Ascend 950 NPUs. It does not list laptop GPUs or H100 support. Verify upstream support for your exact accelerator before planning a deployment.

Does the offline quickstart start an API server?

No. It runs the offline inference example. A complete service still needs the surrounding cache, stage routing, load balancing and API integration.

Is DeepInfer faster than vLLM or SGLang?

There is no universal winner established here. Compare the same checkpoint and request format on matched hardware, with input/output lengths, concurrency, cache state and decoding settings recorded.

Can I use an OpenAI token count for a DeepInfer context limit?

Use the deployed DeepSeek checkpoint’s tokenizer and complete request format. An unrelated encoding count cannot establish that the serialized request fits the model’s configured context budget.