27AI Research

SGLang Inference System Optimization

#ModelScoreStepsIn tokOut tokAvg costAvg time
1GPT-5.6
0.0387
±0.048
609258.0M221k$261.916.1h
2Muse Spark 1.2
0.0152
±0.022
739245.0M810k$69.699.5h
3GLM-5.3
0.0150
±0.023
626208.7M395k$60.4813.5h
4Grok 4.6
0.0073
±0.014
1,085281.2M1.6M$295.8614.3h
5Qwen3.8-Max
0.0060
±0.009
639139.7M1.3M$43.2016.8h
6Gemini 3.7 Flash
0.0034
±0.008
350104.9M171k$11.362.7h
7Kimi K3
0.0021
±0.005
1,032407.1M1.0M$143.3616.6h
8DeepSeek V4 Flash Exp
0.0000
±0.000
622217.1M392k$3.699.4h
9Claude Fable 5.1
0.0000
±0.000
852357.3M878k$199.8510.0h
10Inkling
0.0000
±0.000
1218.1M17k$7.771.3h

Background

LLM serving systems are full-stack performance problems: request scheduling, batching, KV-cache memory management, speculative decoding, CUDA-graph capture, and attention kernels all interact, and the fastest configuration for single sequential requests is rarely the fastest under concurrent load. Optimizing one without regressing the other (while keeping the model's outputs bit-for-bit faithful under greedy decoding) is what production inference teams spend months on.

The starting point here is deliberately not a strawman: the provided SGLang launch configuration already uses an FP8 KV cache, NEXTN/MTP speculative decoding, the extra-buffer mamba scheduler, CUDA graphs, and tuned page and memory settings. Flag-tuning alone is unlikely to yield much; real gains require custom kernels, SGLang or FlashInfer source modifications, or model surgery that preserves output equivalence.

Task

The agent must make an SGLang serving instance with Qwen3.5-4B on a B200 GPU serve requests as fast as possible. Single-request latency across input/output shapes and batched requests at several concurrency levels matter comparably.

  • The server is started through /app/server/launch_server.sh, which receives PORT and MODEL_PATH environment variables and must expose the OpenAI-compatible SGLang HTTP API.
  • Correctness is a hard requirement: with temperature-0 greedy decoding, the optimized server must keep producing the outputs of the starting configuration, with an average whitespace-token prefix match of at least 0.95.
  • Everything the server needs must live inside /app and be reapplied or imported by launch_server.sh: the server is later launched from a fresh copy of the workspace in which only /app carries over, so direct edits to site-packages or in-place edits to /app/model do not survive on their own.
  • The design space is wide: scheduler and batching configuration, tuning or replacing the speculative pipeline, custom Triton or CUDA kernels, direct SGLang and FlashInfer source modifications, and model modifications (quantise, prune, fuse), all under the output-equivalence requirement.

What The Agent Gets

A running serving workspace: Qwen3.5-4B weights pre-downloaded at /app/model, the tuned launch_server.sh starting configuration, and a local measurement loop. compare_outputs.pysnapshots the pristine server's greedy outputs on the visible 174-prompt dev set (dev_prompts.jsonl, generated from the same distribution as the held-back set) and diffs after every change; verify_serving.py sanity-checks the server and run_dev_bench.py measures latency across input-length × output-length quadrants plus a concurrent batch.

Preinstalled tooling includes the CUDA 12.8 dev toolkit (nvcc), PyTorch with Triton and torch.compile, the pinned SGLang + sgl_kernel + FlashInfer serving stack in site-packages, and gcc/ninja for native builds. There is no internet access at runtime (no package installs, no model downloads), and a sandbox-timer CLI reports the remaining budget.

Verification

Verification runs in a separate clean-room environment on the captured /app. It launches the baseline and candidate servers under the same unprivileged user, collects greedy outputs on a held-back prompt set, and measures an A/B/A benchmark: baseline session, candidate session, then a second baseline session whose samples are pooled with the first into the scored median.

  • The correctness gate compares candidate outputs against the baseline's on hidden prompts (normal text, code, math, long-context, degenerate and adversarial inputs); an average whitespace-token prefix-match below 0.95 zeroes the result.
  • Speed is measured on five sequential workloads covering the input-length × output-length quadrants plus a reasoning shape, and two concurrent workloads (4-way and 8-way mixed). Per-class geometric-mean speedups are mapped linearly to credit between a live-zero anchor at 1.02x (parity and no-op relaunches score exactly 0) and a 2.0x cap.
  • The aggregate is capped at 0.30 + 0.70 × the weaker class's credit, so the top of the range is unreachable without genuine improvement in both sequential and concurrent serving; continuous regression gates on each class and on the weakest single workload collapse the score for real regressions while tolerating measured replay noise.
  • The timed path itself is integrity-checked: every benchmark response is compared against the baseline's response to the same salted request, with mean and median prefix-match bars plus a completion-length ratio that catches servers truncating output under load. Failing any of these gates zeroes the result, as does a server that fails to launch.

Environment

Base imagenvidia/cuda:12.8.1-devel-ubuntu22.04
Tools availableCUDA, PyTorch, C/C++ toolchain, Python 3
Compute8 CPUs · 128 GB RAM
GPU1× B200
Time limit20h

Changes From V1

This task is an improved revision of SGLang Inference System Optimization from FrontierSWE V1.

  • The agent budget grew from 4 hours to 20 hours, and the verifier window from 1 hour to 3 hours to cover three full server launches with A/B/A baseline bracketing (both baseline sessions now pool into the scored median instead of serving only as an anomaly check).
  • Scoring changed from a raw geometric-mean speedup to a calibrated credit map: sequential and concurrent classes are scored separately against a 2.0x cap with a live-zero anchor at 1.02x so parity and no-op relaunches score exactly 0, a weak-class cap requires genuine improvement in both classes, and continuous regression gates on each class and the weakest workload replace cliff-edge failures.
  • New timed-path integrity gates: every benchmark response is compared against the baseline's response to the same salted request, with mean and median prefix-match bars and a completion-length ratio that catches truncation under load: a server can no longer buy latency by degrading outputs only while being timed.
  • Correctness became locally measurable: the workspace now ships a visible 174-prompt dev set drawn from the same generator as the held-back set plus a compare_outputs.py snapshot/diff loop, with the 0.95 prefix-match bar and the ~0.97 relaunch-noise budget documented up front.
  • Verification moved to a separate clean-room container with an explicit persistence contract: the server relaunches from a fresh workspace copy in which only /app carries over, and the submission root moved from /app/submission/ to /app/server/.
  • Infrastructure moved to the new harbor schema with pinned agent and verifier images, and the /app/.timer daemon files were replaced by the sandbox-timer CLI.

References

  • SGLang (+ sgl_kernel) (Apache-2.0): Installed into the task image via pip (sglang[srt]) as the serving runtime the agent optimizes and may patch in site-packages; not vendored.
  • FlashInfer (Apache-2.0): Installed via pip as SGLang's attention kernel backend.
  • PyTorch (BSD-3-Clause): The tensor/CUDA runtime (bundling Triton), pulled in by the pinned sglang[srt].
  • FlashAttention 4 (BSD-3-Clause): Installed as the pinned flash-attn-4 package for Blackwell attention kernels.
  • Qwen3.5-4B (Apache-2.0): The served model weights, downloaded into the image at build time and exposed to the server through /app/model.
  • NVIDIA CUDA base image (NVIDIA Deep Learning Container License / CUDA EULA): nvidia/cuda:12.8.1-devel-ubuntu22.04 provides the CUDA 12.8 dev toolkit for Blackwell.
  • python-build-standalone (CPython 3.11) (MPL-2.0 (tooling); interpreter under PSF-2.0): The standalone CPython 3.11 interpreter installed in the image, avoiding a Triton segfault seen with the distro Python on Blackwell.
  • uv (Apache-2.0 OR MIT): Pinned binaries used to create the environment and install its hash-locked Python dependencies.
  • pip (MIT): Installed as a pinned dependency so standard pip commands work inside the agent's environment.
  • NumPy (BSD-3-Clause): Pinned direct dependency for numerical operations.
  • Pillow (HPND): Pinned direct dependency used by model-processing libraries.
  • Hugging Face Hub, Safetensors, and Transformers (Apache-2.0): Pinned direct dependencies for downloading the model at image-build time, reading its tensor files, and loading its configuration and tokenizer.
  • Requests (Apache-2.0): Pinned direct dependency for HTTP client support.