[Core] M0 foundation: workspace, Lean 4 SlabRing/PrefixState contracts, checked safetensors/cache IO, serve proto, telemetry, and HIP ABI

This commit is contained in:
adm committed 2026-11-29 21:32:44 +01:00
commit 63b1668a92
25 files changed
+2991

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
//! `vetta-infer` CLI entrypoint.
use std::collections::BTreeMap;
use std::env;
use std::process::ExitCode;
use vetta_io::SafetensorsArchive;
fn usage() {
eprintln!("vetta-infer {} — MoE-first microkernel inference engine (Rust + HIP)", env!("CARGO_PKG_VERSION"));
eprintln!("Usage:");
eprintln!(" vetta-infer info <safetensors-dir> Inspect shards, dtypes, and checked bounds");
eprintln!(" vetta-infer version Print version & build info");
}
fn cmd_info(dir: &str) -> Result<(), String> {
let t0 = std::time::Instant::now();
let ar = SafetensorsArchive::open(dir)?;
let dt_ms = t0.elapsed().as_secs_f64() * 1000.0;
let mut by_dtype: BTreeMap<String, (usize, u64)> = BTreeMap::new();
for t in ar.tensors.values() {
let entry = by_dtype.entry(t.dtype.clone()).or_insert((0, 0));
entry.0 += 1;
entry.1 += t.byte_len();
}
let tot_gib = ar.total_tensor_bytes() as f64 / (1024.0 * 1024.0 * 1024.0);
println!("dir: {}", ar.dir.display());
println!("shards: {}", ar.shards.len());
println!("tensors: {} (all bounds checked in {:.1} ms)", ar.tensors.len(), dt_ms);
println!("payload: {:.2} GiB", tot_gib);
println!("dtypes:");
for (dt, (cnt, bytes)) in by_dtype {
println!(" {:10} {:6} tensors ({:6.2} GiB)", dt, cnt, bytes as f64 / (1024.0 * 1024.0 * 1024.0));
}
Ok(())
}
fn main() -> ExitCode {
let args: Vec<String> = env::args().skip(1).collect();
match args.first().map(|s| s.as_str()) {
Some("version") | Some("--version") | Some("-V") => {
println!("vetta-infer {} (edition 2024, MoE-first HIP microkernel)", env!("CARGO_PKG_VERSION"));
ExitCode::SUCCESS
}
Some("info") => {
let Some(dir) = args.get(1) else {
eprintln!("error: missing <safetensors-dir>");
usage();
return ExitCode::from(2);
};
match cmd_info(dir) {
Ok(()) => ExitCode::SUCCESS,
Err(e) => {
eprintln!("error: {e}");
ExitCode::FAILURE
}
}
}
_ => {
usage();
ExitCode::from(2)
}
}
}