Skip to content
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
f4d408f
Studio: GPU memory dropdown — llama.cpp --fit on and manual gpu-layer…
oobabooga Jun 17, 2026
75747d5
Merge remote-tracking branch 'origin/main' into studio-gpu-memory-mode
oobabooga Jun 17, 2026
97d0f05
Studio: simplify GPU memory changes (reuse ParamSlider, GPU_LAYERS_AL…
oobabooga Jun 17, 2026
b64d545
Studio: GPU picker — choose which GPUs a GGUF model loads on (gpu_ids)
oobabooga Jun 17, 2026
b557bc0
Studio: simplify GPU picker (share /api/system fetch, validate gpu_ids)
oobabooga Jun 17, 2026
ee769c9
Studio: GPU picker review fixes (gate relative indices, no cross-mode…
oobabooga Jun 17, 2026
96fb38d
Studio: group GPU controls under a collapsible GPU section
oobabooga Jun 17, 2026
6a206be
Studio: GPU feature review fixes (fix fit-ctx test, behavior-test the…
oobabooga Jun 17, 2026
93fc245
Studio: make GPU a top-level settings section (not nested under Model)
oobabooga Jun 17, 2026
53f1137
Studio: flatten GPU controls into the Model section, group by GPU/con…
oobabooga Jun 17, 2026
e91779a
Studio: move GPU Memory to the bottom of Model with its dependent con…
oobabooga Jun 17, 2026
b3ab9c3
Studio: move GPU Memory below Tensor Parallelism and GPUs below GPU M…
oobabooga Jun 17, 2026
52a208a
Studio: tighten GPU Memory and GPU Layers tooltip copy
oobabooga Jun 17, 2026
18b2032
Studio: fix fit-mode context slider track-click, restore GPU Memory t…
oobabooga Jun 17, 2026
f9831ab
Studio: GPU Memory tooltip one mode per line, briefer
oobabooga Jun 17, 2026
e718baf
Studio: note HIP_VISIBLE_DEVICES (ROCm) in the GPUs picker tooltip
oobabooga Jun 17, 2026
bb34eda
Studio: narrow the GPU Memory dropdown to fit the shortened label
oobabooga Jun 17, 2026
f193fbe
Studio: use 'llama.cpp --fit' in the GPU Memory tooltip for consistency
oobabooga Jun 17, 2026
0df3466
Studio: allow Tensor Parallelism in Manual GPU mode
oobabooga Jun 17, 2026
b780ac9
Studio: graduated MoE-on-CPU offload (--n-cpu-moe) replacing the all-…
oobabooga Jun 17, 2026
5699aba
Merge branch 'main' into studio-gpu-memory-mode
oobabooga Jun 17, 2026
20943e7
Studio: size the MoE-offload slider for staged (deferred-load) models
oobabooga Jun 17, 2026
30b6699
Studio: share one GGUF header walk for the context-length and MoE-cou…
oobabooga Jun 17, 2026
ffd089d
Studio: size the GPU Layers slider for staged models (one staged-head…
oobabooga Jun 17, 2026
ffbf87d
Studio: move Tensor Parallelism below the GPUs picker
oobabooga Jun 17, 2026
cb74c24
Studio: GPU split (--tensor-split) per-GPU model share in Manual mode
oobabooga Jun 17, 2026
d94c834
Studio: tolerate whitespace in GPU split input, move it below GPU Layers
oobabooga Jun 17, 2026
6ebd3a0
Studio: rename the GPU split control to "Split ratio"
oobabooga Jun 17, 2026
920ae7c
Studio: Split ratio sends explicit even input; fix blank=free-VRAM (n…
oobabooga Jun 17, 2026
3b205e2
Studio: tighten llama.cpp --fit VRAM margin with --fit-target 512
oobabooga Jun 17, 2026
fcaf599
Studio: GPU memory review fixes (rollback re-baseline, single-GPU TP …
oobabooga Jun 17, 2026
4a284b9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 17, 2026
d1414fd
Studio: move Split ratio below MoE Layers on CPU
oobabooga Jun 17, 2026
6ac618c
Studio: address PR review (fix GPU-info hydration race, share fit con…
oobabooga Jun 17, 2026
e96d25a
Studio: address codex review (manual single-GPU TP guard, GPU-aware s…
oobabooga Jun 17, 2026
491e804
Studio: address codex review round 2 (gpu_present seed, single-GPU te…
oobabooga Jun 17, 2026
685191e
Studio: address codex review round 3 (strip inherited --n-cpu-moe, CP…
oobabooga Jun 18, 2026
27a1915
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2026
84ab11b
Studio: address codex review round 4 (preserve pinned fit context acr…
oobabooga Jun 18, 2026
a05bd8d
Studio: address codex review round 5 (honor GPU picker for diffusion …
oobabooga Jun 18, 2026
59a8bdb
Studio: preserve the pending GPU Memory mode when staging a model
oobabooga Jun 18, 2026
e1cdfb2
Studio: pin diffusion GPU device order and reset GPU-memory state for…
oobabooga Jun 18, 2026
2b132b7
Studio: address codex review round 6 (fit-Auto rollback context, pres…
oobabooga Jun 18, 2026
baea6d9
Studio: persist the applied GPU Memory mode, not the requested one (s…
oobabooga Jun 18, 2026
fca5674
Studio: replace Manual-mode split-ratio field with per-GPU layer sliders
oobabooga Jun 18, 2026
6961eee
Studio: clarify per-GPU layer split hint for tensor-parallel mode
oobabooga Jun 18, 2026
8445186
Merge branch 'main' into studio-gpu-memory-mode
oobabooga Jun 18, 2026
783c11f
Merge branch 'main' into studio-gpu-memory-mode
oobabooga Jun 20, 2026
13daa5e
Studio: address codex review round 7 (allow GGUF gpu_ids past the leg…
oobabooga Jun 20, 2026
8dc5e85
Studio: address codex review round 8 (size the validate preflight lik…
oobabooga Jun 20, 2026
a9f3d3f
Studio: skip the training-OOM guard for llama.cpp --fit GGUF loads (t…
oobabooga Jun 20, 2026
8fa0af1
Studio: drop the now-redundant compare-path validate sizing (the --fi…
oobabooga Jun 20, 2026
6f238ce
Studio: address codex review round 9 (keep the training guard for fit…
oobabooga Jun 20, 2026
974f610
Studio: address codex review round 10 (gate GPU-memory adoption on is…
oobabooga Jun 20, 2026
60ddf08
Studio: handle diffusion GGUFs symmetrically in the GPU Memory contro…
oobabooga Jun 20, 2026
5ba4237
Merge branch 'main' into studio-gpu-memory-mode
oobabooga Jun 21, 2026
6a33e79
Merge branch 'main' into studio-gpu-memory-mode
oobabooga Jun 24, 2026
e85825c
Studio: remember the GPU Memory settings per model
oobabooga Jun 24, 2026
1e9944c
Studio: consolidate --fit mode and Manual mode into a single Manual mode
oobabooga Jun 24, 2026
6a0a67b
Studio: preserve the per-GPU layer split across GPU Layers changes
oobabooga Jun 24, 2026
6b1e560
Studio: trim overly long GPU Memory comments
oobabooga Jun 24, 2026
a67d536
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 24, 2026
a7ad2e0
address GPU memory config review comments
oobabooga Jun 24, 2026
cd273cf
trim redundant GPU memory tests
oobabooga Jun 24, 2026
7b0a5ae
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 24, 2026
ac3a540
Merge branch 'main' into studio-gpu-memory-mode
oobabooga Jul 3, 2026
6cb3923
Reconcile manual-mode TP drops with the #6659 drop-site invariants
oobabooga Jul 3, 2026
bd09e12
Merge remote-tracking branch 'origin/main' into studio-gpu-memory-mode
oobabooga Jul 7, 2026
350bab4
Preserve quantized KV in manual --fit, charge GGUF companions in full…
oobabooga Jul 8, 2026
f376271
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 8, 2026
e9b8cb8
Clear stale GPU baseline on non-GGUF loads so it can't read as dirty
oobabooga Jul 8, 2026
423e753
Fix no-context-shift test for the conditional -c flag
oobabooga Jul 8, 2026
339bdb7
Credit manual GPU-layer offload for cached HF GGUFs
oobabooga Jul 8, 2026
6ac77ff
Reset per-model load knobs on GGUF quant switch
oobabooga Jul 8, 2026
6e59ed0
Merge remote-tracking branch 'origin/main' into r6414
oobabooga Jul 8, 2026
bb3d84f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 8, 2026
5391ae9
Strip inherited tensor-split when manual ratio is cleared
oobabooga Jul 8, 2026
a4515e1
Match auto-load validation to safetensors placement
oobabooga Jul 8, 2026
eb733ee
Reset editable manual knobs after Auto GGUF loads
oobabooga Jul 8, 2026
1c24552
Record a single device for diffusion GPU picks
oobabooga Jul 8, 2026
5187fa6
Reset per-model GPU knobs before applying saved settings
oobabooga Jul 8, 2026
31e911b
Merge remote-tracking branch 'origin/main' into studio-gpu-memory-mode
oobabooga Jul 10, 2026
7d86ea9
Address review comments
oobabooga Jul 10, 2026
83c9118
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
23b008e
Guard manual tensor splits and keep remembered context on auto-load
oobabooga Jul 10, 2026
54e1ece
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
356edcf
Snapshot compare knobs, seed splits from free VRAM, flag zero-offload…
oobabooga Jul 10, 2026
cb5000b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
fa27ea8
Exempt CPU-only loads from the guard floor and harden compare and res…
oobabooga Jul 10, 2026
04ec3be
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
0f96694
Reach full offload from the layers slider and charge extras drafters …
oobabooga Jul 10, 2026
339b092
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
f862f68
Warm the GPU device cache before pick reconciles and disable staged G…
oobabooga Jul 10, 2026
d476d1a
Align the training guard with inherited extras, spec mode, and compar…
oobabooga Jul 10, 2026
1089609
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
ab796d5
Hide GPUs from companion-less zero-offload loads
oobabooga Jul 10, 2026
b484f08
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
4f238a7
Size diffusion picks per device, own manual offload flags, reject XPU…
oobabooga Jul 10, 2026
9afeb40
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
22a35bf
Drop tensor flags at zero layers and exempt CPU-pinned drafters
oobabooga Jul 10, 2026
dd22443
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
34adeda
Allowlist the zero-layer tensor parallel drop site
oobabooga Jul 10, 2026
10d5e44
Keep validate and load guards on the same extras and refresh stale ba…
oobabooga Jul 10, 2026
2699521
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
d871b54
Drop mismatched manual tensor splits before launch
oobabooga Jul 10, 2026
411692f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
9abaeea
Gate XPU picks on the real backend field and harden split and hydrati…
oobabooga Jul 10, 2026
b964bb1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
f070932
Weight full GPUs as zero, clamp split shares, and refine the zero-lay…
oobabooga Jul 10, 2026
eb5b5a1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
76dc2d5
Carry fit context across mode changes and align drafter and picker gates
oobabooga Jul 10, 2026
f09bec4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
962be19
Catch variant switches, uncached diffusion repos, and text-only mmpro…
oobabooga Jul 10, 2026
8e8de89
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
dc7d9be
Check companions on the first device and size native and remote zero-…
oobabooga Jul 10, 2026
e59dda5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
8ff1c09
Replace the training guard's precise VRAM modeling with a conservativ…
oobabooga Jul 10, 2026
da75eed
Baseline context pins on non-GGUF hydration and reprobe list-seeded s…
oobabooga Jul 10, 2026
e164de2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
3663d14
Size manual splits by their largest share and preserve resolved conte…
oobabooga Jul 10, 2026
4d76f96
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
03f2d1f
Default-deny unsized required companions and price KV at the effectiv…
oobabooga Jul 10, 2026
68ab54e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
72b993e
Reserve MTP draft KV and MLA target-copy in the training guard
oobabooga Jul 10, 2026
296bdb6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
6832feb
Size tensor-parallel loads per device and show GPU controls for nativ…
oobabooga Jul 10, 2026
13d0924
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
ab3bdd7
Reserve MTP overhead for uncached remote GGUFs and the mmproj runtime…
oobabooga Jul 10, 2026
3e075bb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
00b7f52
Drop the training-coexistence VRAM estimation this PR added
oobabooga Jul 10, 2026
dbd86ee
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2026
0b46f39
Gate remembered load settings to GGUF picks
oobabooga Jul 13, 2026
740c7e1
Lock the remaining load-time controls during a staged load
oobabooga Jul 13, 2026
9699c12
Clear the stale native-path token on compare loads
oobabooga Jul 13, 2026
22f8b17
Drop a stale guard reference from the zero-offload masking comment
oobabooga Jul 13, 2026
cb96b44
Merge branch 'main' into HEAD
oobabooga Jul 14, 2026
fee595c
Seed GPU baselines from the rollback response and drop never-emitted …
oobabooga Jul 14, 2026
aab943a
Match validate's training guard to load and keep the native reload token
oobabooga Jul 14, 2026
6fe8e81
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 14, 2026
44b9a92
Trim verbose GPU-memory comments
oobabooga Jul 14, 2026
6eecc18
Thread the variants header walk off the event loop, honor device pins…
oobabooga Jul 14, 2026
698a416
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 14, 2026
6c3b7b8
Honor manual placement and classify pinned zero-offload loads
oobabooga Jul 15, 2026
cae79cd
Close diffusion admission and status hydration gaps
oobabooga Jul 15, 2026
1628775
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 15, 2026
8df5b01
Check the actual diffusion GPU during training
oobabooga Jul 15, 2026
a2a9385
Align staged baselines and manual reload dedupe
oobabooga Jul 15, 2026
fb27d58
Merge main into studio-gpu-memory-mode
oobabooga Jul 15, 2026
721007f
Fix GGUF placement and rollback state
oobabooga Jul 15, 2026
8310588
Harden manual GGUF placement boundaries
oobabooga Jul 15, 2026
c5637df
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 15, 2026
fd49733
Merge origin/main into studio-gpu-memory-mode
Jul 19, 2026
66e6b3e
Remove unused resolve_tensor_parallel import in llama_cpp.py
Jul 19, 2026
958ccb1
Fix diffusion GPU dedup and training guard for non-numeric device tokens
Jul 19, 2026
1ddedc5
Tighten comments added by the GPU memory config changes
danielhanchen Jul 19, 2026
43766d3
Harden GGUF placement from independent review: VRAM sizing, diffusion…
Jul 19, 2026
c37f082
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 19, 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
407 changes: 386 additions & 21 deletions studio/backend/core/inference/llama_cpp.py

Large diffs are not rendered by default.

27 changes: 26 additions & 1 deletion studio/backend/core/inference/llama_server_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,25 @@ def is_managed_flag(flag: str) -> bool:
_TENSOR_SPLIT_FLAGS: frozenset[str] = frozenset({"-ts", "--tensor-split"})
_SPLIT_SHADOWING_FLAGS: frozenset[str] = _SPLIT_MODE_FLAGS | _TENSOR_SPLIT_FLAGS

# GPU-offload flags. Stripped only when the GPU Memory mode owns offload
# (manual emits --fit / --gpu-layers / --n-cpu-moe); in auto, a user's
# inherited -ngl is respected (the offload_overridden path), so this group is
# opt-in, not default. Layer flags are shared with llama_cpp's override
# detection; the MoE flags are strip-only (manual's --n-cpu-moe slider owns them).
_LAYER_OFFLOAD_FLAGS: frozenset[str] = frozenset(
{"-ngl", "--gpu-layers", "--n-gpu-layers", "-fit", "--fit"}
)
_MOE_OFFLOAD_FLAGS: frozenset[str] = frozenset({"-ncmoe", "--n-cpu-moe", "-cmoe", "--cpu-moe"})
_OFFLOAD_SHADOWING_FLAGS: frozenset[str] = _LAYER_OFFLOAD_FLAGS | _MOE_OFFLOAD_FLAGS

_SHADOWING_FLAGS: frozenset[str] = (
_CONTEXT_FLAGS | _CACHE_FLAGS | _SPEC_FLAGS | _TEMPLATE_FLAGS | _SPLIT_SHADOWING_FLAGS
)

# Shadowing flags that take no value -- strip the flag only, not the next token.
_BOOLEAN_SHADOWING_FLAGS: frozenset[str] = frozenset({"--spec-default", "--jinja", "--no-jinja"})
_BOOLEAN_SHADOWING_FLAGS: frozenset[str] = frozenset(
{"--spec-default", "--jinja", "--no-jinja", "-cmoe", "--cpu-moe"}
)


def parse_ctx_override(args: Optional[Iterable[str]]) -> Optional[int]:
Expand Down Expand Up @@ -424,6 +437,8 @@ def strip_shadowing_flags(
strip_spec: bool = True,
strip_template: bool = True,
strip_split_mode: bool = True,
strip_tensor_split: bool = False,
strip_offload: bool = False,
) -> list[str]:
"""Strip flags that shadow first-class Studio settings.

Expand All @@ -432,6 +447,12 @@ def strip_shadowing_flags(
(same for cache / spec / template / split-mode). Each ``strip_*``
toggle controls one group; the route only strips groups whose
first-class field the caller actually supplied.

``strip_split_mode`` removes both ``--split-mode`` and the coupled
``--tensor-split`` (the Tensor Parallelism toggle owns the whole split).
``strip_tensor_split`` removes ``--tensor-split`` *alone*, so manual mode can
replace an inherited per-GPU ratio while leaving the user's ``--split-mode``
row/none/layer choice intact.
"""
shadowing: set[str] = set()
if strip_context:
Expand All @@ -444,6 +465,10 @@ def strip_shadowing_flags(
shadowing |= _TEMPLATE_FLAGS
if strip_split_mode:
shadowing |= _SPLIT_SHADOWING_FLAGS
if strip_tensor_split:
shadowing |= _TENSOR_SPLIT_FLAGS
if strip_offload:
shadowing |= _OFFLOAD_SHADOWING_FLAGS

tokens = [str(a) for a in (args or [])]
out: list[str] = []
Expand Down
116 changes: 115 additions & 1 deletion studio/backend/models/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def normalize_blank_chat_template_override(cls, value: Optional[str]) -> Optiona
)
gpu_ids: Optional[List[int]] = Field(
None,
description = "Physical GPU indices to use, for example [0, 1]. Omit or pass [] to use automatic selection. Explicit gpu_ids are unsupported when the parent CUDA_VISIBLE_DEVICES uses UUID/MIG entries. Not supported for GGUF models.",
description = "Physical GPU indices to use, for example [0, 1]. Omit or pass [] to use automatic selection. Explicit gpu_ids are unsupported when the parent CUDA_VISIBLE_DEVICES uses UUID/MIG entries. For GGUF models the picked devices are pinned via CUDA/HIP_VISIBLE_DEVICES.",
)
speculative_type: Optional[str] = Field(
None,
Expand Down Expand Up @@ -100,6 +100,49 @@ def normalize_blank_chat_template_override(cls, value: Optional[str]) -> Optiona
"No effect on a single GPU. Ignored for non-GGUF models."
),
)
gpu_memory_mode: Literal["auto", "manual"] = Field(
"auto",
description = (
"GPU memory strategy for GGUF models. 'auto' (default): Unsloth "
"selects GPUs and caps context to fit VRAM. 'manual': you own the "
"offload. Leave gpu_layers at -1 (Auto) to hand memory management to "
"llama.cpp's --fit (no device masking, no context auto-reduce, no "
"gpu-layer/tensor-split planning); set gpu_layers >= 0 to pin layers "
"and n_cpu_moe yourself (--fit off), with tensor_parallel still "
"applying (split by free VRAM unless tensor_split is set, no planner). "
"Ignored for non-GGUF."
),
)
gpu_layers: int = Field(
-1,
ge = -1,
description = (
"Manual mode only: number of layers to offload to the GPU "
"(--gpu-layers, with --fit off). A value >= the model's layer count "
"offloads all of them. -1 = Auto: hand layer + context sizing to "
"llama.cpp's --fit. Ignored unless gpu_memory_mode is 'manual'."
),
)
n_cpu_moe: int = Field(
0,
ge = 0,
description = (
"Manual mode only: keep the first N MoE expert layers on the CPU "
"(--n-cpu-moe) to save VRAM on MoE models. 0 = none, N = number of "
"MoE layers offloaded (the backend offsets past any leading dense "
"layers). Ignored unless gpu_memory_mode is 'manual' with gpu_layers >= 0."
),
)
tensor_split: Optional[List[float]] = Field(
None,
description = (
"Manual mode only: relative share of the model per GPU (--tensor-split), "
"in the order of the GPUs in use, e.g. [2, 1] for 2:1. Omit it to let "
"llama.cpp use its default, which splits by free VRAM. Any list given is "
"passed through as-is, so send [1, 1] to force an even split. Ignored "
"unless gpu_memory_mode is 'manual' with gpu_layers >= 0."
),
)
llama_extra_args: Optional[List[str]] = Field(
None,
description = (
Expand Down Expand Up @@ -133,6 +176,11 @@ class ValidateModelRequest(BaseModel):
max_seq_length: int = Field(0, ge = 0, le = 1048576)
load_in_4bit: bool = Field(True)
gpu_ids: Optional[List[int]] = Field(None)
# Manual GGUF offload, so validate's training-coexistence guard sizes the same
# GPU-resident footprint /load will (a low gpu_layers keeps most weights on
# CPU). Defaults preserve old behavior for callers that omit them.
gpu_memory_mode: Literal["auto", "manual"] = Field("auto")
gpu_layers: int = Field(-1, ge = -1)
include_context_length: bool = Field(
False,
description = "Also read the native context length from the local GGUF header. "
Expand Down Expand Up @@ -167,6 +215,16 @@ class ValidateModelResponse(BaseModel):
description = "Native training context length, read from the GGUF header when the file "
"is already downloaded locally; None for non-GGUF, gated, or not-yet-downloaded models.",
)
layer_count: Optional[int] = Field(
None,
description = "Total layer count (GGUF block_count), the manual gpu-layers ceiling, read "
"from the header alongside context_length; None when not read.",
)
moe_layer_count: Optional[int] = Field(
None,
description = "MoE expert-layer count (the manual --n-cpu-moe ceiling), read from the GGUF "
"header alongside context_length; 0 for dense models, None when not read.",
)


class GenerateRequest(BaseModel):
Expand Down Expand Up @@ -270,6 +328,34 @@ class LoadResponse(BaseModel):
False,
description = "Whether tensor-parallel split (--split-mode tensor) is active.",
)
gpu_memory_mode: Literal["auto", "manual"] = Field(
"auto",
description = "Active GPU memory strategy ('auto' or 'manual').",
)
gpu_layers: int = Field(
-1,
description = "Manual mode: requested --gpu-layers value (-1 = Auto/--fit, or when not manual).",
)
n_cpu_moe: int = Field(
0,
description = "Manual mode: MoE expert layers pinned to CPU (--n-cpu-moe); 0 = none.",
)
tensor_split: Optional[List[float]] = Field(
None,
description = "Manual mode: relative model share per GPU (--tensor-split); None = default (split by free VRAM).",
)
n_layers: Optional[int] = Field(
None,
description = "Model's layer count (GGUF block_count), for the manual gpu-layers ceiling.",
)
n_moe_layers: int = Field(
0,
description = "Model's MoE expert-layer count (the n_cpu_moe ceiling); 0 if not an MoE model.",
)
gpu_ids: Optional[List[int]] = Field(
None,
description = "Physical GPU indices the model is pinned to, or None for automatic selection.",
)


class UnloadResponse(BaseModel):
Expand Down Expand Up @@ -398,6 +484,34 @@ class InferenceStatusResponse(BaseModel):
False,
description = "Whether tensor-parallel split (--split-mode tensor) is active.",
)
gpu_memory_mode: Literal["auto", "manual"] = Field(
"auto",
description = "Active GPU memory strategy ('auto' or 'manual').",
)
gpu_layers: int = Field(
-1,
description = "Manual mode: requested --gpu-layers value (-1 = Auto/--fit, or when not manual).",
)
n_cpu_moe: int = Field(
0,
description = "Manual mode: MoE expert layers pinned to CPU (--n-cpu-moe); 0 = none.",
)
tensor_split: Optional[List[float]] = Field(
None,
description = "Manual mode: relative model share per GPU (--tensor-split); None = default (split by free VRAM).",
)
n_layers: Optional[int] = Field(
None,
description = "Model's layer count (GGUF block_count), for the manual gpu-layers ceiling.",
)
n_moe_layers: int = Field(
0,
description = "Model's MoE expert-layer count (the n_cpu_moe ceiling); 0 if not an MoE model.",
)
gpu_ids: Optional[List[int]] = Field(
None,
description = "Physical GPU indices the model is pinned to, or None for automatic selection.",
)
llama_cpp_supports_mtp: bool = Field(
True,
description = (
Expand Down
Loading
Loading