Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

fix(serve): align head_max_len handling with core library behavior

Swatantra Yadav0cf633460969
diff --git a/laya/serve.py b/laya/serve.py
index 989f0e26..2c6f19d0 100644
--- a/laya/serve.py
+++ b/laya/serve.py
@@ -394,11 +394,6 @@ def create_app(router: Optional[Any] = None):
max_budget_cap = _resolve_max_token_budget()
max_len = _validate_budget_param(body, "max_len", max_budget_cap)
head_max_len = _validate_budget_param(body, "head_max_len", max_budget_cap)
- if max_len is not None and head_max_len is not None and head_max_len >= max_len:
- raise HTTPException(
- status_code=422,
- detail="head_max_len (%d) must be less than max_len (%d)" % (head_max_len, max_len),
- )
predict_kwargs = {}
if max_len is not None:
predict_kwargs["max_len"] = max_len
diff --git a/tests/test_serve.py b/tests/test_serve.py
index 426632e9..e152f7a2 100644
--- a/tests/test_serve.py
+++ b/tests/test_serve.py
@@ -564,11 +564,13 @@ def test_token_budget_exceeds_server_cap(monkeypatch):
assert "exceeds server limit" in r.json()["detail"]
-def test_token_budget_head_max_len_exceeds_max_len(monkeypatch):
+def test_token_budget_head_max_len_equal_to_max_len(monkeypatch):
+ """Core accepts head_max_len == max_len; serve forwards both without artificial restriction."""
client, fake = _client(monkeypatch)
r = client.post("/v1/systemone", json={**REQ, "max_len": 512, "head_max_len": 512})
- assert r.status_code == 422
- assert "must be less than max_len" in r.json()["detail"]
+ assert r.status_code == 200
+ assert fake.calls[0]["max_len"] == 512
+ assert fake.calls[0]["head_max_len"] == 512
def test_token_budget_env_cap_override(monkeypatch):