You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No actionable comments were generated in the recent review.
Walkthrough
The change adds slot save and restore message types, native handlers that use a temporary file, and public TypeScript methods. The methods save slot state as bytes or restore bytes for a selected slot. Tests cover saved state, restored completions, and invalid restore data.
C++ and TypeScript define request and response messages for slot save and restore. The messages include slot IDs, status fields, token counts, and binary data where applicable.
Native slot save and restore cpp/wllama.cpp, cpp/wllama-context.h, cpp/wllama-fs.h
The action dispatcher routes slot requests to native handlers. The handlers submit server tasks using /tmp/wllama_slot_state.bin, read or write state bytes, and return task results. The file wrapper records successful opens only for paths beginning with models/ or /models/.
Public slot state methods and validation src/wllama.ts, src/wllama.test.ts
saveSlotState returns saved bytes, and restoreSlotState returns the restored token count. Both default to slot 0 and report failures as inference errors. Tests check state persistence, matching completions, and invalid restore handling.
sequenceDiagram
participant Wllama
participant wllama_action
participant wllama_context
participant server_task
participant temp_file
Wllama->>wllama_action: Send slot save or restore request
wllama_action->>wllama_context: Call the matching slot action
wllama_context->>server_task: Submit slot task and run queue
server_task->>temp_file: Save or load slot state
wllama_context->>temp_file: Read saved bytes or write restore bytes
wllama_context-->>Wllama: Return task result and response data
Loading
Suggested reviewers:thomas-0816
Merge Risk: Low · up to 8859c
This change adds methods to save and restore a model slot's state as bytes. Restoring a large saved state makes one extra full-size copy while the request is sent to the worker, which costs memory and time but does not break behavior. It is safe to merge, and transferring the encoded buffer can follow.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the two new public methods, saveSlotState and restoreSlotState, which are the main change in the changeset. The PR adds these methods to the Wllama class in src/wllama.ts, along with t…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title names the two new public methods, saveSlotState and restoreSlotState, which are the main change in the changeset. The PR adds these methods to the Wllama class in src/wllama.ts, along with the worker messages, the native slot save/restore actions, and the generated bindings that support them.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: dc28a2d3-6ab3-4392-b90c-265ef0b02925
Commits
Reviewing files that changed from the base of the PR and between 7ff82ca and 392cc09.
Files selected for processing: 10
compat/wasm/wllama.js
cpp/glue.hpp
cpp/wllama-context.h
cpp/wllama-fs.h
cpp/wllama.cpp
src/glue/messages.ts
src/wasm/wllama.js
src/wllama.test.ts
src/wllama.ts
src/workers-code/generated.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #298
Summary by CodeRabbit