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
19 changes: 11 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ keywords = ["deep-learning", "language", "model", "rwkv"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/cryscan/web-rwkv"
rust-version = "1.83.0"
version = "0.10.16"
version = "0.10.17"

[package]
authors.workspace = true
Expand All @@ -24,23 +24,26 @@ name = "web-rwkv"
repository.workspace = true
version.workspace = true

[workspace.dependencies]
serde = "1.0"

[dependencies]
ahash = "0.8"
bytemuck = { version = "1.23", features = ["extern_crate_alloc"] }
bytemuck = { version = "1.24", features = ["extern_crate_alloc"] }
derive-getters = "0.5"
document-features = "0.2.8"
embed-doc-image = "0.1.4"
flume = "0.11"
futures = "0.3"
gpp = "0.6.2"
half = { version = "2.2", features = ["bytemuck", "serde"] }
half = { version = "2.7", features = ["bytemuck", "serde"] }
instant = { version = "0.1", features = ["inaccurate", "wasm-bindgen"] }
itertools = "0.14"
log = "0.4"
regex = "1.11"
regex = "1.12"
rustc-hash = "2.1"
safetensors = "0.6"
serde = { version = "1.0", features = ["derive", "rc"] }
serde = { workspace = true, features = ["derive", "rc"] }
serde_bytes = "0.11"
serde_json = "1.0"
serde_variant = "0.1.3"
Expand All @@ -52,7 +55,7 @@ tracing-tracy = { version = "0.11.4", optional = true }
trait-variant = "0.1"
uid = "0.1"
wasm-bindgen = "0.2"
wgpu = "26.0"
wgpu = "27.0"

[dependencies.web-rwkv-derive]
path = "crates/web-rwkv-derive"
Expand All @@ -62,7 +65,7 @@ version = "0.10"
default-features = false
features = ["macros", "rt", "sync", "time"]
optional = true
version = "1.47"
version = "1.48"

[dev-dependencies]
anyhow = "1.0"
Expand All @@ -73,7 +76,7 @@ dialoguer = "0.12.0"
fastrand = "2.3"
memmap2 = "0.9"
ratatui = { version = "0.29", features = ["all-widgets"] }
simple_logger = { version = "5.0.0", features = ["stderr"] }
simple_logger = { version = "5.1", features = ["stderr"] }
tokio = { version = "1.41", features = ["full"] }

[features]
Expand Down
10 changes: 10 additions & 0 deletions crates/web-rwkv-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,15 @@ proc-macro2 = "1"
quote = "1"
syn = "2"

[dependencies.serde]
workspace = true

[build-dependencies]
cargo_metadata = "0.23"

[features]
default = []
deserialize_in_place = []

[lib]
proc-macro = true
75 changes: 75 additions & 0 deletions crates/web-rwkv-derive/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
use cargo_metadata::MetadataCommand;
use std::{
collections::{HashSet, VecDeque},
path::Path,
};

fn main() {
let metadata = MetadataCommand::new()
.exec()
.expect("failed to obtain cargo metadata");

// locate the current package using CARGO_MANIFEST_DIR
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
let manifest_path = Path::new(&manifest_dir).join("Cargo.toml");
let manifest_path_str = manifest_path.to_str().expect("path not UTF-8");

let current_package = metadata
.packages
.iter()
.find(|p| p.manifest_path.as_str() == manifest_path_str)
.expect("current package not found in metadata");

let resolve = metadata.resolve.as_ref().expect("resolve graph missing");

let current_node = resolve
.nodes
.iter()
.find(|node| node.id == current_package.id)
.expect("current node not found in resolve graph");

// perform BFS to find the first occurrence of the "serde" crate
let mut queue = VecDeque::new();
let mut visited = HashSet::new();
queue.push_back(current_node);
visited.insert(&current_node.id);

let serde_version = loop {
let node = queue.pop_front().expect("dependency graph exhausted");

// check dependencies of the current node
let mut found = None;
for id in &node.dependencies {
if visited.contains(id) {
continue;
}
visited.insert(id);

let node = resolve
.nodes
.iter()
.find(|n| &n.id == id)
.expect("dependency node not found");
let package = metadata
.packages
.iter()
.find(|p| p.id == node.id)
.expect("dependency package not found");

if package.name == "serde" {
found = Some(package.version.clone());
break;
}
queue.push_back(node);
}

if let Some(version) = found {
break version;
}
};

println!(
"cargo:rustc-env=SERDE_PATCH_VERSION={}",
serde_version.patch
);
}
10 changes: 6 additions & 4 deletions crates/web-rwkv-derive/src/serde/bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn with_bound(

fn visit_type(&mut self, ty: &'ast syn::Type) {
match ty {
#![cfg_attr(all(test), deny(non_exhaustive_omitted_patterns))]
#![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
syn::Type::Array(ty) => self.visit_type(&ty.elem),
syn::Type::BareFn(ty) => {
for arg in &ty.inputs {
Expand Down Expand Up @@ -196,7 +196,7 @@ pub fn with_bound(
syn::PathArguments::AngleBracketed(arguments) => {
for arg in &arguments.args {
match arg {
#![cfg_attr(all(test), deny(non_exhaustive_omitted_patterns))]
#![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
syn::GenericArgument::Type(arg) => self.visit_type(arg),
syn::GenericArgument::AssocType(arg) => self.visit_type(&arg.ty),
syn::GenericArgument::Lifetime(_)
Expand Down Expand Up @@ -225,9 +225,11 @@ pub fn with_bound(

fn visit_type_param_bound(&mut self, bound: &'ast syn::TypeParamBound) {
match bound {
#![cfg_attr(all(test), deny(non_exhaustive_omitted_patterns))]
#![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
syn::TypeParamBound::Trait(bound) => self.visit_path(&bound.path),
syn::TypeParamBound::Lifetime(_) | syn::TypeParamBound::Verbatim(_) => {}
syn::TypeParamBound::Lifetime(_)
| syn::TypeParamBound::PreciseCapture(_)
| syn::TypeParamBound::Verbatim(_) => {}
_ => {}
}
}
Expand Down
Loading
Loading