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
12 changes: 6 additions & 6 deletions crane-serve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,14 @@ fn generate_audio(
let started = std::time::Instant::now();
let result = tts
.generate_voice_clone(&req.input, &req.language, ref_audio_path, ref_text, &opts)
.map_err(|e| e.to_string());
.map_err(|e| format!("{e:#}"));
log_generate_result(&result, started.elapsed());
result
} else {
let started = std::time::Instant::now();
let result = tts
.generate_speech(&req.input, &req.language, req.voice.as_deref(), &opts)
.map_err(|e| e.to_string());
.map_err(|e| format!("{e:#}"));
log_generate_result(&result, started.elapsed());
result
}
Expand Down Expand Up @@ -351,8 +351,8 @@ fn stream_tts(
match tts.generate_speech_stream(&req.input, &req.language, req.voice.as_deref(), &opts) {
Ok(s) => s,
Err(e) => {
tracing::error!("TTS stream setup failed: {e}");
let _ = meta.send(Err(e.to_string()));
tracing::error!("TTS stream setup failed: {e:#}");
let _ = meta.send(Err(format!("{e:#}")));
return;
},
};
Expand Down Expand Up @@ -381,8 +381,8 @@ fn stream_tts(
},
Ok(None) => break,
Err(e) => {
tracing::error!("{model_name} TTS stream failed after {n_chunks} chunks: {e}");
let _ = chunks.send(Err(e.to_string()));
tracing::error!("{model_name} TTS stream failed after {n_chunks} chunks: {e:#}");
let _ = chunks.send(Err(format!("{e:#}")));
break;
},
}
Expand Down
27 changes: 18 additions & 9 deletions example/src/align_qwen35_vl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ fn main() -> Result<()> {

// ===== 1. vision embedding alignment (identical pixel inputs) =====
let emb_crane = model.encode_images(&pv_t, &grid_t)?;
let emb_crane_f = emb_crane.to_dtype(DType::F32)?.flatten_all()?.to_vec1::<f32>()?;
let emb_crane_f = emb_crane
.to_dtype(DType::F32)?
.flatten_all()?
.to_vec1::<f32>()?;
let rows = emb_crane_f.len() / 2048;
let mut row_cos = Vec::with_capacity(rows);
for r in 0..rows {
Expand Down Expand Up @@ -241,7 +244,11 @@ fn main() -> Result<()> {
matches += 1;
}
}
let acc = if n > 0 { matches as f64 / n as f64 } else { 0.0 };
let acc = if n > 0 {
matches as f64 / n as f64
} else {
0.0
};

// also produce decoded text for eyeballing
let text = model
Expand All @@ -264,8 +271,10 @@ fn main() -> Result<()> {

// ===== print report =====
println!("\n========== ALIGNMENT: Crane vs PyTorch (Qwen3.5-2B-VL) ==========");
println!("device={device:?} dtype={dtype:?} prompt_len={s} gen_len(crane)={}",
generated.len());
println!(
"device={device:?} dtype={dtype:?} prompt_len={s} gen_len(crane)={}",
generated.len()
);
println!();
println!("--- vision tower (identical pixel_values) ---");
println!(" vision emb mean row cosine : {mean_row_cos:.6}");
Expand All @@ -275,8 +284,10 @@ fn main() -> Result<()> {
println!();
println!("--- prefill logits (last position) ---");
println!(" logits cosine : {logits_cos:.6}");
println!(" top-1 argmax match : {} (crane={crane_argmax} ref={ref_argmax})",
crane_argmax == ref_argmax);
println!(
" top-1 argmax match : {} (crane={crane_argmax} ref={ref_argmax})",
crane_argmax == ref_argmax
);
println!(" top-5 overlap : {top5_overlap}/5");
println!();
println!("--- greedy decode (same prompt + pixels) ---");
Expand All @@ -285,9 +296,7 @@ fn main() -> Result<()> {
println!(" crane decoded text : {text}");
println!();
println!("--- speed (same machine) ---");
println!(
" load model : {load_ms} ms (crane)"
);
println!(" load model : {load_ms} ms (crane)");
println!(
" prefill (multimodal) : {:.1} ms -> {:.1} t/s (crane) | pytorch {:.1} t/s",
prefill_ms,
Expand Down
Loading