Skip to content

feat(dotnet): port lang_temperatures and per-call lang, max_len and head_max_len - #1370

Merged
NandhaKishorM merged 2 commits into
NandhaKishorM:mainfrom
kevin-gatimu:feat/dotnet-lang-temperatures
Oct 28, 2026
Merged

NandhaKishorM merged 2 commits into
NandhaKishorM:mainfrom
kevin-gatimu:feat/dotnet-lang-temperatures

Conversation

@kevin-gatimu

@kevin-gatimu kevin-gatimu commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Ports Python's lang_temperatures and the per-call lang, max_len and head_max_len to the .NET SDK.

  • LayaOptions.LangTemperatures, resolved as resolve_lang_temperatures (base-code keys, inherit, clamp, Python's error and warning texts).
  • Lang, MaxLen, HeadMaxLen on LayaPredictOptions, LayaBatchOptions and LayaBatchRequest; LayaLongOptions with Lang for PredictLong (no budgets, as in Python). Additive API.
  • Router forwards the explicit lang, else the detected language, and groups batch requests by budget and lang as Python's Router does.
  • Budgets follow Python's arithmetic, including 0 and negative values.
  • Goldens and probes shared with the Rust PR.

Tests: model-free 2314; lanes english 642, multilingual 654, typed-decisions 654, router 4; 0 failed, 0 skipped.

…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.
Copilot AI balanced review requested due to automatic review settings October 25, 2026 17:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

… 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.
@NandhaKishorM
NandhaKishorM merged commit 56de2de into NandhaKishorM:main Oct 28, 2026
50 checks passed
NandhaKishorM added a commit that referenced this pull request Oct 28, 2026
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>
@NandhaKishorM

Copy link
Copy Markdown
Owner

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. laya-dotnet/src/Laya/LanguageDetection.cs holds the diacritic set as a hand-written literal, and #1392 grew it in laya/lang.py without updating this port, so is_english/vietnamese and p0411/vietnamese_combining failed at the release commit. Fixed in dc0916c.

A difference worth knowing about between the two ports you maintain here. laya-rust/tools/dump_differential_golden.py reads the language tables live, so its generated corpus shifts whenever a table changes and a port that missed one gets caught across thousands of cases. The .NET generator does not read them, so its corpus is frozen and only the two curated probes moved. That is why Rust reported 133 mismatches and .NET reported 2. If the .NET differential generator read the tables the same way, the .NET port would get the same breadth of coverage for free.

Shipped in 0.4.17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants