Skip to content

Studio: KV cache dtype, GPU memory limit and seed for vLLM and SGLang loads - #13596

Merged
danielhanchen merged 9 commits into
mainfrom
studio-vllm-engine-args
Oct 13, 2026
Merged

danielhanchen merged 9 commits into
mainfrom
studio-vllm-engine-args

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Related to #11664

When Studio launches vLLM or SGLang itself, the load settings already cover context length (--max-model-len), precision (--dtype, --quantization fp8) and multi-GPU (--tensor-parallel-size / --pipeline-parallel-size). This PR adds the remaining popular engine arguments from the vLLM engine arguments guide that make sense for a single Studio host. They sit beside Precision in the engine picker, in the same style.

Setting vLLM flag SGLang flag Values
KV cache --kv-cache-dtype fp8 --kv-cache-dtype fp8_e4m3 Model default, FP8 (about half the KV cache memory)
GPU memory limit --gpu-memory-utilization --mem-fraction-static Automatic, 95% to 30%
Seed --seed --random-seed empty, or a number
  • Defaults: with every setting at its default, the launch command is byte-identical to main for both engines (pinned by test_default_options_launch_the_same_argv_as_before).
  • Memory limit: the limit only ever lowers Studio's measured memory budget, never raises it past what is free.
  • Compile cache: seed and memory limit share it; KV cache dtype gets its own.
  • Saved settings: each setting is saved per model like Precision, is part of the resident config match (changing one reloads the model), is echoed by load and /status, and survives a rollback. They stay out of shared configs, like the other engine fields.

Left out on purpose:

  • --swap-space: removed from vLLM.
  • --disable-cascade-attn: already the default in vLLM 0.31.
  • --enforce-eager: Studio already sets it where CUDA graphs break.
  • --disable-log-stats: no user-visible effect.
  • --tokenizer: checkpoints ship their own tokenizer.
  • --enable-lora / --max-loras / --max-lora-rank: the managed engine still refuses adapters.
  • --hf-token, --port, --api-key: already managed by Studio.

Evidence

vLLM 0.31.0 on a B200, Qwen3-0.6B, argv built by Studio's validate_model and launch command:

argv: ... --max-model-len 2048 --gpu-memory-utilization 0.15 --tensor-parallel-size 1 ... --kv-cache-dtype fp8 --seed 1234 --generation-config vllm ...
Using fp8 data type to store kv cache.
FlashInfer resolved query dtypes: prefill=torch.float8_e4m3fn, decode=torch.float8_e4m3fn, ..., kv_cache_dtype=torch.float8_e4m3fn
completion: 200 Hi!

FP8 KV cache with vLLM 0.30.0 (the version Studio installs) on Colab, Qwen3-0.6B, --kv-cache-dtype fp8 --seed 1234:

GPU Result
L4 (sm89) starts, Using fp8 data type to store kv cache, answers
A100 (sm80) starts, Using fp8 data type to store kv cache, answers
T4 (sm75) vLLM refuses: FP8 KV cache is not supported by the Triton attention backend on Tesla T4 (compute capability 7.5)

So a load with FP8 KV cache on a GPU older than Ampere is now refused up front, before the resident model is released: "An FP8 KV cache needs an Ampere or newer NVIDIA GPU. Choose Model default for KV cache on this GPU." The compute capability probe only runs when FP8 is picked.

Tests

  • New: tests/test_managed_engine_launch_options.py (17 passed, including the pre-Ampere refusal) and tests/managed-engine-launch-options.test.ts (3 passed).
  • Managed-engine and override suites: 1411 passed (295 in the managed-engine files rerun on this branch).
  • Frontend suite (11823 passed), typecheck and i18n check (strict) are clean.
  • The SGLang mapping is covered by argv tests only; SGLang was not run on a GPU.

#13571 touches the same validate_model options block, so whichever lands second needs a one-hunk rebase.

Screenshots

Merge base (left) vs this PR (right), vLLM selected as the engine in Run settings.

New KV cache, GPU memory limit and Seed controls under Precision:

Engine settings

The KV cache list (Model default, FP8) in the full Run settings panel:

KV cache options

@danielhanchen danielhanchen self-assigned this Oct 13, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-13T18:02:22.303769Z 5df6537 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 8b64307137

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 13, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 13, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: f583ebf540

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 953bba580a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: dc36d54f8b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 742a228 into main Oct 13, 2026
@danielhanchen
danielhanchen deleted the studio-vllm-engine-args branch October 13, 2026 18:52
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 26, 2026
…load (unslothai#15139)

The model picker, the compare pane and auto-load each built two payloads
from the same settings: one for the `/validate` preflight and one for
`/load`. `validateModel` then re-serialized the first through a
hand-kept allow-list. That is 13 payload literals across
`use-chat-model-runtime.ts`, `shared-composer.tsx`, `chat-adapter.ts`
and `chat-api.ts`, and every new load setting had to be added to each
one.

The history shows the copies drifting apart:
- unslothai#9410 added Checkpoints and the draft KV dtype to every load and never
to the allow-list.
- unslothai#13596 (vLLM/SGLang KV dtype, seed, memory limit) had to edit the
picker, compare and `chat-api.ts` separately.
- The managed-engine offer (unslothai#13135, then unslothai#13229) and GGUF settings
preservation (unslothai#9562, then unslothai#11311) each landed on the picker first and
needed a follow-up PR for compare and auto-load.

The preflight exists so Studio refuses a load before it unloads the
working model, and also to guard training. When `/validate` judges a
different command from the one `/load` runs, it approves a load that
`/load` then refuses after the unload, or refuses one that would fit.

## Changes

- **One request, sent twice.** Each path builds one `LoadModelRequest`
and sends it to both `/validate` and `/load`. Only the load-only fields
are added at the `/load` call: request id, lease, force flags and
`alongside`.
- **The allow-list is gone.** `/validate`'s body is the load request;
the route ignores load-only fields. `validateRequestBody` fills defaults
for the non-nullable fields only.
- **`llamaServerLoadFields`** owns the one rule for llama-server's
knobs, which the three paths used to spell out with slightly different
gating:
- reasoning budget, batch sizes, server tuning and pass-through args are
sent for GGUF only;
- diffusion GGUF requests omit custom reasoning overrides, server tuning
and pass-through args, while still forwarding batch sizes;
  - blank values are omitted, never sent as null.
- **The picker re-baselines once.** On a model switch it re-baselines
its per-model settings before `/validate`, instead of mirroring that
reset in a second set of `validate*` variables.
- **New module.** `lib/load-request.ts` holds the three helpers.
Production code is 225 lines shorter.

## Preflight and load now agree

- **The three dropped settings now reach `/validate`.** `validateModel`
dropped `ctx_checkpoints`, `spec_draft_cache_type` and `tensor_split`.
Checkpoints affect sizing; a load with Checkpoints set was priced at the
default 32. Forwarding the draft KV dtype and GPU split makes validation
apply the same explicit-setting precedence over inherited flags as
loading. The training coexistence guard does not directly price draft KV
memory.
- **The picker and compare preflights now send the speculative mode and
depth.** They omitted `speculative_type` and `spec_draft_n_max`, so
validation used the default Auto mode, which already counts some
drafters but can differ from the selected mode. The preflight now
receives the same selected values as loading. Auto-load already sent
them.
- **A model switch with a staged run-settings config is now sized like
the load.** The picker's preflight used Auto layers and no context pin,
while `/load` used the staged layer count and context length.
- **Compare and auto-load no longer send llama-server's pass-through
args or tuning to a diffusion GGUF.** The diffusion runner takes none of
them, and the picker already left them out.

## Validation

- **Wire check:** the same GGUF request was sent through the real
`chat-api.ts` of each checkout, comparing what `/validate` receives with
what `/load` receives. On `main`, `/validate` is missing `tensor_split`,
`spec_draft_cache_type` and `ctx_checkpoints`; here it is missing
nothing.
- **Contract test:** `chat-load-request-one-builder.test.ts` reads
`ValidateModelRequest` from `studio/backend/models/inference.py`. It
fails if any field it prices cannot ride `LoadModelRequest` or is not
forwarded. It also table-tests the llama-server knob rule and checks
that every path sends one request.
- **Frontend:** `npm test` gives 13,857 passed. The 3 failures are
HTML/TextEdit charset decoding tests that fail the same way on `main` in
this environment. Typecheck is clean with both `bun check` and `tsc`.
- **Python contract tests:** the 30 files in `tests/studio` that read
these sources give 807 passed and 63 skipped. The two Playwright files
cannot import here, on `main` too.
- **The auto-load harness** (`test_chat_autoload_failure_gate.py`) now
inlines the real `load-request.ts` instead of a copy; all 81 scenarios
pass.
- **Rewritten tests:** text-matching tests that counted the duplicated
literals now assert one request per path. The rule they pinned is tested
behaviourally in the new file.

| Case | Before | After |
|---|---|---|
| GGUF load with Checkpoints, draft KV dtype or a per-GPU split |
`/validate` sent none of the three; used default checkpoints and could
resolve inherited flags differently | Same fields as `/load` |
| Picker or compare load with a DFlash/DSpark drafter | Preflight sized
Auto rather than the selected speculative mode | Selected mode
forwarded, as in `/load` |
| Model switch from a staged config with a context length and manual
layers | Preflight sized Auto context and Auto layers | Sized like
`/load` |
| Compare or auto-load of a diffusion GGUF with remembered extra args |
Args and tuning sent to a runner that takes none | Not sent, as the
picker already did |

Not in this PR: auto-load still ignores a model's saved engine
(vLLM/SGLang) and loads it on the default engine. That looks deliberate
(background loads avoid starting a managed engine), so it is left as is.

---------

Co-authored-by: Daniel Han <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant