[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
e43304a1b9
commit
506cdc6c8a
4 changed files with 19 additions and 38 deletions
|
|
@ -3440,7 +3440,6 @@ async def _wait_for_model_switch_idle(*, current_request_counted: bool) -> None:
|
|||
exclude them to avoid a queue deadlock.
|
||||
"""
|
||||
from core.inference.llama_keepwarm import other_inference_request_count
|
||||
|
||||
while True:
|
||||
queued_switches = _switch_waiter_count()
|
||||
if current_request_counted and queued_switches > 0:
|
||||
|
|
@ -3732,6 +3731,7 @@ async def _maybe_auto_switch_model(
|
|||
_auto_switch_process_lock.release()
|
||||
finally:
|
||||
_note_switch_waiter(key, -1)
|
||||
|
||||
await _resolve_and_switch()
|
||||
|
||||
|
||||
|
|
@ -4531,9 +4531,7 @@ async def _load_model_impl(
|
|||
|
||||
# Keep the resident model alive until every active generation has
|
||||
# finished. The lifecycle gate held by the caller blocks new starts.
|
||||
await _wait_for_model_switch_idle(
|
||||
current_request_counted = current_request_counted
|
||||
)
|
||||
await _wait_for_model_switch_idle(current_request_counted = current_request_counted)
|
||||
|
||||
# Unload any active Unsloth model only after every hub conflict check.
|
||||
if unsloth_backend.active_model_name:
|
||||
|
|
@ -4745,9 +4743,7 @@ async def _load_model_impl(
|
|||
|
||||
# Unload any active GGUF model first
|
||||
llama_backend = get_llama_cpp_backend()
|
||||
await _wait_for_model_switch_idle(
|
||||
current_request_counted = current_request_counted
|
||||
)
|
||||
await _wait_for_model_switch_idle(current_request_counted = current_request_counted)
|
||||
if llama_backend.is_loaded:
|
||||
logger.info("Unloading GGUF model before loading Unsloth model")
|
||||
llama_backend.unload_model()
|
||||
|
|
|
|||
|
|
@ -1229,9 +1229,7 @@ def test_auto_switch_waits_for_another_inference_to_finish(monkeypatch):
|
|||
|
||||
async def _drive():
|
||||
task = asyncio.create_task(
|
||||
inference_route._maybe_auto_switch_model(
|
||||
"org/B-GGUF:Q8_0", object(), "tester"
|
||||
)
|
||||
inference_route._maybe_auto_switch_model("org/B-GGUF:Q8_0", object(), "tester")
|
||||
)
|
||||
await asyncio.sleep(0.05)
|
||||
assert rec.calls == []
|
||||
|
|
@ -1588,15 +1586,11 @@ def test_swap_waits_until_concurrent_request_finishes_resolving(monkeypatch):
|
|||
|
||||
async def _drive():
|
||||
task = asyncio.create_task(
|
||||
inference_route._maybe_auto_switch_model(
|
||||
"org/B-GGUF:Q8_0", object(), "tester"
|
||||
)
|
||||
inference_route._maybe_auto_switch_model("org/B-GGUF:Q8_0", object(), "tester")
|
||||
)
|
||||
await asyncio.sleep(0.05)
|
||||
assert rec.calls == []
|
||||
inference_route._note_switch_waiter(
|
||||
inference_route._switch_key("org/B-GGUF", "Q8_0"), 1
|
||||
)
|
||||
inference_route._note_switch_waiter(inference_route._switch_key("org/B-GGUF", "Q8_0"), 1)
|
||||
await asyncio.wait_for(task, timeout = 1)
|
||||
|
||||
asyncio.run(_drive())
|
||||
|
|
@ -1655,9 +1649,7 @@ def test_auto_switch_waits_when_unsloth_stream_active(monkeypatch):
|
|||
|
||||
async def _drive():
|
||||
task = asyncio.create_task(
|
||||
inference_route._maybe_auto_switch_model(
|
||||
"org/B-GGUF:Q8_0", object(), "tester"
|
||||
)
|
||||
inference_route._maybe_auto_switch_model("org/B-GGUF:Q8_0", object(), "tester")
|
||||
)
|
||||
await asyncio.sleep(0.05)
|
||||
assert rec.calls == []
|
||||
|
|
|
|||
|
|
@ -606,11 +606,7 @@ class _ModelDownloadProgress:
|
|||
|
||||
|
||||
def _load_model_with_progress(
|
||||
base: str,
|
||||
key: str,
|
||||
model: str,
|
||||
load: LoadOptions,
|
||||
payload: dict,
|
||||
base: str, key: str, model: str, load: LoadOptions, payload: dict
|
||||
) -> dict:
|
||||
"""Run the blocking load request while polling its download progress."""
|
||||
result: list[tuple[bool, object]] = []
|
||||
|
|
|
|||
|
|
@ -1271,9 +1271,7 @@ def test_connect_model_flag_loads_on_server(fake_studio):
|
|||
]
|
||||
assert result.output.index(
|
||||
f"Switching the Unsloth server from {MODEL['id']} to unsloth/Qwen3.5-35B-A3B.\n"
|
||||
) < result.output.index(
|
||||
"This unloads the current model for every attached session.\n"
|
||||
)
|
||||
) < result.output.index("This unloads the current model for every attached session.\n")
|
||||
_assert_env_set(result.output, "ANTHROPIC_MODEL", "unsloth/Qwen3.5-35B-A3B")
|
||||
|
||||
|
||||
|
|
@ -1882,25 +1880,24 @@ def test_start_studio_server_polls_progress_from_early_key(monkeypatch):
|
|||
)
|
||||
|
||||
assert server.pid == 4321
|
||||
assert (
|
||||
BASE,
|
||||
"sk-unsloth-early",
|
||||
"owner/model-GGUF",
|
||||
"Q4_K_M",
|
||||
"created",
|
||||
) in created
|
||||
assert (BASE, "sk-unsloth-early", "owner/model-GGUF", "Q4_K_M", "created") in created
|
||||
assert created.count("poll") == 2
|
||||
assert created[-2:] == ["complete", "close"]
|
||||
assert not any(
|
||||
isinstance(event, tuple) and "server ready" in event[-1] for event in created
|
||||
)
|
||||
assert not any(isinstance(event, tuple) and "server ready" in event[-1] for event in created)
|
||||
|
||||
|
||||
def test_load_model_with_progress_uses_selected_gguf_size(monkeypatch, capsys):
|
||||
release = start.threading.Event()
|
||||
calls = []
|
||||
|
||||
def http_json(method, url, token, payload = None, timeout = 30, error = None):
|
||||
def http_json(
|
||||
method,
|
||||
url,
|
||||
token,
|
||||
payload = None,
|
||||
timeout = 30,
|
||||
error = None,
|
||||
):
|
||||
calls.append((method, url, payload))
|
||||
if url.endswith("/api/inference/load"):
|
||||
assert release.wait(timeout = 2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue