Skip to content

feat(webgpu): wire bridge state persistence#141

Merged
leehack merged 6 commits into
mainfrom
feat/web-state-persistence-v015
May 13, 2026
Merged

feat(webgpu): wire bridge state persistence#141
leehack merged 6 commits into
mainfrom
feat/web-state-persistence-v015

Conversation

@leehack

@leehack leehack commented May 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Update the default WebGPU bridge asset pin/cache-buster to v0.1.15 / llama.cpp b9116.
  • Wire WebGPU bridge KV-cache state save/load through stateSaveFile(...) and stateLoadFile(...), including JS interop and web backend delegation.
  • Document native vs WebGPU state persistence behavior, including the web WASMFS virtual-path durability caveat.
  • Add browser regression coverage for state save/load forwarding, false save returns, load return-shape handling, and clear older-bridge unsupported errors.

Production-readiness scope

  • Users can call LlamaEngine.stateSaveFile(...) / stateLoadFile(...) on native backends and WebGPU bridge assets v0.1.15+.
  • Supported platforms/paths: native app filesystem paths; WebGPU bridge WASMFS virtual paths.
  • Unsupported/older WebGPU bridge assets fail loudly with a v0.1.15 or newer unsupported error instead of silently succeeding.
  • Existing loadModel(...) and existing non-state APIs remain compatible; this is an additive API/runtime wiring update.

Intentionally deferred follow-ups

  • Durable browser storage/export/import for state artifacts across reloads remains app-level work outside the Dart file helpers.

Test Plan

  • git diff --check
  • static added-line security scan
  • dart format --output=none --set-exit-if-changed .
  • dart analyze --fatal-infos
  • dart test -p chrome test/unit/backends/webgpu/webgpu_backend_test.dart
  • dart test -p chrome test/integration/backends/webgpu/webgpu_engine_multimodal_browser_integration_test.dart
  • dart test -p chrome test/unit/backends/web/web_backend_test.dart (includes delegated state-support capability regression)
  • dart test -p vm -j 1 --exclude-tags local-only

Review Notes

  • Independent review passed with no blockers.
  • Copilot comments were addressed in b62cb38c: LlamaEngine.supportsStatePersistence now respects BackendStatePersistenceSupport, WebAutoBackend reports state support from its active delegate, older/custom WebGPU bridge asset caveats are documented, and the handled threads were resolved.
  • Second independent review of the review-fix patch passed with no blockers.

Copilot AI review requested due to automatic review settings May 13, 2026 09:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the WebGPU bridge pin to v0.1.15 and wires KV-cache state persistence (stateSaveFile / stateLoadFile) through the WebGPU JS bridge into the Dart WebGPU backend, with docs and browser test coverage.

Changes:

  • Bump the default pinned WebGPU bridge assets tag to v0.1.15 (and example cache-buster version).
  • Add WebGPU bridge state save/load JS interop + backend forwarding, including handling multiple JS return shapes.
  • Update docs and add browser regression tests for state persistence forwarding and unsupported-bridge errors.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
website/docs/platforms/webgpu-bridge.md Updates pinned tag and documents new state persistence capability + durability caveat.
website/docs/platforms/support-matrix.md Updates platform notes to reflect state persistence support on WebGPU bridge v0.1.15+.
website/docs/guides/model-lifecycle.md Updates lifecycle guide to describe state persistence on native + WebGPU bridge, with caveats.
website/docs/guides/api-levels.md Updates API-level feature list to include WebGPU bridge state persistence (v0.1.15+).
test/unit/backends/webgpu/webgpu_backend_test.dart Adds unit coverage for WebGPU backend state save/load forwarding and error behavior.
test/integration/backends/webgpu/webgpu_engine_multimodal_browser_integration_test.dart Adds integration coverage that LlamaEngine forwards state save/load to the bridge.
scripts/fetch_webgpu_bridge_assets.sh Updates default bridge assets tag and help text to v0.1.15.
README.md Updates docs to describe KV-cache persistence on native + WebGPU bridge v0.1.15+.
lib/src/core/engine/engine.dart Updates supportsStatePersistence docstring to include WebGPU bridge.
lib/src/backends/webgpu/webgpu_backend.dart Implements BackendStatePersistence and forwards state save/load via JS bridge.
lib/src/backends/webgpu/interop.dart Adds JS interop declarations for stateSaveFile / stateLoadFile.
lib/src/backends/web/web_backend.dart Adds state persistence delegation in the unified web backend router.
example/chat_app/web/index.html Updates default bridge tag and local cache-buster version strings.
doc/webgpu_bridge.md Updates contract docs to include state persistence methods and version requirement.
CHANGELOG.md Notes WebGPU bridge state persistence wiring and new version requirements.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/src/core/engine/engine.dart Outdated
Comment thread lib/src/backends/web/web_backend.dart Outdated
@codecov-commenter

codecov-commenter commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.22%. Comparing base (2f4189f) to head (738914a).

Files with missing lines Patch % Lines
lib/src/core/engine/engine.dart 62.50% 3 Missing ⚠️

❌ Your patch status has failed because the patch coverage (62.50%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #141      +/-   ##
==========================================
- Coverage   78.23%   78.22%   -0.02%     
==========================================
  Files          75       75              
  Lines        9696     9703       +7     
==========================================
+ Hits         7586     7590       +4     
- Misses       2110     2113       +3     
Flag Coverage Δ
unittests 78.22% <62.50%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Comment thread lib/src/backends/webgpu/webgpu_backend.dart Outdated
Comment thread lib/src/core/engine/engine.dart

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Comment thread test/unit/backends/web/web_backend_test.dart Outdated
Comment thread website/docs/platforms/support-matrix.md Outdated
Comment thread CHANGELOG.md Outdated
Comment thread README.md

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Comment thread lib/src/core/engine/engine.dart Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.

leehack added 5 commits May 13, 2026 09:33
Update the default WebGPU bridge assets to v0.1.15 and forward KV-cache state save/load calls through the web bridge.\n\nDocument the web WASMFS durability caveat and add browser coverage for bridge forwarding, fallback return shapes, and older bridge asset errors.
Add a backend capability flag so WebAutoBackend can report state persistence support from its active delegate.\n\nClarify the WebGPU bridge asset caveat and cover injected web delegates that do not implement persistence.
Report WebGPU state persistence support only after the active bridge exposes both stateSaveFile and stateLoadFile.\n\nMake LlamaEngine respect BackendStatePersistenceSupport before resolving structural persistence backends, and cover router/bridge missing-API regressions.
Guard the README state persistence example, correct bridge capability wording, and make the web regression assertion await the handled failure path.
Keep the state persistence capability gate while surfacing the WebGPU bridge v0.1.15 requirement from the engine-level unsupported path.
@leehack leehack force-pushed the feat/web-state-persistence-v015 branch from 6d17ee2 to 2ddec2d Compare May 13, 2026 13:39
@leehack leehack requested a review from Copilot May 13, 2026 13:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Comment thread website/docs/guides/model-lifecycle.md

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.

@leehack leehack merged commit bc69b7b into main May 13, 2026
10 checks passed
@leehack leehack deleted the feat/web-state-persistence-v015 branch May 13, 2026 14:00
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