Repository navigation
feat(dotnet): port lang_temperatures and per-call lang, max_len and head_max_len - #1370
Conversation
…ead_max_len Add LayaOptions.LangTemperatures (resolved as Python's resolve_lang_temperatures: base-code keys, inherit, clamp, Python's ValueError and warning texts, warnings before the checkpoint's own), and the per-call Lang, MaxLen and HeadMaxLen on LayaPredictOptions, LayaBatchOptions and LayaBatchRequest, plus LayaLongOptions with Lang for PredictLong. A language hit replaces the checkpoint's per-type and per-bucket temperatures. The router forwards the explicit lang, else the detected language, and groups batch requests by budget and, when a table is set, by lang, as Python's Router does. Budgets follow Python's arithmetic, including 0 and negative values. Existing signatures are unchanged. Goldens and probes come from tools/regen_golden.py; the case lists are shared verbatim with the Rust SDK.
… one at a time WarnOnceTests, TemperatureConfigTests and LangTemperatureTests reset WarnOnce or capture Trace output while other classes emit warnings in parallel, which made the model-free lane fail intermittently (2 of 8 runs at be3ca8b, under load). They now share one xunit collection with parallelization disabled. No assertion changed; 30 runs of the model-free lane passed after the change.
24 PRs. Vietnamese kept off the English checkpoint (#1392), deciding-window attribution preserved through end hooks (#1369), RemoteRouter identifying itself with a configurable User-Agent (#1396), ten more inputs refused where they enter (#1372, #1394, #1397, #1398, #1400, #1401, #1402, #1403, #1404, #1405, #1406), per-language temperatures and per-call budgets in .NET and Rust (#1370, #1371), .NET calibration files (#1384), the Go router lifecycle, SHA-256 pins and routed inference (#1374, #1379, #1395), a C++ foundation (#1399, #1407), and parity-lane sharding that replaces the budget headroom added for 0.4.16 (#1373, #1375). Verified before tagging: all 92 suites pass, 640 tests, up from 612. ruff clean on both lists. laya-ts 1251 tests across 44 files, tsc --noEmit clean. Every generated-artifact gate clean on CPython 3.12 / unicodedata 15.0.0: Java 20 families match laya (9 unverified), UnicodeTables matches CPython 15.0.0, LanguageTables matches laya/lang.py, three Go tables_gen.go match, both laya-cpp .inc files match. Version agrees across pyproject.toml, laya.__version__ and nix/package.nix. README carries 0.4.17 only. Security audit of the merge diff, 362766 added lines over 480 files: zero obfuscation, zero secrets, zero boundary hits, zero binaries, no mode or symlink changes, 20 of 20 actions SHA-pinned including the new cpp.yml, npm install hooks unchanged, and no third-party host in any added line (example.com 90, github.com 2, download.pytorch.org 1, docs.rs 1). The 12 dynamic-exec hits are the C++ test harness invoking its own checker through sys.executable, the Go sample generator reading laya's own example by AST at development time, and one comment in rust.yml. Held: #1364 (unchanged, it moves a cross-port contract), #1381 (a #[doc(hidden)] but pub Rust hook that would ship as public API able to replace the forward pass), #1386 (route_batch switched from self.route to self._route, silently bypassing subclass overrides the docstring promises), and nine stacked port PRs that conflict with each other and need linearizing (#1377, #1378, #1380, #1382, #1383, #1385, #1387, #1388, #1389, #1390). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Merged. The .NET and Rust ports of this landed together, which is the right way to do it: a per-call override that exists in one port and not the other is worse than it existing in neither, because the cross-port tests then encode the gap as expected. One thing to flag, not caused by this PR but in the same file area. A difference worth knowing about between the two ports you maintain here. Shipped in 0.4.17. |
Ports Python's
lang_temperaturesand the per-calllang,max_lenandhead_max_lento the .NET SDK.LayaOptions.LangTemperatures, resolved asresolve_lang_temperatures(base-code keys, inherit, clamp, Python's error and warning texts).Lang,MaxLen,HeadMaxLenonLayaPredictOptions,LayaBatchOptionsandLayaBatchRequest;LayaLongOptionswithLangforPredictLong(no budgets, as in Python). Additive API.Routerdoes.Tests: model-free 2314; lanes english 642, multilingual 654, typed-decisions 654, router 4; 0 failed, 0 skipped.