last update
Jun 24, 2026
license
MITv1.0.0
format
SKILL.md
- Install
// Downloads SKILL.md into ~/.claude/skills/sglang-inference-server/
$ curl -fsSL --create-dirs -o ~/.claude/skills/sglang-inference-server/SKILL.md https://claudeskil.com/skills/sglang-inference-server/SKILL.md - Invoke
// Inside Claude Code, type the skill name as a slash command
> /sglang-inference-server fine-tune on this CSV - Or just ask
// Claude loads the skill by itself when a request matches its description
> fine-tune on this CSV
- name:
- SGLang Inference Server
- slug:
- sglang-inference-server
- version:
- v1.0.0
- license:
- MIT
- author:
- @chiragthummar16
- categories:
- tags:
- #sglang#llm-serving#radixattention#inference#vllm
- description:
Launch and tune SGLang serving — RadixAttention prefix caching, structured generation, tensor parallelism, vLLM benchmarks.
README.md
SGLang Inference Server
This skill helps you stand up and tune an SGLang inference server for production LLM serving. It covers launching the server with the right parallelism and memory flags, exploiting RadixAttention prefix caching, enforcing structured output, and using both the OpenAI-compatible and native endpoints. It is aimed at engineers deploying open-weight models (Llama, Qwen, DeepSeek, Mixtral, etc.) on one or more GPUs who care about throughput and tail latency.
When to use it
- You are serving a model behind an API and want continuous batching plus prefix-cache reuse for shared system prompts or few-shot examples.
- You need guaranteed-valid JSON, regex-constrained, or grammar-constrained output.
- A model does not fit on one GPU and you need tensor or data parallelism.
- You are migrating from vLLM and want to compare throughput/TTFT on the same hardware.
How it works
The entry point is python -m sglang.launch_server. Key flags this skill helps you set:
--tp-size(tensor parallelism across GPUs) and--dp-size(data-parallel replicas).--mem-fraction-staticto size the KV cache pool; lower it if you hit CUDA OOM.--chunked-prefill-sizeto cap tokens per prefill step and protect decode latency.- RadixAttention is on by default; disable with
--disable-radix-cachewhen benchmarking cold paths.
Structured generation is handled by the --grammar-backend (xgrammar or outlines). Requests pass regex, json_schema, or ebnf constraints. The server exposes an OpenAI-compatible surface at /v1/chat/completions and /v1/completions, plus the native /generate endpoint.
Example
curl -fsSL --create-dirs -o ~/.claude/skills/sglang-inference-server/SKILL.md https://claudeskil.com/skills/sglang-inference-server/SKILL.md
# Launch a 7B model across 2 GPUs
python -m sglang.launch_server \
--model-path meta-llama/Llama-3.1-8B-Instruct \
--tp-size 2 --mem-fraction-static 0.85 \
--chunked-prefill-size 4096 --port 30000
# JSON-constrained request via the native API
curl http://localhost:30000/generate -d '{
"text": "List two primes as JSON: ",
"sampling_params": {"max_new_tokens": 64,
"json_schema": "{\"type\":\"array\",\"items\":{\"type\":\"integer\"}}"}
}'
Tips & gotchas
- RadixAttention only helps when requests share prefixes. Put static system prompts and few-shot blocks first so they hit the cache; volatile content goes last.
- OOM at startup is almost always
--mem-fraction-staticset too high alongside a large--context-length. Drop the fraction before lowering batch size. xgrammaris faster thanoutlinesfor JSON schema; switch tooutlinesif you hit an unsupported grammar feature.- Use
--dp-sizefor replicas of a model that fits on one GPU, and--tp-sizeonly when a single copy does not fit.
FAQ
Is it a drop-in vLLM replacement? The /v1 endpoints match the OpenAI spec, so most clients work unchanged. Native features (/generate, RadixAttention, structured outputs) need SGLang-specific request fields.
How do I benchmark it? Use python -m sglang.bench_serving against a running server, or sglang.bench_one_batch for offline throughput; compare TTFT and output token throughput at matched concurrency.
Can I constrain output to a grammar? Yes — pass ebnf, regex, or json_schema in sampling_params, backed by --grammar-backend.
$ cat reviews/