feat(runtime): add SGLang runtime backend (#974)#1059
Open
joryirving wants to merge 12 commits into
Open
Conversation
Signed-off-by: Jory Irving <jory@jory.dev>
Signed-off-by: Jory Irving <jory@jory.dev>
Signed-off-by: Jory Irving <jory@jory.dev>
Signed-off-by: Jory Irving <jory@jory.dev>
Signed-off-by: Jory Irving <jory@jory.dev>
Signed-off-by: Jory Irving <jory@jory.dev>
Signed-off-by: Jory Irving <jory@jory.dev>
Signed-off-by: Jory Irving <jory@jory.dev>
Signed-off-by: Jory Irving <jory@jory.dev>
Signed-off-by: Jory Irving <jory@jory.dev>
…missing) Signed-off-by: Jory Irving <jory@defila.tech>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ec errors Signed-off-by: Jory Irving <jory@jory.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
sglangas a first-classInferenceService.Spec.Runtimevalue,alongside
llamacpp/vllm/tgi/personaplex/generic.A new typed
SGLangConfig(with nestedSGLangSpeculativeConfig) coverssharding, memory, batching, quantization/KV-cache, attention, agentic glue
(tool/reasoning parsers, chat template), speculative decoding (EAGLE /
EAGLE3), and LoRA basics — mirroring the vLLM pattern. GPU vendor (NVIDIA
vs AMD) drives image selection, so the AMD ROCm image is picked automatically
when
model.spec.hardware.gpu.vendorisamd.SGLang launches via
python3 -m sglang.launch_server(mirroring howpersonaplexwraps a Python module). Probes target/health_generateforstartup + readiness (runs a token, accurate) and
/healthfor liveness(cheap). Startup tolerates 180 failures (~30 min) for cold-start model load.
Why
Fixes #974
Headline motivation is SGLang's RadixAttention automatic prefix caching.
A foreman agent's tool loop re-sends the same large shared prefix every turn
(system prompt + tool definitions + issue/repo context); SGLang serves that
shared prefix from cache instead of reprocessing it, which materially cuts
latency and raises throughput for the multi-turn, high-concurrency pattern
the foreman-agent generates. Today an operator who wants SGLang has to fall
back to the
genericruntime and hand-write container config — losing theauto-generated args, mode handling, and health wiring the first-class
backends get.
How
api/v1alpha1/inferenceservice_types.go:SGLangConfig+SGLangSpeculativeConfigstructs,SGLangConfigfield onInferenceServiceSpec,sglangadded to the runtime enum.internal/controller/runtime_sglang.go:SGLangBackendimplementingRuntimeBackend+CommandBuilder+HPAMetricProvider+EnvBuilder.BuildArgsemits base flags +--served-model-name+typed fields in declaration order + auto-derived
--tp+--is-embeddingfor mode + extraArgs last.
internal/controller/runtime_sglang_args.go: free-function helpers,one per flag. Mirrors
runtime_vllm_args.gostructure.internal/controller/runtime.go:case RuntimeSGLANGinresolveBackend.internal/controller/deployment_builder.go:resolveRuntimeImagepicks ROCm image for AMD GPUs; otherwise CUDA.
make manifests+make chart-crdsregenerated CRDs.docs/contributors/adding-a-runtime.md,docs/site/concepts/comparison.md,docs/site/guides/model-matrix.mdupdated.Out of scope (B3 followup): LoRA hot-loading, speculative perf tuning
(
--speculative-accept-threshold-*), data-parallel rendezvous,PodMonitor for
/metrics, and remaining minor SGLang flags. Tracked as aseparate issue.
Checklist
TestSGLangBuildArgstable-driven +TestSGLangBuildCommand+TestSGLangProbes+TestSGLangBuildEnv+TestValidateSGLangConfig+ dispatch + image-resolution tests)make testpasses locallymake lintpasses locallymake lint-allpasses locally (cross-arch)git commit -s)working with a repo collaborator. The agent followed the
docs/contributors/adding-a-runtime.mdpattern, the design spec atdocs/superpowers/specs/2026-07-10-sglang-runtime-backend-design.md(local agent scratch, not committed), and AGENTS.md conventions.