Repository navigation
Studio: forward llama-server args from unsloth studio run , activate unsloth run , and allow passing model:quant to load models - #5271
Conversation
`unsloth studio run --model X --top-k 20 --chat-template-file foo.jinja` now passes the unknown flags through to the llama-server subprocess. Adds a denylist for flags Studio manages (port, -m, -c, --api-key, -ngl, --flash-attn, --no-context-shift, --jinja, GPU-fit, model-identity, ...) that returns HTTP 400 on collision. HTTP callers can supply the same list via LoadRequest.llama_extra_args.
…o run` Mirrors llama.cpp's `-hf <repo>:<quant>` and ollama's pull syntax so `unsloth studio run --model unsloth/gpt-oss-20b-GGUF:UD-Q4_K_XL` is equivalent to `--model unsloth/... --gguf-variant UD-Q4_K_XL`. Local paths and Windows drive letters are preserved verbatim. If both an embedded variant and an explicit `--gguf-variant` are given and they disagree, the command fails with a clear error.
There was a problem hiding this comment.
Code Review
This pull request introduces support for passing extra arguments to llama-server for GGUF models, including a validation layer with a denylist to protect managed flags. The CLI is also updated to support a repo:variant shorthand for model identifiers and to forward unknown arguments to the backend. Feedback was provided to initialize the extra_llama_args variable before its defining try-except block in the inference route to improve code safety and prevent potential reference errors.
Top-level `unsloth run --model ...` is now equivalent to `unsloth studio run --model ...`. Same context_settings, so unknown flags continue to pass through to llama-server.
Trims the denylist to flags Studio fundamentally cannot share with the user (model identity, --host/--port/--path/--api-prefix, --api-key, --ssl-*, --webui, --models-*). Soft-managed flags -- -c/--ctx-size, --parallel, --flash-attn, --no-context-shift, --jinja, -ngl, -t/--threads, --fit* -- now pass through and override Studio's auto-set version via llama.cpp's last-wins CLI parsing. Lets users tune their run on the spot: unsloth run --model X -c 131072 --parallel 1 --threads 32
Matches llama-server's `-hf <repo>:<quant>` spelling so users coming from llama.cpp can use the same flag. Typer claims the aliases before the pass-through validator runs, so the HTTP-API denylist on those flags is unaffected. unsloth run -hf unsloth/gpt-oss-20b-GGUF:UD-Q4_K_XL
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db700e530c
ℹ️ 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".
| frozenset({"-hf", "-hfr", "--hf-repo"}), | ||
| frozenset({"-hff", "--hf-file"}), | ||
| frozenset({"-hfv", "-hfrv", "--hf-repo-v"}), | ||
| frozenset({"-hffv", "--hf-file-v"}), | ||
| frozenset({"-hft", "--hf-token"}), | ||
| frozenset({"-mm", "--mmproj"}), | ||
| frozenset({"-mmu", "--mmproj-url"}), |
There was a problem hiding this comment.
Deny draft-model identity flags in pass-through validator
The new denylist only blocks main-model selectors (-m, -hf, etc.) but it still allows draft-model selectors like -md/--model-draft and -hfd/-hfrd/--hf-repo-draft, so a caller can pass these via llama_extra_args and make llama-server load additional models outside Studio’s managed model identity. I checked the llama-server(1) option list, which documents those flags as model-selection inputs for speculative decoding; allowing them bypasses the stated model-identity boundary and can cause unexpected downloads/VRAM use while Studio still reports a single managed model.
Useful? React with 👍 / 👎.











Summary
unsloth studio run(and the new top-level aliasunsloth run) forward any flag they don't recognize directly to the underlying llama-server subprocess (GGUF only)./api/inference/loadboundary rejects flags Studio fundamentally cannot share with the user (model identity, the auth key, the network endpoint Studio's HTTP proxy targets, single-model server flags). Anything else passes through; llama.cpp's last-wins CLI parsing means the user's value overrides Studio's auto-set version.LoadRequest.llama_extra_args.--model org/repo:variantshorthand is now accepted on the CLI, mirroring llama.cpp's-hf <repo>:<quant>and ollama's pull syntax. Local paths and Windows drive letters are preserved verbatim.unsloth runis registered as a top-level alias forunsloth studio runso users can drop thestudiosegment.-hf,-hfr, and--hf-repoare now Typer aliases for--model, matching llama-server's spelling. Typer claims these before the pass-through validator, so the HTTP-API denylist on those flags is unaffected.Examples
Hard-deny (rejected, returns HTTP 400)
Flags Studio cannot let the user override:
-m/--model,-hf/-hfr/--hf-repo,-hff/--hf-file,-hft/--hf-token,-mu/--model-url,-dr/--docker-repo,-mm/--mmproj,-mmu/--mmproj-url,-hfv/-hfrv,-hffv. Note:-hf/-hfr/--hf-repoare simultaneously Typer CLI aliases for--model(see above) -- the denylist only fires forLoadRequest.llama_extra_argsover HTTP, where the dedicatedmodel_pathfield is the right channel.--host,--port,--path,--api-prefix,--reuse-port--api-key,--api-key-file,--ssl-key-file,--ssl-cert-file--webui/--no-webui,--models-dir,--models-preset,--models-max,--models-autoload/--no-models-autoloadAll short and long aliases are denied as a single group.
Pass-through (user override wins)
Everything else, including knobs Studio also auto-sets:
-c/--ctx-size,-np/--parallel,-fa/--flash-attn,--no-context-shift/--context-shift,--jinja/--no-jinja,-ngl/--gpu-layers,-t/--threads,-fit/--fit,-fitt/--fit-target,-fitc/--fit-ctx--top-k,--top-p,--min-p,--temp,--repeat-penalty,--mirostat*,--xtc-*,--dry-*,--seed, etc.--cache-type-k,--cache-type-v,--chat-template-file,--chat-template-kwargs,--spec-type,--spec-default,--draft-*,--spec-ngram-*,--spec-draft-*-rea/--reasoning,--reasoning-format,--reasoning-budgetUser args are appended last in
cmd; llama.cpp's CLI parser overwrites earlier values, so Studio's auto-set never beats an explicit user override.Files
studio/backend/core/inference/llama_server_args.py(denylist + validator)studio/backend/tests/test_llama_server_args.pytests/studio/test_cli_repo_variant.pytests/studio/test_cli_run_alias.pystudio/backend/models/inference.py(LoadRequest.llama_extra_argsfield)studio/backend/routes/inference.py(validate + forwardextra_argsto both load_model call sites)studio/backend/core/inference/llama_cpp.py(extra_argskwarg, append tocmdafter the--api-keyblock)unsloth_cli/commands/studio.py(ignore_unknown_options+allow_extra_args, capturectx.args, repo:variant splitter,-hfTyper alias on--model)unsloth_cli/__init__.py(top-levelrunalias registration)Test plan
unsloth run --model unsloth/Qwen3-0.6B-GGUF --gguf-variant Q4_K_M --chat-template-fileloads and servesunsloth run --model unsloth/gpt-oss-20b-GGUF:UD-Q4_K_XLloads via embedded variantunsloth run --model X -c 131072 --parallel 1 --threads 32-- llama-server picks up the override values (last-wins)unsloth studio run --model X --chat-template-file /abs/path/template.jinjaoverrides the embedded GGUF chat templateunsloth runandunsloth studio runproduce identical behaviorpytest studio/backend/tests/test_llama_server_args.py -vpytest tests/studio/test_cli_repo_variant.py -vpytest tests/studio/test_cli_run_alias.py -v