model test add tps

This commit is contained in:
jhqxxx
2025-12-10 16:44:20 +08:00
parent 3eb983b5bb
commit 1a0df13bc7
17 changed files with 201 additions and 79 deletions
+15 -37
View File
@@ -19,15 +19,15 @@ fn qwen3vl_generate() -> Result<()> {
"role": "user",
"content": [
{
"type": "image",
"image_url":
"type": "video",
"video_url":
{
"url": "file://./assets/img/ocr_test1.png"
"url": "./assets/video/video_test.mp4"
}
},
},
{
"type": "text",
"text": "请分析图片并提取所有可见文本内容,按从左到右、从上到下的布局,返回纯文本"
"text": "视频中发生了什么?, 现在几点了"
}
]
}
@@ -44,13 +44,19 @@ fn qwen3vl_generate() -> Result<()> {
let res = qwen3vl.generate(mes)?;
let i_duration = i_start.elapsed();
println!("generate: \n {:?}", res);
if res.usage.is_some() {
let num_token = res.usage.as_ref().unwrap().total_tokens;
let duration_secs = i_duration.as_secs_f64();
let tps = num_token as f64 / duration_secs;
println!("Tokens per second (TPS): {:.2}", tps);
}
println!("Time elapsed in generate is: {:?}", i_duration);
Ok(())
}
#[tokio::test]
async fn qwen3vl_stream() -> Result<()> {
// test with cuda: RUST_BACKTRACE=1 cargo test -F cuda qwen3vl_stream -r -- --nocapture
// test with cuda: RUST_BACKTRACE=1 cargo test -F cuda,ffmpeg qwen3vl_stream -r -- --nocapture
let model_path = "/home/jhq/huggingface_model/Qwen/Qwen3-VL-2B-Instruct/";
@@ -60,7 +66,7 @@ async fn qwen3vl_stream() -> Result<()> {
"messages": [
{
"role": "user",
"content": [
"content": [
{
"type": "video",
"video_url":
@@ -70,39 +76,11 @@ async fn qwen3vl_stream() -> Result<()> {
},
{
"type": "text",
"text": "视频中发生了什么?, 现在几点了"
"text": "视频中发生了什么?"
}
]
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_current_time",
"description": "当你想知道现在的时间时非常有用。",
"parameters": {}
}
},
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "当你想查询指定城市的天气时非常有用。",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "城市或县区,比如北京市、杭州市、余杭区等。"
}
},
"required": ["location"]
}
}
}
],
"tool_choice": null
]
}
"#;
let mes: ChatCompletionParameters = serde_json::from_str(message)?;