diff --git a/doc/cross_platform_validation.md b/doc/cross_platform_validation.md index 3afec1a06..54779e720 100644 --- a/doc/cross_platform_validation.md +++ b/doc/cross_platform_validation.md @@ -1793,6 +1793,30 @@ Unicode generation, thinking on/off and tool choice/result controls. Thinking budgets, tool-bearing batching and model-specific qualification remain separate. +### Catalog 7 LiteRT-LM restart and overlap + +Catalog 7 selects `C08.cancel.restart` and `C08.overlap` for LiteRT profiles +([#1115](https://github.com/leehack/llamadart/issues/1115)). Since +[#656](https://github.com/leehack/llamadart/issues/656), a LiteRT-LM generation +requested after a cancel waits for the cancelled run to end, and one requested +during an uncancelled run throws `LlamaStateException`, on native and Web. Case +versions, fixtures and predicates are unchanged. LiteRT journals from catalogs +5 and 6 keep both cases omitted as `litert_restart_contract_undefined`. The Web +host rejects native LiteRT fixtures, so no LiteRT Web profile runs them yet. + +Local macOS arm64 (M4 Max) JIT runs on 2026-10-24 with Qwen3-0.6B, clean +source and LiteRT-LM `0.18.1-2` (diagnostic, not qualification): +`chat-litert-cpu` and `chat-litert-gpu` each passed 17/17. In +`C08.cancel.restart` the second request, issued right after the cancel, began +streaming after the cancelled stream ended (CPU 656 ms after 336 ms; GPU 159 ms +after 86 ms). In `C08.overlap` the timed second request was rejected with +`LlamaStateException` within 4 ms, and the first stream delivered two more +deltas and ended cleanly. The GPU run's placement stayed unverified. When the +native backend starts a post-cancel request without waiting, GPU +`C08.cancel.restart` fails with the wrapped `generation is already in +progress` error; when it queues an uncancelled overlap instead of rejecting it, +`C08.overlap` stays NOT_RUN and the run does not qualify. + ### Catalog 6 in-flight cancellation and overlap Catalog 6 versions `C08.cancel` and `C08.overlap` to 2. Native GGUF runs @@ -1828,19 +1852,16 @@ timings; a missed precondition is NOT_RUN, never PASS. | Case | Request | Passes when | Runs on | | --- | --- | --- | --- | | `C08.cancel.early` | `cancelGeneration()` right after listening to the short request, before any delta ([#602](https://github.com/leehack/llamadart/issues/602)) | The stream ends without content, thinking or tool calls within the 5 s cancel deadline; the same request then completes with output | Every public-API profile | -| `C08.cancel.restart` | At the first delta of the 256-token cancel request, `cancelGeneration()`, then the short request without waiting ([#655](https://github.com/leehack/llamadart/issues/655)) | The short request, issued before the cancelled stream ended, completes with output and its first delta follows that end | GGUF quick core | -| `C08.overlap` | The short request at the first delta of the uncancelled 256-token request | It fails with `LlamaStateException` before the first ends, the first streams at least one more delta and ends cleanly after the harness cancels it, and a later request completes | GGUF quick core | +| `C08.cancel.restart` | At the first delta of the 256-token cancel request, `cancelGeneration()`, then the short request without waiting ([#655](https://github.com/leehack/llamadart/issues/655)) | The short request, issued before the cancelled stream ended, completes with output and its first delta follows that end | GGUF quick core; LiteRT quick core from catalog 7 | +| `C08.overlap` | The short request at the first delta of the uncancelled 256-token request | It fails with `LlamaStateException` before the first ends, the first streams at least one more delta and ends cleanly after the harness cancels it, and a later request completes | GGUF quick core; LiteRT quick core from catalog 7 | | `C12.grammar` | Raw request with GBNF `root ::= "unterminated` | Native: `LlamaInferenceException` `llama.cpp failed to initialize the requested grammar sampler.`; Web: `LlamaInferenceException` whose details contain `(invalid grammar)`; then a request completes | GGUF quick core | | `C07.tools.auto_text` | `ToolChoice.auto` with `get_weather` on the hello prompt ([#654](https://github.com/leehack/llamadart/issues/654)) | Text finish matching the hello regex, no tool call | `tools` selection | Of the GGUF runtimes, only native llama.cpp defines restart and overlap, so -GGUF Web records both as NOT_RUN. LiteRT-LM defines both on native and Web -since [#656](https://github.com/leehack/llamadart/issues/656), but LiteRT -profiles still omit them (`litert_restart_contract_undefined`) until their -cases are enabled and qualified -([#1115](https://github.com/leehack/llamadart/issues/1115)). LiteRT profiles -also omit `C12.grammar` (`litert_grammar_unsupported`: LiteRT-LM rejects every -grammar). C07.tools version 3 also binds the hello fixture its recovery uses. +GGUF Web records both as NOT_RUN. LiteRT profiles run both from catalog 7 and +omit them in catalogs 5 and 6 (`litert_restart_contract_undefined`). LiteRT +profiles also omit `C12.grammar` (`litert_grammar_unsupported`: LiteRT-LM +rejects every grammar). C07.tools version 3 also binds the hello fixture its recovery uses. On Web, a required trial rejected with the documented `LlamaUnsupportedException` for a lazy required-tool grammar counts as that trial's result; elsewhere the rejection stays ERROR. Catalog 1 to 4 reports diff --git a/example/chat_app/test/internal_diagnostic_output_io_test.dart b/example/chat_app/test/internal_diagnostic_output_io_test.dart index a73c80cec..275fa7ac4 100644 --- a/example/chat_app/test/internal_diagnostic_output_io_test.dart +++ b/example/chat_app/test/internal_diagnostic_output_io_test.dart @@ -173,7 +173,7 @@ void main() { root, ) async { final o = InternalDiagnosticOutput.open(root, binding); - await complete(o, catalogVersion: validationCatalogVersion); + await complete(o, catalogVersion: 6); final report = o.finish(); expect( !report.assertionsPassed && seal(o)['complete'] == false, diff --git a/packages/llamadart_validation/README.md b/packages/llamadart_validation/README.md index 908263a71..a49f63033 100644 --- a/packages/llamadart_validation/README.md +++ b/packages/llamadart_validation/README.md @@ -53,6 +53,10 @@ trigger; native token reduction or an actual overlap rejection proves the in-flight condition. A missed condition stays NOT_RUN, and older journals keep their original results. See [the case contract](../../doc/cross_platform_validation.md#catalog-6-in-flight-cancellation-and-overlap). +Catalog 7 runs `C08.cancel.restart` and `C08.overlap` on LiteRT profiles too; +LiteRT journals from older catalogs keep both omitted. See +[the catalog 7 notes](../../doc/cross_platform_validation.md#catalog-7-litert-lm-restart-and-overlap). + ## Running validation Start from the repository root: diff --git a/packages/llamadart_validation/lib/src/case_catalog.dart b/packages/llamadart_validation/lib/src/case_catalog.dart index 0f53ce9c7..eeb11954b 100644 --- a/packages/llamadart_validation/lib/src/case_catalog.dart +++ b/packages/llamadart_validation/lib/src/case_catalog.dart @@ -1,7 +1,7 @@ import 'decision_catalog.dart'; /// Current reproducible catalog contract; older journals retain their version. -const int validationCatalogVersion = 6; +const int validationCatalogVersion = 7; /// Versioned core feature selectors. Optional model/media packs are separate. const validationFeatures = { diff --git a/packages/llamadart_validation/lib/src/manifest.dart b/packages/llamadart_validation/lib/src/manifest.dart index bad678b21..66c99237b 100644 --- a/packages/llamadart_validation/lib/src/manifest.dart +++ b/packages/llamadart_validation/lib/src/manifest.dart @@ -350,7 +350,10 @@ class ValidationProfile { if (!nativeReference) 'C08.cancel', if (!nativeReference && catalogVersion >= 5) ...[ 'C08.cancel.early', - if (runtime == 'gguf') ...['C08.cancel.restart', 'C08.overlap'], + if (runtime == 'gguf' || catalogVersion >= 7) ...[ + 'C08.cancel.restart', + 'C08.overlap', + ], ], 'C09.reload', if (!nativeReference) ...[ diff --git a/packages/llamadart_validation/lib/src/runner.dart b/packages/llamadart_validation/lib/src/runner.dart index b7e348316..619dec989 100644 --- a/packages/llamadart_validation/lib/src/runner.dart +++ b/packages/llamadart_validation/lib/src/runner.dart @@ -1158,12 +1158,12 @@ class ValidationRunner { } Future> _overlapping({required bool restart}) async { - if (engine.isWeb) { + if (engine.isWeb && profile.runtime == 'gguf') { return { 'status': 'NOT_RUN', 'reason': - 'Only native llama.cpp defines generation restart and overlap; ' - 'the Web bridge does not', + 'Only native llama.cpp defines GGUF generation restart and ' + 'overlap; the Web bridge does not', }; } final cancel = profile.fixtures['cancel'] as Map; diff --git a/packages/llamadart_validation/test/validation_test.dart b/packages/llamadart_validation/test/validation_test.dart index 573d160ae..181f874e0 100644 --- a/packages/llamadart_validation/test/validation_test.dart +++ b/packages/llamadart_validation/test/validation_test.dart @@ -1276,7 +1276,7 @@ void main() { engine, selected: ValidationProfile.fromJson(data), ); - expect(result.report.cases.length, native ? 12 : 18); + expect(result.report.cases.length, native ? 12 : 20); expect(result.report.assertionsPassed, true); final histories = engine.requests .where((r) => r['history'] != null) @@ -2266,7 +2266,7 @@ void main() { }); group('catalog 5 cancellation, restart, overlap and grammar cases', () { - test('GGUF quick core adds them; LiteRT omits the undefined contracts', () { + test('GGUF quick core adds them; LiteRT adds restart and overlap', () { expect(gguf('tiny-gguf-cpu').caseIds, [ 'C01.load', 'C02.unicode', @@ -2287,17 +2287,31 @@ void main() { final litert = profile(); expect(litert.caseIds.where(catalogFiveCaseIds.contains), [ 'C08.cancel.early', + 'C08.cancel.restart', + 'C08.overlap', ]); - final omitted = { - for (final entry in (litert.catalog['cases'] as List).cast()) + Map omitted(int version) => { + for (final entry + in (litert.catalogForVersion(version)['cases'] as List).cast()) if (entry['selected'] == false) entry['id']: entry['omission_reason'], }; - expect( - omitted['C08.cancel.restart'], - 'litert_restart_contract_undefined', - ); - expect(omitted['C08.overlap'], 'litert_restart_contract_undefined'); - expect(omitted['C12.grammar'], 'litert_grammar_unsupported'); + expect(omitted(7).keys, isNot(contains('C08.cancel.restart'))); + expect(omitted(7).keys, isNot(contains('C08.overlap'))); + expect(omitted(7)['C12.grammar'], 'litert_grammar_unsupported'); + for (final version in [5, 6]) { + expect( + litert.caseIdsForCatalog(version).where(catalogFiveCaseIds.contains), + ['C08.cancel.early'], + ); + expect( + omitted(version)['C08.cancel.restart'], + 'litert_restart_contract_undefined', + ); + expect( + omitted(version)['C08.overlap'], + 'litert_restart_contract_undefined', + ); + } expect(litert.caseIdsForCatalog(4), isNot(contains('C08.cancel.early'))); expect( gguf().caseIdsForCatalog(4).where(catalogFiveCaseIds.contains), @@ -2466,7 +2480,7 @@ void main() { }, ); - test('Web records restart and overlap as NOT_RUN', () async { + test('GGUF Web records restart and overlap as NOT_RUN', () async { final engine = ggufEngine()..isWeb = true; final result = await run(engine, selected: gguf()); for (final id in ['C08.cancel.restart', 'C08.overlap']) { @@ -2478,6 +2492,45 @@ void main() { expect(record(result, 'C08.cancel.early')['status'], 'PASS'); }); + test('LiteRT runs restart and overlap on native and Web', () async { + for (final web in [false, true]) { + final engine = FakeEngine()..isWeb = web; + final result = await run(engine); + expect(engine.overlapCalls, [true, false], reason: 'web=$web'); + for (final id in ['C08.cancel.restart', 'C08.overlap']) { + expect(record(result, id)['status'], 'PASS', reason: '$id web=$web'); + } + final failed = await run( + FakeEngine() + ..isWeb = web + ..overlapFault = 'overlap_accepted', + ); + expect(record(failed, 'C08.overlap')['status'], 'FAIL'); + expect(failed.report.qualified, false); + } + }); + + test('catalog 6 LiteRT journals keep their restart omissions', () async { + final selected = profile(); + final result = await run(FakeEngine(), selected: selected); + final events = (jsonDecode(jsonEncode(result.events)) as List) + .cast>(); + dropUndeclared(events, selected, 6); + events.first['catalog'] = selected.catalogForVersion(6); + events.first['catalog_hash'] = jsonHash(events.first['catalog']); + final report = ValidationReport.parse(events.map(jsonEncode).join('\n')); + expect(report.problems, isEmpty); + expect( + report.cases.map((e) => e['case_id']), + isNot(anyOf(contains('C08.cancel.restart'), contains('C08.overlap'))), + ); + events.first['case_ids'] = selected.caseIds; + expect( + ValidationReport.parse(events.map(jsonEncode).join('\n')).problems, + contains('Case inventory does not match the profile'), + ); + }); + test( 'invalid grammar needs the backend-specific typed rejection', () async {