unify cargo version and add some ci rules
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
use aha::models::{minicpm4::config::MiniCPM4Config, qwen2_5vl::config::Qwen2_5VLConfig, voxcpm::config::VoxCPMConfig};
|
||||
use aha::models::{
|
||||
minicpm4::config::MiniCPM4Config, qwen2_5vl::config::Qwen2_5VLConfig,
|
||||
voxcpm::config::VoxCPMConfig,
|
||||
};
|
||||
use anyhow::Result;
|
||||
|
||||
#[test]
|
||||
@@ -11,7 +14,6 @@ fn qwen2_5_vl_config() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn minicpm4_config() -> Result<()> {
|
||||
// cargo test -F cuda,flash-attn minicpm4_config -- --nocapture
|
||||
@@ -30,4 +32,4 @@ fn voxcpm_config() -> Result<()> {
|
||||
let config: VoxCPMConfig = serde_json::from_slice(&std::fs::read(config_path)?)?;
|
||||
println!("{:?}", config);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
use aha::utils::audio_utils::{load_audio_with_resample};
|
||||
use aha::utils::audio_utils::load_audio_with_resample;
|
||||
use anyhow::Result;
|
||||
|
||||
#[test]
|
||||
fn messy_test() -> Result<()> {
|
||||
let device = candle_core::Device::Cpu;
|
||||
let wav_path = "./assets/audio/example.wav";
|
||||
let audio_tensor = load_audio_with_resample(wav_path, device,Some(16000))?;
|
||||
|
||||
let audio_tensor = load_audio_with_resample(wav_path, device, Some(16000))?;
|
||||
|
||||
println!("audio_tensor: {}", audio_tensor);
|
||||
// let string = "你好啊".to_string();
|
||||
// let vec_str: Vec<String>= string.chars().map(|c| c.to_string()).collect();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use std::{pin::pin, time::Instant};
|
||||
|
||||
use aha::models::{minicpm4::generate::MiniCPMGenerateModel, GenerateModel};
|
||||
use aha::models::{GenerateModel, minicpm4::generate::MiniCPMGenerateModel};
|
||||
use anyhow::Result;
|
||||
use candle_core::{DType, Device};
|
||||
use openai_dive::v1::resources::chat::ChatCompletionParameters;
|
||||
use rocket::futures::StreamExt;
|
||||
|
||||
@@ -11,7 +10,7 @@ fn minicpm_generate() -> Result<()> {
|
||||
// test with cpu :(太慢了, : RUST_BACKTRACE=1 cargo test minicpm_generate -- --nocapture
|
||||
// test with cuda: RUST_BACKTRACE=1 cargo test -F cuda minicpm_generate -- --nocapture
|
||||
// test with cuda+flash-attn: RUST_BACKTRACE=1 cargo test -F cuda,flash-attn minicpm_generate -- --nocapture
|
||||
|
||||
|
||||
let model_path = "/home/jhq/huggingface_model/OpenBMB/MiniCPM4-0.5B/";
|
||||
let message = r#"
|
||||
{
|
||||
@@ -44,7 +43,7 @@ fn minicpm_generate() -> Result<()> {
|
||||
#[tokio::test]
|
||||
async fn minicpm_stream() -> Result<()> {
|
||||
// test with cuda+flash-attn: RUST_BACKTRACE=1 cargo test -F cuda,flash-attn minicpm_stream -- --nocapture
|
||||
|
||||
|
||||
let model_path = "/home/jhq/huggingface_model/OpenBMB/MiniCPM4-0.5B/";
|
||||
|
||||
let message = r#"
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
use std::{pin::pin, time::Instant};
|
||||
|
||||
use aha::{
|
||||
models::{GenerateModel, qwen2_5vl::generate::Qwen2_5VLGenerateModel},
|
||||
};
|
||||
use aha::models::{GenerateModel, qwen2_5vl::generate::Qwen2_5VLGenerateModel};
|
||||
use anyhow::Result;
|
||||
use candle_core::{DType, Device};
|
||||
use openai_dive::v1::resources::chat::ChatCompletionParameters;
|
||||
use rocket::futures::StreamExt;
|
||||
|
||||
|
||||
+6
-10
@@ -1,20 +1,16 @@
|
||||
use anyhow::{Ok, Result};
|
||||
use std::{time::Instant};
|
||||
use std::time::Instant;
|
||||
|
||||
use aha::{
|
||||
models::voxcpm::{ generate::VoxCPMGenerate,
|
||||
tokenizer::SingleChineseTokenizer,
|
||||
},
|
||||
utils::{
|
||||
audio_utils::save_wav,
|
||||
},
|
||||
models::voxcpm::{generate::VoxCPMGenerate, tokenizer::SingleChineseTokenizer},
|
||||
utils::audio_utils::save_wav,
|
||||
};
|
||||
use anyhow::{Ok, Result};
|
||||
|
||||
#[test]
|
||||
fn voxcpm_generate() -> Result<()> {
|
||||
// RUST_BACKTRACE=1 cargo test -F cuda,flash-attn voxcpm_generate -- --nocapture
|
||||
let model_path = "/home/jhq/huggingface_model/openbmb/VoxCPM-0.5B/";
|
||||
|
||||
|
||||
let i_start = Instant::now();
|
||||
let mut voxcpm_generate = VoxCPMGenerate::init(model_path, None, None)?;
|
||||
let i_duration = i_start.elapsed();
|
||||
@@ -54,7 +50,7 @@ fn voxcpm_generate() -> Result<()> {
|
||||
|
||||
let i_duration = i_start.elapsed();
|
||||
println!("Time elapsed in generate is: {:?}", i_duration);
|
||||
let _ = save_wav(&generate, "voxcpm.wav")?;
|
||||
save_wav(&generate, "voxcpm.wav")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
+11
-8
@@ -1,14 +1,14 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use aha::utils::utils::{find_type_files, get_device};
|
||||
use aha::utils::{find_type_files, get_device};
|
||||
use anyhow::Result;
|
||||
use candle_core::{pickle::{read_all_with_key, read_pth_tensor_info, PthTensors}, safetensors, Device, Tensor};
|
||||
use candle_core::{Device, pickle::read_all_with_key, safetensors};
|
||||
use candle_nn::VarBuilder;
|
||||
|
||||
#[test]
|
||||
fn minicpm4_weight() -> Result<()> {
|
||||
let model_path = "/home/jhq/huggingface_model/OpenBMB/MiniCPM4-0.5B/";
|
||||
let model_list = find_type_files(&model_path, "safetensors")?;
|
||||
let model_list = find_type_files(model_path, "safetensors")?;
|
||||
let device = Device::Cpu;
|
||||
for m in model_list {
|
||||
let weights = safetensors::load(m, &device)?;
|
||||
@@ -24,21 +24,24 @@ fn minicpm4_weight() -> Result<()> {
|
||||
#[test]
|
||||
fn voxcpm_weight() -> Result<()> {
|
||||
let model_path = "/home/jhq/huggingface_model/openbmb/VoxCPM-0.5B/";
|
||||
let model_list = find_type_files(&model_path, "pth")?;
|
||||
let model_list = find_type_files(model_path, "pth")?;
|
||||
println!("model_list: {:?}", model_list);
|
||||
let dev = get_device(None);
|
||||
let mut dict_to_hashmap = HashMap::new();
|
||||
let mut dtype = candle_core::DType::F16;
|
||||
for m in model_list {
|
||||
let dict = read_all_with_key(m, Some("state_dict"))?;
|
||||
for m in model_list {
|
||||
let dict = read_all_with_key(m, Some("state_dict"))?;
|
||||
dtype = dict[0].1.dtype();
|
||||
for (k, v) in dict {
|
||||
println!("key: {}, tensor shape: {:?}", k, v);
|
||||
dict_to_hashmap.insert(k, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
let vb = VarBuilder::from_tensors(dict_to_hashmap, dtype, &dev);
|
||||
let contain_key = vb.contains_tensor("encoder.block.4.block.2.block.3.weight_g");
|
||||
println!("contain encoder.block.4.block.2.block.3.weight_g: {}", contain_key);
|
||||
println!(
|
||||
"contain encoder.block.4.block.2.block.3.weight_g: {}",
|
||||
contain_key
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user