# SGLang server — plain serving, and the rollout/weight-sync pairing for env-GRPO. The default image # is the NCCL-aligned Dockerfile.sglang build (`make build-sglang`, or SGLANG_IMAGE set to the prebuilt # public.ecr.aws/whitecircle/halo:sglang-0.5.22): upstream's NCCL does not match uv.lock's pin, and a # skew hangs the sync group. Host networking; SGLANG_CUDA_DEVICES must not overlap the trainer's. # SGLANG_MODEL= SGLANG_MODEL_DIR= docker compose -f docker-compose.sglang.yml up # (`down` needs both too; add -f docker-compose.sglang.efa.yml on an EFA host) services: sglang-server: image: ${SGLANG_IMAGE:-halo:sglang-0.5.22} ipc: host network_mode: host environment: - CUDA_VISIBLE_DEVICES=${SGLANG_CUDA_DEVICES:-7} - HF_HOME=${HF_HOME:-/root/.cache/huggingface} - HF_TOKEN=${HF_TOKEN:-} # Set to 0 for rollout_weight_precision: fp8_block: DeepGEMM requantizes a block-FP8 checkpoint's dense # scales at boot and rejects every push of fp32 scales. Passed through only when set. - SGLANG_ENABLE_JIT_DEEPGEMM # Weight sync shares an NCCL group with the trainer in another container. cuMem must match on # both ends: SGLang sets NCCL_CUMEM_ENABLE=0 process-wide unless it is already set, the # trainer's NCCL has it on, and the mismatch fails the first cross-container buffer import # (`ncclP2pImportShareableBuffer ... invalid argument`). With parity the same-host group takes # CUDA IPC over NVLink. - NCCL_CUMEM_ENABLE=${NCCL_CUMEM_ENABLE:-1} # No-fabric defaults (InfiniBand off, socket net); the EFA overlay overrides both. - NCCL_NET=${NCCL_NET:-Socket} - NCCL_IB_DISABLE=${NCCL_IB_DISABLE:-1} # Keep the socket transport off Docker's bridge and per-container veth pairs. - NCCL_SOCKET_IFNAME=${NCCL_SOCKET_IFNAME:-^docker,veth} # Passed through bare from the shell or .env (unset stays unset): a protocol table set on the # trainer alone hangs the first collective, so a trainer that pins NCCL_PROTO needs the server # pinned the same way, on every recipe. - NCCL_PROTO deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: [gpu] volumes: # Mounted at the same path inside the container, so HF_HOME resolves either side. - ${HF_HOME:-~/.cache/huggingface}:${HF_HOME:-/root/.cache/huggingface} # The host directory holding SGLANG_MODEL when that is a local path. No fallback; with a hub id # any existing directory serves. - ${SGLANG_MODEL_DIR:?set SGLANG_MODEL_DIR to the host directory holding a local SGLANG_MODEL (any existing directory for a hub id)}:${SGLANG_MODEL_DIR}:ro # The chat templates the recipes pin, at the path their headers name for SGLANG_CHAT_TEMPLATE. - ./jinja-templates:/jinja-templates:ro # Two flags are required, and the trainer's startup preflight refuses a server without them: # --tool-call-parser (tool-using environments need the calls parsed; `auto` reads the parser off the chat # template and disables it on one it cannot detect) and --moe-runner-backend triton (auto-selection picks a # fused runner for most MoE shapes: # triton_kernel and flashinfer skip R3 capture, and flashinfer_trtllm repacks the expert weights an # update writes). # rollout_adapter_sync serves the policy as a LoRA adapter beside the frozen base. SGLANG_LORA_MAX_RANK (at least # the run's lora_r) turns it on, and the module list must cover the adapted projections: the engine drops any # tensor outside it without a trace. # --attention-backend is a per-family need, --trust-remote-code a per-checkpoint one, and SGLANG_EXTRA_ARGS is appended # last so a flag repeated there wins. Values per family: agent-docs/infrastructure/rollout-servers.md command: > python3 -m sglang.launch_server --model-path ${SGLANG_MODEL:?set SGLANG_MODEL to a hub id or a local checkpoint dir} --host 0.0.0.0 --port ${SGLANG_PORT:-30000} --tp-size ${SGLANG_TP:-1} --mem-fraction-static ${SGLANG_GPU_MEM:-0.85} --tool-call-parser ${SGLANG_TOOL_PARSER:-auto} --moe-runner-backend ${SGLANG_MOE_RUNNER_BACKEND:-triton} ${SGLANG_ENABLE_R3:+--enable-return-routed-experts} ${SGLANG_LORA_MAX_RANK:+--enable-lora --max-lora-rank ${SGLANG_LORA_MAX_RANK} --lora-target-modules ${SGLANG_LORA_TARGET_MODULES:-q_proj k_proj v_proj o_proj} --max-loaded-loras ${SGLANG_MAX_LOADED_LORAS:-8} --max-loras-per-batch ${SGLANG_MAX_LORAS_PER_BATCH:-3}} ${SGLANG_REASONING_PARSER:+--reasoning-parser ${SGLANG_REASONING_PARSER}} ${SGLANG_CHAT_TEMPLATE:+--chat-template ${SGLANG_CHAT_TEMPLATE}} ${SGLANG_ATTENTION_BACKEND:+--attention-backend ${SGLANG_ATTENTION_BACKEND}} ${SGLANG_TRUST_REMOTE_CODE:+--trust-remote-code} ${SGLANG_EXTRA_ARGS:-} healthcheck: test: ["CMD-SHELL", "python3 -c \"import urllib.request; urllib.request.urlopen('http://localhost:${SGLANG_PORT:-30000}/health')\""] interval: 15s timeout: 10s retries: 40 start_period: 180s restart: unless-stopped