Studio: simplify the inference backend (#6490)
This commit is contained in:
parent
72254e0a81
commit
e6b4480832
5 changed files with 1089 additions and 1535 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -878,8 +878,10 @@ class TestExtraArgsMtpDetection:
|
|||
# f16/f16 on the layer fallback) (#6312).
|
||||
load = "".join(inspect.getsource(LlamaCppBackend.load_model).split())
|
||||
assert "_tensor_dropped_extra_args=list(extra_args)" in load
|
||||
# All three tensor->layer downgrade points restore the saved originals.
|
||||
assert load.count("strip_split_mode_only(_tensor_dropped_extra_argsif") == 3
|
||||
# The original extras are restored via one shared closure, called at all
|
||||
# three tensor->layer downgrade points.
|
||||
assert "strip_split_mode_only(_tensor_dropped_extra_argsif" in load
|
||||
assert load.count("_restore_after_tensor_downgrade()") >= 3
|
||||
|
||||
def test_load_model_tensor_skips_reserve_for_cpu_drafter(self):
|
||||
# A separate CPU-offloaded drafter (no embedded head) uses no GPU, so the
|
||||
|
|
|
|||
22
studio/backend/tests/test_sse_streaming_headers.py
Normal file
22
studio/backend/tests/test_sse_streaming_headers.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
|
||||
|
||||
"""Regression tests for the shared SSE streaming-response helper.
|
||||
|
||||
Streaming endpoints must disable proxy buffering (``X-Accel-Buffering: no``);
|
||||
without it a reverse proxy (nginx / cloudflare tunnel) buffers the response and
|
||||
tokens stop appearing in real time. The native ``/generate/stream`` and legacy
|
||||
``/v1/completions`` streams historically omitted it and now route through the
|
||||
shared helper, so locking the helper's headers guards every standard path.
|
||||
"""
|
||||
|
||||
import routes.inference as inference_route
|
||||
|
||||
|
||||
def test_sse_helper_sets_no_proxy_buffering_headers():
|
||||
resp = inference_route._sse_streaming_response(iter(()))
|
||||
assert resp.media_type == "text/event-stream"
|
||||
# Starlette lowercases header keys in init_headers.
|
||||
assert resp.headers["cache-control"] == "no-cache"
|
||||
assert resp.headers["connection"] == "close"
|
||||
assert resp.headers["x-accel-buffering"] == "no"
|
||||
|
|
@ -1153,4 +1153,7 @@ def test_load_model_restores_quantized_kv_on_tensor_downgrade():
|
|||
# GPU-count and capacity-gate downgrades.
|
||||
compact = "".join(inspect.getsource(LlamaCppBackend.load_model).split())
|
||||
assert "_tensor_dropped_cache_type_kv=cache_type_kv" in compact # captured pre-null
|
||||
assert compact.count("cache_type_kv=_tensor_dropped_cache_type_kv") >= 2 # restored
|
||||
# Restore is shared in one closure, called at every tensor->layer downgrade.
|
||||
assert "cache_type_kv=_tensor_dropped_cache_type_kv" in compact # restored in the closure
|
||||
assert "def_restore_after_tensor_downgrade():" in compact # one shared restore helper
|
||||
assert compact.count("_restore_after_tensor_downgrade()") >= 3 # called at each downgrade
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue