Repository navigation
feat(dotnet): port predict_tournament and cached_embed_fn - #1387
Open
kevin-gatimu wants to merge 3 commits into
Open
kevin-gatimu wants to merge 3 commits into
kevin-gatimu wants to merge 3 commits into
Conversation
Owner
|
Held for integration, not on merit. This is one of nine PRs in the same chain that were each opened against The full conflict map and what I need is on #1377, so I am not repeating it here: short version, pick an order, rebase each onto the one before it, and regenerate For this one specifically, the conflicting paths against the integration branch were: |
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>
kevin-gatimu
force-pushed
the
feat/dotnet-tournament
branch
from
October 30, 2026 11:06
43cc192 to
2d1a8bc
Compare
Contributor
Author
kevin-gatimu
force-pushed
the
feat/dotnet-tournament
branch
from
November 1, 2026 07:44
2d1a8bc to
80f1698
Compare
9 tasks
ChoiceQuestion, ScoreQuestion and NoulQuestion gain OptionOrder and WithOptionOrder (a permutation of the option slots). Options are encoded and marked in slot order, the softmax runs in slot order and the probabilities are mapped back to option order before the answer is built, as laya/common.py and Agent do. The order is validated with Python's text where Python validates it, joins the router's batch grouping key, and is dropped with Python's warning when the shortlist narrows the labels. Existing signatures are unchanged. Goldens come from tools/regen_golden.py; the case lists are shared verbatim with the Rust SDK.
NoulQuestion gains Labels, WithLabels and WithoutLabels: the false and true option labels Python's noul questions accept. They are validated and stripped as laya/common.py _resolve_noul_labels does, with Python's text, at prediction as Agent._check_question does; rendered as "<label>: <criterion or default text>"; part of the router's batch grouping key. The answer is unchanged (P(true)). Existing signatures are unchanged. Goldens come from tools/regen_golden.py; the case lists are shared verbatim with the Rust SDK.
LayaShortlist.PredictTournament narrows each large choice in rounds of
contiguous groups of groupSize labels, one predict call per round with
the group winners kept in order, then answers the full request once with
each choice cut to its finalists, as laya/shortlist.py predict_tournament
does: same group slicing, round ids, errors and option_order warning; the
result is the final call's with Tournament metadata {labels, n, rounds}.
An overload takes a predict function so per-call options reach every
round, as Python's **predict_kwargs.
CachedEmbedFunction ports cached_embed_fn: an LRU of float32 rows keyed
on the exact text, misses embedded in one de-duplicated call, non-finite
values cached as 0.0, the dimension guard, CacheInfo and CacheClear.
Goldens, a tournament probe and a cache probe come from
tools/regen_golden.py and Python's own functions; the case lists are
shared verbatim with the Rust SDK.
kevin-gatimu
force-pushed
the
feat/dotnet-tournament
branch
from
November 1, 2026 16:35
80f1698 to
1361fa1
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #1382 (noul labels, on #1377 option_order); only the last commit is new.
Ports Python's
predict_tournamentandcached_embed_fnto the .NET SDK.LayaShortlist.PredictTournament: rounds of contiguous groups, one predict per round, winners in group order, then one final call with each choice cut to its finalists. Result is the final call's plusTournamentmetadata{labels, n, rounds}; same errors andoption_orderwarning aslaya/shortlist.py. An overload takes a predict function, so per-call options reach every round as**predict_kwargsdo.CachedEmbedFunction: LRU of float32 rows keyed on the exact text, misses embedded in one de-duplicated call, non-finite values cached as 0.0, dimension guard,CacheInfo/CacheClear.predict_tournamentover a scripted predictor, andcached_embed_fn), shared with the Rust PR.Tests: model-free 2264; lanes english 627, multilingual 639, typed-decisions 639, router 4; 0 failed, 0 skipped.