Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
c06fa19
Studio: add opt-in vLLM and SGLang inference engines
oobabooga Sep 21, 2026
42e5c51
Studio: extend optional engines with vision, precision and parallel m…
oobabooga Sep 21, 2026
a67b8f1
Studio: allow loading explicitly restored inference engines
oobabooga Sep 21, 2026
5b6e9f8
Studio: support tool calling with managed inference engines
oobabooga Sep 21, 2026
3960bdf
Merge main into feat/studio-opt-in-engines
oobabooga Sep 22, 2026
eec4b11
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2026
c38665c
Restore managed engine settings on rollback and launch the normalized…
oobabooga Sep 22, 2026
b3fa171
Run optional engine checks in validate before the picker unloads
oobabooga Sep 22, 2026
26b2bd4
Patch the httpx module the managed tool route imports in its tests
oobabooga Sep 22, 2026
f0d40ad
Fetch remote image URLs in Studio before forwarding them to a managed…
oobabooga Sep 22, 2026
b624522
Give managed engine requests the llama-server first-token deadline
oobabooga Sep 22, 2026
daa5da8
Refuse an outdated engine profile on the backend unless it was restored
oobabooga Sep 22, 2026
5b0c980
Name the text encoding for engine subprocess output and the lease file
oobabooga Sep 22, 2026
21a9b95
Update repository guard tests for the optional engine changes
oobabooga Sep 22, 2026
d4e098a
Merge main into feat/studio-opt-in-engines
oobabooga Sep 23, 2026
bfe7a08
Run optional engines on Studio's PyTorch instead of a separate Python…
oobabooga Sep 23, 2026
bf56a58
Keep the chat GPU claim when a managed engine does not stop on unload
oobabooga Sep 24, 2026
424e26b
Report a managed engine that survives load cancellation and keep it h…
oobabooga Sep 24, 2026
86cfd70
Launch managed engines only on GPUs visible to Studio
oobabooga Sep 24, 2026
2394aa4
Default the engine GPU picker to the first GPU Studio sees
oobabooga Sep 24, 2026
c1649be
Merge main into feat/studio-opt-in-engines
oobabooga Sep 25, 2026
3d563ec
Load a compare pane with its remembered vLLM or SGLang settings
oobabooga Sep 25, 2026
0dffb49
Validate a model switch on the GPUs its load will use
oobabooga Sep 25, 2026
a2c3765
Trim comments in opt-in engine code
danielhanchen Sep 25, 2026
300b507
Send managed engines only data URL images
danielhanchen Sep 25, 2026
3e095cb
Keep engine status probes from failing real engine work
danielhanchen Sep 25, 2026
afb6f34
Give the load-time nvidia-smi probes the same 60s allowance
danielhanchen Sep 25, 2026
b7c2a63
Time out engine startup on silence, not a fixed 15 minutes
danielhanchen Sep 25, 2026
8482d76
Disable vLLM's vendored DeepGEMM when it was built for another Python
danielhanchen Sep 25, 2026
cedc789
Start a model switch without a saved config on the default engine
danielhanchen Sep 25, 2026
4fabd0f
Cache a failed nvidia-smi probe for 5 minutes
danielhanchen Sep 25, 2026
9a8715e
Format the engine switch test
danielhanchen Sep 25, 2026
b8057ec
Give the engine silence test room for a slow interpreter start
danielhanchen Sep 25, 2026
38bc4b0
Never run nvidia-smi inside an engines status poll
danielhanchen Sep 25, 2026
6ca8706
Run the malware and remote-code consent gates before a managed engine…
danielhanchen Sep 25, 2026
11c6df2
Treat saved vLLM/SGLang targets as managed in image checks
danielhanchen Sep 25, 2026
ec7c160
Let the legacy model_id-only delete clear a saved engine choice
danielhanchen Sep 25, 2026
c9ac7d8
Merge main into feat/studio-opt-in-engines
danielhanchen Sep 25, 2026
0f6207d
Reap a crashed engine before engine status, install, repair or removal
danielhanchen Sep 25, 2026
5250577
Count managed-engine tokens when reasoning_effort is "none"
danielhanchen Sep 25, 2026
3412f23
Tighten engine comments
danielhanchen Sep 25, 2026
d8ea265
Merge main into feat/studio-opt-in-engines
danielhanchen Sep 26, 2026
f602f83
Share Studio's PyTorch with engines installed from the PyTorch index
danielhanchen Sep 26, 2026
59a5f65
Keep each engine environment's FlashInfer JIT cache inside it
danielhanchen Sep 26, 2026
0c3c2e9
Hide Studio's NVFP4 FlashInfer from shared engine environments
danielhanchen Sep 26, 2026
dc683cf
Give engines the locked pip nvcc for FlashInfer JIT on driver-only hosts
danielhanchen Sep 26, 2026
b226fc6
Download only what Studio lacks: reuse its accepted versions, fetch F…
danielhanchen Sep 26, 2026
0e061d6
Require glibc 2.35 for vLLM, whose wheel is manylinux_2_35
danielhanchen Sep 26, 2026
0513f1e
Update engines to vLLM 0.26.0 and SGLang 0.5.17
danielhanchen Sep 26, 2026
0417f6c
Keep TorchAO precisions working on the upgraded engines
danielhanchen Sep 26, 2026
511e5fe
Merge remote-tracking branch 'origin/main' into r11491
danielhanchen Sep 27, 2026
6e6fedb
Accept a text response_format on managed engines and name audio model…
danielhanchen Sep 27, 2026
8f8beca
Merge remote-tracking branch 'origin/main' into r11491
danielhanchen Sep 28, 2026
3df4446
Merge remote-tracking branch 'origin/main' into r11491
danielhanchen Sep 28, 2026
e1a7439
Serve managed-engine n > 1 one choice at a time, reap an engine a can…
danielhanchen Sep 28, 2026
916e2e3
Report the public model id on managed-engine tool responses
danielhanchen Sep 28, 2026
4af4116
Serve a tool catalog with tool_choice none as plain chat on models wi…
danielhanchen Sep 28, 2026
fdf3502
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 28, 2026
c1d084d
Store only non-default engine fields in model overrides, so an all-de…
danielhanchen Sep 29, 2026
abeaca9
Refuse to start training while a managed engine that failed to stop s…
danielhanchen Sep 29, 2026
7c0c000
Pass the engine key in the environment and guard every vLLM route wit…
danielhanchen Sep 29, 2026
5acac1d
Reuse Studio's TorchAO for engines only at the version the adapter co…
danielhanchen Sep 29, 2026
571a37c
Leave engine-specific VRAM headroom measured on a 24 GB card
danielhanchen Sep 29, 2026
c9e9a10
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 29, 2026
36c20fc
Merge main into feat/studio-opt-in-engines
danielhanchen Sep 29, 2026
08d934f
Keep the NVIDIA driver's library path for managed engines and their i…
danielhanchen Sep 29, 2026
5f6a726
Revert the driver library path change; it moves to its own PR
danielhanchen Sep 29, 2026
3be719c
Merge main into feat/studio-opt-in-engines
danielhanchen Oct 1, 2026
7d82b0f
Engines: lock a release per Studio PyTorch (vLLM 0.30 / SGLang 0.5.20…
danielhanchen Oct 1, 2026
197d96f
SGLang 0.5.18+: run without --torchao-config and refuse load-time INT…
danielhanchen Oct 1, 2026
7c419a1
Precision picker: disable INT8 and 4-bit for SGLang releases without …
danielhanchen Oct 1, 2026
d070583
SGLang 0.5.18+: disable CUDA graphs with the per-phase backend flags
danielhanchen Oct 1, 2026
54b15c0
Merge main into feat/studio-opt-in-engines
danielhanchen Oct 1, 2026
6899423
Merge remote-tracking branch 'origin/main' into r11491
danielhanchen Oct 2, 2026
24dd21e
Engines: skip CUTLASS DSL's CUDA 12 libraries, which a driver 580 hos…
danielhanchen Oct 2, 2026
ea82f00
unsloth run: --engine vllm|sglang serves through an optional engine, …
danielhanchen Oct 2, 2026
5915028
Engines: share nvcc's headers only at the locked release, so FlashInf…
danielhanchen Oct 2, 2026
55df9b3
Engines: take nvcc and its headers from one release, all from Studio …
danielhanchen Oct 2, 2026
a900d9f
Reaping a crashed engine also drops its chat GPU claim and shared res…
danielhanchen Oct 2, 2026
2b03e2d
Shared engines: keep the engine's nvidia tree first when Studio's sit…
danielhanchen Oct 2, 2026
22019df
Engines: an INT4 / INT8 SGLang cannot convert resets on switching and…
danielhanchen Oct 2, 2026
3badbb7
Engines: CUDA runtime headers travel with nvcc, so a shared engine ne…
danielhanchen Oct 2, 2026
3632693
unsloth run --engine: a restored engine loads as is
danielhanchen Oct 2, 2026
feb9ac1
Engines: one merged CUDA include tree, so Studio headers pick up the …
danielhanchen Oct 2, 2026
bc06998
Engines: keep a share of large GPUs free for vLLM's sampler warmup
danielhanchen Oct 2, 2026
829ce71
Engines: keep the current-date note on rebuilt managed-engine messages
danielhanchen Oct 2, 2026
1c03ce1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 2, 2026
c5d783b
Model picker: keep GGUF row badges aligned with rows that have the se…
danielhanchen Oct 2, 2026
edc9f42
Engines: validate the INT4 a legacy load_in_4bit request becomes, bef…
danielhanchen Oct 2, 2026
0c6c6a0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 2, 2026
4757676
Engines: keep lock files byte-exact on Windows clones; mark Linux-onl…
danielhanchen Oct 2, 2026
ee2c279
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 2, 2026
95df13b
Engines: install-machinery tests are Linux engine-host tests
danielhanchen Oct 2, 2026
246a61b
Merge main into feat/studio-opt-in-engines
danielhanchen Oct 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ studio/frontend/** text=auto eol=lf
# HashMismatch. WDAC treats that as tampering, which is worse than shipping unsigned.
# -text disables conversion in both directions, matching the docs_ui rule above.
*.ps1 -text

# Engine locks are pinned by sha256 in their .compat.json and in each install's record, so a
# Windows clone (core.autocrlf=true) rewriting them to CRLF would mark every engine stale.
studio/backend/requirements/engines/** -text
222 changes: 222 additions & 0 deletions studio/INFERENCE_ENGINES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
# Optional inference engines

Studio can install and run vLLM or SGLang for local text and image chat. Installation
is opt-in. Select a model, open its run settings, and choose **Inference engine**.
Choose **Install engine** to install and load the selected model. Selecting **Default** returns
to Studio's normal backend. Remembered model settings include the engine choice.

**Settings > System > Inference engines** provides installation, cancellation,
repair, removal, and restoration of the previous installation. Unload the model
before changing an installed engine. Installation continues if the panel closes;
if it closes before installation finishes, use **Load model** when you return.
Removing an engine keeps downloaded models and the shared package cache.
Installation progress appears in the shared download panel and returns after
refreshing the page. It shows live package-manager output and expandable details.
Model settings show a brief installation status and a cancel action, without
duplicating the progress bar or live log.
The progress bar stays indeterminate because the installer does not report reliable
byte totals; Studio does not invent a percentage, transfer speed or ETA.

## Initial support

This experimental profile requires Linux x86_64, glibc 2.34 or newer, an NVIDIA
GPU with compute capability 8.0 or newer, and driver 580 or newer. It uses
the model's standard chat template and each engine's native model loaders.
Select one or more GPUs in the model settings. With multiple GPUs, choose
**Multi-GPU mode**:

- **Tensor parallel** splits computations within model layers. This is the default
for existing settings. Studio checks head and layer dimensions before unloading
the current model.
- **Pipeline parallel** places different layers on each GPU. It can reduce
communication overhead on systems without NVLink. Layer allocation follows the
engine's default partition; Studio does not automatically balance unequal cards.
- **Replicas (data parallel)** distributes requests across GPU workers. Dense
models need a full model copy and cache on each GPU. Native vLLM data parallelism
can shard MoE experts across workers, so these are not independent full replicas
for every architecture.

All selected devices must satisfy the hardware requirements. The engine validates
model and quantization support for the selected mode. These modes use one machine;
combined tensor/pipeline/data configurations are not exposed.
Text and vision architectures are validated by the selected engine. Individual
models can still exceed available memory or require unsupported kernels.

OpenAI chat requests support client-owned tool calls, streamed arguments and tool-result
history. Studio can also execute its existing built-in and MCP tools through the
shared approval and execution flow. Native output parsers are selected from the
model's Jinja template syntax; Studio does not replace the template. Models with
unrecognized tool syntax remain available for ordinary chat. The pinned SGLang
version can return multiple calls even with `parallel_tool_calls: false`.
Legacy completions and Anthropic endpoints retain their existing GGUF requirement;
exact token counting for tool-enabled prompts is not available.

LoRA adapters, audio/video input, structured output, reasoning
controls and continuation are outside this profile. Custom model code uses the
existing trust-remote-code consent setting. Multi-node serving is not configured by Studio.
Engine servers honor Studio's VRAM budget, capped by the most constrained
selected GPU's measured free-memory fraction, with at least 512 MiB left per GPU for driver allocations.
GPU memory is not treated as a single pool: each device must fit its own shard
and runtime allocations. Training evicts them before allocating
GPU memory. Startup includes model downloads and kernel compilation and can take
several minutes. The UI reports phases without inventing progress percentages.

The load API accepts `engine_parallelism`: `tensor` (default), `pipeline` or `data`.
The selected mode spans `gpu_ids`; the other parallel dimensions stay at one.
For example, `{"engine": "vllm", "gpu_ids": [0, 1], "engine_parallelism": "pipeline"}`
uses two pipeline stages with tensor parallel size one. With one selected GPU, all
parallel sizes are one and the saved mode is retained for later multi-GPU loads.

The existing `tensor_parallel` request switch remains a GGUF setting. Optional
engine load and status responses report `engine_parallelism`, selected GPU IDs,
and whether tensor parallelism is actually active. Remembered model settings and
API auto-loads preserve mode and GPU order. Changing either requires reloading.

## Precision and images

The existing model settings include a **Precision** selector for optional engines:

- **Model default** lets the engine detect the checkpoint's dtype or stored
quantization, including compatible AWQ, GPTQ, FP8 and BitsAndBytes checkpoints.
- **BF16** and **FP16** choose a 16-bit dtype for an unquantized checkpoint.
- **4-bit** converts an unquantized checkpoint with BitsAndBytes in vLLM
tensor/data modes, or TorchAO in vLLM pipeline mode and SGLang.
- **INT8** uses the engines' native TorchAO weight-only conversion.
- **FP8** uses vLLM's TorchAO weight-only conversion. SGLang uses native FP8
conversion on Ada and newer GPUs, or TorchAO weight-only conversion on Ampere.

Available kernels depend on the model and GPUs. Prequantized checkpoints use
**Model default** and are not requantized. Prequantized BitsAndBytes models cannot use
tensor parallelism in these pinned engines. SGLang also cannot split these
prequantized weights across pipeline stages; use replicas or an unquantized
checkpoint with on-load 4-bit conversion instead. Other combinations use the
native loader and retain its model-specific constraints. FP8 conversion on Ampere GPUs and SGLang prequantized BitsAndBytes INT8
use eager execution because their compiled paths are incompatible with these
pinned dependencies. Conversion can need more memory during loading
than the final model occupies. A dependency profile change shows **Update engine**
before loading from the picker.

The load API accepts `engine_precision`: `auto`, `bf16`, `fp16`, `int4`, `int8` or
`fp8`. Remembered settings and status responses preserve the value. Existing API
clients that explicitly send `load_in_4bit: true` without `engine_precision` select
4-bit conversion. Changing precision requires a reload.

Vision models accept text-only chat and OpenAI `image_url` content parts, including
multiple images and images on earlier turns. Studio forwards the original image
bytes to the engine, fetching remote URLs itself with the same limits as other backends. The selected model determines its image and context limits.

## Environment and cache design

Engines run in their own processes from environments under the Studio home's
`engines` directory. Studio never imports engine packages into its own Python
process. Compiler caches, including Triton, are scoped to each engine profile, model,
precision, context and GPU selection to avoid reusing incompatible kernels.
The committed requirements profiles lock versions and wheel hashes for Python 3.13.
Each engine has one locked release per PyTorch build it can share, newest first:

| Engine | Release | PyTorch | Lock |
|---|---|---|---|
| vLLM | 0.30.0 | 2.13.0 (CUDA 13.0) | `vllm-linux-cu130-torch213.txt` |
| vLLM | 0.26.0 | 2.11.0 (CUDA 13.0) | `vllm-linux-cu130.txt` |
| SGLang | 0.5.20 | 2.13.0 (CUDA 13.0) | `sglang-linux-cu130-torch213.txt` |
| SGLang | 0.5.17 | 2.11.0 (CUDA 13.0) | `sglang-linux-cu130.txt` |

Studio installs the release built on its own PyTorch, so a new install (torch 2.13) and an
existing default install (torch 2.11) both share. Any other PyTorch (2.10, 2.12, a CUDA 12 build)
gets the newest release in a complete isolated environment, since no vLLM or SGLang release is
built on it. Windows hosts install the newest release inside WSL.

The engines cannot share Studio's site-packages: they pin Transformers and other
packages at versions Studio does not use, and they conflict with each other. They
can share its interpreter, PyTorch and CUDA libraries. When Studio runs Python 3.13
and its torch, together with the Triton and NVIDIA packages torch loads, is exactly
the version an engine is locked to, the engine environment uses Studio's
interpreter and holds only the locked packages Studio lacks or has at another
version. A `.pth` file adds Studio's site-packages after the engine's own, so the
engine's pins win and multiprocessing workers see the same packages. A CUDA library torch accepts as a range (nvjitlink)
only has to satisfy every locked package's requirement. Otherwise, for example with
another torch version or CUDA build, the engine gets a complete isolated environment
from the newest lock.

A shared environment records the Studio packages it was checked against. If a
Studio update changes any of them, or the Python version, the engine reports an
available update, refuses to load until it is repaired, and cannot be rolled back
to an environment built on the old packages. Repair reuses cached downloads.

Installation uses the shared uv cache, honoring `UV_CACHE_DIR` when configured.
Otherwise it reuses the installer's recorded cache path, with Studio's own cache
as the fallback.
Copy-on-write clones allow identical cached files to share storage on supporting
filesystems; uv falls back to copies elsewhere. Environments do not hardlink
mutable files into Studio's Python environment. Existing installations may use
different Torch or CUDA builds, or may not retain cached wheels, so no fixed disk
savings are promised. Model downloads use Studio's configured Hugging Face cache.

An exclusive file lock protects installation and removal across Studio processes.
Running engines hold shared leases. A staged environment must pass dependency,
CUDA import and server entry-point checks before an atomic active marker changes.
The dependency check runs in the engine's interpreter, so it covers both layers of a
shared environment: every locked package must resolve to its locked version, with
its requirements met.
Failed or cancelled installations preserve the prior marker. A successful repair
keeps one previous environment for restoration. Explicitly restoring an older
profile allows model loading while still offering the pinned update. That choice
survives restart and failed repairs; a successful update replaces it. Interrupted
jobs are reported after restarting Studio.

Servers bind to loopback with a random port and authentication key. Studio owns
their process trees, startup cancellation, health checks, streaming cancellation
and GPU handoff. These engines participate in the local model lifecycle. They
are not entries in the external provider registry.

Engine adapters own command lines and startup phases; the orchestrator remains
the source of resident-model state. HTTP response cleanup is shared with the
external OpenAI transport. A bounded async bridge provides synchronous streaming
to the orchestrator without letting a slow consumer buffer unlimited output.
Children are spawned through Studio's process-lifetime thread so they survive
the short-lived thread that requested their start.

Controls use the shared Select, Switch and Settings components. New copy lives in the
translation catalog, with explicit English fallback for untranslated locales.

SGLang uses Triton attention and PyTorch sampling in this profile so its default
FlashInfer JIT path does not require a matching system CUDA toolkit. Runtime
executables such as Ninja are resolved from the engine environment first, then from
Studio's environment for a shared engine.
For tensor parallelism, SGLang probes GPU peer access and falls back to its
standard collective when peer access is unavailable. Its equal-free-memory
guard is disabled for these managed groups: Studio checks every GPU, and SGLang
sizes its cache from the minimum available memory across ranks. This allows
cards with different memory capacities without treating their VRAM as a pool.

## Maintaining profiles

Run from the repository root using uv. Seed each output file with `uv pip freeze`
from a default Studio install first: uv prefers versions already in the output file,
which keeps each engine's own layer small.

```sh
cd studio/backend/requirements/engines
for lock in vllm-linux-cu130-torch213 vllm-linux-cu130 sglang-linux-cu130-torch213 sglang-linux-cu130; do
uv pip compile $lock.in --python-version 3.13 --python-platform x86_64-manylinux_2_34 --index-url https://pypi.org/simple --refresh --generate-hashes --excludes $lock.excludes -o $lock.txt
python engine_compat.py $lock
done
```

Keep each lock's torch, torchvision, torchaudio and CUDA pins equal to the Studio
install it serves, or no installation can share them. `engine_compat.py` also records
each wheel's download size, which the install prompt shows. SGLang's excludes file drops `outlines`,
whose `outlines-core` pin has no Python 3.13 wheel; SGLang only imports it for
`--grammar-backend outlines`. Every lock drops `nvidia-cutlass-dsl-libs-cu12`: CUTLASS DSL loads the newest
CUDA flavour the driver runs, and the engines require driver 580 (CUDA 13).

Add a release to `PROFILES` (newest first) and `PYTHON` in `engine_install.py` when
changing the runtime baseline. SGLang's requirements explicitly pin its required Flash
Attention beta and a Transformers-compatible `kernels` release. Do not enable
prereleases globally. Regeneration must refresh hashes when changing indexes.

Validate installation, failed repair, restoration, streaming usage, cancellation,
process cleanup and training handoff. Test server startup and real generation on
supported hardware: importing an engine alone does not validate its CUDA runtime.
Exact SGLang prompt counting is currently unavailable; generated usage is reported
from the server. Performance and storage savings require separate measurements.
Loading