105 lines
2.2 KiB
Rust
105 lines
2.2 KiB
Rust
//! Sampled reconstruction diagnostics for a verified sharded KAR archive.
|
|
//! These measurements do not substitute for a full-model quality gate.
|
|
|
|
use std::{collections::HashMap, fs::File, io::Write, path::Path};
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::{
|
|
derived_mixed, gguf, gguf_f32_stream,
|
|
kar::{self, VerifiedRangeDecoder},
|
|
model::Manifest,
|
|
prepare_preview, stream_parts,
|
|
};
|
|
|
|
const SAMPLE_ELEMENTS: u64 = 4096;
|
|
|
|
#[derive(Serialize)]
|
|
pub struct Report {
|
|
pub schema: &'static str,
|
|
pub archive_sha256: String,
|
|
pub derived_f32_sha256: String,
|
|
pub levels: u8,
|
|
pub method: &'static str,
|
|
pub verification: &'static str,
|
|
pub records: Vec<RecordError>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
struct Provenance {
|
|
schema: String,
|
|
archive_sha256: String,
|
|
derived_f32_sha256: String,
|
|
derived_f32_bytes: u64,
|
|
levels: u8,
|
|
shards: Vec<ProvenanceShard>,
|
|
tensors: Vec<ProvenanceTensor>,
|
|
partitioned_tensors: Vec<ProvenancePartition>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
struct ProvenanceShard {
|
|
name: String,
|
|
gguf_sha256: String,
|
|
gguf_bytes: u64,
|
|
tensor_count: usize,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
struct ProvenanceTensor {
|
|
name: String,
|
|
source_kind: u32,
|
|
source_sha256: String,
|
|
derived_offset: u64,
|
|
derived_bytes: u64,
|
|
f32_sha256: String,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
struct ProvenancePartition {
|
|
parent_name: String,
|
|
source_kind: u32,
|
|
parts: Vec<ProvenancePart>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
struct ProvenancePart {
|
|
name: String,
|
|
dimensions: Vec<u64>,
|
|
source_byte_offset: u64,
|
|
source_bytes: u64,
|
|
source_sha256: String,
|
|
derived_offset: u64,
|
|
derived_bytes: u64,
|
|
f32_sha256: String,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
pub struct RecordError {
|
|
pub name: String,
|
|
pub parent_name: String,
|
|
pub source_kind: u32,
|
|
pub elements: u64,
|
|
pub sampled_elements: u64,
|
|
pub relative_l2: f64,
|
|
pub windows: Vec<SampleWindow>,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
pub struct SampleWindow {
|
|
pub start: u64,
|
|
pub elements: u64,
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|
|
|
|
mod analyze;
|
|
mod previous;
|
|
mod sample;
|
|
#[allow(unused_imports)]
|
|
pub use analyze::*;
|
|
mod parse_digest;
|
|
#[allow(unused_imports)]
|
|
pub use parse_digest::*;
|