[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
9ec6c8bb5a
commit
b5cada1028
5 changed files with 11 additions and 33 deletions
|
|
@ -280,9 +280,7 @@ class ApiMonitor:
|
|||
if subject is None:
|
||||
self._entries.clear()
|
||||
return
|
||||
self._entries = deque(
|
||||
entry for entry in self._entries if entry.subject != subject
|
||||
)
|
||||
self._entries = deque(entry for entry in self._entries if entry.subject != subject)
|
||||
|
||||
def _find_locked(self, entry_id: str) -> Optional[ApiMonitorEntry]:
|
||||
for entry in self._entries:
|
||||
|
|
|
|||
|
|
@ -3742,8 +3742,7 @@ async def _maybe_auto_switch_model(
|
|||
override,
|
||||
# variant is set for every GGUF the resolver returns; the
|
||||
# reload-stash path carries the quant it froze.
|
||||
is_gguf = bool(variant)
|
||||
or target_id.lower().endswith(".gguf"),
|
||||
is_gguf = bool(variant) or target_id.lower().endswith(".gguf"),
|
||||
)
|
||||
)
|
||||
# Reuse the load impl so its dedup, tensor fallback, and threading
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ class ModelOverridePayload(BaseModel):
|
|||
n_cpu_moe: Optional[int] = Field(default = None, ge = 0, le = 1024)
|
||||
gpu_ids: Optional[list[int]] = None
|
||||
|
||||
|
||||
@field_validator("chat_template_override")
|
||||
@classmethod
|
||||
def _limit_chat_template_bytes(cls, value: Optional[str]) -> Optional[str]:
|
||||
|
|
@ -168,9 +167,7 @@ class ModelOverridePayload(BaseModel):
|
|||
if value is None:
|
||||
return None
|
||||
if len(value.encode("utf-8")) > MAX_CHAT_TEMPLATE_BYTES:
|
||||
raise ValueError(
|
||||
f"Chat template exceeds the {MAX_CHAT_TEMPLATE_BYTES}-byte limit."
|
||||
)
|
||||
raise ValueError(f"Chat template exceeds the {MAX_CHAT_TEMPLATE_BYTES}-byte limit.")
|
||||
return value
|
||||
|
||||
|
||||
|
|
@ -331,6 +328,7 @@ def update_openai_auto_switch_override(
|
|||
) -> ModelOverridesResponse:
|
||||
from core.inference.llama_server_args import validate_extra_args
|
||||
from utils.openai_auto_switch_settings import get_model_override
|
||||
|
||||
try:
|
||||
# A payload carrying only model_id is the documented "remove", so it
|
||||
# wipes everything. Otherwise it is a real save, and omitted launch flags
|
||||
|
|
@ -341,14 +339,10 @@ def update_openai_auto_switch_override(
|
|||
exclude = {"model_id", "llama_extra_args"}, exclude_none = True
|
||||
)
|
||||
is_removal = not payload.tensor_parallel and not {
|
||||
key: value
|
||||
for key, value in saved_fields.items()
|
||||
if key != "tensor_parallel"
|
||||
key: value for key, value in saved_fields.items() if key != "tensor_parallel"
|
||||
}
|
||||
if requested_extra_args is None and not is_removal:
|
||||
requested_extra_args = get_model_override(payload.model_id).get(
|
||||
"llama_extra_args"
|
||||
)
|
||||
requested_extra_args = get_model_override(payload.model_id).get("llama_extra_args")
|
||||
extra_args = validate_extra_args(requested_extra_args)
|
||||
set_model_override(
|
||||
payload.model_id,
|
||||
|
|
|
|||
|
|
@ -3843,11 +3843,7 @@ def test_normalize_model_override_drops_unusable_fields_and_keeps_the_rest():
|
|||
"llama_extra_args": [],
|
||||
}
|
||||
)
|
||||
assert entry == {
|
||||
"max_seq_length": 8192,
|
||||
"speculative_type": "mtp",
|
||||
"gpu_ids": [1, 0, 2],
|
||||
}
|
||||
assert entry == {"max_seq_length": 8192, "speculative_type": "mtp", "gpu_ids": [1, 0, 2]}
|
||||
|
||||
|
||||
def test_normalize_model_override_rejects_oversized_chat_template():
|
||||
|
|
@ -3862,15 +3858,11 @@ def test_normalize_model_override_rejects_oversized_chat_template():
|
|||
|
||||
|
||||
def test_spec_draft_n_max_only_stored_for_mtp_modes():
|
||||
mtp = settings.normalize_model_override(
|
||||
{"speculative_type": "mtp", "spec_draft_n_max": 4}
|
||||
)
|
||||
mtp = settings.normalize_model_override({"speculative_type": "mtp", "spec_draft_n_max": 4})
|
||||
assert mtp["spec_draft_n_max"] == 4
|
||||
# A non-MTP mode ignores the draft count at load time, so storing it would
|
||||
# show the user an edit that never takes effect.
|
||||
ngram = settings.normalize_model_override(
|
||||
{"speculative_type": "ngram", "spec_draft_n_max": 4}
|
||||
)
|
||||
ngram = settings.normalize_model_override({"speculative_type": "ngram", "spec_draft_n_max": 4})
|
||||
assert "spec_draft_n_max" not in ngram
|
||||
|
||||
|
||||
|
|
@ -3886,10 +3878,7 @@ def test_resolve_fit_max_seq_length_hands_sizing_to_fit_under_manual_auto_layers
|
|||
== 4096
|
||||
)
|
||||
# Pinning the layer count takes --fit back out of the picture.
|
||||
assert (
|
||||
settings.resolve_fit_max_seq_length({**override, "gpu_layers": 20}, is_gguf = True)
|
||||
== 8192
|
||||
)
|
||||
assert settings.resolve_fit_max_seq_length({**override, "gpu_layers": 20}, is_gguf = True) == 8192
|
||||
# Not a GGUF, so none of this applies.
|
||||
assert settings.resolve_fit_max_seq_length(override, is_gguf = False) == 8192
|
||||
|
||||
|
|
|
|||
|
|
@ -306,9 +306,7 @@ def normalize_model_override(payload: dict[str, Any]) -> dict[str, Any]:
|
|||
# Only meaningful for the MTP modes; storing it otherwise would resurface
|
||||
# in the UI as an edit the loader silently ignores.
|
||||
if speculative_type in MTP_SPECULATIVE_TYPES:
|
||||
spec_draft_n_max = _bounded_int(
|
||||
payload.get("spec_draft_n_max"), minimum = 1, maximum = 16
|
||||
)
|
||||
spec_draft_n_max = _bounded_int(payload.get("spec_draft_n_max"), minimum = 1, maximum = 16)
|
||||
if spec_draft_n_max:
|
||||
entry["spec_draft_n_max"] = spec_draft_n_max
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue