Skip to content

Commit

Permalink
Require BackedState to be serializable.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryscan committed Feb 20, 2024
1 parent f43b3f6 commit d2fc79d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "web-rwkv"
version = "0.6.12"
version = "0.6.13"
edition = "2021"
authors = ["Zhenyuan Zhang <[email protected]>"]
license = "MIT OR Apache-2.0"
Expand All @@ -17,9 +17,9 @@ exclude = ["assets/", "crates/", "screenshots/"]
wgpu = "0.18"
bytemuck = { version = "1.13", features = ["extern_crate_alloc"] }
half = { version = "2.2", features = ["bytemuck"] }
safetensors = "0.4.1"
safetensors = "0.4"
flume = "0.11.0"
regex = "1.8.4"
regex = "1.10"
gpp = "0.6.2"
uid = "0.1"
ahash = "0.8"
Expand Down
6 changes: 5 additions & 1 deletion src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ pub trait FromBuilder: Sized {
fn from_builder(builder: Self::Builder<'_>) -> Result<Self, Self::Error>;
}

pub trait BackedState: for<'a> FromBuilder<Builder<'a> = StateBuilder, Error = Infallible> {
pub trait BackedState:
Serialize
+ for<'a> Deserialize<'a>
+ for<'a> FromBuilder<Builder<'a> = StateBuilder, Error = Infallible>
{
fn num_batch(&self) -> usize;
fn num_layer(&self) -> usize;

Expand Down
2 changes: 1 addition & 1 deletion src/model/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl super::ModelState for ModelState {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BackedState {
pub shape: Shape,
pub data: Vec<f32>,
Expand Down
2 changes: 1 addition & 1 deletion src/model/v5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ impl super::ModelState for ModelState {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BackedState {
pub num_batch: usize,
pub chunk_size: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/model/v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ impl super::ModelState for ModelState {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BackedState {
pub num_batch: usize,
pub chunk_size: usize,
Expand Down

0 comments on commit d2fc79d

Please sign in to comment.