Skip to content

Commit

Permalink
Remove TRANSPOSE and RENAME constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryscan committed May 15, 2024
1 parent c794601 commit c49626d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
16 changes: 9 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "web-rwkv-converter"
version = "0.1.1"
edition = "2021"
authors = ["Zhang Zhenyuan <cryscan@umich.edu>"]
license = "MIT OR Apache-2.0"
categories = ["science"]
description = "Converts an RWKV PTH model to SafeTensors."
edition = "2021"
homepage = "https://github.com/cryscan/web-rwkv-converter"
keywords = ["LLM", "deep-learning", "model", "rwkv"]
license = "MIT OR Apache-2.0"
name = "web-rwkv-converter"
repository = "https://github.com/cryscan/web-rwkv-converter"
keywords = ["deep-learning", "LLM", "model", "rwkv"]
categories = ["science"]
version = "0.1.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -17,10 +17,12 @@ anyhow = "1"
bytemuck = { version = "1.13", features = ["extern_crate_alloc"] }
half = { version = "2.2", features = ["bytemuck"] }
safetensors = "0.4.1"
# serde = { version = "1", features = ["derive"] }
# serde-pickle = "1.1.1"

[dependencies.repugnant-pickle]
version = "0.0.1"
features = ["torch"]
version = "0.0.1"

[dev-dependencies]
clap = { version = "4.3", features = ["derive"] }
Expand Down
18 changes: 17 additions & 1 deletion examples/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,23 @@ use std::{fs::File, path::PathBuf};
use anyhow::Result;
use clap::Parser;
use memmap2::Mmap;
use web_rwkv_converter::{convert_safetensors, RENAME, TRANSPOSE};
use web_rwkv_converter::convert_safetensors;

pub const RENAME: [(&str, &str); 4] = [
("time_faaaa", "time_first"),
("time_maa", "time_mix"),
("lora_A", "lora.0"),
("lora_B", "lora.1"),
];

pub const TRANSPOSE: [&str; 6] = [
"time_mix_w1",
"time_mix_w2",
"time_decay_w1",
"time_decay_w2",
"time_state",
"lora.0",
];

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
Expand Down
14 changes: 0 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@ use repugnant_pickle::{
};
use safetensors::{Dtype, View};

pub const RENAME: [(&str, &str); 4] = [
("time_faaaa", "time_first"),
("time_maa", "time_mix"),
("lora_A", "lora.0"),
("lora_B", "lora.1"),
];

pub const TRANSPOSE: [&str; 4] = [
"time_mix_w1",
"time_mix_w2",
"time_decay_w1",
"time_decay_w2",
];

struct Tensor {
name: String,
shape: Vec<usize>,
Expand Down

0 comments on commit c49626d

Please # to comment.