Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Unsloth Studio MLX: Fast Verify toggle (#16259)

Long Yixingebb1293f110d
diff --git a/studio/backend/core/inference/mlx_inference.py b/studio/backend/core/inference/mlx_inference.py
index 09f7b00304d..62d7a9e8ed0 100644
--- a/studio/backend/core/inference/mlx_inference.py
+++ b/studio/backend/core/inference/mlx_inference.py
@@ -1160,10 +1160,20 @@ _MLX_LEGACY_SCOPES = (
)
+def _fast_verify_kwargs(fast_verify):
+ return {} if fast_verify is None else {"fast_verify": fast_verify}
+
+
@contextmanager
-def _mlx_inference_scopes(model, call, int8_prefill):
+def _mlx_inference_scopes(
+ model,
+ call,
+ int8_prefill,
+ fast_verify = None,
+):
"""Hold the Zoo scopes Zoo picks for `call` (its call traits), so a new Zoo scope needs no Studio change.
- A Zoo without the registry keeps the scopes Studio listed before it (none for the text batch)."""
+ A Zoo without the registry keeps the scopes Studio listed before it (none for the text batch).
+ `fast_verify` is the load's settled decision (None under a Zoo without it): a refusal here would drop every scope."""
compose = _mlx_inference_patch("inference_scopes")
with ExitStack() as scope:
if compose is None and "batch" not in call:
@@ -1179,6 +1189,7 @@ def _mlx_inference_scopes(model, call, int8_prefill):
call,
int8_prefill = int8_prefill,
on_error = _mlx_scope_refused,
+ **_fast_verify_kwargs(fast_verify),
)
)
except Exception as error:
@@ -1188,14 +1199,18 @@ def _mlx_inference_scopes(model, call, int8_prefill):
yield model
-def _mlx_warm_inference(model, int8_prefill):
+def _mlx_warm_inference(
+ model,
+ int8_prefill,
+ fast_verify = None,
+):
"""Zoo's warm-up generation, so the first request skips the scopes' kernel builds and first-use
checks. A Zoo without it, or a failed warm-up, leaves them to the first request."""
warm = _mlx_inference_patch("warm_inference")
if warm is None:
return
try:
- warm(model, int8_prefill = int8_prefill)
+ warm(model, int8_prefill = int8_prefill, **_fast_verify_kwargs(fast_verify))
except Exception as error:
if is_metal_queue_dead(error):
raise
@@ -1282,6 +1297,60 @@ def _ane_prefill_status(requested, model):
return status
+def _fast_verify_zoo():
+ """unsloth_zoo's MLX inference module when it can run Fast Verify, else None."""
+ try:
+ zoo = importlib.import_module("unsloth_zoo.mlx.inference")
+ if "fast_verify" in inspect.signature(zoo.inference_scopes).parameters:
+ return zoo
+ except Exception:
+ pass
+ return None
+
+
+def _fast_verify_status(requested, model):
+ """Whether a load builds any drafter for Fast Verify: asked for, and the loaded model can use it here."""
+ status = {"requested": bool(requested), "active": False, "reason": ""}
+ if not requested:
+ return status
+ zoo = _fast_verify_zoo()
+ if zoo is None:
+ status["reason"] = "unsupported_zoo"
+ return status
+ try:
+ verdict = zoo.fast_verify_available(model)
+ except Exception as exc:
+ if is_metal_queue_dead(exc):
+ raise
+ logger.warning("MLX Fast Verify check failed: %s", exc)
+ status["reason"] = "probe_failed"
+ return status
+ status["reason"] = verdict.reason
+ status["active"] = verdict.available
+ if not verdict.available:
+ logger.info("MLX Fast Verify not applied: %s", verdict.reason)
+ return status
+
+
+def _settle_fast_verify(status, model, drafter):
+ """Pin the load's decision on `model` once its drafter is built, so every later Zoo call agrees,
+ including those that take no argument and would read UNSLOTH_MLX_FAST_VERIFY. Without a drafter
+ it is off: Zoo's scopes serve only speculative calls, so a plain decode has nothing to gain."""
+ zoo = _fast_verify_zoo()
+ if zoo is None:
+ return status
+ decided = status["active"] and drafter is not None
+ try:
+ zoo.pin_fast_verify(model, decided)
+ except ValueError:
+ # A drafter that failed after pinning its target holds it until reload, so generations must follow.
+ logger.warning("MLX Fast Verify stays on without a drafter: a failed build pinned it")
+ return status
+ if decided == status["active"]:
+ return status
+ return {**status, "active": False, "reason": "no_drafter"}
+
+
_MLX_OFFLOAD_PARTS = (("ple", "PLE tables"), ("experts", "quantized routed experts"))
@@ -1557,6 +1626,19 @@ def mlx_ane_prefill_checkpoint_status(model_dir) -> tuple[bool, str]:
return answer
+def mlx_fast_verify_checkpoint_status(model_dir) -> tuple[bool, str]:
+ """(available, reason) of Fast Verify for a downloaded MLX checkpoint, without loading it."""
+ zoo = _fast_verify_zoo()
+ if zoo is None:
+ return False, "unsupported_zoo"
+ try:
+ verdict = zoo.fast_verify_checkpoint_available(model_dir)
+ except Exception as exc:
+ logger.debug("MLX Fast Verify checkpoint check failed for %s: %s", model_dir, exc)
+ return False, "probe_failed"
+ return bool(verdict.available), verdict.reason
+
+
def _vlm_generation_context():
import mlx.core as mx
from mlx_vlm.generate import generation_stream
@@ -5169,6 +5251,7 @@ class MLXInferenceBackend:
self._kv_quant = _kv_quant_status(None, None, False)
self._int8_prefill = _int8_prefill_status(False, None)
self._ane_prefill = _ane_prefill_status(False, None)
+ self._fast_verify = _fast_verify_status(False, None)
self._kv_cache_window = None
self._kv_context_budget = None
self._served_context = None
@@ -5256,6 +5339,7 @@ class MLXInferenceBackend:
self._kv_cache_window,
bool(self._int8_prefill.get("active")),
bool(self._ane_prefill.get("active")),
+ bool(self._fast_verify.get("active")),
self._prefill_step,
self._resume_load_args,
)
@@ -5599,7 +5683,13 @@ class MLXInferenceBackend:
"""Zoo's scopes for a generation of this load, under its Int8 Prefill decision. Nested in
_prefill_decision_scopes, which stays outermost."""
active = (getattr(self, "_int8_prefill", None) or {}).get("active", False)
- return _mlx_inference_scopes(self._model, call, active)
+ return _mlx_inference_scopes(self._model, call, active, self._fast_verify_decision())
+
+ def _fast_verify_decision(self):
+ """This load's settled Fast Verify, or None under a Zoo that takes no such argument."""
+ if _fast_verify_zoo() is None:
+ return None
+ return (getattr(self, "_fast_verify", None) or {}).get("active", False)
def _kv_quant_bits(self):
return (getattr(self, "_kv_quant", None) or {}).get("kv_bits")
@@ -5867,6 +5957,7 @@ class MLXInferenceBackend:
chat_template_override = None,
int8_prefill = False,
ane_prefill = False,
+ fast_verify = False,
speculative_type = None,
spec_draft_n_max = None,
spec_draft_model = None,
@@ -6155,6 +6246,7 @@ class MLXInferenceBackend:
if spec_mode == "auto" and not spec_draft_model
else mlx_speculative.RUNTIME_ERROR
)
+ self._fast_verify = _fast_verify_status(fast_verify, self._model)
if speculates:
model_dir = _snapshot_dir(self._model, model_name)
resolution = mlx_speculative.resolve_speculation(
@@ -6197,6 +6289,7 @@ class MLXInferenceBackend:
fits = _fits,
stretch = _stretch,
draft_n_max = _positive_int(spec_draft_n_max),
+ fast_verify = self._fast_verify_decision(),
)
logger.info(
"MLX speculative decoding: %s (mode %s, reason %s)",
@@ -6204,6 +6297,9 @@ class MLXInferenceBackend:
spec_mode,
spec_reason,
)
+ self._fast_verify = _settle_fast_verify(
+ self._fast_verify, self._model, getattr(self._speculative_draft, "drafter", None)
+ )
# TurboQuant's layout is not one the planner prices, and a refused one stays full width:
# fit either at full width, which only ever under-promises.
_requested_bits = None if self._turboquant else _normalize_mlx_kv_bits(kv_bits)
@@ -6355,6 +6451,9 @@ class MLXInferenceBackend:
"mlx_ane_prefill": self._ane_prefill["active"],
"mlx_ane_prefill_requested": self._ane_prefill["requested"],
"mlx_ane_prefill_reason": self._ane_prefill["reason"],
+ "mlx_fast_verify": self._fast_verify["active"],
+ "mlx_fast_verify_requested": self._fast_verify["requested"],
+ "mlx_fast_verify_reason": self._fast_verify["reason"],
"mlx_offload": _offload,
"chat_template_override_requested": self._template_override["requested"],
"chat_template_override_reason": self._template_override["reason"],
@@ -6373,7 +6472,9 @@ class MLXInferenceBackend:
# Every rank of a distributed load must run each forward together.
if not is_distributed:
with mlx_rng_preserved(), self._prefill_decision_scopes():
- _mlx_warm_inference(model, self._int8_prefill["active"])
+ _mlx_warm_inference(
+ model, self._int8_prefill["active"], self._fast_verify_decision()
+ )
if self._ane_prefill["active"]:
self._ane_prefill = _ane_prefill_status(True, model)
self.models[model_name].update(
@@ -6484,6 +6585,7 @@ class MLXInferenceBackend:
except Exception as exc:
logger.warning("MLX Neural Engine prefill release failed: %s", exc)
self._ane_prefill = _ane_prefill_status(False, None)
+ self._fast_verify = _fast_verify_status(False, None)
if model_name in self.models:
del self.models[model_name]
self._speculative_draft = None
diff --git a/studio/backend/core/inference/mlx_speculative.py b/studio/backend/core/inference/mlx_speculative.py
index 30e708cc819..29c530e5db3 100644
--- a/studio/backend/core/inference/mlx_speculative.py
+++ b/studio/backend/core/inference/mlx_speculative.py
@@ -375,22 +375,25 @@ def build_draft(
fits,
stretch = None,
draft_n_max: Optional[int] = None,
+ fast_verify: Optional[bool] = None,
) -> tuple:
"""``(draft, kind, reason, context)`` for the first source ``fits`` accepts that builds, else copies
alone when the mode allows. ``reason`` names a passed-over choice, so a substitute never attaches silently.
- A chosen mode with none that fits attaches an unfit source ``stretch`` (its fit under MLX's own cap) admits."""
+ A chosen mode with none that fits attaches an unfit source ``stretch`` (its fit under MLX's own cap) admits.
+ ``fast_verify`` is None under a zoo without it, whose factories take no such argument."""
from unsloth_zoo.mlx.speculative import companion_drafter, native_mtp_drafter
if _carries_encoder_state(target):
logger.info("MLX speculative decoding: %s carries encoder state", type(target).__name__)
return None, None, None if resolution.mode == "auto" else RUNTIME_ERROR, None
reason, incompatible, unfit = resolution.reason, False, []
+ decision = {} if fast_verify is None else {"fast_verify": fast_verify}
def build(source):
nonlocal reason, incompatible
try:
drafter = (native_mtp_drafter if source.builtin else companion_drafter)(
- source.path, target
+ source.path, target, **decision
)
if drafter is None:
raise ValueError("no MTP splitter knows this checkpoint")
diff --git a/studio/backend/core/inference/orchestrator.py b/studio/backend/core/inference/orchestrator.py
index 933cb7b384c..3482c4d53e6 100644
--- a/studio/backend/core/inference/orchestrator.py
+++ b/studio/backend/core/inference/orchestrator.py
@@ -277,6 +277,9 @@ _MLX_RUNTIME_MIRROR_FIELDS = (
"mlx_ane_prefill",
"mlx_ane_prefill_requested",
"mlx_ane_prefill_reason",
+ "mlx_fast_verify",
+ "mlx_fast_verify_requested",
+ "mlx_fast_verify_reason",
"mlx_offload",
"chat_template_override_requested",
"chat_template_override_reason",
@@ -2009,6 +2012,7 @@ class InferenceOrchestrator:
mlx_kv_quant: Optional[str] = None,
mlx_int8_prefill: bool = False,
mlx_ane_prefill: bool = False,
+ mlx_fast_verify: bool = False,
mlx_offload: tuple = (None, None),
speculative_type: Optional[str] = None,
spec_draft_n_max: Optional[int] = None,
@@ -2088,6 +2092,7 @@ class InferenceOrchestrator:
"mlx_kv_quant": mlx_kv_quant,
"mlx_int8_prefill": bool(mlx_int8_prefill),
"mlx_ane_prefill": bool(mlx_ane_prefill),
+ "mlx_fast_verify": bool(mlx_fast_verify),
"mlx_offload": tuple(mlx_offload),
"speculative_type": speculative_type,
"spec_draft_n_max": spec_draft_n_max,
diff --git a/studio/backend/core/inference/worker.py b/studio/backend/core/inference/worker.py
index a5cd65fb2b1..243bc14d91a 100644
--- a/studio/backend/core/inference/worker.py
+++ b/studio/backend/core/inference/worker.py
@@ -794,6 +794,7 @@ def _handle_load(backend, config: dict, resp_queue: Any) -> None:
load_kwargs["kv_quant"] = config.get("mlx_kv_quant")
load_kwargs["int8_prefill"] = bool(config.get("mlx_int8_prefill"))
load_kwargs["ane_prefill"] = bool(config.get("mlx_ane_prefill"))
+ load_kwargs["fast_verify"] = bool(config.get("mlx_fast_verify"))
load_kwargs["offload"] = tuple(config.get("mlx_offload") or (None, None))
load_kwargs["speculative_type"] = config.get("speculative_type")
load_kwargs["spec_draft_n_max"] = config.get("spec_draft_n_max")
@@ -905,6 +906,9 @@ def _handle_load(backend, config: dict, resp_queue: Any) -> None:
"mlx_ane_prefill",
"mlx_ane_prefill_requested",
"mlx_ane_prefill_reason",
+ "mlx_fast_verify",
+ "mlx_fast_verify_requested",
+ "mlx_fast_verify_reason",
"mlx_offload",
"chat_template_override_requested",
"chat_template_override_reason",
diff --git a/studio/backend/models/inference.py b/studio/backend/models/inference.py
index 96c25e3071d..e10bb664172 100644
--- a/studio/backend/models/inference.py
+++ b/studio/backend/models/inference.py
@@ -224,6 +224,15 @@ class LoadRequest(BaseModel):
"measured faster here; the status reports the reason otherwise."
),
)
+ mlx_fast_verify: bool = Field(
+ False,
+ description = (
+ "Experimental, MLX only: verify a drafter's tokens on faster kernels during speculative "
+ "decoding. Changes decode output slightly against plain greedy decoding, repeatably. "
+ "Applied only when the load attaches a drafter and the model supports it; the status "
+ "reports the reason otherwise. Decided at load: changing it reloads the model."
+ ),
+ )
mlx_ple_offload: MlxOffload = Field(
None,
description = (
@@ -1211,6 +1220,27 @@ class AnePrefillAvailabilityResponse(BaseModel):
)
+class FastVerifyAvailabilityRequest(BaseModel):
+ """A model whose run settings may offer MLX Fast Verify."""
+
+ model_path: str = Field(..., description = "Model identifier or local path")
+ hf_token: Optional[str] = Field(None, description = "Token for gated repositories")
+
+ _resolve_the_handle = field_validator("model_path")(resolve_inventory_handle)
+
+
+class FastVerifyAvailabilityResponse(BaseModel):
+ """Whether a load of this model could run MLX Fast Verify, judged from its downloaded files."""
+
+ available: bool
+ reason: Optional[str] = Field(
+ None,
+ description = "Cause when available is false: 'not_downloaded', 'unsupported_model', "
+ "'unsupported_zoo', or unsloth_zoo's own reason ('no_lane_kernel', "
+ "'no_eligible_projections', 'probe_failed').",
+ )
+
+
class MlxDraftersRequest(BaseModel):
model_path: str = Field(..., description = "Model identifier or local path of the target")
@@ -1873,6 +1903,16 @@ class _InferenceRuntimeFields(BaseModel):
description = "Why requested Neural Engine prefill is not active, as unsloth_zoo reports it "
"(for example no_neural_engine, no_eligible_mlps, no_gain, not_enough_memory or released)",
)
+ mlx_fast_verify: Optional[bool] = Field(
+ None, description = "Whether MLX Fast Verify is active for the loaded model"
+ )
+ mlx_fast_verify_requested: Optional[bool] = Field(
+ None, description = "Whether the load asked for MLX Fast Verify"
+ )
+ mlx_fast_verify_reason: Optional[str] = Field(
+ None,
+ description = "Why requested Fast Verify is not active: no_drafter, unsupported_zoo, or unsloth_zoo's reason",
+ )
mlx_offload: Optional[MlxOffloadStatus] = Field(None, description = "MLX: weights read from disk")
chat_template: Optional[str] = Field(
None,
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index 1d9fea30ff5..de87baa8a2f 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -3466,6 +3466,8 @@ from models.inference import (
Int8PrefillAvailabilityResponse,
AnePrefillAvailabilityRequest,
AnePrefillAvailabilityResponse,
+ FastVerifyAvailabilityRequest,
+ FastVerifyAvailabilityResponse,
MlxDraftersRequest,
MlxDraftersResponse,
TransformersUpgradeInfo,
@@ -8308,6 +8310,9 @@ def _llama_runtime_fields(llama_backend: LlamaCppBackend) -> dict:
mlx_ane_prefill = None,
mlx_ane_prefill_requested = None,
mlx_ane_prefill_reason = None,
+ mlx_fast_verify = None,
+ mlx_fast_verify_requested = None,
+ mlx_fast_verify_reason = None,
mlx_offload = None,
mlx_context_budget = None,
spec_draft_model = None,
@@ -17237,6 +17242,8 @@ def _mlx_runtime_settings_match(backend, request) -> bool:
== bool(getattr(request, "mlx_int8_prefill", False))
and bool(entry.get("mlx_ane_prefill_requested"))
== bool(getattr(request, "mlx_ane_prefill", False))
+ and bool(entry.get("mlx_fast_verify_requested"))
+ == bool(getattr(request, "mlx_fast_verify", False))
and all(
normalize_mlx_offload(
((entry.get("mlx_offload") or {}).get(part) or {}).get("requested")
@@ -18995,6 +19002,9 @@ async def _load_model_impl(
mlx_ane_prefill = _model_info.get("mlx_ane_prefill"),
mlx_ane_prefill_requested = _model_info.get("mlx_ane_prefill_requested"),
mlx_ane_prefill_reason = _model_info.get("mlx_ane_prefill_reason"),
+ mlx_fast_verify = _model_info.get("mlx_fast_verify"),
+ mlx_fast_verify_requested = _model_info.get("mlx_fast_verify_requested"),
+ mlx_fast_verify_reason = _model_info.get("mlx_fast_verify_reason"),
mlx_offload = _model_info.get("mlx_offload"),
memory_warning = _mlx_offload_warning(_model_info),
# Requested, as /status reports it: a null override would read
@@ -19666,6 +19676,7 @@ async def _load_model_impl(
mlx_kv_quant = request.mlx_kv_quant,
mlx_int8_prefill = request.mlx_int8_prefill,
mlx_ane_prefill = request.mlx_ane_prefill,
+ mlx_fast_verify = request.mlx_fast_verify,
mlx_offload = (request.mlx_ple_offload, request.mlx_expert_offload),
speculative_type = request.speculative_type,
spec_draft_n_max = request.spec_draft_n_max,
@@ -19864,6 +19875,9 @@ async def _load_model_impl(
mlx_ane_prefill = _model_info.get("mlx_ane_prefill"),
mlx_ane_prefill_requested = _model_info.get("mlx_ane_prefill_requested"),
mlx_ane_prefill_reason = _model_info.get("mlx_ane_prefill_reason"),
+ mlx_fast_verify = _model_info.get("mlx_fast_verify"),
+ mlx_fast_verify_requested = _model_info.get("mlx_fast_verify_requested"),
+ mlx_fast_verify_reason = _model_info.get("mlx_fast_verify_reason"),
mlx_offload = _model_info.get("mlx_offload"),
memory_warning = _mlx_offload_warning(_model_info),
# Requested, as /status reports it: a null override would read as
@@ -21083,6 +21097,18 @@ async def ane_prefill_availability(
)
[email protected]("/fast-verify-availability", response_model = FastVerifyAvailabilityResponse)
+async def fast_verify_availability(
+ request: FastVerifyAvailabilityRequest, current_subject: str = Depends(get_current_subject)
+):
+ """Whether MLX Fast Verify could apply to this model, judged from its downloaded checkpoint
+ without loading it; whether a drafter attaches still decides at load."""
+ from core.inference.mlx_inference import mlx_fast_verify_checkpoint_status
+ return await _mlx_prefill_option_availability(
+ request, FastVerifyAvailabilityResponse, mlx_fast_verify_checkpoint_status
+ )
+
+
@router.post("/estimate-memory", response_model = EstimateMemoryResponse)
async def estimate_memory(
request: EstimateMemoryRequest,
@@ -22415,6 +22441,9 @@ async def _slot_status(current_subject: str):
mlx_ane_prefill = model_info.get("mlx_ane_prefill"),
mlx_ane_prefill_requested = model_info.get("mlx_ane_prefill_requested"),
mlx_ane_prefill_reason = model_info.get("mlx_ane_prefill_reason"),
+ mlx_fast_verify = model_info.get("mlx_fast_verify"),
+ mlx_fast_verify_requested = model_info.get("mlx_fast_verify_requested"),
+ mlx_fast_verify_reason = model_info.get("mlx_fast_verify_reason"),
mlx_offload = model_info.get("mlx_offload"),
memory_warning = _mlx_offload_warning(model_info),
chat_template_override = model_info.get("chat_template_override_requested"),
diff --git a/studio/backend/routes/settings.py b/studio/backend/routes/settings.py
index 7dfd588211a..226329c1d31 100644
--- a/studio/backend/routes/settings.py
+++ b/studio/backend/routes/settings.py
@@ -1064,6 +1064,7 @@ class ModelOverridePayload(BaseModel):
disable_vision: bool = False
mlx_int8_prefill: bool = False
mlx_ane_prefill: bool = False
+ mlx_fast_verify: bool = False
# Auto (null or "auto") is stored as absence; omitted keeps the stored value.
mlx_ple_offload: Optional[Union[Literal["auto", "off"], float]] = None
mlx_expert_offload: Optional[Union[Literal["auto", "off"], float]] = None
@@ -2694,6 +2695,7 @@ def update_openai_auto_switch_override(
and not payload.disable_vision
and not payload.mlx_int8_prefill
and not payload.mlx_ane_prefill
+ and not payload.mlx_fast_verify
and payload.load_in_4bit
# null clears just that knob, so naming one is not a forget.
and not {"mlx_ple_offload", "mlx_expert_offload"} & payload.model_fields_set
@@ -2706,6 +2708,7 @@ def update_openai_auto_switch_override(
"disable_vision",
"mlx_int8_prefill",
"mlx_ane_prefill",
+ "mlx_fast_verify",
"load_in_4bit",
)
}
@@ -2932,6 +2935,7 @@ def update_openai_auto_switch_override(
disable_vision = payload.disable_vision,
mlx_int8_prefill = payload.mlx_int8_prefill,
mlx_ane_prefill = payload.mlx_ane_prefill,
+ mlx_fast_verify = payload.mlx_fast_verify,
load_in_4bit = payload.load_in_4bit,
chat_template_override = payload.chat_template_override,
gpu_memory_mode = payload.gpu_memory_mode,
diff --git a/studio/backend/tests/test_gguf_load_cache_reuse.py b/studio/backend/tests/test_gguf_load_cache_reuse.py
index bc90145555c..ead77c40aca 100644
--- a/studio/backend/tests/test_gguf_load_cache_reuse.py
+++ b/studio/backend/tests/test_gguf_load_cache_reuse.py
@@ -1201,6 +1201,9 @@ class TestLoadHubDownloadExclusion:
"mlx_ane_prefill",
"mlx_ane_prefill_requested",
"mlx_ane_prefill_reason",
+ "mlx_fast_verify",
+ "mlx_fast_verify_requested",
+ "mlx_fast_verify_reason",
"mlx_offload",
"mlx_context_budget",
"spec_draft_model",
diff --git a/studio/backend/tests/test_memory_estimate.py b/studio/backend/tests/test_memory_estimate.py
index 5f041882416..b2443db63c4 100644
--- a/studio/backend/tests/test_memory_estimate.py
+++ b/studio/backend/tests/test_memory_estimate.py
@@ -1647,6 +1647,30 @@ class TestPrefillOptionAvailabilityRoute:
assert asked == ([model_dir] if answer[0] else [])
+class TestFastVerifyAvailabilityRoute:
+ @pytest.mark.parametrize(
+ "capable,verdict,answer",
+ [
+ (True, (True, ""), (True, None)),
+ (True, (False, "no_lane_kernel"), (False, "no_lane_kernel")),
+ (False, (True, ""), (False, "unsupported_zoo")),
+ ],
+ )
+ def test_the_answer(self, monkeypatch, tmp_path, capable, verdict, answer):
+ import models.inference as models
+
+ zoo = _types.ModuleType("unsloth_zoo.mlx.inference")
+ zoo.inference_scopes = (lambda m, fast_verify = None: m) if capable else (lambda m: m)
+ zoo.fast_verify_checkpoint_available = lambda path: SimpleNamespace(
+ available = verdict[0], reason = verdict[1]
+ )
+ monkeypatch.setitem(sys.modules, "unsloth_zoo.mlx.inference", zoo)
+ TestEstimateMemoryRoute._mlx_target(monkeypatch, str(tmp_path))
+ request = models.FastVerifyAvailabilityRequest(model_path = "org/model")
+ resp = asyncio.run(ri.fast_verify_availability(request, current_subject = "test"))
+ assert (resp.available, resp.reason) == answer
+
+
class TestParallelSlotResolution:
"""Blank Parallel Slots means the server default (four in a standard launch), so price it, not one."""
diff --git a/studio/backend/tests/test_mlx_inference_backend.py b/studio/backend/tests/test_mlx_inference_backend.py
index 0d97510b709..ee429bb8542 100644
--- a/studio/backend/tests/test_mlx_inference_backend.py
+++ b/studio/backend/tests/test_mlx_inference_backend.py
@@ -65,6 +65,8 @@ def _stub_inference_scopes(module):
ane_prefill = None,
on_error = None,
_modules = None,
+ # Newer zoo keywords (fast_verify), unnamed so Studio's signature probe still reads this stub as an older zoo.
+ **_newer,
):
# The call-shape replay below passes placeholders; anything but a tuple serves every scope.
traits = set(call) if isinstance(call, tuple) else None
@@ -128,7 +130,14 @@ def _fusion_modules(model, modules):
# Plain-function helpers zoo's generate.py imports; the neutral scope cannot stand in for them.
-PLAIN_HELPERS = {"_fusion_modules": _fusion_modules}
+PLAIN_HELPERS = {
+ "_fusion_modules": _fusion_modules,
+ # Private names zoo's speculative.py imports (unsloth_zoo #2330); only their presence matters here.
+ "_SparseDrafter": type(
+ "_SparseDrafter", (), {"__init__": lambda self, *_args, **_kwargs: None}
+ ),
+ "_VERIFY_GDN_MAX_ROWS": 16,
+}
def _fused_drafter_ops(model, *_args, **_kwargs):
@@ -138,7 +147,15 @@ def _fused_drafter_ops(model, *_args, **_kwargs):
# Plain calls whose zoo body cannot run here, so the stub returns their do-nothing answer instead.
-NEUTRAL_PLAIN_HELPERS = {"fused_drafter_ops": _fused_drafter_ops}
+def _unless_failed_buffer(error):
+ """zoo re-raises a failed Metal command buffer (unsloth_zoo #2333); the stub has none to fail."""
+
+
+NEUTRAL_PLAIN_HELPERS = {
+ "fused_drafter_ops": _fused_drafter_ops,
+ "fused_drafter_layers": _fused_drafter_ops,
+ "_unless_failed_buffer": _unless_failed_buffer,
+}
def _neutral_zoo_helper(name):
@@ -5796,6 +5813,133 @@ def test_ane_prefill_is_pinned_inside_int8_released_on_unload_and_reloads_on_cha
pytest.fail("the Neural Engine scope's error was swallowed")
+def _fast_verify_zoo(module, *verdict):
+ """Zoo's pin over the stub: `calls` holds what Zoo calls were told, with a refusal recorded as raised."""
+ calls, pinned = [], {}
+ inner = module.inference_scopes
+ available, reason = verdict or (True, "")
+
+ def pin_fast_verify(model, fast_verify = None):
+ if pinned.setdefault(id(model), fast_verify) != fast_verify:
+ raise ValueError("pinned the other way")
+
+ @contextmanager
+ def inference_scopes(model, call, *, fast_verify, **others):
+ calls.append(("scopes", fast_verify))
+ if pinned.get(id(model), fast_verify) != fast_verify:
+ calls.append("refused")
+ raise ValueError("pinned the other way")
+ with inner(model, call, **others):
+ yield model
+
+ module.inference_scopes = inference_scopes
+ module.pin_fast_verify = pin_fast_verify
+ module.fast_verify_available = lambda m: SimpleNamespace(available = available, reason = reason)
+ module.warm_inference = lambda m, fast_verify, **_: calls.append(("warm", fast_verify))
+ return calls, pinned
+
+
+def _load_for_fast_verify(monkeypatch, drafter, requested, mode, build):
+ from core.inference import mlx_speculative
+
+ backend = _install_fake_text_stack(monkeypatch, {"p": [1, 2], "generated": [7, 8]}, [])
+ _install_fake_fast_mlx(monkeypatch, [])
+ sys.modules["mlx.core"].clear_cache = lambda: None
+ told = []
+
+ def build_draft(target, resolution, **kwargs):
+ told.append(kwargs.get("fast_verify"))
+ if build is not None:
+ build(target, kwargs.get("fast_verify"))
+ draft = None if drafter is None else SimpleNamespace(drafter = drafter)
+ return draft, "dflash" if drafter else None, None, None
+
+ monkeypatch.setattr(mlx_speculative, "speculation_refusal", lambda **k: None)
+ resolved = lambda m, *a, **k: mlx_speculative.SpecResolution(m)
+ monkeypatch.setattr(mlx_speculative, "resolve_speculation", resolved)
+ monkeypatch.setattr(mlx_speculative, "build_draft", build_draft)
+ config = SimpleNamespace(identifier = "fake/text", is_vision = False, is_lora = False)
+ assert backend.load_model(config, speculative_type = mode, fast_verify = requested) is True
+ return backend, told, backend.models["fake/text"]
+
+
+def test_fast_verify_reloads_on_change_and_reports_why_it_is_off(mlx_inference_patches):
+ from core.inference import mlx_inference, orchestrator
+ from models.inference import LoadRequest
+ from routes.inference import _mlx_runtime_settings_match
+
+ req = lambda **knobs: LoadRequest(model = "m", model_path = "m", **knobs)
+ entry = {"mlx_kv_quant_requested": "auto", "mlx_fast_verify_requested": False}
+ be = SimpleNamespace(active_model_name = "m", models = {"m": entry})
+ assert _mlx_runtime_settings_match(be, req())
+ assert not _mlx_runtime_settings_match(be, req(mlx_fast_verify = True))
+ entry["mlx_fast_verify_requested"] = True
+ assert _mlx_runtime_settings_match(be, req(mlx_fast_verify = True))
+ assert not _mlx_runtime_settings_match(be, req())
+ assert "mlx_fast_verify_requested" in orchestrator._MLX_RUNTIME_MIRROR_FIELDS
+
+ status = lambda *a: mlx_inference._fast_verify_status(*a)["reason"]
+ assert status(True, object()) == "unsupported_zoo"
+ _fast_verify_zoo(mlx_inference_patches)
+ mlx_inference_patches.fast_verify_available = None # raises inside the check
+ assert status(True, object()) == "probe_failed"
+
+
+ "requested,available,drafter,mode,active,reason,told",
+ [
+ (True, True, object(), "dflash", True, "", [True]),
+ (False, True, object(), "dflash", False, "", [False]),
+ (True, False, object(), "dflash", False, "no_lane_kernel", [False]),
+ (True, True, None, "dflash", False, "no_drafter", [True]), # built for it, nothing attached
+ (True, True, None, "off", False, "no_drafter", []),
+ ],
+)
+def test_a_load_tells_every_zoo_call_one_fast_verify_decision(
+ monkeypatch, mlx_inference_patches, requested, available, drafter, mode, active, reason, told
+):
+ calls, pinned = _fast_verify_zoo(
+ mlx_inference_patches, available, "" if available else "no_lane_kernel"
+ )
+ backend, heard, entry = _load_for_fast_verify(monkeypatch, drafter, requested, mode, None)
+ assert (entry["mlx_fast_verify"], entry["mlx_fast_verify_reason"]) == (active, reason)
+ assert entry["mlx_fast_verify_requested"] is requested
+ assert heard == told and pinned == {id(backend._model): active}
+ assert calls == [("warm", active)]
+ for call in ((), ("batch",), ("vision", "speculative")):
+ with backend._generation_scopes(*call):
+ pass
+ assert calls[1:] == [("scopes", active)] * 3
+ assert backend.unload_model("fake/text") and not backend._fast_verify["requested"]
+
+
+def test_a_drafter_that_failed_after_pinning_keeps_fast_verify_on(
+ monkeypatch, mlx_inference_patches
+):
+ calls, pinned = _fast_verify_zoo(mlx_inference_patches)
+ pin = mlx_inference_patches.pin_fast_verify
+ backend, _, entry = _load_for_fast_verify(monkeypatch, None, True, "dflash", pin)
+ assert (entry["mlx_fast_verify"], entry["mlx_fast_verify_reason"]) == (True, "")
+ assert pinned == {id(backend._model): True}
+ with backend._generation_scopes():
+ pass
+ assert calls[-1] == ("scopes", True) and "refused" not in calls
+
+
+def test_a_zoo_without_fast_verify_is_never_told_of_it(monkeypatch, mlx_inference_patches):
+ from core.inference import mlx_inference
+
+ warmed = []
+ mlx_inference_patches.warm_inference = lambda m, int8_prefill = None: warmed.append(int8_prefill)
+ backend, told, entry = _load_for_fast_verify(monkeypatch, object(), True, "dflash", None)
+ assert (entry["mlx_fast_verify"], entry["mlx_fast_verify_reason"]) == (False, "unsupported_zoo")
+ assert told == [None] and warmed == [False]
+ refused = _capture_rng_warnings(monkeypatch, mlx_inference)
+ with backend._generation_scopes():
+ pass
+ assert not refused and backend._fast_verify_decision() is None
+
+
def test_a_batch_session_holds_int8_prefill_for_its_whole_life(monkeypatch, mlx_inference_patches):
from core.inference import mlx_inference
diff --git a/studio/backend/tests/test_mlx_speculative.py b/studio/backend/tests/test_mlx_speculative.py
index 9bc14d8083a..6a94f478b9c 100644
--- a/studio/backend/tests/test_mlx_speculative.py
+++ b/studio/backend/tests/test_mlx_speculative.py
@@ -144,6 +144,37 @@ def test_cached_drafters_are_matched_by_shape_and_weights_then_marked_by_name(ca
assert spec._stem("g/gemma-4-31B-it-qat-q4_0-unquantized-assistant") == "gemma431bit"
[email protected]("decision", [None, False, True])
+def test_a_drafter_build_hears_fast_verify_only_from_a_zoo_that_takes_it(monkeypatch, decision):
+ drafters = pytest.importorskip("unsloth_zoo.mlx.speculative")
+ told = []
+ factory = lambda path, target, **kw: told.append(kw) or SimpleNamespace(max_depth = 8)
+ monkeypatch.setattr(drafters, "companion_drafter", factory)
+ monkeypatch.setattr(drafters, "native_mtp_drafter", factory)
+ sources = (spec.DrafterSource("dflash", "a", False), spec.DrafterSource("mtp", "b", True))
+ for source in sources:
+ resolution = spec.SpecResolution("dflash", (source,))
+ spec.build_draft(None, resolution, fits = lambda _: (True, None), fast_verify = decision)
+ assert told == [{} if decision is None else {"fast_verify": decision}] * 2
+
+
+def test_the_installed_zoo_refuses_a_fast_verify_flip_or_reports_no_support():
+ import inspect
+
+ from core.inference import mlx_inference as mi
+
+ zoo = pytest.importorskip("unsloth_zoo.mlx.inference")
+ if "fast_verify" not in inspect.signature(zoo.inference_scopes).parameters:
+ assert mi._fast_verify_status(True, object())["reason"] == "unsupported_zoo"
+ assert mi.mlx_fast_verify_checkpoint_status("/none") == (False, "unsupported_zoo")
+ return
+ assert mi._fast_verify_zoo() is zoo
+ target = SimpleNamespace()
+ zoo.pin_fast_verify(target, True)
+ with pytest.raises(ValueError):
+ zoo.pin_fast_verify(target, False)
+
+
def test_a_drafter_passed_over_keeps_its_reason_on_the_one_that_attaches(monkeypatch):
drafters = pytest.importorskip("unsloth_zoo.mlx.speculative")
diff --git a/studio/backend/tests/test_openai_auto_switch.py b/studio/backend/tests/test_openai_auto_switch.py
index f07081efdb9..8f6b6b87647 100644
--- a/studio/backend/tests/test_openai_auto_switch.py
+++ b/studio/backend/tests/test_openai_auto_switch.py
@@ -9105,7 +9105,7 @@ def test_mlx_kv_quant_survives_the_whole_override_projection():
assert LoadRequest(model_path = "unsloth/A", **kwargs).mlx_kv_quant == "tq-4"
[email protected]("knob", ["mlx_int8_prefill", "mlx_ane_prefill"])
[email protected]("knob", ["mlx_int8_prefill", "mlx_ane_prefill", "mlx_fast_verify"])
def test_mlx_prefill_options_are_stored_only_when_on_and_reach_the_load(monkeypatch, knob):
_mock_override_store(monkeypatch)
assert settings.normalize_model_override({knob: False}) == {}
diff --git a/studio/backend/utils/openai_auto_switch_settings.py b/studio/backend/utils/openai_auto_switch_settings.py
index 9591afaca15..4dbc5699f70 100644
--- a/studio/backend/utils/openai_auto_switch_settings.py
+++ b/studio/backend/utils/openai_auto_switch_settings.py
@@ -553,6 +553,9 @@ def normalize_model_override(
if _coerce_bool(payload.get("mlx_ane_prefill")):
entry["mlx_ane_prefill"] = True
+ if _coerce_bool(payload.get("mlx_fast_verify")):
+ entry["mlx_fast_verify"] = True
+
for key in ("mlx_ple_offload", "mlx_expert_offload"):
value = payload.get(key)
if value == "off" or (
@@ -706,6 +709,7 @@ def model_override_load_kwargs(override: dict[str, Any], *, is_gguf: bool) -> di
("chat_template_override", "chat_template_override"),
("mlx_int8_prefill", "mlx_int8_prefill"),
("mlx_ane_prefill", "mlx_ane_prefill"),
+ ("mlx_fast_verify", "mlx_fast_verify"),
("mlx_ple_offload", "mlx_ple_offload"),
("mlx_expert_offload", "mlx_expert_offload"),
):
diff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.ts
index 30e65d2fdb8..d26f06f51a2 100644
--- a/studio/frontend/src/features/chat/api/chat-adapter.ts
+++ b/studio/frontend/src/features/chat/api/chat-adapter.ts
@@ -2735,6 +2735,8 @@ const VISIBLE_MODEL_RUNTIME_KEYS = [
"loadedMlxInt8PrefillRequested",
"mlxAnePrefill",
"loadedMlxAnePrefillRequested",
+ "mlxFastVerify",
+ "loadedMlxFastVerifyRequested",
"mlxPleOffload",
"mlxExpertOffload",
"loadedMlxPleOffloadRequested",
@@ -3711,6 +3713,7 @@ async function autoLoadSmallestModel(options?: AutoLoadOptions): Promise<{
mlx_kv_quant: config.mlxKvQuant ?? null,
mlx_int8_prefill: config.mlxInt8Prefill ?? false,
mlx_ane_prefill: config.mlxAnePrefill ?? false,
+ mlx_fast_verify: config.mlxFastVerify ?? false,
mlx_ple_offload: config.mlxPleOffload ?? null,
mlx_expert_offload: config.mlxExpertOffload ?? null,
speculative_type: effectiveSpeculativeType,
diff --git a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts
index 4a3ae6fdecc..2e19ad8cbb0 100644
--- a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts
+++ b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts
@@ -1974,6 +1974,9 @@ export function useChatModelRuntime() {
const previousMlxAnePrefill = rollbackConfig
? (rollbackConfig.mlxAnePrefill ?? false)
: useChatRuntimeStore.getState().mlxAnePrefill;
+ const previousMlxFastVerify = rollbackConfig
+ ? (rollbackConfig.mlxFastVerify ?? false)
+ : useChatRuntimeStore.getState().mlxFastVerify;
const previousMlxPleOffload = rollbackConfig
? (rollbackConfig.mlxPleOffload ?? null)
: useChatRuntimeStore.getState().mlxPleOffload;
@@ -2068,6 +2071,9 @@ export function useChatModelRuntime() {
let loadMlxAnePrefill = pendingLoadConfig
? (pendingLoadConfig.mlxAnePrefill ?? false)
: stateBeforeUnload.mlxAnePrefill;
+ let loadMlxFastVerify = pendingLoadConfig
+ ? (pendingLoadConfig.mlxFastVerify ?? false)
+ : stateBeforeUnload.mlxFastVerify;
let loadMlxPleOffload = pendingLoadConfig
? (pendingLoadConfig.mlxPleOffload ?? null)
: stateBeforeUnload.mlxPleOffload;
@@ -2242,6 +2248,7 @@ export function useChatModelRuntime() {
loadMlxKvQuant = pendingLoadConfig?.mlxKvQuant ?? null;
loadMlxInt8Prefill = pendingLoadConfig?.mlxInt8Prefill ?? false;
loadMlxAnePrefill = pendingLoadConfig?.mlxAnePrefill ?? false;
+ loadMlxFastVerify = pendingLoadConfig?.mlxFastVerify ?? false;
loadMlxPleOffload = pendingLoadConfig?.mlxPleOffload ?? null;
loadMlxExpertOffload = pendingLoadConfig?.mlxExpertOffload ?? null;
loadChatTemplateOverride =
@@ -2346,6 +2353,7 @@ export function useChatModelRuntime() {
mlx_kv_quant: loadMlxKvQuant ?? null,
mlx_int8_prefill: loadMlxInt8Prefill,
mlx_ane_prefill: loadMlxAnePrefill,
+ mlx_fast_verify: loadMlxFastVerify,
mlx_ple_offload: loadMlxPleOffload,
mlx_expert_offload: loadMlxExpertOffload,
speculative_type: loadSpeculativeType,
@@ -2929,6 +2937,7 @@ export function useChatModelRuntime() {
mlx_kv_quant: rollbackState.loadedMlxKvQuantRequested,
mlx_int8_prefill: rollbackState.loadedMlxInt8PrefillRequested,
mlx_ane_prefill: rollbackState.loadedMlxAnePrefillRequested,
+ mlx_fast_verify: rollbackState.loadedMlxFastVerifyRequested,
mlx_ple_offload: rollbackState.loadedMlxPleOffloadRequested,
mlx_expert_offload: rollbackState.loadedMlxExpertOffloadRequested,
speculative_type:
@@ -3027,6 +3036,7 @@ export function useChatModelRuntime() {
mlxKvQuant: previousMlxKvQuant,
mlxInt8Prefill: previousMlxInt8Prefill,
mlxAnePrefill: previousMlxAnePrefill,
+ mlxFastVerify: previousMlxFastVerify,
mlxPleOffload: previousMlxPleOffload,
mlxExpertOffload: previousMlxExpertOffload,
loadedChatTemplateOverride:
diff --git a/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts b/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts
index 61133fcb410..ba2812662be 100644
--- a/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts
+++ b/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts
@@ -230,6 +230,7 @@ export function applyActiveModelStatusToStore(
const incomingMlxKvQuant = normalizeMlxKvQuant(status.mlx_kv_quant_requested);
const incomingMlxInt8Prefill = status.mlx_int8_prefill_requested === true;
const incomingMlxAnePrefill = status.mlx_ane_prefill_requested === true;
+ const incomingMlxFastVerify = status.mlx_fast_verify_requested === true;
const incomingMlxOffload = mlxOffloadStateFrom(status);
const prevState = useChatRuntimeStore.getState();
// A pin is one model's; clamp the chat's own level once the model is actually resident.
@@ -543,6 +544,7 @@ export function applyActiveModelStatusToStore(
mlxKvQuantNote: status.mlx_kv_quant_note ?? null,
loadedMlxInt8PrefillRequested: incomingMlxInt8Prefill,
loadedMlxAnePrefillRequested: incomingMlxAnePrefill,
+ loadedMlxFastVerifyRequested: incomingMlxFastVerify,
...incomingMlxOffload,
...((hydratingExistingModel ||
(prevState.mlxPleOffload ?? null) ===
@@ -569,6 +571,11 @@ export function applyActiveModelStatusToStore(
prevState.loadedMlxAnePrefillRequested) && {
mlxAnePrefill: incomingMlxAnePrefill,
}),
+ ...((hydratingExistingModel ||
+ prevState.mlxFastVerify ===
+ prevState.loadedMlxFastVerifyRequested) && {
+ mlxFastVerify: incomingMlxFastVerify,
+ }),
}
: {
loadedMlxKvQuantRequested: null,
@@ -577,6 +584,7 @@ export function applyActiveModelStatusToStore(
mlxKvQuantNote: null,
loadedMlxInt8PrefillRequested: false,
loadedMlxAnePrefillRequested: false,
+ loadedMlxFastVerifyRequested: false,
...incomingMlxOffload,
})),
// Baseline only, never the control: the echo is the RESOLVED count and would pin a blank
diff --git a/studio/frontend/src/features/chat/lib/mlx-runtime-state.ts b/studio/frontend/src/features/chat/lib/mlx-runtime-state.ts
index 208245e9d43..e859acdf84e 100644
--- a/studio/frontend/src/features/chat/lib/mlx-runtime-state.ts
+++ b/studio/frontend/src/features/chat/lib/mlx-runtime-state.ts
@@ -18,6 +18,7 @@ type MlxRuntimeResponse = Pick<
| "mlx_kv_quant_note"
| "mlx_int8_prefill_requested"
| "mlx_ane_prefill_requested"
+ | "mlx_fast_verify_requested"
| "mlx_offload"
>;
@@ -60,8 +61,10 @@ export function mlxRuntimeStateFrom(resp: MlxRuntimeResponse): {
mlxKvQuantNote: string | null;
mlxInt8Prefill?: boolean;
mlxAnePrefill?: boolean;
+ mlxFastVerify?: boolean;
loadedMlxInt8PrefillRequested: boolean;
loadedMlxAnePrefillRequested: boolean;
+ loadedMlxFastVerifyRequested: boolean;
mlxPleOffload?: MlxOffload;
mlxExpertOffload?: MlxOffload;
} & ReturnType<typeof mlxOffloadStateFrom> {
@@ -74,6 +77,7 @@ export function mlxRuntimeStateFrom(resp: MlxRuntimeResponse): {
mlxKvQuantNote: null,
loadedMlxInt8PrefillRequested: false,
loadedMlxAnePrefillRequested: false,
+ loadedMlxFastVerifyRequested: false,
...offload,
};
}
@@ -88,6 +92,8 @@ export function mlxRuntimeStateFrom(resp: MlxRuntimeResponse): {
loadedMlxInt8PrefillRequested: resp.mlx_int8_prefill_requested === true,
mlxAnePrefill: resp.mlx_ane_prefill_requested === true,
loadedMlxAnePrefillRequested: resp.mlx_ane_prefill_requested === true,
+ mlxFastVerify: resp.mlx_fast_verify_requested === true,
+ loadedMlxFastVerifyRequested: resp.mlx_fast_verify_requested === true,
mlxPleOffload: offload.loadedMlxPleOffloadRequested,
mlxExpertOffload: offload.loadedMlxExpertOffloadRequested,
...offload,
diff --git a/studio/frontend/src/features/chat/lib/resident-config-match.ts b/studio/frontend/src/features/chat/lib/resident-config-match.ts
index f803fb9c191..461c27518c3 100644
--- a/studio/frontend/src/features/chat/lib/resident-config-match.ts
+++ b/studio/frontend/src/features/chat/lib/resident-config-match.ts
@@ -37,6 +37,7 @@ type ResidentRuntime = Pick<
| "mlx_kv_quant_requested"
| "mlx_int8_prefill_requested"
| "mlx_ane_prefill_requested"
+ | "mlx_fast_verify_requested"
| "mlx_offload"
| "speculative_type"
| "spec_draft_n_max"
@@ -246,6 +247,12 @@ const SETTING_CHECKS: SettingCheck[] = [
agrees: (c, s) =>
Boolean(c.mlxAnePrefill) === (s.mlx_ane_prefill_requested === true),
},
+ {
+ mlxComparable: true,
+ pinned: () => true,
+ agrees: (c, s) =>
+ Boolean(c.mlxFastVerify) === (s.mlx_fast_verify_requested === true),
+ },
{
// The request, not the applied fraction: Auto stays Auto whatever it picked.
mlxComparable: true,
diff --git a/studio/frontend/src/features/chat/presets/preset-load-config.ts b/studio/frontend/src/features/chat/presets/preset-load-config.ts
index b774b9d5b03..8f28d4c4265 100644
--- a/studio/frontend/src/features/chat/presets/preset-load-config.ts
+++ b/studio/frontend/src/features/chat/presets/preset-load-config.ts
@@ -333,6 +333,7 @@ export function applyPresetLoadConfig(config?: PresetLoadConfig | null): void {
// Not carried by presets: enabling it always goes through its confirmation.
mlxInt8Prefill: store.mlxInt8Prefill,
mlxAnePrefill: store.mlxAnePrefill,
+ mlxFastVerify: store.mlxFastVerify,
mlxPleOffload: store.mlxPleOffload,
mlxExpertOffload: store.mlxExpertOffload,
gpuMemoryMode: config.gpuMemoryMode,
diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsx
index 938ba86e67c..9231f12b327 100644
--- a/studio/frontend/src/features/chat/shared-composer.tsx
+++ b/studio/frontend/src/features/chat/shared-composer.tsx
@@ -1801,6 +1801,7 @@ export function SharedComposer({
mlx_kv_quant: ownConfig.mlxKvQuant ?? null,
mlx_int8_prefill: ownConfig.mlxInt8Prefill ?? false,
mlx_ane_prefill: ownConfig.mlxAnePrefill ?? false,
+ mlx_fast_verify: ownConfig.mlxFastVerify ?? false,
mlx_ple_offload: ownConfig.mlxPleOffload ?? null,
mlx_expert_offload: ownConfig.mlxExpertOffload ?? null,
speculative_type: effectiveSpeculativeType,
diff --git a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
index 8d4d3985e57..1f362a7dc37 100644
--- a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
+++ b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
@@ -2484,6 +2484,8 @@ type ChatRuntimeStore = {
loadedMlxInt8PrefillRequested: boolean;
mlxAnePrefill: boolean;
loadedMlxAnePrefillRequested: boolean;
+ mlxFastVerify: boolean;
+ loadedMlxFastVerifyRequested: boolean;
/** MLX offload knobs as chosen (null = Auto), as the resident load asked for them, the
* fraction it applied (null = none), and why a request was not applied. */
mlxPleOffload: MlxOffload;
@@ -4272,6 +4274,8 @@ export const useChatRuntimeStore = create<ChatRuntimeStore>((set, get) => ({
loadedMlxInt8PrefillRequested: false,
mlxAnePrefill: false,
loadedMlxAnePrefillRequested: false,
+ mlxFastVerify: false,
+ loadedMlxFastVerifyRequested: false,
mlxPleOffload: null,
mlxExpertOffload: null,
loadedMlxPleOffloadRequested: null,
@@ -5209,6 +5213,8 @@ export const useChatRuntimeStore = create<ChatRuntimeStore>((set, get) => ({
loadedMlxInt8PrefillRequested: false,
mlxAnePrefill: false,
loadedMlxAnePrefillRequested: false,
+ mlxFastVerify: false,
+ loadedMlxFastVerifyRequested: false,
mlxPleOffload: null,
mlxExpertOffload: null,
loadedMlxPleOffloadRequested: null,
diff --git a/studio/frontend/src/features/chat/types/api.ts b/studio/frontend/src/features/chat/types/api.ts
index 6fd78fa5ad3..890723d98a3 100644
--- a/studio/frontend/src/features/chat/types/api.ts
+++ b/studio/frontend/src/features/chat/types/api.ts
@@ -89,6 +89,7 @@ export interface LoadModelRequest {
mlx_kv_quant?: string | null;
mlx_int8_prefill?: boolean;
mlx_ane_prefill?: boolean;
+ mlx_fast_verify?: boolean;
/** MLX only: share of the PLE tables / routed experts read from disk, "off", or null for Auto. */
mlx_ple_offload?: "off" | number | null;
mlx_expert_offload?: "off" | number | null;
@@ -272,6 +273,9 @@ export interface LoadModelResponse {
mlx_ane_prefill?: boolean | null;
mlx_ane_prefill_requested?: boolean | null;
mlx_ane_prefill_reason?: string | null;
+ mlx_fast_verify?: boolean | null;
+ mlx_fast_verify_requested?: boolean | null;
+ mlx_fast_verify_reason?: string | null;
mlx_offload?: MlxOffloadReport | null;
chat_template?: string | null;
speculative_type?: string | null;
@@ -411,6 +415,9 @@ export interface InferenceStatusResponse {
mlx_ane_prefill?: boolean | null;
mlx_ane_prefill_requested?: boolean | null;
mlx_ane_prefill_reason?: string | null;
+ mlx_fast_verify?: boolean | null;
+ mlx_fast_verify_requested?: boolean | null;
+ mlx_fast_verify_reason?: string | null;
mlx_offload?: MlxOffloadReport | null;
chat_template_override?: string | null;
speculative_type?: string | null;
diff --git a/studio/frontend/src/features/model-picker/api/int8-prefill.ts b/studio/frontend/src/features/model-picker/api/int8-prefill.ts
index ffea2b45f39..7319197cdc8 100644
--- a/studio/frontend/src/features/model-picker/api/int8-prefill.ts
+++ b/studio/frontend/src/features/model-picker/api/int8-prefill.ts
@@ -3,7 +3,7 @@
import { authFetch } from "@/features/auth";
-export type PrefillOption = "int8" | "ane";
+export type PrefillOption = "int8" | "ane" | "fast-verify";
/** Failure only hides the setting: a stored choice is kept and the load-time check guards it. */
export async function fetchPrefillOptionAvailable(
@@ -12,7 +12,8 @@ export async function fetchPrefillOptionAvailable(
hfToken: string | null,
signal?: AbortSignal,
): Promise<boolean> {
- const response = await authFetch(`/api/inference/${option}-prefill-availability`, {
+ const route = option === "fast-verify" ? option : `${option}-prefill`;
+ const response = await authFetch(`/api/inference/${route}-availability`, {
method: "POST",
headers: { "Content-Type": "application/json" },
signal,
diff --git a/studio/frontend/src/features/model-picker/api/model-overrides.ts b/studio/frontend/src/features/model-picker/api/model-overrides.ts
index bb1280c113c..d7b2092773d 100644
--- a/studio/frontend/src/features/model-picker/api/model-overrides.ts
+++ b/studio/frontend/src/features/model-picker/api/model-overrides.ts
@@ -43,6 +43,7 @@ export interface ApiModelOverride {
// biome-ignore lint/style/useNamingConvention: API schema
mlx_int8_prefill?: boolean;
mlx_ane_prefill?: boolean;
+ mlx_fast_verify?: boolean;
// biome-ignore lint/style/useNamingConvention: API schema
mlx_ple_offload?: "off" | number | null;
// biome-ignore lint/style/useNamingConvention: API schema
@@ -359,6 +360,7 @@ export function fromApiOverride(
disableVision: override.disable_vision ?? local.disableVision,
mlxInt8Prefill: override.mlx_int8_prefill ?? local.mlxInt8Prefill,
mlxAnePrefill: override.mlx_ane_prefill ?? local.mlxAnePrefill,
+ mlxFastVerify: override.mlx_fast_verify ?? local.mlxFastVerify,
mlxPleOffload: override.mlx_ple_offload ?? local.mlxPleOffload,
mlxExpertOffload: override.mlx_expert_offload ?? local.mlxExpertOffload,
loadIn4bit: override.load_in_4bit ?? local.loadIn4bit,
@@ -462,6 +464,9 @@ export function toApiOverride(config: PerModelConfig | null): ApiModelOverride {
if (config.mlxAnePrefill) {
payload.mlx_ane_prefill = true;
}
+ if (config.mlxFastVerify) {
+ payload.mlx_fast_verify = true;
+ }
if (config.loadIn4bit === false) {
payload.load_in_4bit = false;
}
diff --git a/studio/frontend/src/features/model-picker/components/model-config-page.tsx b/studio/frontend/src/features/model-picker/components/model-config-page.tsx
index 1ee33461367..8380a037066 100644
--- a/studio/frontend/src/features/model-picker/components/model-config-page.tsx
+++ b/studio/frontend/src/features/model-picker/components/model-config-page.tsx
@@ -1454,11 +1454,15 @@ function MlxSpeculativeRows({
update,
speculativeFallback,
modelPath,
+ fastVerifyAvailable,
+ onFastVerifyChange,
}: {
config: PerModelConfig;
update: (patch: Partial<PerModelConfig>) => void;
speculativeFallback: string;
modelPath: string;
+ fastVerifyAvailable: boolean;
+ onFastVerifyChange: (checked: boolean) => void;
}) {
const [drafters, setDrafters] = useState<MlxDrafter[]>([]);
useEffect(() => {
@@ -1595,6 +1599,27 @@ function MlxSpeculativeRows({
</Select>
</div>
)}
+ {/* Only a drafter runs it; stays visible while on so it can be turned off. */}
+ {((fastVerifyAvailable && DRAFTER_MODEL_SPEC_TYPES.has(mode)) || config.mlxFastVerify) && (
+ <div className={ROW_CLASS}>
+ <div className="flex min-w-0 items-center gap-1.5">
+ <span className={LABEL_CLASS}>Fast Verify</span>
+ <span className="shrink-0 rounded-md bg-[rgb(0_0_0_/_calc(0.04*var(--contrast-wash-gain,1)))] px-1.5 py-0.5 text-ui-10 font-medium uppercase tracking-wide text-muted-foreground dark:bg-muted">
+ Exp
+ </span>
+ <InfoHint>
+ Speeds up speculative decoding with faster checks of the drafter's
+ tokens. Answers can change slightly from plain decoding, the same way
+ on every run. Applies only when a drafter loads; changing it reloads.
+ </InfoHint>
+ </div>
+ <Switch
+ className="panel-switch shrink-0"
+ checked={config.mlxFastVerify ?? false}
+ onCheckedChange={onFastVerifyChange}
+ />
+ </div>
+ )}
</>
);
}
@@ -1608,6 +1633,8 @@ function MlxAdvancedSettings({
onInt8PrefillChange,
anePrefillAvailable,
onAnePrefillChange,
+ fastVerifyAvailable,
+ onFastVerifyChange,
offloadable,
offloadDecided,
offloadNotes,
@@ -1624,6 +1651,8 @@ function MlxAdvancedSettings({
onInt8PrefillChange: (checked: boolean) => void;
anePrefillAvailable: boolean;
onAnePrefillChange: (checked: boolean) => void;
+ fastVerifyAvailable: boolean;
+ onFastVerifyChange: (checked: boolean) => void;
offloadable: readonly MlxOffloadablePart[];
offloadDecided: Record<MlxOffloadablePart, number | null> | null;
offloadNotes: Record<MlxOffloadablePart, string | null>;
@@ -1721,6 +1750,8 @@ function MlxAdvancedSettings({
update={update}
speculativeFallback={speculativeFallback}
modelPath={modelPath}
+ fastVerifyAvailable={fastVerifyAvailable}
+ onFastVerifyChange={onFastVerifyChange}
/>
)}
{servedByMlx && (
@@ -2705,6 +2736,12 @@ export function ModelConfigPage({
);
const [int8PrefillConfirmOpen, setInt8PrefillConfirmOpen] = useState(false);
const [anePrefillConfirmOpen, setAnePrefillConfirmOpen] = useState(false);
+ const fastVerifyAvailable = usePrefillOptionAvailable(
+ "fast-verify",
+ prefillOptionPath,
+ hfToken || null,
+ );
+ const [fastVerifyConfirmOpen, setFastVerifyConfirmOpen] = useState(false);
// Read live: the sidebar copy stays mounted while collapsed.
const advancedPreference = useSyncExternalStore(
subscribeAdvancedSettingsOpen,
@@ -2731,6 +2768,7 @@ export function ModelConfigPage({
const [initialMlxAnePrefill] = useState(
() => configState.mlxAnePrefill ?? false,
);
+ const [initialMlxFastVerify] = useState(() => configState.mlxFastVerify ?? false);
const [initialMlxOffload] = useState(
() => configState.mlxPleOffload != null || configState.mlxExpertOffload != null,
);
@@ -2739,6 +2777,7 @@ export function ModelConfigPage({
const autoOpenForMlxKvQuant = servedByMlx && initialMlxKvQuant != null;
const autoOpenForMlxInt8Prefill = servedByMlx && initialMlxInt8Prefill;
const autoOpenForMlxAnePrefill = servedByMlx && initialMlxAnePrefill;
+ const autoOpenForMlxFastVerify = servedByMlx && initialMlxFastVerify;
const autoOpenForMlxOffload = servedByMlx && initialMlxOffload;
// Opened to change one field: show its section for this visit, leaving the saved switch alone.
const [revealForFocus, setRevealForFocus] = useState(focusField != null);
@@ -2749,6 +2788,7 @@ export function ModelConfigPage({
autoOpenForMlxKvQuant ||
autoOpenForMlxInt8Prefill ||
autoOpenForMlxAnePrefill ||
+ autoOpenForMlxFastVerify ||
autoOpenForMlxOffload));
const toggleAdvanced = (open: boolean) => {
setRevealForFocus(false);
@@ -4310,6 +4350,12 @@ export function ModelConfigPage({
? setAnePrefillConfirmOpen(true)
: update({ mlxAnePrefill: false })
}
+ fastVerifyAvailable={fastVerifyAvailable}
+ onFastVerifyChange={(checked) =>
+ checked
+ ? setFastVerifyConfirmOpen(true)
+ : update({ mlxFastVerify: false })
+ }
offloadable={memoryEstimate.estimate?.mlxOffloadable ?? []}
offloadDecided={mlxOffloadDecidedNow}
offloadNotes={mlxOffloadNotes}
@@ -4533,6 +4579,34 @@ export function ModelConfigPage({
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
+ <AlertDialog
+ open={fastVerifyConfirmOpen}
+ onOpenChange={setFastVerifyConfirmOpen}
+ >
+ <AlertDialogContent size="sm">
+ <AlertDialogHeader>
+ <AlertDialogTitle>Turn on Fast Verify?</AlertDialogTitle>
+ <AlertDialogDescription>
+ Speculative decoding runs faster, but the model&apos;s answers will
+ change slightly from plain decoding, the same way on every run. It
+ applies only when a drafter loads, and changing it reloads the
+ model. You can turn it off at any time.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <AlertDialogAction
+ variant="destructive"
+ onClick={() => {
+ update({ mlxFastVerify: true });
+ setFastVerifyConfirmOpen(false);
+ }}
+ >
+ Turn on
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
<AlertDialog
open={pendingDelete !== null}
onOpenChange={(open) => {
diff --git a/studio/frontend/src/features/model-picker/hooks/use-active-model-config.ts b/studio/frontend/src/features/model-picker/hooks/use-active-model-config.ts
index 8446e3a3dc0..e852534bff4 100644
--- a/studio/frontend/src/features/model-picker/hooks/use-active-model-config.ts
+++ b/studio/frontend/src/features/model-picker/hooks/use-active-model-config.ts
@@ -42,6 +42,7 @@ export function useActiveModelConfig(): ActiveModelConfigState {
const mlxKvQuant = useChatRuntimeStore((s) => s.mlxKvQuant);
const mlxInt8Prefill = useChatRuntimeStore((s) => s.mlxInt8Prefill);
const mlxAnePrefill = useChatRuntimeStore((s) => s.mlxAnePrefill);
+ const mlxFastVerify = useChatRuntimeStore((s) => s.mlxFastVerify);
const mlxPleOffload = useChatRuntimeStore((s) => s.mlxPleOffload);
const mlxExpertOffload = useChatRuntimeStore((s) => s.mlxExpertOffload);
const speculativeType = useChatRuntimeStore((s) => s.speculativeType);
@@ -103,6 +104,7 @@ export function useActiveModelConfig(): ActiveModelConfigState {
const effectiveMlxKvQuant = isMlx ? (mlxKvQuant ?? null) : null;
const effectiveMlxInt8Prefill = isMlx && mlxInt8Prefill;
const effectiveMlxAnePrefill = isMlx && mlxAnePrefill;
+ const effectiveMlxFastVerify = isMlx && mlxFastVerify;
const effectiveMlxPleOffload = isMlx ? (mlxPleOffload ?? null) : null;
const effectiveMlxExpertOffload = isMlx ? (mlxExpertOffload ?? null) : null;
@@ -121,6 +123,7 @@ export function useActiveModelConfig(): ActiveModelConfigState {
mlxKvQuant: effectiveMlxKvQuant,
mlxInt8Prefill: effectiveMlxInt8Prefill,
mlxAnePrefill: effectiveMlxAnePrefill,
+ mlxFastVerify: effectiveMlxFastVerify,
mlxPleOffload: effectiveMlxPleOffload,
mlxExpertOffload: effectiveMlxExpertOffload,
speculativeType: speculativeType ?? "auto",
@@ -181,6 +184,7 @@ export function useActiveModelConfig(): ActiveModelConfigState {
effectiveMlxKvQuant,
effectiveMlxInt8Prefill,
effectiveMlxAnePrefill,
+ effectiveMlxFastVerify,
effectiveMlxPleOffload,
effectiveMlxExpertOffload,
speculativeType,
diff --git a/studio/frontend/src/features/model-picker/model-config/apply-per-model-config.ts b/studio/frontend/src/features/model-picker/model-config/apply-per-model-config.ts
index bd8f22768da..f83d7e16d8d 100644
--- a/studio/frontend/src/features/model-picker/model-config/apply-per-model-config.ts
+++ b/studio/frontend/src/features/model-picker/model-config/apply-per-model-config.ts
@@ -77,6 +77,7 @@ export function applyPerModelConfigToRuntime(
mlxKvQuant: config.mlxKvQuant ?? null,
mlxInt8Prefill: config.mlxInt8Prefill ?? false,
mlxAnePrefill: config.mlxAnePrefill ?? false,
+ mlxFastVerify: config.mlxFastVerify ?? false,
mlxPleOffload: config.mlxPleOffload ?? null,
mlxExpertOffload: config.mlxExpertOffload ?? null,
kvCacheDtype: config.kvCacheDtype ?? null,
@@ -153,6 +154,7 @@ export function currentRuntimePerModelConfig(
mlxKvQuant: s.mlxKvQuant ?? null,
mlxInt8Prefill: s.mlxInt8Prefill ?? false,
mlxAnePrefill: s.mlxAnePrefill ?? false,
+ mlxFastVerify: s.mlxFastVerify ?? false,
mlxPleOffload: s.mlxPleOffload ?? null,
mlxExpertOffload: s.mlxExpertOffload ?? null,
speculativeType: normalizeSpeculativeType(s.speculativeType),
@@ -212,6 +214,7 @@ export function perModelConfigsEqual(
(a.mlxKvQuant ?? null) === (b.mlxKvQuant ?? null) &&
Boolean(a.mlxInt8Prefill) === Boolean(b.mlxInt8Prefill) &&
Boolean(a.mlxAnePrefill) === Boolean(b.mlxAnePrefill) &&
+ Boolean(a.mlxFastVerify) === Boolean(b.mlxFastVerify) &&
(a.mlxPleOffload ?? null) === (b.mlxPleOffload ?? null) &&
(a.mlxExpertOffload ?? null) === (b.mlxExpertOffload ?? null) &&
speculative(a.speculativeType) === speculative(b.speculativeType) &&
diff --git a/studio/frontend/src/features/model-picker/model-config/config-signature.ts b/studio/frontend/src/features/model-picker/model-config/config-signature.ts
index b5bf0f59fa4..0cadce4a21e 100644
--- a/studio/frontend/src/features/model-picker/model-config/config-signature.ts
+++ b/studio/frontend/src/features/model-picker/model-config/config-signature.ts
@@ -56,6 +56,7 @@ export function loadedConfigSignature(
config.mlxKvQuant ?? "",
config.mlxInt8Prefill ? "1" : "0",
config.mlxAnePrefill ? "1" : "0",
+ config.mlxFastVerify ? "1" : "0",
config.mlxPleOffload ?? "",
config.mlxExpertOffload ?? "",
config.speculativeType ?? "",
diff --git a/studio/frontend/src/features/model-picker/model-config/per-model-config.ts b/studio/frontend/src/features/model-picker/model-config/per-model-config.ts
index 4717faeccbe..aad9d7abedc 100644
--- a/studio/frontend/src/features/model-picker/model-config/per-model-config.ts
+++ b/studio/frontend/src/features/model-picker/model-config/per-model-config.ts
@@ -36,6 +36,7 @@ export interface PerModelConfig {
mlxKvQuant?: MlxKvQuant | null;
mlxInt8Prefill?: boolean;
mlxAnePrefill?: boolean;
+ mlxFastVerify?: boolean;
/** MLX only: share of the PLE tables / routed experts read from disk, "off", or null for Auto. */
mlxPleOffload?: MlxOffload;
mlxExpertOffload?: MlxOffload;
@@ -86,6 +87,7 @@ export const DEFAULT_PER_MODEL_CONFIG: PerModelConfig = {
mlxKvQuant: null,
mlxInt8Prefill: false,
mlxAnePrefill: false,
+ mlxFastVerify: false,
mlxPleOffload: null,
mlxExpertOffload: null,
speculativeType: null,
@@ -409,9 +411,10 @@ const LEGACY_MIGRATION_FLAG = "unsloth_model_configs_migrated";
// would normalize the unknown field straight back out of the record.
// v2 added nBatch/nUbatch, v3 llamaExtraArgs, v4 disableVision, v5 the llama-server tuning group
// (loadMode / specDraftCacheDtype / ctxCheckpoints / cacheRam), v6 the reasoning budget pair,
-// v7 mlxKvQuant, v9 mlxInt8Prefill, v10 the per-GPU split, v11 the MLX drafter, v12 the MLX offload pair, v13 mlxAnePrefill. v8 is skipped: nightly builds stamped it for the reverted custom
+// v7 mlxKvQuant, v9 mlxInt8Prefill, v10 the per-GPU split, v11 the MLX drafter, v12 the MLX offload pair, v13 mlxAnePrefill, v14 mlxFastVerify. v8 is skipped: nightly builds stamped it for the reverted custom
// llama.cpp config (#12725), so a v8 client must not claim to understand an int8 prefill record.
-const STORAGE_SCHEMA_VERSION = 13;
+const STORAGE_SCHEMA_VERSION = 14;
+const PRE_MLX_FAST_VERIFY_SCHEMA_VERSION = 13;
const PRE_MLX_ANE_PREFILL_SCHEMA_VERSION = 12;
const PRE_MLX_OFFLOAD_SCHEMA_VERSION = 11;
const PRE_MLX_DRAFTER_SCHEMA_VERSION = 10;
@@ -461,6 +464,7 @@ const STORED_CONFIG_FIELDS = new Set([
"mlxKvQuant",
"mlxInt8Prefill",
"mlxAnePrefill",
+ "mlxFastVerify",
"mlxPleOffload",
"mlxExpertOffload",
"loadIn4bit",
@@ -1086,6 +1090,7 @@ function normalizeV1(partial: RawConfig): PerModelConfig {
mlxKvQuant: normalizeMlxKvQuant(partial.mlxKvQuant, partial.mlxKvBits),
mlxInt8Prefill: partial.mlxInt8Prefill === true,
mlxAnePrefill: partial.mlxAnePrefill === true,
+ mlxFastVerify: partial.mlxFastVerify === true,
mlxPleOffload: normalizeMlxOffload(partial.mlxPleOffload),
mlxExpertOffload: normalizeMlxOffload(partial.mlxExpertOffload),
kvCacheDtype:
@@ -1172,9 +1177,12 @@ function storedSchemaVersion(normalized: PerModelConfig): number {
const mode = normalized.speculativeType;
// A kept Auto and the MLX-only modes are values an older client folds back to unset.
const mlxMode = mode === "auto" || (MLX_ONLY_SPEC_TYPES as readonly string[]).includes(mode ?? "");
- if (normalized.mlxAnePrefill) {
+ if (normalized.mlxFastVerify) {
return STORAGE_SCHEMA_VERSION;
}
+ if (normalized.mlxAnePrefill) {
+ return PRE_MLX_FAST_VERIFY_SCHEMA_VERSION;
+ }
if (normalized.mlxPleOffload != null || normalized.mlxExpertOffload != null) {
return PRE_MLX_ANE_PREFILL_SCHEMA_VERSION;
}
@@ -1370,6 +1378,7 @@ export function isDefaultConfig(config: PerModelConfig): boolean {
(config.mlxKvQuant ?? null) === DEFAULT_PER_MODEL_CONFIG.mlxKvQuant &&
!config.mlxInt8Prefill &&
!config.mlxAnePrefill &&
+ !config.mlxFastVerify &&
config.mlxPleOffload == null &&
config.mlxExpertOffload == null &&
config.speculativeType === DEFAULT_PER_MODEL_CONFIG.speculativeType &&
diff --git a/studio/frontend/src/features/model-picker/sharing/fields.ts b/studio/frontend/src/features/model-picker/sharing/fields.ts
index 2ca9bcdb091..a7783d635de 100644
--- a/studio/frontend/src/features/model-picker/sharing/fields.ts
+++ b/studio/frontend/src/features/model-picker/sharing/fields.ts
@@ -48,6 +48,7 @@ export type SharedConfigKey = Exclude<
| "mlxKvQuant"
| "mlxInt8Prefill"
| "mlxAnePrefill"
+ | "mlxFastVerify"
| "mlxPleOffload"
| "mlxExpertOffload"
| "engine"
diff --git a/studio/frontend/tests/hydration-clears-stale-local-record.test.ts b/studio/frontend/tests/hydration-clears-stale-local-record.test.ts
index c3429ad08e3..d03bb3a5222 100644
--- a/studio/frontend/tests/hydration-clears-stale-local-record.test.ts
+++ b/studio/frontend/tests/hydration-clears-stale-local-record.test.ts
@@ -33,6 +33,7 @@ const VARIANT = "q4_k_m";
for (const [key, wire] of [
["mlxInt8Prefill", "mlx_int8_prefill"],
["mlxAnePrefill", "mlx_ane_prefill"],
+ ["mlxFastVerify", "mlx_fast_verify"],
] as const) {
test(`${key} reaches the server row only when on`, () => {
const on = { ...DEFAULT_PER_MODEL_CONFIG, [key]: true };
diff --git a/studio/frontend/tests/mlx-context-pin-record-compat.test.ts b/studio/frontend/tests/mlx-context-pin-record-compat.test.ts
index 55b0e6508c2..cb405f21e3f 100644
--- a/studio/frontend/tests/mlx-context-pin-record-compat.test.ts
+++ b/studio/frontend/tests/mlx-context-pin-record-compat.test.ts
@@ -189,8 +189,8 @@ const ROWS: Row[] = [
"and reads normally.",
},
{
- name: "version 14 (genuinely future)",
- raw: { version: 14, customContextLength: 32768 },
+ name: "version 15 (genuinely future)",
+ raw: { version: 15, customContextLength: 32768 },
normalizedPin: null,
rawPin: 32768,
isDefault: true,
@@ -341,10 +341,7 @@ test("both pin shapes are stamped version 1, so neither is distinguishable by ve
stage({ version: 13, customContextLength: 32768 }).remembered,
true,
);
- assert.equal(
- stage({ version: 14, customContextLength: 32768 }).remembered,
- false,
- );
+ assert.equal(stage({ version: 15, customContextLength: 32768 }).remembered, false);
});
@@ -387,6 +384,14 @@ test("Neural Engine prefill defaults off, and only an enabled one stamps v13", (
assert.equal(stage({ mlxAnePrefill: true }).config.mlxAnePrefill, true);
});
+test("Fast Verify defaults off, and only an enabled one stamps v14", () => {
+ assert.equal(normalizePerModelConfig({ version: 13 }).mlxFastVerify, false);
+ assert.equal(isDefaultConfig({ ...DEFAULT_PER_MODEL_CONFIG, mlxFastVerify: true }), false);
+ assert.equal(stampedVersion({ mlxFastVerify: false, mlxAnePrefill: true }), 13);
+ assert.equal(stampedVersion({ mlxFastVerify: true }), 14);
+ assert.equal(stage({ mlxFastVerify: true }).config.mlxFastVerify, true);
+});
+
/** Old config page, non-GGUF: the number reads maxSeqLength; customContextLength only sets atDefault. */
function oldClientConfigPage(
diff --git a/studio/frontend/tests/resident-config-match-accelerator-matrix.test.ts b/studio/frontend/tests/resident-config-match-accelerator-matrix.test.ts
index bdfbc91e751..4e1c01bd8de 100644
--- a/studio/frontend/tests/resident-config-match-accelerator-matrix.test.ts
+++ b/studio/frontend/tests/resident-config-match-accelerator-matrix.test.ts
@@ -260,6 +260,12 @@ const FIELDS: FieldCase[] = [
same: true,
different: false,
},
+ {
+ key: "mlxFastVerify",
+ statusKey: "mlx_fast_verify_requested",
+ same: true,
+ different: false,
+ },
{ key: "mlxPleOffload", statusKey: "mlx_offload", same: 0.5, different: "off", wrap: offloadRequest("ple") },
{
key: "mlxExpertOffload",
diff --git a/studio/frontend/tests/same-model-reload-load-settings.test.ts b/studio/frontend/tests/same-model-reload-load-settings.test.ts
index dd2acd2f57f..71f27cdec4a 100644
--- a/studio/frontend/tests/same-model-reload-load-settings.test.ts
+++ b/studio/frontend/tests/same-model-reload-load-settings.test.ts
@@ -63,6 +63,7 @@ function mlxStatus(over: Record<string, unknown>) {
chat_template_override_reason: null,
mlx_int8_prefill_requested: false,
mlx_ane_prefill_requested: false,
+ mlx_fast_verify_requested: false,
...over,
};
}
@@ -162,6 +163,19 @@ test("a same-model MLX reload keeps a value this tab staged but advances the bas
assert.equal(s.loadedMlxKvQuantRequested, null);
});
+test("a same-model MLX reload moves a clean Fast Verify both ways, and a poll leaves a staged one alone", () => {
+ useChatRuntimeStore.setState({ activeGgufVariant: null });
+ hydrate(mlxStatus({}), MLX);
+ const pair = ({ mlxFastVerify: on, loadedMlxFastVerifyRequested: loaded } = useChatRuntimeStore.getState()) => [on, loaded];
+ reload(mlxStatus({ mlx_fast_verify_requested: true }), MLX);
+ assert.deepEqual(pair(), [true, true]);
+ reload(mlxStatus({ mlx_fast_verify_requested: false }), MLX);
+ assert.deepEqual(pair(), [false, false]);
+ useChatRuntimeStore.setState({ mlxFastVerify: true });
+ reload(mlxStatus({ mlx_fast_verify_requested: false }), MLX);
+ assert.deepEqual(pair(), [true, false]);
+});
+
for (const staged of ["int8", "ane"] as const) {
test(`a steady MLX poll leaves a staged ${staged} value alone while the other follows the server`, () => {
useChatRuntimeStore.setState({ activeGgufVariant: null });
diff --git a/studio/frontend/tests/server-tuning-settings.test.ts b/studio/frontend/tests/server-tuning-settings.test.ts
index 89a36bbced1..1457a058563 100644
--- a/studio/frontend/tests/server-tuning-settings.test.ts
+++ b/studio/frontend/tests/server-tuning-settings.test.ts
@@ -102,8 +102,9 @@ test("the four take part in the editor's identity", () => {
test("a record only claims the new schema version when it carries one", () => {
// toStoredConfig stamps the oldest version that understands every field present.
const source = readSrc("features/model-picker/model-config/per-model-config.ts");
- assert.match(source, /const STORAGE_SCHEMA_VERSION = 13;\nconst PRE_MLX_ANE_PREFILL_SCHEMA_VERSION = 12;\nconst PRE_MLX_OFFLOAD_SCHEMA_VERSION = 11;\nconst PRE_MLX_DRAFTER_SCHEMA_VERSION = 10;/);
- assert.match(source, /mlxAnePrefill\)\s*\{\s*return STORAGE_SCHEMA_VERSION;/);
+ assert.match(source, /const STORAGE_SCHEMA_VERSION = 14;\nconst PRE_MLX_FAST_VERIFY_SCHEMA_VERSION = 13;\nconst PRE_MLX_ANE_PREFILL_SCHEMA_VERSION = 12;\nconst PRE_MLX_OFFLOAD_SCHEMA_VERSION = 11;\nconst PRE_MLX_DRAFTER_SCHEMA_VERSION = 10;/);
+ assert.match(source, /mlxFastVerify\)\s*\{\s*return STORAGE_SCHEMA_VERSION;/);
+ assert.match(source, /mlxAnePrefill\)\s*\{\s*return PRE_MLX_FAST_VERIFY_SCHEMA_VERSION;/);
assert.match(source, /mlxExpertOffload != null\)\s*\{\s*return PRE_MLX_ANE_PREFILL_SCHEMA_VERSION;/);
assert.match(source, /specDraftModel != null \|\| mlxMode\)\s*\{\s*return PRE_MLX_OFFLOAD_SCHEMA_VERSION;/);
assert.match(source, /tensorSplit != null\)\s*\{\s*return PRE_MLX_DRAFTER_SCHEMA_VERSION;/);