DeepSeek-R1
DeepSeek-R1
이 문서는 강력한 언어 이해와 단계별 추론 능력을 결합한 DeepSeek의 고급 추론 모델인 DeepSeek-R1을 SGLang으로 배포하고 호출하는 방법을 설명해요. 다양한 하드웨어 플랫폼에 최적화된 여러 양자화 형식으로 제공돼요. 원문 페이지에는 하드웨어 플랫폼과 배포 전략을 골라 명령을 자동 생성해 주는 대화형 선택기가 포함되어 있어요.
출처: 문서
본문
1. 모델 소개
DeepSeek-R1은 강력한 언어 이해와 단계별 추론 능력을 결합한 DeepSeek의 고급 추론 모델이에요. 이 모델은 다양한 하드웨어 플랫폼에 최적화된 여러 양자화 형식으로 제공돼요.
주요 특징:
- 고급 추론 (Advanced Reasoning): 복잡한 문제 해결을 위한 내장 추론 능력
- 여러 양자화 (Multiple Quantizations): 성능/메모리 트레이드오프가 다른 FP8 및 FP4 변형
- 하드웨어 최적화 (Hardware Optimization): NVIDIA B200(Blackwell) 및 H200(Hopper) GPU, AMD MI300X, MI325X, MI355X GPU, 그리고 Intel Xeon CPU에 특별히 튜닝됨
- 높은 성능 (High Performance): 처리량과 지연 시간 시나리오 모두에 최적화
사용 가능한 모델:
- FP8 (8-bit 양자화): deepseek-ai/DeepSeek-R1-0528 - H200 및 MI300X에 권장
- FP4 (4-bit 양자화): nvidia/DeepSeek-R1-0528-FP4-v2 - B200 및 MI355X에 권장
- BF16 (FP8에서 upcast): unsloth/DeepSeek-R1-0528-BF16
- INT8 (channel-wise): meituan/DeepSeek-R1-Channel-INT8
- W4A8: novita/Deepseek-R1-0528-W4AFP8
- AWQ (4-bit): QuixiAI/DeepSeek-R1-0528-AWQ
- MXFP4: amd/DeepSeek-R1-MXFP4
라이선스: DeepSeek-R1을 사용하려면 DeepSeek 커뮤니티 라이선스에 동의해야 해요. 자세한 내용은 LICENSE를 참고하세요.
자세한 내용은 공식 DeepSeek-R1 저장소를 참고하세요.
2. SGLang 설치
설치 지침은 공식 SGLang 설치 가이드를 참고하세요.
SGLang CPU 설치는 CPU 버전 설치 가이드를 참고하세요.
3. 모델 배포
이 섹션은 서로 다른 하드웨어 플랫폼과 사용 사례에 최적화된 배포 설정을 제공해요.
3.1 기본 설정
대화형 명령 생성기 (Interactive Command Generator): 아래 설정 선택기를 사용해 하드웨어 플랫폼, 양자화 방법, 배포 전략에 맞는 기본 배포 명령을 자동으로 생성할 수 있어요. (대화형 위젯은 원문 페이지에서 동작하므로, 기본 설정 기준 명령은 다음과 같아요.)
python -m sglang.launch_server \
--model-path deepseek-ai/DeepSeek-R1-0528 \
--tp 8
3.2 최적 설정
B200, H200, MI300X, MI325X, MI355X 하드웨어에 대한 파레토 최적 설정. (원문 페이지의 대화형 선택기를 참고하세요.)
3.3 설정 팁
DeepSeek-R1은 DeepSeek-V3와 동일한 MoE 아키텍처를 공유하므로, 동일한 하드웨어·최적화 권장 사항이 적용돼요.
가중치 유형별 권장 GPU 설정:
| 가중치 유형 | 지원 하드웨어 |
|---|---|
| FP8 (권장) | 8× H200, 8× B200, 8× MI300X, 2×8× H100/H800/H20 |
| BF16 (FP8에서 upcast) | 2×8× H200, 2×8× MI300X, 4×8× H100/H800, 4×8× A100/A800 |
| INT8 | 16× A100/A800, 32× L40S, Xeon 6980P CPU, 4× Ascend A3 Series |
| W4A8 / AWQ / MXFP4 / NVFP4 | 8× H20/H100, 4× H200; 8× H100/A100; 8/4× MI355X/MI350X; 8/4× B200 |
공식 DeepSeek-R1 체크포인트는 이미 FP8 형식이에요 — 서빙할 때
--quantization fp8을 추가하지 마세요.
DeepGEMM 사전 컴파일 (NVIDIA Hopper / Blackwell): JIT 오버헤드(약 10분)를 피하기 위해 GEMM 커널을 사전 컴파일하세요:
python3 -m sglang.compile_deep_gemm --model deepseek-ai/DeepSeek-R1 --tp 8 --trust-remote-code
데이터 병렬화 어텐션 (--enable-dp-attention): 높은 처리량 시나리오에 권장돼요. 단일 8-GPU 노드에서는 --enable-dp-attention --tp 8 --dp 8을 사용하세요.
NCCL 타임아웃: 모델 로딩이 느리면 늘리세요: --dist-timeout 3600.
Xeon CPU 서비스 설정: SGLang CPU 서버 문서의 서빙 엔진 실행 부분에 있는 Notes 항목을 참고해 인자, 특히 TP(텐서 병렬) 및 NUMA 바인딩 설정을 이해하세요.
4. 모델 호출
4.1 기본 사용법
기본 API 사용법과 요청 예시는 다음을 참고하세요:
4.2 고급 사용법
4.2.1 추론 파서 (Reasoning Parser)
DeepSeek-R1은 내장 사고 과정을 갖춘 고급 추론 능력을 지원해요. 배포 중 reasoning parser를 활성화해 thinking 섹션과 content 섹션을 분리하세요:
python -m sglang.launch_server \
--model-path deepseek-ai/DeepSeek-R1-0528 \
--reasoning-parser deepseek-r1 \
--tp 8
사고 과정이 포함된 스트리밍:
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:30000/v1",
api_key="EMPTY"
)
# Enable streaming to see the thinking process in real-time
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-R1-0528",
messages=[
{"role": "user", "content": "Solve this problem step by step: What is 15% of 240?"}
],
temperature=0.7,
max_tokens=2048,
stream=True
)
# Process the stream
has_thinking = False
has_answer = False
thinking_started = False
for chunk in response:
if chunk.choices and len(chunk.choices) > 0:
delta = chunk.choices[0].delta
# Print thinking process
if hasattr(delta, 'reasoning_content') and delta.reasoning_content:
if not thinking_started:
print("=============== Thinking =================", flush=True)
thinking_started = True
has_thinking = True
print(delta.reasoning_content, end="", flush=True)
# Print answer content
if delta.content:
# Close thinking section and add content header
if has_thinking and not has_answer:
print("\n=============== Content =================", flush=True)
has_answer = True
print(delta.content, end="", flush=True)
print()
출력 예시:
=============== Thinking =================
To solve this problem, I need to calculate 15% of 240.
Step 1: Convert 15% to decimal: 15% = 0.15
Step 2: Multiply 240 by 0.15
Step 3: 240 × 0.15 = 36
=============== Content =================
The answer is 36. To find 15% of 240, we multiply 240 by 0.15, which equals 36.
참고: reasoning parser는 모델의 단계별 사고 과정을 캡처해 모델이 결론에 도달하는 방식을 볼 수 있게 해줘요.
4.2.2 도구 호출 (Tool Calling)
DeepSeek-R1은 도구 호출 기능을 지원해요. tool call parser를 활성화하세요:
python -m sglang.launch_server \
--model-path deepseek-ai/DeepSeek-R1-0528 \
--reasoning-parser deepseek-r1 \
--tool-call-parser deepseekv3 \
--chat-template examples/chat_template/tool_chat_template_deepseekr1.jinja \
--tp 8
Python 예시 (사고 과정 포함):
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:30000/v1",
api_key="EMPTY"
)
# Define available tools
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city name"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "Temperature unit"
}
},
"required": ["location"]
}
}
}
]
# Make request with streaming to see thinking process
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-R1-0528",
messages=[
{"role": "user", "content": "What's the weather in Beijing?"}
],
tools=tools,
temperature=0.7,
stream=True
)
# Process streaming response
thinking_started = False
has_thinking = False
for chunk in response:
if chunk.choices and len(chunk.choices) > 0:
delta = chunk.choices[0].delta
# Print thinking process
if hasattr(delta, 'reasoning_content') and delta.reasoning_content:
if not thinking_started:
print("=============== Thinking =================", flush=True)
thinking_started = True
has_thinking = True
print(delta.reasoning_content, end="", flush=True)
# Print tool calls
if hasattr(delta, 'tool_calls') and delta.tool_calls:
# Close thinking section if needed
if has_thinking and thinking_started:
print("\n=============== Content =================", flush=True)
thinking_started = False
for tool_call in delta.tool_calls:
if tool_call.function:
print(f"🔧 Tool Call: {tool_call.function.name}")
print(f" Arguments: {tool_call.function.arguments}")
# Print content
if delta.content:
print(delta.content, end="", flush=True)
print()
출력 예시:
=============== Thinking =================
The user is asking about the weather in Beijing. I need to use the get_weather function to retrieve this information.
I should call the function with location="Beijing".
=============== Content =================
🔧 Tool Call: get_weather
Arguments:
🔧 Tool Call: None
Arguments: {"location": "Beijing"}
참고:
- reasoning parser는 모델이 도구를 어떻게 사용하기로 결정하는지 보여줘요
- 도구 호출은 함수 이름과 인자로 명확하게 표시돼요
- 그런 다음 함수를 실행하고 결과를 다시 보내 대화를 이어갈 수 있어요
도구 호출 결과 처리:
# After getting the tool call, execute the function
def get_weather(location, unit="celsius"):
# Your actual weather API call here
return f"The weather in {location} is 22°{unit[0].upper()} and sunny."
# Send tool result back to the model
messages = [
{"role": "user", "content": "What's the weather in Beijing?"},
{
"role": "assistant",
"content": None,
"tool_calls": [{
"id": "call_123",
"type": "function",
"function": {
"name": "get_weather",
"arguments": '{"location": "Beijing", "unit": "celsius"}'
}
}]
},
{
"role": "tool",
"tool_call_id": "call_123",
"content": get_weather("Beijing", "celsius")
}
]
final_response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-R1-0528",
messages=messages,
temperature=0.7
)
print(final_response.choices[0].message.content)
# Output: "The weather in Beijing is currently 22°C and sunny."
4.2.3 다중 토큰 예측 (Multi-Token Prediction, EAGLE 추측 디코딩)
DeepSeek-R1은 DeepSeek-V3와 동일한 메커니즘인 EAGLE 기반 Multi-Token Prediction(MTP)을 지원해요. 전체 실행 명령, 플래그 참고, 튜닝 가이드(--speculative-num-steps, --speculative-eagle-topk, --max-running-requests), bench_speculative.py 링크는 DeepSeek-V3 §4.2.3을 참고하세요. --speculative-* 플래그를 포함한 R1의 속도 벤치마크 명령이 이 메커니즘을 사용해요.
4.2.4 사고 예산 (Thinking Budget)
CustomLogitProcessor를 사용해 모델의 사고 토큰 예산을 제한하세요. --enable-custom-logit-processor로 실행하세요:
python3 -m sglang.launch_server \
--model deepseek-ai/DeepSeek-R1 \
--tp 8 \
--port 30000 \
--reasoning-parser deepseek-r1 \
--enable-custom-logit-processor
import openai
from sglang.srt.sampling.custom_logit_processor import DeepSeekR1ThinkingBudgetLogitProcessor
client = openai.Client(base_url="http://127.0.0.1:30000/v1", api_key="*")
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-R1",
messages=[{"role": "user", "content": "Is Paris the Capital of France?"}],
max_tokens=1024,
extra_body={
"custom_logit_processor": DeepSeekR1ThinkingBudgetLogitProcessor().to_str(),
"custom_params": {"thinking_budget": 512},
},
)
print(response)
5. 벤치마크
이 섹션은 비교 가능한 벤치마크 결과를 위해 산업 표준 설정을 사용해요.
5.1 속도 벤치마크
테스트 환경:
- 하드웨어: B200 GPU (8x)
- 모델: DeepSeek-R1-0528
- 텐서 병렬화(Tensor Parallelism): 8
- SGLang 버전: 0.5.6.post1
벤치마크 방법론:
결과가 프레임워크와 하드웨어 플랫폼 전반에서 비교 가능하도록 업계 표준 벤치마크 설정을 사용해요.
5.1.1 표준 테스트 시나리오
세 가지 핵심 시나리오가 실제 사용 패턴을 반영해요:
| 시나리오 | 입력 길이 | 출력 길이 | 사용 사례 |
|---|---|---|---|
| Chat | 1K | 1K | 가장 흔한 대화형 AI 워크로드 |
| Reasoning | 1K | 8K | 장문 생성, 복잡한 추론 작업 |
| Summarization | 8K | 1K | 문서 요약, RAG 검색 |
5.1.2 동시성 수준
각 시나리오를 서로 다른 동시성 수준에서 테스트해 처리량과 지연 시간의 트레이드오프를 포착하세요:
- 낮은 동시성 (Low Concurrency):
--max-concurrency 1(지연 시간 최적화) - 중간 동시성 (Medium Concurrency):
--max-concurrency 16(균형) - 높은 동시성 (High Concurrency):
--max-concurrency 100(처리량 최적화)
5.1.3 프롬프트 수
각 동시성 수준에 대해 num_prompts를 구성해 현실적인 사용자 부하를 시뮬레이션하세요:
- 빠른 테스트 (Quick Test):
num_prompts = concurrency × 1(최소 테스트) - 권장 (Recommended):
num_prompts = concurrency × 5(표준 벤치마크) - 안정적 측정 (Stable Measurements):
num_prompts = concurrency × 10(프로덕션 등급)
5.1.4 벤치마크 명령
시나리오 1: Chat (1K/1K) - 가장 중요
- 모델 배포
python -m sglang.launch_server \
--model-path deepseek-ai/DeepSeek-R1-0528 \
--tp 8
- 낮은 동시성 (지연 시간 최적화)
python -m sglang.bench_serving \
--backend sglang \
--model deepseek-ai/DeepSeek-R1-0528 \
--dataset-name random \
--random-input-len 1000 \
--random-output-len 1000 \
--num-prompts 10 \
--max-concurrency 1 \
--request-rate inf
============ Serving Benchmark Result ============
Backend: sglang
Traffic request rate: inf
Max request concurrency: 1
Successful requests: 10
Benchmark duration (s): 40.00
Total input tokens: 6101
Total input text tokens: 6101
Total input vision tokens: 0
Total generated tokens: 4210
Total generated tokens (retokenized): 4205
Request throughput (req/s): 0.25
Input token throughput (tok/s): 152.52
Output token throughput (tok/s): 105.24
Peak output token throughput (tok/s): 110.00
Peak concurrent requests: 2
Total token throughput (tok/s): 257.76
Concurrency: 1.00
----------------End-to-End Latency----------------
Mean E2E Latency (ms): 3998.40
Median E2E Latency (ms): 3207.53
---------------Time to First Token----------------
Mean TTFT (ms): 153.00
Median TTFT (ms): 140.76
P99 TTFT (ms): 214.66
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms): 9.16
Median TPOT (ms): 9.15
P99 TPOT (ms): 9.21
---------------Inter-Token Latency----------------
Mean ITL (ms): 9.16
Median ITL (ms): 9.15
P95 ITL (ms): 9.47
P99 ITL (ms): 9.63
Max ITL (ms): 15.45
==================================================
- 중간 동시성 (균형)
python -m sglang.bench_serving \
--backend sglang \
--model deepseek-ai/DeepSeek-R1-0528 \
--dataset-name random \
--random-input-len 1000 \
--random-output-len 1000 \
--num-prompts 80 \
--max-concurrency 16 \
--request-rate inf
============ Serving Benchmark Result ============
Backend: sglang
Traffic request rate: inf
Max request concurrency: 16
Successful requests: 80
Benchmark duration (s): 51.21
Total input tokens: 39668
Total input text tokens: 39668
Total input vision tokens: 0
Total generated tokens: 40725
Total generated tokens (retokenized): 40458
Request throughput (req/s): 1.56
Input token throughput (tok/s): 774.66
Output token throughput (tok/s): 795.30
Peak output token throughput (tok/s): 1088.00
Peak concurrent requests: 21
Total token throughput (tok/s): 1569.96
Concurrency: 13.93
----------------End-to-End Latency----------------
Mean E2E Latency (ms): 8918.33
Median E2E Latency (ms): 9466.16
---------------Time to First Token----------------
Mean TTFT (ms): 273.51
Median TTFT (ms): 131.71
P99 TTFT (ms): 839.57
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms): 17.56
Median TPOT (ms): 17.46
P99 TPOT (ms): 28.68
---------------Inter-Token Latency----------------
Mean ITL (ms): 17.02
Median ITL (ms): 14.70
P95 ITL (ms): 16.41
P99 ITL (ms): 112.38
Max ITL (ms): 461.90
==================================================
- 높은 동시성 (처리량 최적화)
python -m sglang.bench_serving \
--backend sglang \
--model deepseek-ai/DeepSeek-R1-0528 \
--dataset-name random \
--random-input-len 1000 \
--random-output-len 1000 \
--num-prompts 500 \
--max-concurrency 100 \
--request-rate inf
============ Serving Benchmark Result ============
Backend: sglang
Traffic request rate: inf
Max request concurrency: 100
Successful requests: 500
Benchmark duration (s): 110.46
Total input tokens: 249831
Total input text tokens: 249831
Total input vision tokens: 0
Total generated tokens: 252162
Total generated tokens (retokenized): 251441
Request throughput (req/s): 4.53
Input token throughput (tok/s): 2261.80
Output token throughput (tok/s): 2282.90
Peak output token throughput (tok/s): 3900.00
Peak concurrent requests: 109
Total token throughput (tok/s): 4544.71
Concurrency: 92.26
----------------End-to-End Latency----------------
Mean E2E Latency (ms): 20380.71
Median E2E Latency (ms): 19391.65
---------------Time to First Token----------------
Mean TTFT (ms): 563.14
Median TTFT (ms): 147.62
P99 TTFT (ms): 2632.11
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms): 40.11
Median TPOT (ms): 41.98
P99 TPOT (ms): 50.10
---------------Inter-Token Latency----------------
Mean ITL (ms): 39.37
Median ITL (ms): 26.36
P95 ITL (ms): 98.16
P99 ITL (ms): 150.08
Max ITL (ms): 2052.85
==================================================
시나리오 2: Reasoning (1K/8K)
- 낮은 동시성
python -m sglang.bench_serving \
--backend sglang \
--model deepseek-ai/DeepSeek-R1-0528 \
--dataset-name random \
--random-input-len 1000 \
--random-output-len 8000 \
--num-prompts 10 \
--max-concurrency 1 \
--request-rate inf
============ Serving Benchmark Result ============
Backend: sglang
Traffic request rate: inf
Max request concurrency: 1
Successful requests: 10
Benchmark duration (s): 411.34
Total input tokens: 6101
Total input text tokens: 6101
Total input vision tokens: 0
Total generated tokens: 44452
Total generated tokens (retokenized): 44390
Request throughput (req/s): 0.02
Input token throughput (tok/s): 14.83
Output token throughput (tok/s): 108.07
Peak output token throughput (tok/s): 110.00
Peak concurrent requests: 2
Total token throughput (tok/s): 122.90
Concurrency: 1.00
----------------End-to-End Latency----------------
Mean E2E Latency (ms): 41132.04
Median E2E Latency (ms): 44288.71
---------------Time to First Token----------------
Mean TTFT (ms): 125.76
Median TTFT (ms): 126.19
P99 TTFT (ms): 137.69
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms): 9.21
Median TPOT (ms): 9.20
P99 TPOT (ms): 9.27
---------------Inter-Token Latency----------------
Mean ITL (ms): 9.23
Median ITL (ms): 9.22
P95 ITL (ms): 9.64
P99 ITL (ms): 9.86
Max ITL (ms): 15.18
==================================================
- 중간 동시성
python -m sglang.bench_serving \
--backend sglang \
--model deepseek-ai/DeepSeek-R1-0528 \
--dataset-name random \
--random-input-len 1000 \
--random-output-len 8000 \
--num-prompts 80 \
--max-concurrency 16 \
--request-rate inf
============ Serving Benchmark Result ============
Backend: sglang
Traffic request rate: inf
Max request concurrency: 16
Successful requests: 80
Benchmark duration (s): 348.93
Total input tokens: 39668
Total input text tokens: 39668
Total input vision tokens: 0
Total generated tokens: 318226
Total generated tokens (retokenized): 317630
Request throughput (req/s): 0.23
Input token throughput (tok/s): 113.69
Output token throughput (tok/s): 912.02
Peak output token throughput (tok/s): 1088.00
Peak concurrent requests: 19
Total token throughput (tok/s): 1025.70
Concurrency: 14.07
----------------End-to-End Latency----------------
Mean E2E Latency (ms): 61360.70
Median E2E Latency (ms): 62071.20
---------------Time to First Token----------------
Mean TTFT (ms): 176.02
Median TTFT (ms): 153.75
P99 TTFT (ms): 268.44
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms): 15.42
Median TPOT (ms): 15.59
P99 TPOT (ms): 16.07
---------------Inter-Token Latency----------------
Mean ITL (ms): 15.39
Median ITL (ms): 15.17
P95 ITL (ms): 16.62
P99 ITL (ms): 18.13
Max ITL (ms): 226.59
==================================================
- 높은 동시성
python -m sglang.bench_serving \
--backend sglang \
--model deepseek-ai/DeepSeek-R1-0528 \
--dataset-name random \
--random-input-len 1000 \
--random-output-len 8000 \
--num-prompts 320 \
--max-concurrency 64 \
--request-rate inf
============ Serving Benchmark Result ============
Backend: sglang
Traffic request rate: inf
Max request concurrency: 64
Successful requests: 320
Benchmark duration (s): 589.31
Total input tokens: 158939
Total input text tokens: 158939
Total input vision tokens: 0
Total generated tokens: 1300705
Total generated tokens (retokenized): 1297658
Request throughput (req/s): 0.54
Input token throughput (tok/s): 269.70
Output token throughput (tok/s): 2207.16
Peak output token throughput (tok/s): 2944.00
Peak concurrent requests: 68
Total token throughput (tok/s): 2476.86
Concurrency: 57.03
----------------End-to-End Latency----------------
Mean E2E Latency (ms): 105032.36
Median E2E Latency (ms): 108229.09
---------------Time to First Token----------------
Mean TTFT (ms): 223.91
Median TTFT (ms): 158.15
P99 TTFT (ms): 474.86
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms): 25.94
Median TPOT (ms): 26.72
P99 TPOT (ms): 27.99
---------------Inter-Token Latency----------------
Mean ITL (ms): 25.79
Median ITL (ms): 25.37
P95 ITL (ms): 26.70
P99 ITL (ms): 105.49
Max ITL (ms): 237.91
==================================================
시나리오 3: Summarization (8K/1K)
- 낮은 동시성
python -m sglang.bench_serving \
--backend sglang \
--model deepseek-ai/DeepSeek-R1-0528 \
--dataset-name random \
--random-input-len 8000 \
--random-output-len 1000 \
--num-prompts 10 \
--max-concurrency 1 \
--request-rate inf
============ Serving Benchmark Result ============
Backend: sglang
Traffic request rate: inf
Max request concurrency: 1
Successful requests: 10
Benchmark duration (s): 40.65
Total input tokens: 41941
Total input text tokens: 41941
Total input vision tokens: 0
Total generated tokens: 4210
Total generated tokens (retokenized): 4195
Request throughput (req/s): 0.25
Input token throughput (tok/s): 1031.65
Output token throughput (tok/s): 103.56
Peak output token throughput (tok/s): 110.00
Peak concurrent requests: 2
Total token throughput (tok/s): 1135.20
Concurrency: 1.00
----------------End-to-End Latency----------------
Mean E2E Latency (ms): 4063.62
Median E2E Latency (ms): 3296.13
---------------Time to First Token----------------
Mean TTFT (ms): 165.91
Median TTFT (ms): 154.96
P99 TTFT (ms): 240.92
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms): 9.26
Median TPOT (ms): 9.27
P99 TPOT (ms): 9.42
---------------Inter-Token Latency----------------
Mean ITL (ms): 9.28
Median ITL (ms): 9.28
P95 ITL (ms): 9.66
P99 ITL (ms): 9.83
Max ITL (ms): 14.06
==================================================
- 중간 동시성
python -m sglang.bench_serving \
--backend sglang \
--model deepseek-ai/DeepSeek-R1-0528 \
--dataset-name random \
--random-input-len 8000 \
--random-output-len 1000 \
--num-prompts 80 \
--max-concurrency 16 \
--request-rate inf
============ Serving Benchmark Result ============
Backend: sglang
Traffic request rate: inf
Max request concurrency: 16
Successful requests: 80
Benchmark duration (s): 56.71
Total input tokens: 300020
Total input text tokens: 300020
Total input vision tokens: 0
Total generated tokens: 41589
Total generated tokens (retokenized): 41490
Request throughput (req/s): 1.41
Input token throughput (tok/s): 5290.75
Output token throughput (tok/s): 733.41
Peak output token throughput (tok/s): 1024.00
Peak concurrent requests: 20
Total token throughput (tok/s): 6024.16
Concurrency: 14.25
----------------End-to-End Latency----------------
Mean E2E Latency (ms): 10098.99
Median E2E Latency (ms): 10623.46
---------------Time to First Token----------------
Mean TTFT (ms): 486.80
Median TTFT (ms): 189.59
P99 TTFT (ms): 2138.73
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms): 19.06
Median TPOT (ms): 19.23
P99 TPOT (ms): 30.69
---------------Inter-Token Latency----------------
Mean ITL (ms): 18.53
Median ITL (ms): 15.63
P95 ITL (ms): 16.64
P99 ITL (ms): 109.71
Max ITL (ms): 1471.36
==================================================
- 높은 동시성
python -m sglang.bench_serving \
--backend sglang \
--model deepseek-ai/DeepSeek-R1-0528 \
--dataset-name random \
--random-input-len 8000 \
--random-output-len 1000 \
--num-prompts 320 \
--max-concurrency 64 \
--request-rate inf
============ Serving Benchmark Result ============
Backend: sglang
Traffic request rate: inf
Max request concurrency: 64
Successful requests: 320
Benchmark duration (s): 115.55
Total input tokens: 1273893
Total input text tokens: 1273893
Total input vision tokens: 0
Total generated tokens: 169680
Total generated tokens (retokenized): 169275
Request throughput (req/s): 2.77
Input token throughput (tok/s): 11024.93
Output token throughput (tok/s): 1468.50
Peak output token throughput (tok/s): 2254.00
Peak concurrent requests: 70
Total token throughput (tok/s): 12493.43
Concurrency: 59.45
----------------End-to-End Latency----------------
Mean E2E Latency (ms): 21465.98
Median E2E Latency (ms): 20686.26
---------------Time to First Token----------------
Mean TTFT (ms): 913.93
Median TTFT (ms): 224.92
P99 TTFT (ms): 6257.83
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms): 39.93
Median TPOT (ms): 40.99
P99 TPOT (ms): 60.91
---------------Inter-Token Latency----------------
Mean ITL (ms): 38.83
Median ITL (ms): 26.29
P95 ITL (ms): 113.81
P99 ITL (ms): 176.94
Max ITL (ms): 5521.53
==================================================
5.1.5 결과 이해하기
핵심 지표:
- 요청 처리량 (Request Throughput, req/s): 초당 처리되는 요청 수
- 출력 토큰 처리량 (Output Token Throughput, tok/s): 초당 생성되는 총 토큰 수
- 평균 TTFT (ms): Time to First Token - 응답성을 측정
- 평균 TPOT (ms): Time Per Output Token - 생성 속도를 측정
- 평균 ITL (ms): Inter-Token Latency - 스트리밍 일관성을 측정
이 설정들이 중요한 이유:
- 1K/1K (Chat): 가장 흔한 대화형 AI 워크로드를 나타내요. 대부분의 배포에서 최우선 시나리오예요.
- 1K/8K (Reasoning): 복잡한 추론, 코드 생성, 상세한 설명에 중요한 장문 생성 능력을 테스트해요.
- 8K/1K (Summarization): RAG 시스템, 문서 Q&A, 요약 작업에 필수적인 큰 컨텍스트 입력 성능을 평가해요.
- 가변 동시성 (Variable Concurrency): 파레토 프론티어를 포착해요 — 서로 다른 부하 수준에서 처리량과 지연 시간 간의 최적 트레이드오프. 낮은 동시성은 최상의 지연 시간을, 높은 동시성은 최대 처리량을 보여줘요.
결과 해석:
- 결과를 하드웨어에 대한 기준 수치와 비교하세요
- 같은 지연 시간에서 더 높은 처리량 = 더 나은 성능
- 더 낮은 TTFT = 더 반응성 좋은 사용자 경험
- 더 낮은 TPOT = 더 빠른 생성 속도
5.2 정확도 벤치마크
표준 벤치마크에서 모델 정확도를 문서화하세요:
5.2.1 GSM8K 벤치마크
- 벤치마크 명령
python3 benchmark/gsm8k/bench_sglang.py \
--num-shots 8 \
--num-questions 1316 \
--parallel 1316
테스트 결과:
Accuracy: 0.959
Invalid: 0.000
Latency: 29.185 s
Output throughput: 4854.672 token/s