DeepSeek 系列
DeepSeek R1系列
定位:通用型大语言模型(LLM),面向多场景、多任务的智能化需求。
特点:
- 更强的通用性和泛化能力,适用于开放域问答、文本生成、代码编写等多种任务
- 支持更长的上下文窗口,能够处理更复杂的对话和长文本分析
- 在自然语言理解(NLU)和生成(NLG)方面表现优异,适合需要高交互性和创造力的场景
适用场景:内容创作、智能客服、软件编程、教育辅导等
DeepSeek V3系列
定位:垂直领域优化模型,专注于特定行业或任务的高精度需求。
特点:
- 针对特定领域(如金融、医疗、法律等)进行了深度优化,具备更强的领域知识理解能力
- 在特定领域的任务上有着更高的准确性和效率
- 模型规模更小,但部署和推理成本相对较高
适用场景:金融风控、医疗诊断、法律咨询等垂直领域
**DeepSeek商业接口文档**
1 | lscpu #查看CPU信息 |
CPU信息
查看物理CPU个数、核数、逻辑CPU个数、内存信息
GPU信息
多 GPU 拓扑
软件环境
【ubuntu】安装nvidia-docker方式:【ubuntu】安装nvidia-docker - 代码诠释的世界 - 博客园
k8s集群节点配置GPU:k8s集群节点配置GPU - shookm - 博客园
1.准备机器
| 机器IP | GPU | 备注 |
| — | — | — |
| 10.103.72.1 | H20 141 | 新机器 |
| 10.103.72.2 | H20 141 | 新机器 |
2.安装驱动及必要软件
新加入的机器需要分别安装驱动,Docker,Nvidia-Docker
1 | 安装驱动 |
1 | 安装Docker |
1 |
|
3.下载镜像&模型下载
https://huggingface.co/deepseek-ai/DeepSeek-V3-0324
4.准备集群脚本
wget https://github.com/vllm-project/vllm/blob/main/examples/online_serving/run_cluster.sh
5.启动主节点
选择10.103.72.1这台服务器作为主节点
1 | bash run_cluster.sh \ |
启动一个主节点(–head参数就是主节点),然后把本地的模型挂载到了容器,并指定vLLM的监听的IP和IP对应的网卡名字。
6.启动从节点10.103.72.2
1 | bash run_cluster.sh \ |
这里就是启动了一个从节点(–worker),并指定主节点的ip地址是10.103.72.1。
7.检查集群状态
进入主节点容器
1 | docker exec -it node bash |
这里显示2个节点,总共16个GPU显示以后就ray集群启动成功。
8.启动服务
1 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m vllm.entrypoints.openai.api_server \ |
vLLM vs. SGLang
https://www.zhihu.com/question/666943660
- vLLM :专注推理引擎性能优化,核心是 PagedAttention,借鉴操作系统虚拟内存和分页思想管理 KV Cache,减少内存碎片、提升吞吐量,在处理变长序列、多请求并发时效率高。
- SGLang :引入控制流概念并与底层优化结合,适用于需精细控制生成内容、实现高级 Agent 逻辑、RAG 中复杂检索与生成协同、模型输出严格遵守特定格式等场景。前端有专门语言,能简洁编排复杂生成任务,后端引擎如 RadixAttention 吸取类似 PagedAttention 精髓并协同优化。
本次测试的是LLM Serving 开源推理框架 : SGLang 和 vLLM ;同时,为了环境搭建的便利性,本次测试直接采用起docker的方式进行测试。本次采用的docker images信息如下: - docker pull lmsysorg/sglang:deepep
- docker pull vllm/vllm-openai:v0.8.5.post1
- docker pull lmsysorg/sglang:v0.4.6.post4-cu124
DeepSeek-V3-0324 部署
vLLM 部署 DeepSeek-V3
vLLM 服务启动
1、–enable-prefix-caching、–chunked-prefill-enabled、–use-v2-block-manager默认开启;
2、–enforce-eager、–enable-expert-parallel默认关闭;
1 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m vllm.entrypoints.openai.api_server \ |
vLLM 0.8.5.post1日志分析
vLLM API server version 0.8.5.post1
1
INFO 05-20 19:53:50 [api_server.py:1044] args: Namespace(host=None, port=8995, uvicorn_log_level='info', disable_uvicorn_access_log=False, allow_credentials=False, allowed_origins=['*'], allowed_methods=['*'], allowed_headers=['*'], api_key='fe21b93dd0234e64a8ab44d4c49cf365', lora_modules=None, prompt_adapters=None, chat_template=None, chat_template_content_format='auto', response_role='assistant', ssl_keyfile=None, ssl_certfile=None, ssl_ca_certs=None, enable_ssl_refresh=False, ssl_cert_reqs=0, root_path=None, middleware=[], return_tokens_as_token_ids=False, disable_frontend_multiprocessing=False, enable_request_id_headers=False, enable_auto_tool_choice=False, tool_call_parser=None, tool_parser_plugin='', model='/models/DeepSeek-V3-0324', task='auto', tokenizer=None, hf_config_path=None, skip_tokenizer_init=False, revision=None, code_revision=None, tokenizer_revision=None, tokenizer_mode='auto', trust_remote_code=False, allowed_local_media_path=None, load_format='auto', download_dir=None, model_loader_extra_config={}, use_tqdm_on_load=True, config_format=<ConfigFormat.AUTO: 'auto'>, dtype='auto', max_model_len=32768, guided_decoding_backend='auto', reasoning_parser=None, logits_processor_pattern=None, model_impl='auto', distributed_executor_backend=None, pipeline_parallel_size=1, tensor_parallel_size=8, data_parallel_size=1, enable_expert_parallel=False, max_parallel_loading_workers=None, ray_workers_use_nsight=False, disable_custom_all_reduce=False, block_size=None, gpu_memory_utilization=0.95, swap_space=4, kv_cache_dtype='auto', num_gpu_blocks_override=None, enable_prefix_caching=None, prefix_caching_hash_algo='builtin', cpu_offload_gb=0, calculate_kv_scales=False, disable_sliding_window=False, use_v2_block_manager=True, seed=None, max_logprobs=20, disable_log_stats=False, quantization=None, rope_scaling=None, rope_theta=None, hf_token=None, hf_overrides=None, enforce_eager=False, max_seq_len_to_capture=8192, tokenizer_pool_size=0, tokenizer_pool_type='ray', tokenizer_pool_extra_config={}, limit_mm_per_prompt={}, mm_processor_kwargs=None, disable_mm_preprocessor_cache=False, enable_lora=None, enable_lora_bias=False, max_loras=1, max_lora_rank=16, lora_extra_vocab_size=256, lora_dtype='auto', long_lora_scaling_factors=None, max_cpu_loras=None, fully_sharded_loras=False, enable_prompt_adapter=None, max_prompt_adapters=1, max_prompt_adapter_token=0, device='auto', speculative_config=None, ignore_patterns=[], served_model_name=['deepseek-v3-0324'], qlora_adapter_name_or_path=None, show_hidden_metrics_for_version=None, otlp_traces_endpoint=None, collect_detailed_traces=None, disable_async_output_proc=False, max_num_batched_tokens=None, max_num_seqs=None, max_num_partial_prefills=1, max_long_partial_prefills=1, long_prefill_token_threshold=0, num_lookahead_slots=0, scheduler_delay_factor=0.0, preemption_mode=None, num_scheduler_steps=1, multi_step_stream_outputs=True, scheduling_policy='fcfs', enable_chunked_prefill=None, disable_chunked_mm_input=False, scheduler_cls='vllm.core.scheduler.Scheduler', override_neuron_config=None, override_pooler_config=None, compilation_config=None, kv_transfer_config=None, worker_cls='auto', worker_extension_cls='', generation_config='auto', override_generation_config=None, enable_sleep_mode=False, additional_config=None, enable_reasoning=False, disable_cascade_attn=False, disable_log_requests=False, max_log_len=None, disable_fastapi_docs=False, enable_prompt_tokens_details=False, enable_server_load_tracking=False)
This model supports multiple tasks: {‘embed’, ‘classify’, ‘generate’, ‘reward’, ‘score’}. Defaulting to ‘generate’.
rope_scaling‘s factor field must be a float >= 1, got 40rope_scaling‘s beta_fast field must be a float, got 32rope_scaling‘s beta_slow field must be a float, got 1Defaulting to use mp for distributed inference
Chunked prefill is enabled with max_num_batched_tokens=8192.
Forcing kv cache block size to 64 for FlashMLA backend.
1
INFO 05-20 19:54:03 [core.py:58] Initializing a V1 LLM engine (v0.8.5.post1) with config: model='/models/DeepSeek-V3-0324', speculative_config=None, tokenizer='/models/DeepSeek-V3-0324', skip_tokenizer_init=False, tokenizer_mode=auto, revision=None, override_neuron_config=None, tokenizer_revision=None, trust_remote_code=False, dtype=torch.bfloat16, max_seq_len=32768, download_dir=None, load_format=LoadFormat.AUTO, tensor_parallel_size=8, pipeline_parallel_size=1, disable_custom_all_reduce=False, quantization=fp8, enforce_eager=False, kv_cache_dtype=auto, device_config=cuda, decoding_config=DecodingConfig(guided_decoding_backend='auto', reasoning_backend=None), observability_config=ObservabilityConfig(show_hidden_metrics=False, otlp_traces_endpoint=None, collect_model_forward_time=False, collect_model_execute_time=False), seed=None, served_model_name=deepseek-v3-0324, num_scheduler_steps=1, multi_step_stream_outputs=True, enable_prefix_caching=True, chunked_prefill_enabled=True, use_async_output_proc=True, disable_mm_preprocessor_cache=False, mm_processor_kwargs=None, pooler_config=None, compilation_config={"level":3,"custom_ops":["none"],"splitting_ops":["vllm.unified_attention","vllm.unified_attention_with_output"],"use_inductor":true,"compile_sizes":[],"use_cudagraph":true,"cudagraph_num_of_warmups":1,"cudagraph_capture_sizes":[512,504,496,488,480,472,464,456,448,440,432,424,416,408,400,392,384,376,368,360,352,344,336,328,320,312,304,296,288,280,272,264,256,248,240,232,224,216,208,200,192,184,176,168,160,152,144,136,128,120,112,104,96,88,80,72,64,56,48,40,32,24,16,8,4,2,1],"max_capture_size":512}
vLLM is using nccl==2.21.5
Using Flash Attention backend on V1 engine.
Using FlashInfer for top-p & top-k sampling.
*Using default W8A8 Block FP8 kernel config. Performance might be sub-optimal! *
Using default MoE config. Performance might be sub-optimal!
vLLM 0.8.5调用日志
1 | INFO 05-20 20:02:45 [logger.py:39] Received request chatcmpl-9f8732e94f4244d1933f728398e926d6: prompt: '<|begin▁of▁sentence|>你是人工智能助手<|User|>zoomlion里面有几个o<|Assistant|>', params: SamplingParams(n=1, presence_penalty=0.0, frequency_penalty=0.0, repetition_penalty=1.0, temperature=0.0, top_p=1.0, top_k=-1, min_p=0.0, seed=None, stop=[], stop_token_ids=[], bad_words=[], include_stop_str_in_output=False, ignore_eos=False, max_tokens=256, min_tokens=0, logprobs=None, prompt_logprobs=None, skip_special_tokens=True, spaces_between_special_tokens=True, truncate_prompt_tokens=None, guided_decoding=None, extra_args=None), prompt_token_ids: None, lora_request: None, prompt_adapter_request: None. |
思考模式:流式返回的首个token
Ray + vLLM 多机多卡
1 | sudo docker run --gpus all -it -d --network host --name deepseek-vllm-raycluster --ipc=host -P -p 8995:8995 -v /data4/models:/models llm_management_20250328:py311 /bin/bash |
首先修改/etc/profile来建立NCCL网络通信解决下面问题,然后使用source /etc/profile激活配置
1 | Network |
主节点:
nohup ray start –disable-usage-stats –head –num-gpus 8 &
从节点
nohup ray start –disable-usage-stats –num-gpus 8 –address=’10.103.72.1:6379’ &
tensor-parallel-size
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 python -m vllm.entrypoints.openai.api_server \
--served-model-name deepseek-v3-0324 \
--port 8995 \
--model /models/DeepSeek-V3-0324 \
--tensor-parallel-size 16 \
--max-model-len 32768 \
--gpu-memory-utilization 0.95 \
--quantization fp8 \
--api-key fe21b93dd0234e64a8ab44d4c49cf365
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 nohup python -m vllm.entrypoints.openai.api_server \
--served-model-name deepseek-v3-0324 \
--port 8995 \
--model /models/DeepSeek-V3-0324 \
--tensor-parallel-size 16 \
--max-model-len 32768 \
--gpu-memory-utilization 0.95 \
--quantization fp8 \
--api-key fe21b93dd0234e64a8ab44d4c49cf365 > DeepSeek-V3-0324.log 2>&1 &tensor-parallel-size * pipeline-parallel-size
1
2
3
4
5
6
7
8
9
10CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 python -m vllm.entrypoints.openai.api_server \
--served-model-name deepseek-v3-0324 \
--port 8995 \
--model /models/DeepSeek-V3-0324 \
--tensor-parallel-size 8 \
--pipeline-parallel-size 2\
--max-model-len 32768 \
--gpu-memory-utilization 0.95 \
--quantization fp8
--api-key fe21b93dd0234e64a8ab44d4c49cf365 pipeline-parallel-size
SGLang 部署 DeepSeek-V3
SGLang 服务启动
推荐配置:2 x 8 x H100/800/20,来源:SGLang DeepSeek
1、MLA optimization、Radix Cache、CUDA Graph默认开启,可使用–disable-mla、–disable-radix-cache、–disable-cuda-graph关闭
2、Torch Compile、Flashinfer MLA默认关闭,可使用–enable-torch-compile、–enable-flashinfer-mla开启;
3、Speculative Decoding (Next-N)默认关闭,与 Flashinfer-mla、Radix Cache、DP-Attention 存在兼容性问题;
4、Tensor Parallelism默认开启,Expert Parallelism、Data Parallelism Attention默认关闭,可使用–enable-ep-moe,–ep-size、–enable-dp-attention开启;5、–quantization fp8 启用 fp8 权重量化,–kv-cache-dtype fp8_e5m2开启FP8 KV缓存量化;
1 | python -m sglang.compile_deep_gemm \ |
SGLang 0.4.6.post4日志分析
SGLang API server version 0.4.6.post4
1
[2025-05-21 11:36:54] server_args=ServerArgs(model_path='/models/DeepSeek-V3-0324', tokenizer_path='/models/DeepSeek-V3-0324', tokenizer_mode='auto', skip_tokenizer_init=False, enable_tokenizer_batch_encode=False, load_format='auto', trust_remote_code=False, dtype='auto', kv_cache_dtype='auto', quantization=None, quantization_param_path=None, context_length=32768, device='cuda', served_model_name='deepseek-v3-0324', chat_template=None, completion_template=None, is_embedding=False, revision=None, host='0.0.0.0', port=8995, mem_fraction_static=0.9, max_running_requests=None, max_total_tokens=None, chunked_prefill_size=8192, max_prefill_tokens=16384, schedule_policy='fcfs', schedule_conservativeness=1.0, cpu_offload_gb=0, page_size=1, tp_size=8, pp_size=1, max_micro_batch_size=None, stream_interval=1, stream_output=False, random_seed=818160410, constrained_json_whitespace_pattern=None, watchdog_timeout=3600, dist_timeout=None, download_dir=None, base_gpu_id=0, gpu_id_step=1, log_level='info', log_level_http=None, log_requests=False, log_requests_level=0, show_time_cost=False, enable_metrics=True, decode_log_interval=40, enable_request_time_stats_logging=False, api_key='fe21b93dd0234e64a8ab44d4c49cf365', file_storage_path='sglang_storage', enable_cache_report=False, reasoning_parser=None, dp_size=1, load_balance_method='round_robin', ep_size=1, dist_init_addr=None, nnodes=1, node_rank=0, json_model_override_args='{}', lora_paths=None, max_loras_per_batch=8, lora_backend='triton', attention_backend=None, sampling_backend='flashinfer', grammar_backend='xgrammar', speculative_algorithm=None, speculative_draft_model_path=None, speculative_num_steps=None, speculative_eagle_topk=None, speculative_num_draft_tokens=None, speculative_accept_threshold_single=1.0, speculative_accept_threshold_acc=1.0, speculative_token_map=None, enable_double_sparsity=False, ds_channel_config_path=None, ds_heavy_channel_num=32, ds_heavy_token_num=256, ds_heavy_channel_type='qk', ds_sparse_decode_threshold=4096, disable_radix_cache=False, disable_cuda_graph=True, disable_cuda_graph_padding=False, enable_nccl_nvls=False, disable_outlines_disk_cache=False, disable_custom_all_reduce=False, enable_multimodal=None, disable_overlap_schedule=False, enable_mixed_chunk=False, enable_dp_attention=False, enable_dp_lm_head=False, enable_ep_moe=False, enable_deepep_moe=False, deepep_mode='auto', enable_torch_compile=False, torch_compile_max_bs=32, cuda_graph_max_bs=None, cuda_graph_bs=None, torchao_config='', enable_nan_detection=False, enable_p2p_check=False, triton_attention_reduce_in_fp32=False, triton_attention_num_kv_splits=8, num_continuous_decode_steps=1, delete_ckpt_after_loading=False, enable_memory_saver=False, allow_auto_truncate=False, enable_custom_logit_processor=False, tool_call_parser=None, enable_hierarchical_cache=False, hicache_ratio=2.0, hicache_size=0, hicache_write_policy='write_through_selective', flashinfer_mla_disable_ragged=False, warmups='compile-deep-gemm', moe_dense_tp_size=None, n_share_experts_fusion=0, disable_chunked_prefix_cache=False, disable_fast_image_processor=False, mm_attention_backend=None, debug_tensor_dump_output_folder=None, debug_tensor_dump_input_file=None, debug_tensor_dump_inject=False, disaggregation_mode='null', disaggregation_bootstrap_port=8998, disaggregation_transfer_backend='mooncake', disaggregation_ib_device=None, pdlb_url=None)
Disable CUDA Graph and Torch Compile to save time…
Begin DeepGEMM Kernels compilation…
It may take a long time and timeout maybe raised while the compilation is still in progress.
Just feel free to restart the command until the compilation is fully finished.
rope_scaling‘s factor field must be a float >= 1, got 40rope_scaling‘s beta_fast field must be a float, got 32rope_scaling‘s beta_slow field must be a float, got 1max_total_num_tokens=681182, chunked_prefill_size=8192, max_prefill_tokens=16384, max_running_requests=4097, context_len=32768
Try DeepGEMM JIT Compiling for <gemm_fp8_fp8_bf16_nt> N=7168, K=2304, num_groups=1 with all Ms.
Generate warm up request for compiling DeepGEMM…
SGLang 部署 DeepSeek-R1
SGLang 服务启动
1 | python -m sglang.launch_server \ |
bench_serving 测试
测试基准方法
并发计算规则,一般情况下,搜索业务、助手、问答业务为主:
- 轻度使用:并发数需求=员工(组织)总数/20,得到并发数;
- 中度使用:并发数需求=员工(组织)总数/10,得到并发数;
- 重度使用:并发数需求=员工(组织)总数/5,得到并发数;
输入输出长度规则,一般情况下4k的输入输出能够覆盖95%的日常办公需求根据任务,比如会议总结、问答、智能客服等等场景,输入输出对等情况下,按照256、512、1024、2048、4096等5个设定测试性能数据
时延要求规则:一般情况下,影响用户体验的就是TTFT和TPOT,延迟肯定是越短越好,但是短意味着硬件成本高,一般情况下TTFT小于5~10s 可接受。大模型的推理任务一般分为两个阶段:
- 一是Prefill,处理所有输入的 Token,生成第一个输出 token 和 KV cache,是算力密集型,这个阶段需要算力越大越好。
- 二是Decode,利用 KV Cache 进行多轮迭代,每轮生成一个 token,需要反复读取前面所有token的 Key 和 Value,瓶颈在于内存访问,这个阶段需要显存越快越好。
生成速度规则:目前大家默认每个访问每秒产生10个token(10个汉字),就属于一个体验较好的范畴,chat.deepseek官网基本就是这个速度。
智商对等规则:这里的智商对等是指跟chat.deepseek的官网智商一致,简单理解就是把同一问题,发给官网和目标系统,返回结果基本一致。
**5个典型问题,可以把问题发给官网和待测试的目标平台,对比返回的答案。**
**问题1:** 7.11和7.9哪个大? **问题2**:三个说谎者A/B/C,其中一人会说真话当且仅当另外两人同时说谎,请建立非线性方程组描述其关系。 **问题3**:假设你是某国央行AI顾问,请设计一个货币政策:在保持通胀目标制的同时,允许加密货币合法流通,并预防量子计算机对传统加密体系的冲击。 **问题4**:结合量子生物学、计算神经科学和现象学,解释人类意识产生机制,并提出实验方案验证你的理论,需包含可证伪性标准。 **问题5**:果要求你破译线形文字A,请设计一个多模态神经网络架构,整合考古学背景知识、陶器纹样分析和音节统计特征,给出破译路线图。1 | python3 -m sglang.launch_server |
SGLang 部署评测
bench_serving 需要开两个终端,其中一个终端先起serving服务,另一个终端再执行具体指令
1 | 终端1 起服务指令 |
vLLM 部署评测
跟sglang serving一样,vLLM benchmark也采用serving的模式,同样也需要起两个终端分别用于起serve和执行具体任务
1 | 终端1 起服务指令 |

