Repository navigation
feat(laya): add native decision models and routing - #1614
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (49)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review. 📝 Walkthrough
WalkthroughAdds Laya structured-decision model support. The changes build TensorRT checkpoints, add native tokenization and inference with model routing, and provide fixtures and validation tools for the supported variants. ChangesLaya structured-decision runtime
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~60 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Caller
participant FamilyFactory
participant Router
participant Routing
participant Pipeline
participant TensorRTEngine
Caller->>FamilyFactory: Load Laya bundle
FamilyFactory->>Router: Create router when router.json is present
Router->>Routing: Route document
Routing-->>Router: Return selected model and routing decision
Router->>Pipeline: Decide using selected model
Pipeline->>TensorRTEngine: Run padded input tensors
TensorRTEngine-->>Pipeline: Return logits and action logits
Pipeline-->>Caller: Return answers, scores, usage, and routing decision
Merge Risk: ⚪ Minimal · up to This change adds new, self-contained Laya model support and an optional router under families/laya. No concrete defect was found in the reviewed code. Final-head CI is reported as pending and should complete normally before merge. 🚥 Pre-merge checks | ✅ 6 | ❌ 2 | ❓ 1❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (6 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 21.58% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 190 functions across 30 files. (19 skipped: 19 unsupported.) Full details: Benchmark Validation IntegrityExplanation The benchmark paths do not measure equivalent regions. Resolution Define one timing contract and use it for both implementations. Run the same logical record against the same topology, either a single variant on both sides or a three-variant router bundle on both sides. Align request parsing and response serialization: include both in both measurements, or exclude both with equivalent adapters. Keep CUDA/device synchronization around the same region. Use identical warmup and iteration counts, retain raw per-iteration samples, and compute p50/p95 from both paths under the same aggregation and task-unit definition. Record both measurements and the selected bundle identity in one comparison artifact. Full details: Shared Change Blast RadiusExplanation The diff is family-local except for Resolution Provide the complete pull request description or an explicit rationale for the shared catalog entry. Identify its consumers, document any behavior or compatibility impact, list validation for those consumers, and explain why the entry must be maintained outside
Comment |
Add the English, multilingual, and typed-decisions checkpoints with an optional native router. Keep model construction, tokenization, calibration, runtime orchestration, and original-SDK validation inside the Laya family. Signed-off-by: yifeif <277870278+yifeif-nv@users.noreply.github.com>
Signed-off-by: yifeif <277870278+yifeif-nv@users.noreply.github.com>
Signed-off-by: yifeif <277870278+yifeif-nv@users.noreply.github.com>
Signed-off-by: yifeif <277870278+yifeif-nv@users.noreply.github.com>
Signed-off-by: yifeif <277870278+yifeif-nv@users.noreply.github.com>
Signed-off-by: yifeif <277870278+yifeif-nv@users.noreply.github.com>
Keep the original logit, probability, selected-choice, and action gates. Check derived fields with the released SDK formulas on the validated native probabilities, including exact rounding and response metadata. Require repeated public responses to match. Signed-off-by: yifeif <277870278+yifeif-nv@users.noreply.github.com>
0a73107 to
be695cd
Compare
Background
Add the three checkpoints bundled in
convaiinnovations/laya@7b928d828b7b0e022f929d9bd2e44165aa270148: English at the root, multilingual, and typed-decisions. The native implementation targets the releasedlaya==0.3.20request and response behavior.Exit Criteria
All declared variants and model-card examples must pass original-reference accuracy checks, native inference must contain no Python/Torch dependency, matched complete Router calls must beat a validated compiled reference, and stable Community CI plus Internal CI must pass on the final head. The original per-option accuracy gates are unchanged. Derived response fields must follow the released SDK formulas, with exact four-decimal formatting of the validated native probabilities.
Implementation
One new family owns the ModernBERT encoder, decision/action heads, TensorRT plans, native BPE/NFC tokenization, question batching, calibration, response formatting, and routing. The
buildcommand selects one variant or a three-model router bundle. The C++decidecommand and existing structured-decision Task execute both bundle kinds. No shared API, ABI, or bundle-framing change is required.Change categories
Validation
Commands and Results
python -m tools.model_ci validate: passed.python -m pytest families/laya/tests/test_support.py -q: 11 passed.python -m tools.legal_headers --check: no findings.ruff check --config ruff.toml families/layaandgit diff --check: passed.python -m families.laya.tests.compare_record --checkpoint /artifacts/checkpoint --probe /src/build/laya_record_probe --output /artifacts/record-parity: each variant matched 2,099 tokenizer inputs and 18 complete records exactly, including Unicode normalization and long-conversation truncation.python -m families.laya.tests.compare_routing --probe /src/build/laya_routing_probe --output /artifacts/routing-parity: 665 exact routing decisions and metadata comparisons passed.python -m pytest families/laya/tests/test_e2e.py --e2e-model laya -q: 23 passed against the original CUDA SDK, using the qualified English, multilingual, typed-decisions, and three-model Router bundles. This covers the model-card examples, empty requests, single-option questions, long conversations, question batches, and repeated public responses. The native process loads no Python/Torch libraries.atol=0.125, rtol=0.015; per-option probabilities retainatol=0.002, rtol=0.01. Choices, usage, routing, and response structure match the reference; action probabilities retain their original gate. Entropy confidence and expected scores are checked with the SDK formulas on the validated native probabilities. Their numeric differences from original inference can reflect propagated probability error; the long-conversation confidence is 0.3635 versus 0.3695.python -m families.laya.tests.compare_router --checkpoint /artifacts/checkpoint --bundle /artifacts/laya-router-qualified.bundle --probe /src/build/laya_task_probe --runtime-root /src/build --output /artifacts/router-behavior-qualified: all 22 explicit/automatic Router cases passed, with every variant exercised through the combined bundle.torch.compile(max-autotune)p50: English email 2.44 / 5.41 ms, Hindi 2.45 / 3.71 ms, Spanish 1.89 / 2.60 ms, typed-decisions email 2.25 / 4.77 ms. Both sides measure the complete public Router call, excluding build/load/warmup.Hardware, Environment, and Revisions
Head
be695cddadc575a870f71a938d02aaa5405ebd94; checkpointconvaiinnovations/laya@7b928d828b7b0e022f929d9bd2e44165aa270148; SDKlaya==0.3.20; Transformers 5.10.2; Torch 2.12.0+cu130; TensorRT 11.1.0.106. Local validation uses NVIDIA GB300, driver 580.105.08, and Ubuntu 24.04.4. Runtime graphs preserve the checkpoint's operand precision with explicit FP32 arithmetic boundaries.Not Run / Remaining Gaps
Final-head Stable Community CI and Internal CI passed on
be695cddadc575a870f71a938d02aaa5405ebd94. The optional 8192-token capacity and other GPU platforms have not been qualified. SDK callbacks and external integrations are outside the native Task interface. Local E2E reused previously built qualified bundles, except for the multilingual standalone bundle rebuilt from the current source; Internal CI also passed with freshly built bundles.Contributor Self-Review
Contributor self-review completed on head
be695cddadc575a870f71a938d02aaa5405ebd94againste6c674ebe329f109a6d4a5da20d08f472fe094c9. No blocking architecture or code findings remain; both required final-head CI lanes passed.Notes For Future Readers
Start with
model.py, then followruntime/plugin.cppinto record, tokenizer, and routing behavior. The original SDK remains a build/reference dependency only. The router loads all three native engines; SDK callbacks and external integrations are outside the Task interface. Dev CI is informational; stable Community CI and Internal CI are the required readiness gates. Leave this PR unmerged.Risk level
The change is isolated to one new family. It adds a complete encoder, native tokenizer, and routing protocol; qualification currently covers the declared default capacities on GB300.