use candle_core::{DType, Device};
use mlmf::{formats::awq::is_awq_model, loader::load_awq_auto, LoadOptions};
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("๐ฌ Testing AWQ Model Loading Support");
println!("===================================\n");
let device = Device::cuda_if_available(0).unwrap_or(Device::Cpu);
let dtype = DType::F16;
println!("๐ฑ Device: {:?}", device);
println!("๐ข Data type: {:?}\n", dtype);
let test_dirs = [
"./models/awq",
"./models/llama-7b-awq",
"../models/awq-test",
];
for model_dir in &test_dirs {
println!("๐ Testing AWQ model directory: {}", model_dir);
if std::path::Path::new(model_dir).exists() {
if is_awq_model(model_dir) {
println!(" โ
Confirmed AWQ model format");
match load_awq_auto(model_dir) {
Ok(loaded) => {
println!(" ๐ AWQ model loaded successfully!");
println!(
" ๐๏ธ Architecture: {:?}",
loaded.name_mapper.architecture()
);
println!(" ๐ Configuration: {}", loaded.config.summary());
println!(
" ๐งฎ Smart mappings: {}",
loaded.name_mapper.all_mappings().len()
);
let tensor_count = loaded.raw_tensors.len();
println!(" ๐ฆ Raw tensors loaded: {}", tensor_count);
}
Err(e) => {
println!(" โ Failed to load AWQ model: {}", e);
}
}
} else {
println!(" โ ๏ธ Directory exists but not detected as AWQ model");
}
} else {
println!(" โช Directory not found (expected for test)");
}
println!();
}
println!("๐งช Testing AWQ format detection...");
println!("๐ AWQ models are identified by:");
println!(" โข config.json with 'quantization_config' field");
println!(" โข quantization_config contains 'bits', 'group_size', etc.");
println!(" โข .safetensors files with quantized weights");
println!(" โข Compatible with Candle's quantized tensor support");
println!("\n๐ก To test with real AWQ models:");
println!(" 1. Download an AWQ model from HuggingFace");
println!(" 2. cargo run --example test_awq_loading --features awq -- /path/to/awq/model");
println!("\nโ
AWQ loading infrastructure is ready!");
Ok(())
}