Open-source inference server and production cluster for all the models your agent needs.
Python bgecolbertdata-pipelinedeep-learningembeddingsinferenceinference-serverinformation-retrievalllmmlmlopsnatural-language-processingnlppythonrerankingretrievalretrieval-augmented-generationsemantic-searchspladevector-search
perf(models): raise the Hy-MT2-1.8B KV budget to 65536 tokens
Shai Shmuelf625df2353eb
diff --git a/packages/sie_server/models/tencent__Hy-MT2-1.8B.yaml b/packages/sie_server/models/tencent__Hy-MT2-1.8B.yamlindex 3bf0aaf9f..f600015ad 100644--- a/packages/sie_server/models/tencent__Hy-MT2-1.8B.yaml+++ b/packages/sie_server/models/tencent__Hy-MT2-1.8B.yaml@@ -22,7 +22,16 @@ max_sequence_length: 4096profiles:default:max_batch_tokens: 8192- kv_budget_tokens: 8192+ # The KV budget is the SGLang pool size (--max-total-tokens), and the pool+ # bounds requests in flight: SGLang admits a request only while the pool+ # can hold its prompt plus max_tokens, and keeps 0.7 (decaying to 0.098)+ # of each running request's unused max_tokens reserved. A translation+ # request (about 80 prompt and 110 output tokens, max_tokens at the 1024+ # cap) holds about 300 tokens under steady load, so 8192 kept about 25 in+ # flight and 65536 keeps about 200. One L4 still gains throughput from 64+ # to 128 in flight. Reservation in bf16: 4.0 GiB weights + 4.0 GiB KV+ # (64 KiB per token) + 3 GiB headroom, about 11 GiB of the L4's 22.5 GiB.+ kv_budget_tokens: 65536compute_precision: bfloat16adapter_path: sie_server.adapters.sglang.generation:SGLangGenerationAdapteradapter_options:diff --git a/packages/sie_server/tests/config/test_sglang_memory_profiles.py b/packages/sie_server/tests/config/test_sglang_memory_profiles.pyindex f0b3b2441..5c4d698ac 100644--- a/packages/sie_server/tests/config/test_sglang_memory_profiles.py+++ b/packages/sie_server/tests/config/test_sglang_memory_profiles.py@@ -1,9 +1,15 @@+import json+import math+import structfrom pathlib import Pathimport pytest+from sie_server.adapters.sglang import _memory+from sie_server.adapters.sglang._memory import GIBfrom sie_server.core.loader import expand_profile_variants, load_adapter, load_model_configMODELS = Path(__file__).resolve().parents[2] / "models"+L4_TOTAL_BYTES = 23034 * 1024**2@pytest.mark.parametrize(@@ -14,6 +20,7 @@ MODELS = Path(__file__).resolve().parents[2] / "models""ibm-granite__granite-guardian-3.0-2b","Qwen__Qwen3-Embedding-4B","lightonai__LightOnOCR-2-1B",+ "tencent__Hy-MT2-1.8B",],)def test_default_profiles_use_model_sized_memory(name):@@ -25,6 +32,29 @@ def test_default_profiles_use_model_sized_memory(name):assert adapter._memory_budget.kv_budget_tokens == profile.kv_budget_tokens+def test_hy_mt2_pool_fits_an_l4_with_room_for_translation_batches(tmp_path, monkeypatch):+ config = load_model_config(MODELS / "tencent__Hy-MT2-1.8B.yaml")+ assert config.resolve_profile("default").kv_budget_tokens == 65536+ # Geometry and bf16 parameter count of the pinned checkpoint: 64 KiB of KV per token.+ (tmp_path / "config.json").write_text(+ json.dumps({"num_hidden_layers": 32, "num_attention_heads": 16, "num_key_value_heads": 4, "head_dim": 128})+ )+ params = 2_038_515_712+ header = json.dumps(+ {"model.weight": {"dtype": "BF16", "shape": [params], "data_offsets": [0, params * 2]}}+ ).encode()+ (tmp_path / "model.safetensors").write_bytes(struct.pack("<Q", len(header)) + header)+ budget = load_adapter(config, MODELS, device="cuda:0")._memory_budget+ budget.model_name_or_path = str(tmp_path)++ required = budget.required_bytes(device_type="cuda", device_total_bytes=L4_TOTAL_BYTES)+ assert required == math.ceil(params * 2 * 1.05) + (65536 + 512) * 65536 + 3 * GIB+ # Half of the card stays available to co-resident models.+ assert required < L4_TOTAL_BYTES / 2+ monkeypatch.setattr(_memory, "device_memory", lambda _: (L4_TOTAL_BYTES - GIB, L4_TOTAL_BYTES))+ assert budget.launch_args(0)[2:] == ["--max-total-tokens", "65536"]++def test_guard_calibrated_profile_retains_explicit_override():config = load_model_config(MODELS / "Qwen__Qwen3Guard-Gen-4B.yaml")assert config.resolve_profile("default").kv_budget_tokens == 32768