로컬 GPU에서 모델을 서빙할 때는 모델이 단순히 로드되는 것뿐 아니라 요청이 정상적으로 처리되는지, 어느 정도의 메모리와 지연이 발생하는지 확인해야 한다. OpenCode와 연동하는 경우 모델 서버의 API 형식도 맞춰야 한다.
이 기록에서는 vLLM 구축 → OpenAI 호환 API → OpenCode 연동 → 성능 관측을 다룬다. 서로 다른 모델·버전에서 얻은 로그를 같은 조건의 성능 비교로 합치지 않고 읽는다.
1. GPU 서버와 기본 서빙 환경
Spec 확인
# nvidia-smi
GPU: NVIDIA RTX A6000
VRAM: 49140 MiB (약 48GB)
Driver: 580.173.02
CUDA 지원 버전: 13.0
GPU 사용률: 0%
GPU 메모리 사용량: 1 MiB
실행 중인 GPU 프로세스: 없음# free -h
전체 메모리: 31GiB
사용 중: 약 605MiB
사용 가능: 약 30GiB
Swap: 8GiB, 미사용# df -h /
전체: 491GB
사용: 15GB
여유: 451GB
사용률: 4%# lscpu
CPU: Intel Xeon Gold 5220R @ 2.20GHz
CPU 코어: 16
아키텍처: x86_64
가상화 환경: VMware# cat /etc/os-release
Ubuntu 22.04.3 LTS (Jammy)Docker Install
의존성과 배포 환경을 관리하기 위해 Docker를 선택했다. Python 직접 실행과 성능이 동일하다는 비교 측정은 남아 있지 않다.
새 Ubuntu 호스트에는 Docker 패키지를 설치하기 전에 공식 APT 저장소를 등록해야 한다. 다음은 root 권한에서 실행하는 구성 예다. 기존 Docker·containerd와 실행 중인 서비스가 있다면 패키지 충돌과 교체 영향을 먼저 확인한다.
apt update
apt install -y ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
cat >/etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
apt update
apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl is-active docker
docker version
docker compose version
docker run --rm hello-world당시 Docker 설치 명령 원본
apt update
apt install -y ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
-o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
apt update
apt install -y ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
-o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
apt update
apt install -y \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
systemctl is-active docker
docker version
docker compose version
docker run --rm hello-worldvLLM 설정
https://docs.vllm.ai/en/latest/getting_started/installation/gpu/
연결 확인
docker run --rm --gpus all \
nvidia/cuda:12.9.0-base-ubuntu22.04 \
nvidia-smi작업중 에러 (GPU 인식은 하고있으나, 실제 브릿지 링크에 대한 이슈가 있어보임)
https://knowledge.broadcom.com/external/article/418517/passthrough-nvidia-gpu-becomes-unrespons.html
해결 완료
디렉토리 생성
mkdir -p /srv/vllm/huggingface
mkdir -p /srv/vllm/cache
cd /srv/vllm초기 접근 시험은 인증을 구성하기 전 단계다. 아래의 외부 인터페이스 바인딩과 더미 키를 공용 운영 설정으로 재사용하지 않는다. 뒤의 Gateway 단계에서는 백엔드 인증키와 팀별 키를 분리한다.
컴포즈 작성
services:
gemma:
image: vllm/vllm-openai:v0.26.0
container_name: vllm-gemma4-31b
restart: "no"
gpus: all
ipc: host
ports:
- "0.0.0.0:8000:8000"
volumes:
- /srv/vllm/huggingface:/root/.cache/huggingface
- /srv/vllm/cache:/root/.cache/vllm
command:
- google/gemma-4-31B-it-qat-w4a16-ct
- --served-model-name
- gemma-4-31b
- --host
- 0.0.0.0
- --port
- "8000"
- --dtype
- auto
- --max-model-len
- "16384"
- --gpu-memory-utilization
- "0.90"
- --max-num-seqs
- "4"
- --enable-prefix-caching
# 모델이 지원하는 자동 tool choice·도구 출력 형식에 맞춘 설정
- --enable-auto-tool-choice
- --tool-call-parser
- gemma4
- --reasoning-parser
- gemma4
- --chat-template
- examples/tool_chat_template_gemma4.jinja실행
docker compose version
cd /srv/vllm
docker compose pull
docker compose up -d
docker compose logs -f --tail=100 gemmavllm-gemma4-31b | (APIServer pid=1) INFO: Started server process [1]
vllm-gemma4-31b | (APIServer pid=1) INFO: Waiting for application startup.
vllm-gemma4-31b | (APIServer pid=1) INFO: Application startup complete.curl -i http://127.0.0.1:8000/health
curl http://127.0.0.1:8000/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "gemma-4-31b",
"messages": [
{
"role": "system",
"content": "당신은 기업 문서를 정확하게 요약하는 도우미입니다."
},
{
"role": "user",
"content": "RAG 시스템에서 임베딩 모델과 reranker의 역할 차이를 세 문장으로 설명해줘."
}
],
"temperature": 0.2,
"max_tokens": 300
}'
docker compose downOPENCODE 연동
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"local": {
"npm": "@ai-sdk/openai-compatible",
"name": "Local vLLM",
"options": {
"baseURL": "http://192.0.2.11:8000/v1",
"apiKey": "dummy"
},
"models": {
"gemma-4-31b": {
"name": "Gemma 4 31B (Local)",
"limit": {
"context": 16384,
"output": 4096
}
}
}
}
}
}/models
테스트

vllm-gemma4-31b | (APIServer pid=1) INFO: 192.0.2.12:57664 - "POST /v1/chat/completions HTTP/1.1" 200 OK
vllm-gemma4-31b | (APIServer pid=1) INFO: 192.0.2.12:57674 - "POST /v1/chat/completions HTTP/1.1" 200 OK
vllm-gemma4-31b | (EngineCore pid=164) WARNING 08-06 08:31:37 [jit_monitor.py:135] Triton kernel JIT compilation during inference: kernel_unified_attention. This causes a latency spike; consider extending warmup to cover this shape/config.
vllm-gemma4-31b | (APIServer pid=1) INFO 08-06 08:31:43 [loggers.py:310] Engine 000: Avg prompt throughput: 56.0 tokens/s, Avg generation throughput: 0.3 tokens/s, Running: 2 reqs, Waiting: 0 reqs, GPU KV cache usage: 23.7%, Prefix cache hit rate: 0.0%GPU 상태


2. 컨텍스트 확장과 KV 캐시 용량

에이전트에서 사용시 Context 크기 에러 발생
기존 Context를 낮게 설정해서 발생한 문제로 vLLM 설정 변경 작업 필요
컴포즈 설정
services:
gemma:
image: vllm/vllm-openai:v0.26.0
container_name: vllm-gemma4-31b
restart: "no"
gpus: all
ipc: host
ports:
- "0.0.0.0:8000:8000"
volumes:
- /srv/vllm/huggingface:/root/.cache/huggingface
- /srv/vllm/cache:/root/.cache/vllm
command:
- google/gemma-4-31B-it-qat-w4a16-ct
- --served-model-name
- gemma-4-31b
- --host
- 0.0.0.0
- --port
- "8000"
- --dtype
- auto
- --max-model-len
- "32768"
- --gpu-memory-utilization
- "0.90"
- --max-num-seqs
- "6"
- --enable-prefix-caching
- --enable-auto-tool-choice
- --tool-call-parser
- gemma4
- --reasoning-parser
- gemma4
- --chat-template
- examples/tool_chat_template_gemma4.jinja
root@bastion:/srv/vllm# docker logs vllm-gemma4-31b 2>&1 | \
grep -Ei 'KV cache|Maximum concurrency|cache size'
root@bastion:/srv/vllm# docker logs vllm-gemma4-31b 2>&1 | grep -Ei 'KV cache|Maximum concurrency|cache size'
(EngineCore pid=164) INFO 08-10 08:33:34 [gpu_worker.py:560] Available KV cache memory: 22.28 GiB
(EngineCore pid=164) INFO 08-10 08:33:34 [kv_cache_utils.py:2177] GPU KV cache size: 102,775 tokens
(EngineCore pid=164) INFO 08-10 08:33:34 [kv_cache_utils.py:2178] Maximum concurrency for 32,768 tokens per request: 3.14x
(EngineCore pid=164) INFO 08-10 08:33:42 [gpu_worker.py:857] Free memory on device (47.14/47.4 GiB) on startup. Desired GPU memory utilization is (0.9, 42.66 GiB). Actual usage is 19.78 GiB for weight, 0.52 GiB for peak activation, 0.08 GiB for non-torch memory, and 0.1 GiB for CUDAGraph memory. Replace gpu_memory_utilization config with `--kv-cache-memory=23654344807` (22.03 GiB) to fit into requested memory, or `--kv-cache-memory=28459713024` (26.51 GiB) to fully utilize gpu memory. Current kv cache memory in use is 22.28 GiB.
(EngineCore pid=164) INFO 08-10 08:33:54 [core.py:340] init engine (profile, create kv cache, warmup model) took 99.78 s (compilation: 75.12 s)
root@bastion:/srv/vllm#메모리 사용량 이유 찾기
A6000 약 47.4 GiB
Gemma weights 19.78 GiB
Peak activation 0.52 GiB
Non-torch 0.08 GiB
CUDA Graph 0.10 GiB
KV Cache 22.28 GiB
기타/여유
─────────────────────────
gpu-util 목표 42.66 GiBAvailable KV cache memory: 22.28 GiB
GPU KV cache size: 102,775 tokens
Maximum concurrency for 32,768 tokens per request: 3.14x당시 로그의 KV 캐시 용량은 102,775토큰이며, 요청당 32,768토큰 기준 Maximum concurrency는 3.14x였다. 아래 표는 캐시 용량만 단순 계산한 결과이며 실제 동시 사용자 수나 응답 지연을 보장하지 않는다.
| 동시에 실행 | 1명당 평균 컨텍스트 | 총 KV 토큰 | KV 용량만 비교한 결과 |
|---|---|---|---|
| 1명 | 32K | 32,768 | 여유 |
| 2명 | 32K | 65,536 | 여유 |
| 3명 | 32K | 98,304 | 가능 |
| 4명 | 32K | 131,072 | 부족 |
| 6명 | 16K | 98,304 | 가능 |
| 6명 | 17K | 102,000 | 거의 한계 |
| 6명 | 20K | 120,000 | 부족 |
| 6명 | 32K | 196,608 | 많이 부족 |
| max-num-seqs=6은 동시 스케줄링 시퀀스의 상한이며 각 요청에 32K 캐시를 미리 예약한다는 뜻은 아니다. |
--max-model-len 32768
↓
"한 요청이 최대 32K까지 갈 수 있음"
--max-num-seqs 6
↓
"최대 6개의 sequence를 동시에 처리할 수 있음"
KV capacity = 102,775
↓
"그 6개의 실제 KV 사용량 합계가 이 안에 들어와야 함"| 컨텍스트 | KV 메모리 |
|---|---|
| 8K | ~1.78 GiB |
| 16K | ~3.55 GiB |
| 32K | ~7.10 GiB |
| 32K × 2명 | ~14.2 GiB |
| 32K × 3명 | ~21.3 GiB |
| 32K × 6명 | ~42.6 GiB |
| 3.14x는 해당 요청 길이를 기준으로 한 캐시 용량 비율이다. 최대 입력·출력 길이와 대기 시간·preemption·OOM을 포함한 부하 시험이 필요하다. |
배치 처리와 관련 옵션
배치는 여러 사용자 요청을 GPU가 묶어서 계산하는 방식이다. vLLM의 관련 옵션은 의미가 비슷해 보여도 역할이 다르므로 구분해 확인한다.
max-num-seqs = 6
이 값은 동시에 스케줄링할 수 있는 시퀀스 수의 상한이다. 실제 동시 실행과 메모리 사용량은 요청 길이·KV 캐시·배치 상태에 영향을 받는다.
예를 들어 생성 중인 요청 여섯 개가 함께 스케줄링된다면 다음처럼 생각할 수 있다:
A ─ "쿠버네티스 분석해줘"
B ─ "로그 분석해줘"
C ─ "코드 작성해줘"
D ─ "번역해줘"
E ─ "설명해줘"
F ─ "에러 원인 알려줘"
↓
vLLM Scheduler
↓
┌─────────────────────────┐
│ A B C D E F 를 묶어서 │
│ GPU에서 batch로 계산 │
└─────────────────────────┘continuous batching에서는 실행 중인 여러 요청의 토큰 계산을 함께 스케줄링할 수 있다. 한 요청을 완전히 끝낸 뒤 다음 요청을 처리하는 순차 방식과 구분한다.
max_num_batched_tokens = 2496
이 값은 요청 수가 아니라 scheduler iteration에서 처리할 토큰 작업량을 제한한다. 당시 로그에서 적용값을 확인할 수 있다:
max_num_seqs = 6
max_num_batched_tokens = 2496이 값을 단순화한 예시는 다음과 같다:
동시에 최대 6 sequence
그리고 한 번의 scheduler step에
최대 2496 token 규모의 작업을 배치이 차이는 prefill과 decode를 나누어 보면 이해하기 쉽다.
Prefill vs Decode
12,000토큰 입력을 받은 모델은 답변 생성 전에 입력을 처리해야 한다.
12,000 token 입력
↓
PREFILL
↓
"알겠습니다."
↓
토큰 하나씩 생성
↓
DECODEPrefill은 입력을 처리하고 KV cache를 구성하는 단계이고, decode는 후속 토큰을 생성하는 단계다. 긴 prefill이 다른 요청의 생성과 GPU 자원을 공유하면 지연에 영향을 줄 수 있다.
사용자 A
12K짜리 긴 prompt
████████████████████████
사용자 B
답변 생성 중 → 기다림
사용자 C
답변 생성 중 → 기다림아래는 긴 입력 처리와 다른 요청의 토큰 생성이 자원을 공유하는 상황이다. 당시 로그에는 다음 설정이 표시됐다:
Chunked prefill is enabled
max_num_batched_tokens=2496이를 이용하면 긴 입력을 다음처럼 나눠 처리할 수 있다:
12K prompt
2496
2496
2496
2496
2016chunk 사이에 다른 요청의 decode를 함께 배치할 수 있다.
A prefill 2496
B decode
C decode
D decode
A prefill 2496
B decode
C decode
A prefill 2496
...이 도식은 개념을 단순화한 예이며 실제 chunk 크기와 순서는 남은 토큰 예산과 실행 상태에 따라 달라진다.
세 설정의 역할을 함께 정리하면 다음과 같다:
max-num-seqs = 6
│
└─ 동시에 최대 6 sequence를 스케줄링
max-num-batched-tokens = 2496
│
└─ 한 iteration의 token budget
chunked-prefill = true
│
└─ 긴 입력을 budget에 맞춰 쪼개서 처리이때 2496을 8192로 늘리는 것만으로 모든 요청이 빨라지지는 않는다.
큰 batch-token budget은 긴 입력 처리에 유리할 수 있지만 다른 요청의 토큰 간 지연과 상충할 수 있다. 반대로 너무 작으면 긴 입력의 처리 시간이 늘어날 수 있어 같은 부하 조건으로 비교해야 한다.
당시 초기값은 로그에 나온 2496과 chunked prefill이었다. 실제 동시 요청에서 첫 토큰 지연·토큰 간 지연·처리량을 비교해 유지 여부를 결정한다. vLLM 설정 가이드는 설치 버전과 대조할 참고 자료다.
로그의 Avg prompt throughput 235 tok/s와 Avg generation throughput 25 tok/s는 각각 입력 처리와 출력 생성의 처리량이다. 전체 집계인지 개별 요청인지, 측정 구간과 동시성을 확인한 뒤 비교한다.
3. thinking·effort 프로필과 Gateway
이 구성에서는 모델의 thinking 출력과 Gateway가 해석하는 effort 값을 구분했다. high 프로필은 자체 훅에서 관리 프롬프트를 추가한 실험이며 모델 고유의 추론 강도 제어가 검증된 것은 아니다. 정확한 모델 ID·revision·chat template·parser·Gateway 버전을 기준으로 지원 여부를 확인한다.
LiteLLM Proxy를 호환 API 경유지로 사용했다. 라이선스·요금은 배포 버전과 기능별로 확인하며 SSO 사용 여부만으로 판단하지 않는다. API 형식이 호환돼도 모든 경로·인자·응답 필드가 같지는 않다.
프론티어 모델이 제공해주는 방식 (ex GPT)
https://developers.openai.com/api/docs/guides/text
목표는 클라이언트가 사용할 API 경로와 자체 thinking·effort 프로필을 Gateway에서 일관되게 제공하는 것이었다.
4. Gateway 구성과 클라이언트 연결
서버 설정
# /etc/hosts
192.0.2.13 nexus.example.com# /etc/docker/daemon.json
{
"runtimes": {
"nvidia": {
"args": [],
"path": "nvidia-container-runtime"
}
},
"insecure-registries": [
"nexus.example.com:55000"
]
}키 생성
openssl rand -hex 32
VLLM_API_KEY=EXAMPLE_LOCAL_API_KEY
LITELLM_MASTER_KEY={}
# 예시
#VLLM_API_KEY=EXAMPLE_LOCAL_API_KEY
#LITELLM_MASTER_KEY=test-gateway-난수VLLM_API_KEY
- vLLM에 인증키이자 LLM Gateway가 vLLM에게 연결할 API 키
- 직접 접근 시에는 해당키로 접근해야 된다 ( 서버의 경우 포트 8000)
LITELLLM_MASTER_KEY
- Proxy 관리와 초기 연결 시험에 사용한 master key로, 일반 사용자에게 배포하는 키와 구분한다.
- 초기 단계에서는 사용자별 제한을 구성하지 않았다. 뒤의 UI·DB 단계에서 팀별 virtual key 생성·폐기 시험을 진행했다. LiteLLM virtual key 문서
vLLM 수정
compose.yaml
services:
gemma:
image: vllm/vllm-openai:v0.26.0
container_name: vllm-gemma4-31b
restart: "no"
gpus: all
ipc: host
environment:
VLLM_API_KEY: ${VLLM_API_KEY:?set VLLM_API_KEY}
ports:
- "0.0.0.0:8000:8000"
volumes:
- /srv/vllm/huggingface:/root/.cache/huggingface
- /srv/vllm/cache:/root/.cache/vllm
command:
- google/gemma-4-31B-it-qat-w4a16-ct
- --served-model-name
- gemma-4-31b
- --host
- 0.0.0.0
- --port
- "8000"
- --dtype
- auto
- --max-model-len
- "32768"
- --gpu-memory-utilization
- "0.90"
- --max-num-seqs
- "6"
- --enable-prefix-caching
- --enable-auto-tool-choice
- --tool-call-parser
- gemma4
- --reasoning-parser
- gemma4
- --chat-template
- examples/tool_chat_template_gemma4.jinja
- --default-chat-template-kwargs
- '{"enable_thinking":true}'.env
VLLM_API_KEY={직접 생성}실행
chmod 600 .env
docker compose config --quiet
docker compose pull
docker compose up -d
docker compose psLLM Gateway
compose.yaml
services:
llm-gateway:
image: ${GATEWAY_IMAGE:-nexus.example.com:55000/platform/platform-common/llm-gateway:latest}
restart: unless-stopped
environment:
VLLM_API_BASE: http://gemma:8000/v1
VLLM_API_KEY: ${VLLM_API_KEY:-not-required}
LITELLM_MASTER_KEY: ${LITELLM_MASTER_KEY:?set LITELLM_MASTER_KEY}
GATEWAY_MAX_PARALLEL_REQUESTS: ${GATEWAY_MAX_PARALLEL_REQUESTS:-6}
ports:
- "${GATEWAY_PORT:-4000}:4000"
networks:
- vllm_default
read_only: true
tmpfs:
- /tmp:size=64m,uid=65534,gid=65534,mode=1777
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
stop_grace_period: 30s
networks:
vllm_default:
external: true.env
VLLM_API_BASE=http://gemma:8000/v1
VLLM_API_KEY=EXAMPLE_LOCAL_API_KEY
LITELLM_MASTER_KEY={}
LITELLM_PORT=4000
GATEWAY_MAX_PARALLEL_REQUESTS=6
# HIGH_REASONING_PROMPT=Optional override; keep this value out of logs.- gemma:8000 인 이유는 vLLM의 서비스 이름을 Gemma로 올렸기 때문이다.
실행
chmod 600 .env
docker compose config --quiet
docker compose pull
docker compose up -d
docker compose psOpenCode
{
"$schema": "https://opencode.ai/config.json",
"model": "platform-local/gemma-4-31b",
"provider": {
"platform-local": {
"npm": "@ai-sdk/openai-compatible",
"name": "Team Local (A6000)",
"options": {
"baseURL": "http://192.0.2.11:4000/v1",
"apiKey": "{env:GEMMA_GATEWAY_API_KEY}"
},
"models": {
"gemma-4-31b": {
"name": "Gemma 4 31B",
"limit": {
"context": 32768,
"output": 8192
},
"variants": {
"off": {
"reasoningEffort": "none"
},
"medium": {
"reasoningEffort": "medium"
},
"high": {
"reasoningEffort": "high"
}
}
}
}
}
}
}- "baseURL": "http://GATEWAY_HOST:GATEWAY_PORT/v1"
- LLM Gateway IP : LLM Gateway 포트
- "apiKey": "{env:GEMMA_GATEWAY_API_KEY}"
- 초기 시험에는 LITELLM_MASTER_KEY를 사용했다. 뒤에서 구성한 사용자·팀별 virtual key도 해당 권한 범위에서 사용할 수 있으므로 master key가 필수인 것은 아니다.
클라이언트의 effort 선택과 모델의 thinking 응답을 확인했다. 프로필 전달과 품질 개선은 별도 검증 대상이다.
캡처의 설정·출력 기록 · 식별정보 제외
클라이언트 프로필: Gemma 4 31B / high
질문: 너 하이야?
응답: 아니요, 저는 gemma-4-31b입니다.
질문: 너의 추론 능력이 궁금한걸?
응답: 복잡한 문제 분석, 코드 작성 및 수정, 논리적 추론 등이 가능합니다. 테스트해 보세요.
이 대화 화면만으로 모델의 실제 추론 능력이나 high 프로필 효과를 평가하지 않는다.API 경로
| 구분 | Chat Completions | Responses |
|---|---|---|
| Endpoint | /v1/chat/completions | /v1/responses |
| SDK | chat.completions.create() | responses.create() |
| 입력 | messages | input, instructions |
| 추론 설정 | reasoning_effort | reasoning: { effort } |
| https://developers.openai.com/api/docs/guides/latest-model |
https://developers.openai.com/api/reference/resources/chat
구현·시험한 연동 경로는 Chat Completions다. 표의 Responses 항목은 API 비교를 위한 참고 항목이다.
추후 계획
사용자별 API, API 발급 및 관리용 간단한 페이지
인증·인가와 effort 프로필 검증
보안 적용 등등
5. 팀별 API 키 관리
포트번호로 접근, 관리가 불편한 부분이 있어서 추가
docker compose로 Postgres, nginx를 배포했다.
- Postgres는 Lite LLM이 사용하는 DB
- nginx는 Lite LLM 에 접근하기 위한 Proxy
캡처의 설정·출력 기록 · 식별정보 제외
LiteLLM API 문서 화면
표시 버전: 1.93.0
OpenAPI: OAS 3.1
API 문서·관리 UI·모델 목록 링크와 Authorize 버튼 확인
접속 주소: http://llm.example.com/캡처의 설정·출력 기록 · 식별정보 제외
LiteLLM 관리 UI / Virtual Keys
Create New Key 버튼과 키 목록 확인
Key ID / Key Alias / Token / Secret Key / Team / User / Created / Expires / Spend 항목
당시 목록: No keys found초기 연동 시험은 HTTP로 진행했다. 사설 인증서의 클라이언트 신뢰 설정과 DNS-01 발급을 이용한 HTTPS 전환은 후속 구성으로 남았다.
팀 생성
캡처의 설정·출력 기록 · 식별정보 제외
LiteLLM 관리 UI / Teams
팀 목록 1개와 Create Team 버튼 확인
팀 식별자와 계정 정보는 이 예시에서 표시하지 않음키 생성
캡처의 설정·출력 기록 · 식별정보 제외
LiteLLM / Create New Key
Key Ownership: You / Service Account / Another User / Agent
Team 선택
Key Name 입력
Models 선택
Key Type: All APIs
Create Key 버튼- Gateway 관리 키로도 요청할 수 있지만, 사용자·서비스별 키를 분리하면 권한과 감사 이력을 관리하기 쉽다.
- 하지만 root key를 주기보다는 팀에게 키를 할당해주는 방식으로 하기위해 키 생성후 접근 테스트를 진행
키 테스트
캡처의 설정·출력 기록 · 식별정보 제외
Authentication Error, Invalid proxy server token passed.
Unable to find token in cache or LiteLLM_VerificationTokenTable.
삭제한 키를 다시 사용한 시험에서 인증 오류를 확인했다.
해당 인증 오류는 삭제된 키로 다시 요청했을 때 나타난 결과다.- 키 삭제 전에는 해당 키로 요청이 처리됐고, 삭제 후 같은 키로 요청하자 인증 오류가 발생했다. 이를 통해 키 폐기 상태가 요청 검증에 반영되는지 확인했다.
고추론 프로필 요청 검증
Gateway의 고추론 프로필에 지정한 지시문이 모델 요청에 반영되는지 확인한다.
curl -i http://192.0.2.11/v1/chat/completions \
-H "Authorization: Bearer REDACTED_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"model": "gemma-4-31b",
"messages": [
{"role": "user", "content": "17과 19의 곱을 계산하고 검산해줘."}
],
"reasoning_effort": "high",
"max_tokens": 512,
"stream": false
}'
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 11 Aug 2026 18:21:46 GMT
Content-Type: application/json
Content-Length: 2604
Connection: keep-alive
x-litellm-call-id: 6ce34284-7dc9-45f2-9022-b975f5f941ec
x-litellm-model-id: 45866ccba3549c03457cbdf0a13104119b7b559a574eeca528049900441e4d43
x-litellm-model-api-base: http://gemma:8000/v1
x-litellm-version: 1.93.0
x-litellm-key-spend: 0.0
x-litellm-response-duration-ms: 16044.646
x-litellm-overhead-duration-ms: 2.946
x-litellm-callback-duration-ms: 0.0
llm_provider-date: Tue, 11 Aug 2026 18:21:29 GMT
llm_provider-server: uvicorn
llm_provider-content-length: 1877
llm_provider-content-type: application/json
x-litellm-model-group: gemma-4-31b
x-litellm-attempted-retries: 0
x-litellm-attempted-fallbacks: 0
x-gateway-high-profile: applied
x-frame-options: DENY
content-security-policy: frame-ancestors 'none'
x-content-type-options: nosniff
{"id":"chatcmpl-9e28bcd9dc2c1b6b","created":1786472489,"model":"gemma-4-31b","object":"chat.completion","system_fingerprint":"vllm-0.26.0-2c7836d2","choices":[{"finish_reason":"length","index":0,"message":{"content":"**계산:**\n17 × 19 = **323**\n\n**검산 (두 가지 방법):**\n\n1. **분배법칙 이용:**\n 17 × (20 - 1) = (17 × 20) - (17 × 1)\n = 340 - 17\n = **323**\n\n2. **합차 공식 이용 (18을 기준으로):**\n (18 - 1) × (18 + 1) = 18² - 1²\n = 324 - 1\n = **323**\n\n따라서 계산 결과는 **323**","role":"assistant","reasoning_content":"* Task: Calculate the product of 17 and 19.\n * Requirement: Perform the calculation and verify it (검산).\n * Language: Korean.\n\n * Calculation: $17 \\times 19$\n * Method 1 (Standard Multiplication):\n $17 \\times 10 = 170$\n $17 \\times 9 = 153$\n $170 + 153 = 323$\n * Method 2 (Algebraic Trick - Difference of Squares):\n $(18 - 1) \\times (18 + 1) = 18^2 - 1^2$\n $18^2 = 324$\n $324 - 1 = 323$\n\n * Step 1: $17 \\times 19 = 323$.\n * Step 2: Verification (검산).\n * Check 1: $323 \\div 17 = 19$.\n * Check 2: $323 \\div 19 = 17$.\n * Alternative verification: Use the difference of squares method shown above.\n\n * Calculation process: 17 x 19 = 323.\n * Verification:\n * $17 \\times 20 = 340$.\n * $340 - 17 = 323$.\n * Conclusion: Correct.","provider_specific_fields":{"refusal":null,"reasoning":"* Task: Calculate the product of 17 and 19.\n * Requirement: Perform the calculation and verify it (검산).\n * Language: Korean.\n\n * Calculation: $17 \\times 19$\n * Method 1 (Standard Multiplication):\n $17 \\times 10 = 170$\n $17 \\times 9 = 153$\n $170 + 153 = 323$\n * Method 2 (Algebraic Trick - Difference of Squares):\n $(18 - 1) \\times (18 + 1) = 18^2 - 1^2$\n $18^2 = 324$\n $324 - 1 = 323$\n\n * Step 1: $17 \\times 19 = 323$.\n * Step 2: Verification (검산).\n * Check 1: $323 \\div 17 = 19$.\n * Check 2: $323 \\div 19 = 17$.\n * Alternative verification: Use the difference of squares method shown above.\n\n * Calculation process: 17 x 19 = 323.\n * Verification:\n * $17 \\times 20 = 340$.\n * $340 - 17 = 323$.\n * Conclusion: Correct."}},"provider_specific_fields":{"routed_experts":null,"token_ids":null,"stop_reason":null}}],"usage":{"completion_tokens":512,"prompt_tokens":196,"total_tokens":708}}응답에는 high 프로필 적용을 나타내는 자체 헤더가 있었다.
x-gateway-high-profile: applied이 헤더에는 Gateway가 보고한 처리 상태가 나타난다. 프롬프트의 실제 반영 여부는 같은 요청의 훅 코드·전송 payload·로그에 연결되는 정보다.
실제 처리 구조는 다음과 같습니다.
사용자 메시지
↓
Gateway가 high 확인
↓
high 관리 system prompt 앞에 추가
↓
Gemma thinking 활성화
↓
vLLM으로 전달응답의 reasoning_content는 parser가 추론 출력을 별도 필드로 반환한 결과다. finish_reason=length는 토큰 한도에 도달했음을 보여 준다. effort별 품질 차이는 이 응답과 별개의 평가 항목이다.
medium으로 요청하면 thinking은 켜지지만 x-gateway-high-profile 헤더와 추가 관리 프롬프트는 없어야 정상입니다.
medium
curl -i http://192.0.2.11/v1/chat/completions \
-H "Authorization: Bearer REDACTED_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"model": "gemma-4-31b",
"messages": [
{"role": "user", "content": "17과 19의 곱을 계산하고 검산해줘."}
],
"reasoning_effort": "medium",
"max_tokens": 512,
"stream": false
}'
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 11 Aug 2026 18:25:08 GMT
Content-Type: application/json
Content-Length: 2774
Connection: keep-alive
x-litellm-call-id: cafe8979-d63e-48d4-b9fb-d78d2988da9d
x-litellm-model-id: 45866ccba3549c03457cbdf0a13104119b7b559a574eeca528049900441e4d43
x-litellm-model-api-base: http://gemma:8000/v1
x-litellm-version: 1.93.0
x-litellm-response-cost-original: 0.0
x-litellm-response-cost-discount-amount: 0.0
x-litellm-response-cost-margin-amount: 0.0
x-litellm-response-cost-margin-percent: 0.0
x-litellm-key-spend: 0.0
x-litellm-response-duration-ms: 15937.909
x-litellm-overhead-duration-ms: 2.544
x-litellm-callback-duration-ms: 0.0
llm_provider-date: Tue, 11 Aug 2026 18:24:51 GMT
llm_provider-server: uvicorn
llm_provider-content-length: 1810
llm_provider-content-type: application/json
x-litellm-model-group: gemma-4-31b
x-litellm-attempted-retries: 0
x-litellm-attempted-fallbacks: 0
x-frame-options: DENY
content-security-policy: frame-ancestors 'none'
x-content-type-options: nosniff
{"id":"chatcmpl-bab01f5cbebe4004","created":1786472692,"model":"gemma-4-31b","object":"chat.completion","system_fingerprint":"vllm-0.26.0-2c7836d2","choices":[{"finish_reason":"length","index":0,"message":{"content":"**계산:**\n17 × 19를","role":"assistant","reasoning_content":"* Task: Calculate $17 \\times 19$.\n * Requirement: Show the calculation and verify (검산).\n\n * Method 1: Standard Multiplication\n * $17 \\times 10 = 170$\n * $17 \\times 9 = 153$\n * $170 + 153 = 323$\n * Method 2: Using $(a-b)(a+b)$ or $(x-1)(x+1)$ pattern\n * $17 \\times 19 = (18 - 1) \\times (18 + 1)$\n * $= 18^2 - 1^2$\n * $= 324 - 1 = 323$\n\n * *Calculation process:*\n $17 \\times 19$\n $= 17 \\times (20 - 1)$\n $= 340 - 17$\n $= 323$\n\n * *Verification (검산) method 1 (Reverse multiplication):*\n $323 \\div 17 = ?$\n $17 \\times 10 = 170$\n $323 - 170 = 153$\n $17 \\times 9 = 153$\n $10 + 9 = 19$ (Correct)\n\n * *Verification (검산) method 2 (Using different regrouping):*\n $19 \\times 17$\n $19 \\times 10 = 190$\n $19 \\times 7 = 133$\n $190 + 133 = 323$ (Correct)\n\n * Direct Answer: 323.\n * Steps:\n 1. $17 \\times 19 = 17 \\times (20 - 1) = 340 - 17 = 323$.\n 2. Verification: $323 \\div 17 = 19$.","provider_specific_fields":{"refusal":null,"reasoning":"* Task: Calculate $17 \\times 19$.\n * Requirement: Show the calculation and verify (검산).\n\n * Method 1: Standard Multiplication\n * $17 \\times 10 = 170$\n * $17 \\times 9 = 153$\n * $170 + 153 = 323$\n * Method 2: Using $(a-b)(a+b)$ or $(x-1)(x+1)$ pattern\n * $17 \\times 19 = (18 - 1) \\times (18 + 1)$\n * $= 18^2 - 1^2$\n * $= 324 - 1 = 323$\n\n * *Calculation process:*\n $17 \\times 19$\n $= 17 \\times (20 - 1)$\n $= 340 - 17$\n $= 323$\n\n * *Verification (검산) method 1 (Reverse multiplication):*\n $323 \\div 17 = ?$\n $17 \\times 10 = 170$\n $323 - 170 = 153$\n $17 \\times 9 = 153$\n $10 + 9 = 19$ (Correct)\n\n * *Verification (검산) method 2 (Using different regrouping):*\n $19 \\times 17$\n $19 \\times 10 = 190$\n $19 \\times 7 = 133$\n $190 + 133 = 323$ (Correct)\n\n * Direct Answer: 323.\n * Steps:\n 1. $17 \\times 19 = 17 \\times (20 - 1) = 340 - 17 = 323$.\n 2. Verification: $323 \\div 17 = 19$."}},"provider_specific_fields":{"routed_experts":null,"token_ids":null,"stop_reason":null}}],"usage":{"completion_tokens":512,"prompt_tokens":32,"total_tokens":544}}- **x-gateway-high-profile: applied **이 안보인다.
6. 평가 도구 연동과 응답 추출 문제
출력 토큰 속도 46~55 tok/s (테스트 중 log로 확인)
mkdir -p /srv/llm-benchmark/results
cd /srv/llm-benchmark# Dockerfile
FROM python:3.12-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir "lm-eval[api]"
WORKDIR /benchmark
ENTRYPOINT ["lm-eval"]#.env
OPENAI_API_KEY=EXAMPLE_LOCAL_API_KEYdocker run --rm \
--network vllm_default \
--env-file /srv/llm-benchmark/.env \
-v /srv/llm-benchmark/results:/results \
nexus.example.com:55000/platform/platform-common/llm-benchmark:latest \
--model local-chat-completions \
--model_args "model=gemma-4-31b,base_url=http://vllm-gemma4-31b:8000/v1/chat/completions,num_concurrent=1,max_retries=3" \
--tasks gsm8k \
--limit 10 \
--apply_chat_template \
--log_samples \
--output_path /results/default
# --output_path /results/fp8-e4m3
# --output_path /results/default-high- vllm이 도커네트워크라 model_args랑 network쪽은 수정
문제 발생 현재 방식은 로컬로 돌릴 경우 전체 벤치가 아닌 컨텍스트 양자화에 대한 벤치를 중심으로 돌렸고
리즈닝 기능이 true일경우 정확도가 떨어지는 이슈 발생 (정확히는 판단 불가 판정)
결과물에 exact가 0.1로 10문제중 1문제 맞춘것으로 판단되는 이슈
litellm일 경우 글만 왔다갔다 하니까 이걸로 테스트 진행 해볼 생각
root@bastion:/srv/llm-benchmark# vi Dockerfile
root@bastion:/srv/llm-benchmark# docker inspect llm-gateway-llm-gateway-1 \
--format '{{range $k,$v := .NetworkSettings.Networks}}{{$k}}{{"\n"}}{{end}}'
llm-gateway_gateway_database
llm-gateway_gateway_frontend
vllm_default
# 도커파일 수정해도 여전히 빈 문자열이 들어온다..
root@bastion:/srv/llm-benchmark/results/default/gemma-4-31b# head -1 samples_gsm8k_2026-08-16T14-24-23.985820.jsonl | python3 -m json.tool
{
"doc_id": 0,
"doc": {
"question": "Janet\u2019s ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?",
"answer": "Janet sells 16 - 3 - 4 = <<16-3-4=9>>9 duck eggs a day.\nShe makes 9 * 2 = $<<9*2=18>>18 every day at the farmer\u2019s market.\n#### 18"
},
"target": "Janet sells 16 - 3 - 4 = <<16-3-4=9>>9 duck eggs a day.\nShe makes 9 * 2 = $<<9*2=18>>18 every day at the farmer\u2019s market.\n#### 18",
"arguments": {
"gen_args_0": {
"arg_0": [
"[{\"role\": \"user\", \"content\": \"Question: Jen and Tyler are gymnasts practicing flips. Jen is practicing the triple-flip while Tyler is practicing the double-flip. Jen did sixteen triple-flips during practice. Tyler flipped in the air half the number of times Jen did. How many double-flips did Tyler do?\\nAnswer:\"}, {\"role\": \"assistant\", \"content\": \"Jen did 16 triple-flips, so she did 16 * 3 = <<16*3=48>>48 flips.\\nTyler did half the number of flips, so he did 48 / 2 = <<48/2=24>>24 flips.\\nA double flip has two flips, so Tyler did 24 / 2 = <<24/2=12>>12 double-flips.\\n#### 12\"}, {\"role\": \"user\", \"content\": \"Question: Four people in a law firm are planning a party. Mary will buy a platter of pasta for $20 and a loaf of bread for $2. Elle and Andrea will split the cost for buying 4 cans of soda which cost $1.50 each, and chicken wings for $10. Joe will buy a cake that costs $5. How much more will Mary spend than the rest of the firm put together?\\nAnswer:\"}, {\"role\": \"assistant\", \"content\": \"Mary will spend $20 + $2 = $<<20+2=22>>22.\\nElle and Andrea will spend $1.5 x 4 = $<<1.5*4=6>>6 for the soda.\\nElle and Andrea will spend $6 + $10 = $<<6+10=16>>16 for the soda and chicken wings.\\nElle, Andrea, and Joe together will spend $16 + $5 = $<<16+5=21>>21.\\nSo, Mary will spend $22 - $21 = $<<22-21=1>>1 more than all of them combined.\\n#### 1\"}, {\"role\": \"user\", \"content\": \"Question: A charcoal grill burns fifteen coals to ash every twenty minutes of grilling. The grill ran for long enough to burn three bags of coals. Each bag of coal contains 60 coals. How long did the grill run?\\nAnswer:\"}, {\"role\": \"assistant\", \"content\": \"The grill burned 3 * 60 = <<3*60=180>>180 coals.\\nIt takes 20 minutes to burn 15 coals, so the grill ran for 180 / 15 * 20 = <<180/15*20=240>>240 minutes.\\n#### 240\"}, {\"role\": \"user\", \"content\": \"Question: A bear is preparing to hibernate for the winter and needs to gain 1000 pounds. At the end of summer, the bear feasts on berries and small woodland animals. During autumn, it devours acorns and salmon. It gained a fifth of the weight it needed from berries during summer, and during autumn, it gained twice that amount from acorns. Salmon made up half of the remaining weight it had needed to gain. How many pounds did it gain eating small animals?\\nAnswer:\"}, {\"role\": \"assistant\", \"content\": \"The bear gained 1 / 5 * 1000 = <<1/5*1000=200>>200 pounds from berries.\\nIt gained 2 * 200 = <<2*200=400>>400 pounds from acorns.\\nIt still needed 1000 - 200 - 400 = <<1000-200-400=400>>400 pounds.\\nThus, it gained 400 / 2 = <<400/2=200>>200 pounds from salmon.\\nTherefore, the bear gained 400 - 200 = <<400-200=200>>200 pounds from small animals.\\n#### 200\"}, {\"role\": \"user\", \"content\": \"Question: Brendan can cut 8 yards of grass per day, he bought a lawnmower and it helped him to cut more yards by Fifty percent per day. How many yards will Brendan be able to cut after a week?\\nAnswer:\"}, {\"role\": \"assistant\", \"content\": \"The additional yard Brendan can cut after buying the lawnmower is 8 x 0.50 = <<8*0.50=4>>4 yards.\\nSo, the total yards he can cut with the lawnmower is 8 + 4 = <<8+4=12>>12.\\nTherefore, the total number of yards he can cut in a week is 12 x 7 = <<12*7=84>>84 yards.\\n#### 84\"}, {\"role\": \"user\", \"content\": \"Question: Janet\u2019s ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?\\nAnswer:\"}]"
],
"arg_1": {
"until": [
"Question:",
"</s>",
"<|im_end|>"
],
"do_sample": false,
"temperature": 0.0
}
}
},
"resps": [
[
""
]
],
"filtered_resps": [
"[invalid]"
],
"filter": "strict-match",
"metrics": [
"exact_match"
],
"doc_hash": "986c19252f3c7f6eaeff2229e9a5777f96a85c0ceea931a92d2289084dfd518c",
"prompt_hash": "186f661ab969ce14d829576c94407a0f0258694b14e04e152cb94bce7fa1e6b1",
"target_hash": "623a0fbdf774fcb55e485a3e6b012e6c3965616af5b8eb9b9aebd2f6712be2eb",
"exact_match": 0.0
}
root@bastion:/srv/llm-benchmark/results/default/gemma-4-31b#
Requesting API: 0%| | 0/10 [00:00<?, ?it/s]2026-08-16:14:30:57 WARNING [models.api_models:378] Cannot determine EOS string to pass to stop sequence. Manually set by passing `eos_string` to model_args.
2026-08-16:14:31:06 WARNING [models.api_models:789] API returned null content. Content filled with `LMEVAL_MODEL_NONE_ANSWER_PLACEHOLDER = `. Check reasoning_content field or generation limits.
Requesting API: 20%|██ | 2/10 [00:15<00:59, 7.44s/it]NULL을 받는 중 ..
평가 실패를 조사하며 lm-evaluation-harness 이슈 #3355를 참고했다. 이 사례의 null 응답 원인을 좁히는 데 필요한 자료는 같은 샘플의 요청 한도·finish_reason·응답 필드와 정답 추출 로그다.
docker run --rm \
--network vllm_default \
--env-file /srv/llm-benchmark/.env \
-v /srv/llm-benchmark/results:/results \
nexus.example.com:55000/platform/platform-common/llm-benchmark:latest \
--model local-chat-completions \
--model_args "model=gemma-4-31b,base_url=http://llm-gateway-llm-gateway-1:4000/v1/chat/completions,num_concurrent=1,max_retries=3" \
--tasks gsm8k \
--limit 1 \
--apply_chat_template \
--gen_kwargs max_gen_toks=4096 \
--log_samples \
--output_path /results/debug-4096root@bastion:/srv/llm-benchmark/results/default/gemma-4-31b# cat results_2026-08-16T14-36-10.067074.json | grep exact
"exact_match,strict-match": 1.0,
"exact_match_stderr,strict-match": 0.0,
"exact_match,flexible-extract": 1.0,
"exact_match_stderr,flexible-extract": 0.0
"metric": "exact_match",
"exact_match": true
root@bastion:/srv/llm-benchmark/results/default/gemma-4-31b#생성 토큰 한도를 늘린 뒤에는 평가가 진행됐다. 앞선 exact=0.1은 10개 샘플의 소규모 시험 결과로, content:null·길이 제한·정답 추출 실패가 함께 포함돼 있다.
| 벤치 | 주로 보는 것 | 문제 형태 | 이 시험에서 보는 항목 |
|---|---|---|---|
| GSM8K | 수학적 추론 | 초중등 문장제 | 논리/계산 능력 |
| IFEval | 지시 이행 | 자유 응답 | 사용자의 요구조건을 정확히 지키는가 |
| GPQA | 고난도 전문 추론 | 대학원급 과학 객관식 | 어려운 문제에서 추론력이 유지되는가 |
| MMLU-Pro | 지식 + 추론 | 여러 분야 객관식 | 전반적인 모델 지능/지식 |
| 추론 시간이 길어 thinking을 끈 조건에서 100개 항목을 시험하는 계획을 세웠다. 완료된 정답 평가표는 기록에 없어 결과로 보고하지 않는다. |
7. Qwen 서빙과 FP8 KV 캐시
이후 Qwen3.8로 기록한 모델 구성과 서빙 로그를 별도 비교 대상으로 남겼다.
Compose
services:
qwen:
image: vllm/vllm-openai:v0.26.0
container_name: vllm-qwen3.8-27b
restart: "no"
gpus: all
ipc: host
environment:
VLLM_API_KEY: ${VLLM_API_KEY:?set VLLM_API_KEY}
expose:
- "8001"
volumes:
- /srv/vllm-qwen3.8-27b/huggingface:/root/.cache/huggingface
- /srv/vllm-qwen3.8-27b/cache:/root/.cache/vllm
networks:
- vllm
command:
# Hugging Face에서 불러올 서빙 모델
## 7. Qwen 서빙과 FP8 KV 캐시-27B의 AWQ INT4 양자화 버전
- cyankiwi/Qwen3.8-27B-AWQ-INT4
# OpenAI-Compatible API에서 노출할 모델 이름
# 요청 시 model: "qwen3.8-27b" 로 사용
- --served-model-name
- qwen3.8-27b
# 접근 port 설정
- --host
- 0.0.0.0
- --port
- "8001"
# 모델 연산에 사용할 dtype 자동 선택
# 모델 config와 하드웨어를 기준으로 vLLM이 적절한 dtype 결정
# AWQ INT4 weight 자체를 FP16/BF16으로 되돌리는 옵션은 아님
- --dtype
- auto
# 요청 1개가 사용할 수 있는 최대 모델 컨텍스트 길이
# 입력(prompt) + 생성(output)을 합쳐 아래 max-model-len 값까지
- --max-model-len
- "114688"
# vLLM이 사용할 GPU VRAM budget 비율
# A6000 약 47.4 GiB 기준 0.80 × 47.4 = 약 37.92 GiB budget
# 모델 weight + activation + CUDA graph + KV cache 등에 사용됨
- --gpu-memory-utilization
- "0.80"
# 동시에 실행할 수 있는 최대 sequence 수
# 아래 max-num-seqs=4는 동시에 스케줄링하는 sequence 상한 4개
# 사용자 수와 같지 않으며 실제 동시 실행은 KV 캐시와 요청 길이에도 제한됨
- --max-num-seqs
- "4"
# KV Cache를 FP8로 저장
# FP16/BF16 KV 대비 메모리 사용량을 크게 줄여
# 같은 VRAM에서 더 긴 context 또는 높은 동시성 확보
- --kv-cache-dtype
- fp8
# FP8 KV Cache에 필요한 K/V scale을 런타임에서 계산
# scale 적용 여부와 품질 영향은 모델·설치 버전별로 확인
# 당시 무시 경고를 관측했다. 하이브리드 구조가 원인인지는 이 기록만으로 확정하지 않는다.
- --calculate-kv-scales
# 동일한 prefix의 KV Cache를 재사용
# 시스템 프롬프트나 반복되는 대화 prefix가 같을 때
# prefill 연산량을 줄여 응답 시작 속도 개선 가능
- --enable-prefix-caching
# Qwen3 계열 reasoning 출력 파싱
# reasoning/thinking 영역을 OpenAI-Compatible 응답 형식으로 분리
- --reasoning-parser
- qwen3
# 모델이 필요에 따라 자동으로 tool call을 선택하도록 활성화
- --enable-auto-tool-choice
# Qwen3 Coder 형식의 tool call 출력을 파싱
# 모델이 생성한 tool 호출을 OpenAI-Compatible tool_calls로 변환
- --tool-call-parser
- qwen3_coder
# Qwen chat template에 전달할 기본 추가 옵션
# template에 전달한 요청값이며 실제 지원·효과는 별도 검증
- --default-chat-template-kwargs
- '{"reasoning_effort":"xhigh"}'
networks:
vllm:
external: true
name: vllm_default# KV cache 용도로 실제 확보된 VRAM
(EngineCore pid=172) INFO 08-17 07:30:48 [gpu_worker.py:560] Available KV cache memory: 16.21 GiB
# gpu-memory-utilization=0.80 설정
# GPU 전체 usable VRAM 47.4 GiB의 80%인 약 xx GiB를
# vLLM 전체 메모리 budget으로 사용
[gpu_worker.py:575] CUDA graph memory profiling is enabled (default since v0.21.0). The current --gpu-memory-utilization=0.8000 is equivalent to --gpu-memory-utilization=0.7899 without CUDA graph memory profiling. To maintain the same effective KV cache size as before, increase --gpu-memory-utilization to 0.8101. To disable, set VLLM_MEMORY_PROFILER_ESTIMATE_CUDAGRAPHS=0
# 현재 확보된 KV cache가 저장할 수 있는 총 token capacity
(EngineCore pid=172) INFO 08-17 07:30:48 [kv_cache_utils.py:2177] GPU KV cache size: 484,556 tokens
# max-model-len=98,304 기준,
# KV 메모리만 놓고 보면 최대 context를 약 4.22개까지 동시에 담을 수 있음
# 단 실제 동시 실행 수는 max-num-seqs 설정에도 제한됨
(EngineCore pid=172) INFO 08-17 07:30:48 [kv_cache_utils.py:2178] Maximum concurrency for 114,688 tokens per request: 4.22xMaximum concurrency는 특정 요청 길이를 기준으로 계산한 KV 캐시 용량 비율이다. 주석의 max-model-len은 98,304였지만 로그는 114,688토큰 기준으로 4.22x를 보고했다. 동시 요청의 안정성은 실제 입력·출력 길이, 캐시 재사용과 메모리 사용량에 따라 달라진다.
8. 배치·추측 디코딩과 처리량 관측
KV cache usage: 14.0%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:40:55 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 33.2 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.0%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:41:05 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 33.2 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.0%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:41:15 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 33.2 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.0%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:41:25 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 33.2 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.4%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:41:35 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 33.2 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.4%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:41:45 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 33.2 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.4%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:41:55 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 33.2 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.4%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:42:05 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 33.2 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.7%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:42:15 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 33.1 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.7%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:42:25 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 33.1 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.7%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:42:35 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 33.1 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.7%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:42:45 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 33.1 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.7%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:42:55 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 29.7 tokens/s, Running: 0 reqs, Waiting: 0 reqs, GPU KV cache usage: 0.0%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO 08-21 01:43:05 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 0.0 tokens/s, Running: 0 reqs, Waiting: 0 reqs, GPU KV cache usage: 0.0%, Prefix cache hit rate: 88.0%
(APIServer pid=1) INFO: 192.0.2.14:44740 - "POST /v1/chat/completions HTTP/1.1" 200 OK
(APIServer pid=1) INFO 08-21 01:43:25 [loggers.py:310] Engine 000: Avg prompt throughput: 491.5 tokens/s, Avg generation throughput: 6.3 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 15.1%,이후 speculative decoding을 추가해 수용률·출력 속도·지연을 관측했다. 거절된 draft 토큰은 최종 출력에 채택되지 않는다. 병목의 위치와 클럭 조정 효과, 설정별 품질 차이는 각각의 비교 측정 범위다.
(APIServer pid=1) INFO 08-21 03:58:59 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 51.8 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 14.7%, Prefix cache hit rate: 39.1%
(APIServer pid=1) INFO 08-21 03:58:59 [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 2.54, Accepted throughput: 31.40 tokens/s, Drafted throughput: 40.80 tokens/s, Accepted: 314 tokens, Drafted: 408 tokens, Per-position acceptance rate: 0.833, 0.706, Avg Draft acceptance rate: 77.0%
(APIServer pid=1) INFO 08-21 03:59:09 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 51.6 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 15.1%, Prefix cache hit rate: 39.1%
(APIServer pid=1) INFO 08-21 03:59:09 [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 2.54, Accepted throughput: 31.30 tokens/s, Drafted throughput: 40.60 tokens/s, Accepted: 313 tokens, Drafted: 406 tokens, Per-position acceptance rate: 0.837, 0.704, Avg Draft acceptance rate: 77.1%
(APIServer pid=1) INFO 08-21 03:59:19 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 48.3 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 15.1%, Prefix cache hit rate: 39.1%
(APIServer pid=1) INFO 08-21 03:59:19 [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 2.37, Accepted throughput: 27.90 tokens/s, Drafted throughput: 40.80 tokens/s, Accepted: 279 tokens, Drafted: 408 tokens, Per-position acceptance rate: 0.770, 0.598, Avg Draft acceptance rate: 68.4%
(APIServer pid=1) INFO 08-21 03:59:29 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 48.0 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 15.1%, Prefix cache hit rate: 39.1%
(APIServer pid=1) INFO 08-21 03:59:29 [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 2.35, Accepted throughput: 27.60 tokens/s, Drafted throughput: 40.80 tokens/s, Accepted: 276 tokens, Drafted: 408 tokens, Per-position acceptance rate: 0.775, 0.578, Avg Draft acceptance rate: 67.6%
(APIServer pid=1) INFO 08-21 03:59:39 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 52.8 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 15.4%, Prefix cache hit rate: 39.1%
(APIServer pid=1) INFO 08-21 03:59:39 [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 2.61, Accepted throughput: 32.60 tokens/s, Drafted throughput: 40.39 tokens/s, Accepted: 326 tokens, Drafted: 404 tokens, Per-position acceptance rate: 0.856, 0.757, Avg Draft acceptance rate: 80.7%
(APIServer pid=1) INFO 08-21 03:59:49 [loggers.py:310] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 50.8 tokens/s, Running: 1 reqs, Waiting: 0 reqs, GPU KV cache usage: 15.4%, Prefix cache hit rate: 39.1%
(APIServer pid=1) INFO 08-21 03:59:49 [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 2.47, Accepted throughput: 30.20 tokens/s, Drafted throughput: 41.20 tokens/s, Accepted: 302 tokens, Drafted: 412 tokens, Per-position acceptance rate: 0.801, 0.665, Avg Draft acceptance rate: 73.3%추가 로그의 한 구간에서 generation throughput 약 51.8 tok/s가 관측됐다. 10초 내외 구간이며 요청 길이·동시성·캐시 적중률을 맞춘 전후 비교가 없어 50% 향상으로 확정하지 않는다.
services:
qwen:
image: vllm/vllm-openai:v0.26.0
container_name: vllm-qwen3.8-27b
restart: "no"
gpus: all
ipc: host
environment:
VLLM_API_KEY: ${VLLM_API_KEY:?set VLLM_API_KEY}
expose:
- "8001"
volumes:
- /srv/vllm-qwen3.8-27b/huggingface:/root/.cache/huggingface
- /srv/vllm-qwen3.8-27b/cache:/root/.cache/vllm
networks:
- vllm
command:
# Hugging Face에서 불러올 서빙 모델
## 7. Qwen 서빙과 FP8 KV 캐시-27B의 AWQ INT4 양자화 버전
- cyankiwi/Qwen3.8-27B-AWQ-INT4
# OpenAI-Compatible API에서 노출할 모델 이름
# 요청 시 model: "qwen3.8-27b" 로 사용
- --served-model-name
- qwen3.8-27b
# 접근 port 설정
- --host
- 0.0.0.0
- --port
- "8001"
# 모델 연산에 사용할 dtype 자동 선택
# 모델 config와 하드웨어를 기준으로 vLLM이 적절한 dtype 결정
# AWQ INT4 weight 자체를 FP16/BF16으로 되돌리는 옵션은 아님
- --dtype
- auto
# 요청 1개가 사용할 수 있는 최대 모델 컨텍스트 길이
# 입력(prompt) + 생성(output)을 합쳐 max-model-len
- --max-model-len
- "114688"
# vLLM이 사용할 GPU VRAM budget 비율
# A6000 약 47.4 GiB 기준 0.80 × 47.4 ≈ 37.92 GiB budget
# 모델 weight + activation + CUDA graph + KV cache 등에 사용됨
- --gpu-memory-utilization
- "0.80"
# 동시에 실행할 수 있는 최대 sequence 수
# 최대 4개의 요청을 continuous batching으로 동시에 처리
# 사용자 수와 같지 않으며 요청 길이·KV 캐시 여유에도 제한됨
- --max-num-seqs
- "4"
# KV Cache를 FP8로 저장
# FP16/BF16 KV 대비 메모리 사용량을 크게 줄여
# 같은 VRAM에서 더 긴 context 또는 높은 동시성 확보
- --kv-cache-dtype
- fp8
# FP8 KV Cache에 필요한 K/V scale을 런타임에서 계산
# scale 적용 여부와 품질 영향은 모델·설치 버전별로 확인
# - --calculate-kv-scales
# 동일한 prefix의 KV Cache를 재사용
# 시스템 프롬프트나 반복되는 대화 prefix가 같을 때
# prefill 연산량을 줄여 응답 시작 속도 개선 가능
- --enable-prefix-caching
# 긴 prompt를 잘라서 처리
- --enable-chunked-prefill
- --max-num-batched-tokens
- "16384"
# Qwen3 계열 reasoning 출력 파싱
# reasoning/thinking 영역을 OpenAI-Compatible 응답 형식으로 분리
- --reasoning-parser
- qwen3
- --language-model-only
# 모델이 필요에 따라 자동으로 tool call을 선택하도록 활성화
- --enable-auto-tool-choice
# Qwen3 Coder 형식의 tool call 출력을 파싱
# 모델이 생성한 tool 호출을 OpenAI-Compatible tool_calls로 변환
- --tool-call-parser
- qwen3_coder
# Qwen chat template에 전달할 기본 추가 옵션
# template에 전달한 요청값이며 실제 지원·효과는 별도 검증
- --default-chat-template-kwargs
- '{"reasoning_effort":"xhigh"}'
- --speculative-config
- '{"method":"mtp","num_speculative_tokens":2}'
networks:
vllm:
external: true
name: vllm_default지금 옵션
별도 GPU의 GGUF 모델 준비
아래는 별도 GPU 환경을 준비하며 모델 파일을 내려받은 명령이다. 파일 다운로드와 실제 모델 서빙·추론 성공을 구분한다.
cd /srv/gemma4-26b-a4b
mkdir -p model
docker run --rm \
-v /srv/gemma4-26b-a4b/model:/model \
--entrypoint python3 \
vllm/vllm-openai:v0.28.0-gguf \
-c '
from huggingface_hub import hf_hub_download
path = hf_hub_download(
repo_id="google/gemma-4-26B-A4B-it-qat-q4_0-gguf",
filename="gemma-4-26B_q4_0-it.gguf",
local_dir="/model",
)
print(path)
'드라이버 자동 업데이트와 변경 관리
자동 업데이트 뒤 드라이버 문제가 발생해 A6000에서는 모듈 재로드를 조사했다. 아래 패키지 자동 업데이트 제외는 별도 GPU 호스트에 적용한 당시 설정이다. 업데이트 제외는 문제 해결 자체가 아니므로, 드라이버·Toolkit 호환성을 확인하고 계획된 업데이트와 기능 검증으로 관리한다.
cat >/etc/apt/apt.conf.d/51-nvidia-blacklist <<'EOF'
Unattended-Upgrade::Package-Blacklist {
"^nvidia-";
"^libnvidia-";
"^xserver-xorg-video-nvidia-";
};
EOF