Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions doc/cross_platform_validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions packages/llamadart_validation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion packages/llamadart_validation/lib/src/case_catalog.dart
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
5 changes: 4 additions & 1 deletion packages/llamadart_validation/lib/src/manifest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) ...[
Expand Down
6 changes: 3 additions & 3 deletions packages/llamadart_validation/lib/src/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1158,12 +1158,12 @@ class ValidationRunner {
}

Future<Map<String, dynamic>> _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;
Expand Down
75 changes: 64 additions & 11 deletions packages/llamadart_validation/test/validation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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',
Expand All @@ -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>())
Map<Object?, Object?> omitted(int version) => {
for (final entry
in (litert.catalogForVersion(version)['cases'] as List).cast<Map>())
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),
Expand Down Expand Up @@ -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']) {
Expand All @@ -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<Map<String, dynamic>>();
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 {
Expand Down
Loading