feat(webgpu): wire bridge state persistence#141
Conversation
There was a problem hiding this comment.
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.
Codecov Report❌ Patch coverage is
❌ 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
6d17ee2 to
2ddec2d
Compare
Summary
v0.1.15/ llama.cppb9116.stateSaveFile(...)andstateLoadFile(...), including JS interop and web backend delegation.Production-readiness scope
LlamaEngine.stateSaveFile(...)/stateLoadFile(...)on native backends and WebGPU bridge assetsv0.1.15+.v0.1.15 or newerunsupported error instead of silently succeeding.loadModel(...)and existing non-state APIs remain compatible; this is an additive API/runtime wiring update.Intentionally deferred follow-ups
Test Plan
git diff --checkdart format --output=none --set-exit-if-changed .dart analyze --fatal-infosdart test -p chrome test/unit/backends/webgpu/webgpu_backend_test.dartdart test -p chrome test/integration/backends/webgpu/webgpu_engine_multimodal_browser_integration_test.dartdart 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-onlyReview Notes
b62cb38c:LlamaEngine.supportsStatePersistencenow respectsBackendStatePersistenceSupport,WebAutoBackendreports state support from its active delegate, older/custom WebGPU bridge asset caveats are documented, and the handled threads were resolved.