Modern Apps git

← Modern-Apps.git

ml: model-wide v2 digest, single-space weight bridge, real parity paths

Commit
64082b77ae026acc479d1a4b7b72f6b58f90800e
Author
vayun-mathur <[email protected]>
When
2026-09-14 07:52 UTC (2 months ago)
Parents
df1c2fb

Diff

library/ml/src/main/rust/examples/check_sampler_maml2.rs
diff --git a/library/ml/src/main/rust/examples/check_sampler_maml2.rs b/library/ml/src/main/rust/examples/check_sampler_maml2.rsindex d9452d8131..ddd9fccbe4 100644--- a/library/ml/src/main/rust/examples/check_sampler_maml2.rs+++ b/library/ml/src/main/rust/examples/check_sampler_maml2.rs@@ -41,16 +41,15 @@ fn main() {         println!("graph {}: {} shapes inferred", graph.graph, graph.shapes.len());     } -    // Digest check against the stored row: the recompute must equal what the-    // emitter wrote, which is also what Python recomputed independently.-    let model = verified.model;-    let stored: Vec<u8> =-        model.graph_digest().map(|d| d.iter().collect()).unwrap_or_default();-    assert_eq!(&stored[..], &inferred[0].graph_digest[..], "digest matches stored");+    // The model-wide digest gate already ran inside `infer` (a mismatch is a+    // load error there, not an assert here). Report the per-graph digest for+    // bisection; the stored model digest it folds into is what the emitter+    // wrote. The mismatch arm has its own negative in `maml2::infer`'s+    // unit tests, where a hand-built model carries a wrong digest.     println!("digest: {}", hex(&inferred[0].graph_digest)); -    // Negative checks: truncated, flipped-version, and flipped-op files must-    // all fail (never a wrong answer, never a silent pass).+    // Negative checks: truncated and flipped-identifier files must fail+    // (never a wrong answer, never a silent pass).     let mut bad = bytes.clone();     bad.truncate(bad.len() / 2);     assert!(verify::verify(&bad).is_err(), "truncated file must fail");
library/ml/src/main/rust/schema/maml2.fbs
diff --git a/library/ml/src/main/rust/schema/maml2.fbs b/library/ml/src/main/rust/schema/maml2.fbsindex 36ecb92f07..3044503b20 100644--- a/library/ml/src/main/rust/schema/maml2.fbs+++ b/library/ml/src/main/rust/schema/maml2.fbs@@ -54,7 +54,12 @@ enum Op : byte {   View = 25,   Constant = 26,   Copy = 27,-  CustomOp = 28+  CustomOp = 28,+  // Transposed convolution (spec section 5.2): weights `[in_c, m/group, kh,+  // kw]`. Appended for the vision nets' learned upsamples; opset stays 1 —+  // the catalog grows together with its only loader until the first+  // on-device ship (spec section 12.1).+  ConvTranspose = 29 }  // Spec section 3.1. Integer dtypes are always quantised weights (section
library/ml/src/main/rust/src/maml2/emit.rs
diff --git a/library/ml/src/main/rust/src/maml2/emit.rs b/library/ml/src/main/rust/src/maml2/emit.rsindex 6bccdd17b9..c1ad99adea 100644--- a/library/ml/src/main/rust/src/maml2/emit.rs+++ b/library/ml/src/main/rust/src/maml2/emit.rs@@ -306,18 +306,26 @@ fn softmax_mode_code(mode: SoftmaxMode) -> i32 { }  /// One emitted v2 node: op, tensor refs, and attributes.-struct EmittedNode {-    op: fb::Op,-    inputs: Vec<i32>,-    outputs: Vec<i32>,-    attrs: Vec<(String, AttrValue)>,+pub struct EmittedNode {+    /// The catalog op.+    pub op: fb::Op,+    /// Input tensor indices.+    pub inputs: Vec<i32>,+    /// Output tensor indices.+    pub outputs: Vec<i32>,+    /// Typed attributes in emission order (digest order).+    pub attrs: Vec<(String, AttrValue)>, } -/// Attribute values the Phase 1 emitter needs.-enum AttrValue {+/// Attribute values the emitter writes.+pub enum AttrValue {+    /// A single integer.     Int(i32),+    /// An integer vector.     Ints(Vec<i32>),+    /// A float.     Float(f32),+    /// A boolean.     Bool(bool), } @@ -654,6 +662,35 @@ fn emit_nodes(     Ok(nodes) } +/// Hash emitted nodes in the canonical order (spec 9.2): op byte, inputs,+/// outputs, then per-attribute name + value bytes. [`infer::digest_graph`]+/// must hash the same sequence from the file, including the caller's graph+/// index prefix.+pub fn digest_nodes(hasher: &mut Sha256, nodes: &[EmittedNode]) {+    for node in nodes {+        hasher.update([node.op.0 as u8]);+        for input in &node.inputs {+            hasher.update(input.to_le_bytes());+        }+        for output in &node.outputs {+            hasher.update(output.to_le_bytes());+        }+        for (name, attr) in &node.attrs {+            hasher.update(name.as_bytes());+            match attr {+                AttrValue::Int(v) => hasher.update(v.to_le_bytes()),+                AttrValue::Ints(vs) => {+                    for v in vs {+                        hasher.update(v.to_le_bytes());+                    }+                }+                AttrValue::Float(v) => hasher.update(v.to_le_bytes()),+                AttrValue::Bool(v) => hasher.update([u8::from(*v)]),+            }+        }+    }+}+ /// A finished v2 model: the FlatBuffers bytes plus the checks the emitter ran. pub struct Emitted {     /// The `MAM2` file bytes.@@ -875,31 +912,19 @@ pub fn emit_sampler(         })         .collect::<Result<Vec<i32>, String>>()?; -    // 6. Canonical digest over op/edge/attr sequence (spec section 9.2).+    // 6. Canonical digest over the graph-indexed op/edge/attr sequences+    // (spec section 9.2): the graph index first, then the nodes in the same+    // order `infer` replays. Model-wide so a second graph (prefill ++    // decode, twin towers) cannot smuggle an unaudited topology past the+    // gate; single-graph files hash index 0, then fold once like every+    // model with one graph.     let mut hasher = Sha256::new();-    for node in &nodes {-        hasher.update([node.op.0 as u8]);-        for input in &node.inputs {-            hasher.update(input.to_le_bytes());-        }-        for output in &node.outputs {-            hasher.update(output.to_le_bytes());-        }-        for (name, attr) in &node.attrs {-            hasher.update(name.as_bytes());-            match attr {-                AttrValue::Int(v) => hasher.update(v.to_le_bytes()),-                AttrValue::Ints(vs) => {-                    for v in vs {-                        hasher.update(v.to_le_bytes());-                    }-                }-                AttrValue::Float(v) => hasher.update(v.to_le_bytes()),-                AttrValue::Bool(v) => hasher.update([u8::from(*v)]),-            }-        }-    }-    let graph_digest: [u8; 32] = hasher.finalize().into();+    hasher.update(0u32.to_le_bytes());+    digest_nodes(&mut hasher, &nodes);+    let graph0: [u8; 32] = hasher.finalize().into();+    let mut model_hasher = Sha256::new();+    model_hasher.update(graph0);+    let graph_digest: [u8; 32] = model_hasher.finalize().into();      // 7. Assemble the FlatBuffers model.     let mut builder = flatbuffers::FlatBufferBuilder::new();
library/ml/src/main/rust/src/maml2/infer.rs
diff --git a/library/ml/src/main/rust/src/maml2/infer.rs b/library/ml/src/main/rust/src/maml2/infer.rsindex 11e743de6d..b74ba6c0c7 100644--- a/library/ml/src/main/rust/src/maml2/infer.rs+++ b/library/ml/src/main/rust/src/maml2/infer.rs@@ -25,6 +25,7 @@ pub struct Inferred { }  /// The inference result for one graph.+#[derive(Debug)] pub struct InferredGraph {     /// Graph index in `Model.graphs`.     pub graph: usize,@@ -95,12 +96,30 @@ impl<'a> Attrs<'a> {  /// Run shape/layout inference over every graph in the verified model. ///-/// Returns one [`InferredGraph`] per graph, in model order.+/// Returns one [`InferredGraph`] per graph, in model order. Also enforces+/// the model-wide digest gate (spec section 9.2): the per-graph digests+/// folded in model order must equal the stored `graph_digest`, or the file+/// is rejected — a topology no emitter vouched for never reaches lowering. pub fn infer(verified: &Verified<'_>) -> Result<Vec<InferredGraph>, String> {     let model = verified.model;     let tensors = model.tensors().ok_or("a model with no tensors")?;     let graphs = model.graphs().ok_or("a model with no graphs")?;-    (0..graphs.len()).map(|g| infer_graph(&tensors, &graphs.get(g), g)).collect()+    let inferred: Vec<InferredGraph> =+        (0..graphs.len()).map(|g| infer_graph(&tensors, &graphs.get(g), g)).collect::<Result<_, _>>()?;+    // Fold the per-graph digests in model order: the stored `graph_digest`+    // is over the indexed graph sequences, so reordering graphs past the+    // gate hashes differently.+    let mut hasher = Sha256::new();+    for graph in &inferred {+        hasher.update(graph.graph_digest);+    }+    let recomputed: [u8; 32] = hasher.finalize().into();+    let stored: Vec<u8> =+        model.graph_digest().map(|d| (0..d.len()).map(|i| d.get(i)).collect()).unwrap_or_default();+    if stored.as_slice() != recomputed {+        return Err("the model digest does not match the recomputed graph digests".into());+    }+    Ok(inferred) }  /// Stored dims of one tensor row.@@ -150,6 +169,10 @@ fn infer_graph(     }      let mut hasher = Sha256::new();+    // The graph index prefixes the digest (spec 9.2): the emitter hashes+    // each graph's sequence under its index, so a graph reordered past the+    // gate hashes differently. Must match `emit::digest_nodes`' caller.+    hasher.update((graph_index as u32).to_le_bytes());     // Defined tensors: inputs + file tensors. Anything else must be written     // by a topologically earlier node (acyclicity by construction order).     let mut defined: HashSet<i32> = shapes.keys().copied().collect();@@ -464,3 +487,121 @@ fn digest_node(     }     Ok(()) }++#[cfg(test)]+mod tests {+    use super::*;+    use crate::maml2::{FORMAT_VERSION, OPSET_VERSION};++    /// Build a minimal one-graph model: `Add([2,1,1], [2,1,1]) -> [2,1,1]`,+    /// carrying `digest` as its stored model digest.+    fn tiny_model(digest: [u8; 32]) -> Vec<u8> {+        let mut builder = flatbuffers::FlatBufferBuilder::new();+        let mut tensors = Vec::new();+        for name in ["a", "b", "y"] {+            let name = builder.create_string(name);+            let dims = builder.create_vector(&[2, 1, 1]);+            let quant = fb::Quantization::new(fb::QuantKind::NONE, -1, -1, 0, 0);+            tensors.push(fb::Tensor::create(+                &mut builder,+                &fb::TensorArgs {+                    name: Some(name),+                    dtype: fb::DType::F16,+                    dims: Some(dims),+                    dim_params: None,+                    layout: fb::Layout::NCHW,+                    quantization: Some(&quant),+                    buffer: -1,+                    buffer_offset: 0,+                    elem_count: 2,+                    placement: fb::Placement::DEVICE,+                    state: fb::StateKind::NONE,+                },+            ));+        }+        let tensors = builder.create_vector(&tensors);+        let inputs = builder.create_vector(&[0, 1]);+        let outputs = builder.create_vector(&[2]);+        let attrs = builder.create_vector::<flatbuffers::WIPOffset<fb::Attribute<'_>>>(&[]);+        let node = fb::Node::create(+            &mut builder,+            &fb::NodeArgs {+                op: fb::Op::Add,+                inputs: Some(inputs),+                outputs: Some(outputs),+                attrs: Some(attrs),+                payload: None,+            },+        );+        let nodes = builder.create_vector(&[node]);+        let graph_inputs = builder.create_vector(&[0, 1]);+        let graph_outputs = builder.create_vector(&[2]);+        let graph_name = builder.create_string("tiny");+        let graph = fb::Graph::create(+            &mut builder,+            &fb::GraphArgs {+                name: Some(graph_name),+                tensors: None,+                nodes: Some(nodes),+                inputs: Some(graph_inputs),+                outputs: Some(graph_outputs),+            },+        );+        let graphs = builder.create_vector(&[graph]);+        let digest = builder.create_vector(&digest);+        let model = fb::Model::create(+            &mut builder,+            &fb::ModelArgs {+                version: FORMAT_VERSION,+                opset_version: OPSET_VERSION,+                runtime_min_version: None,+                converter_version: None,+                source_sha256: None,+                graph_digest: Some(digest),+                description: None,+                backends: None,+                tensors: Some(tensors),+                buffers: None,+                graphs: Some(graphs),+                entry_points: None,+                metadata: None,+            },+        );+        builder.finish(model, Some(fb::MODEL_IDENTIFIER));+        builder.finished_data().to_vec()+    }++    /// The model-wide digest gate fires: a structurally valid file carrying a+    /// wrong digest verifies but never reaches lowering.+    #[test]+    fn a_wrong_model_digest_is_rejected_at_inference() {+        let bytes = tiny_model([0xAB; 32]);+        let verified = crate::maml2::verify::verify(&bytes).expect("structure is valid");+        let err = infer(&verified).expect_err("the digest must not match");+        assert!(err.contains("digest"), "unexpected error: {err}");+    }++    /// The gate passes when the stored digest is the true fold: inference of+    /// the same topology succeeds, proving the fold both sides compute is+    /// the same one. The expected digests are hashed by hand from the spec+    /// section 9.2 sequence (graph index, op byte, inputs, outputs, no+    /// attrs) — emitter-independent.+    #[test]+    fn the_true_model_digest_passes_inference() {+        let mut graph_hasher = Sha256::new();+        graph_hasher.update(0u32.to_le_bytes());+        graph_hasher.update([fb::Op::Add.0 as u8]);+        graph_hasher.update(0i32.to_le_bytes());+        graph_hasher.update(1i32.to_le_bytes());+        graph_hasher.update(2i32.to_le_bytes());+        let graph_digest: [u8; 32] = graph_hasher.finalize().into();+        let mut model_hasher = Sha256::new();+        model_hasher.update(graph_digest);+        let model_digest: [u8; 32] = model_hasher.finalize().into();+        let bytes = tiny_model(model_digest);+        let verified = crate::maml2::verify::verify(&bytes).expect("structure is valid");+        let inferred = infer(&verified).expect("the true digest passes");+        assert_eq!(inferred.len(), 1);+        assert_eq!(inferred[0].graph_digest, graph_digest);+    }+}
library/ml/src/main/rust/src/maml2/lower.rs
diff --git a/library/ml/src/main/rust/src/maml2/lower.rs b/library/ml/src/main/rust/src/maml2/lower.rsindex e14de7dbe8..4008997872 100644--- a/library/ml/src/main/rust/src/maml2/lower.rs+++ b/library/ml/src/main/rust/src/maml2/lower.rs@@ -36,12 +36,13 @@ fn act_from_code(code: i32) -> Result<Act, String> {  /// A [`WeightSource`] over v2 weight tensors. ///-/// v1 weight bytes are repacked (channel-blocked) in the v2 buffers, so the-/// offsets the `*_raw` builders take are *payload-relative element indices*-/// assigned here, not file offsets. The bridge owns the repacked payloads-/// (kept alive for the caller to upload verbatim) and hands out indices into-/// them. Quantized kernels are addressed by word index, mirroring the v1-/// convention the shaders implement.+/// The bridge lays the v2 payloads out in tensor order at 16-aligned byte+/// offsets — v1's scheme — and hands out `byte / 2` element indices for+/// fp16 tensors and `byte / 4` word indices for quantized ones, exactly as+/// v1's `elem_offset` / `word_offset` do. One blob, two consistent address+/// spaces: the interpreter and the device both read the plan's offsets+/// against [`V2Weights::blob`], and an fp16 read at element `e` and a quant+/// read at word `w` land at blob bytes `2e` and `4w` with no rebase. /// /// Read-marking lives in the loader, not here: `lower` marks every weight /// tensor the nodes name before finishing (host tensors via an explicit@@ -54,14 +55,23 @@ pub struct V2Weights {     /// `shaped` (the `host_tensor` path resolves through `weight`, which     /// checks dims like any other tensor).     dims: Vec<Vec<u32>>,-    /// Element offset per v2 tensor index within its payload class.+    /// Element offset per v2 tensor index (fp16): blob byte / 2.     elem_offsets: HashMap<usize, u32>,-    /// Word offset per v2 tensor index (quantized kernels).+    /// Word offset per v2 tensor index (quantized kernels): blob byte / 4.     word_offsets: HashMap<usize, u32>,+    /// Blob byte offset per v2 tensor index, 16-aligned.+    placements: HashMap<usize, u32>,+    /// Blob length in bytes (end of the last payload, unpadded).+    blob_len: usize,     /// Tensor count (weights + computed), for the `count` gate.     count: usize, } +/// Payload start alignment in the blob, matching v1's tensor alignment so+/// every fp16 payload starts on an even byte and every quantized payload on+/// a word boundary.+const BLOB_ALIGN: usize = 16;+ impl V2Weights {     /// Build the bridge from the verified model: copy each buffered weight     /// payload out of the FlatBuffers vectors.@@ -73,8 +83,8 @@ impl V2Weights {         let mut stored_dims: Vec<Vec<u32>> = Vec::with_capacity(tensors.len());         let mut elem_offsets = HashMap::new();         let mut word_offsets = HashMap::new();-        let mut elem_cursor: u32 = 0;-        let mut word_cursor: u32 = 0;+        let mut placements = HashMap::new();+        let mut cursor: usize = 0;         for t in 0..tensors.len() {             let tensor = tensors.get(t);             stored_dims.push(@@ -100,23 +110,34 @@ impl V2Weights {             for i in 0..data.len() {                 bytes.push(data.get(i));             }-            // Offsets are assigned per dtype class: fp16 payloads are-            // addressed by element index, int8/int4 by word index. The two-            // cursors mirror the v1 `elem_offset` / `word_offset` split.+            // One address space, v1's way: the payload lands at the next+            // 16-aligned blob byte, and the offset is that byte divided by+            // the addressing unit — 2 for fp16 elements, 4 for quant words.+            // 16-alignment keeps both divisions exact.+            cursor = cursor.next_multiple_of(BLOB_ALIGN);             match tensor.dtype() {                 fb::DType::F16 => {-                    elem_offsets.insert(t, elem_cursor);-                    elem_cursor += (bytes.len() / 2) as u32;+                    elem_offsets.insert(t, (cursor / 2) as u32);                 }                 fb::DType::I8 | fb::DType::I4 => {-                    word_offsets.insert(t, word_cursor);-                    word_cursor += (bytes.len() / 4).max(1) as u32;+                    word_offsets.insert(t, (cursor / 4) as u32);                 }                 _ => return Err(format!("tensor {t} has a non-Phase-1 dtype")),             }+            placements.insert(t, cursor as u32);+            cursor += bytes.len();             payloads.push(bytes);         }-        Ok(V2Weights { payloads, dims: stored_dims, elem_offsets, word_offsets, count: tensors.len() })+        let blob_len = cursor;+        Ok(V2Weights {+            payloads,+            dims: stored_dims,+            elem_offsets,+            word_offsets,+            placements,+            blob_len,+            count: tensors.len(),+        })     }      /// Payload bytes for every v2 tensor index, in order. The caller uploads@@ -126,30 +147,24 @@ impl V2Weights {         &self.payloads     } -    /// Lay the payloads out the way the resolved plan addresses them: all-    /// fp16 payloads concatenated (element-addressed), then all quantized-    /// payloads concatenated (word-addressed). The interpreter and the-    /// device both read the plan's offsets against a blob in this layout —-    /// it is what `Net` uploads when the v2 bridge (not the v1 file) is the-    /// weights source.+    /// The payloads laid out the way the resolved plan addresses them: in+    /// tensor order, each at its 16-aligned placement, zero padding between.+    /// The interpreter and the device both read the plan's offsets against+    /// this blob — it is what `Net` uploads when the v2 bridge (not the v1+    /// file) is the weights source.     ///     /// Computed tensors (no buffer) contribute nothing; host tensors (no     /// buffer) likewise — neither is addressed by the plan.     pub fn blob(&self) -> Vec<u8> {-        let mut fp16: Vec<u8> = Vec::new();-        let mut quant: Vec<u8> = Vec::new();+        let mut blob = vec![0u8; self.blob_len.next_multiple_of(BLOB_ALIGN)];         for (t, payload) in self.payloads.iter().enumerate() {             if payload.is_empty() {                 continue;             }-            if self.word_offsets.contains_key(&t) {-                quant.extend_from_slice(payload);-            } else {-                fp16.extend_from_slice(payload);-            }+            let at = self.placements.get(&t).copied().unwrap_or(0) as usize;+            blob[at..at + payload.len()].copy_from_slice(payload);         }-        fp16.extend_from_slice(&quant);-        fp16+        blob     } } 
library/ml/src/main/rust/src/maml2/parity.rs
diff --git a/library/ml/src/main/rust/src/maml2/parity.rs b/library/ml/src/main/rust/src/maml2/parity.rsindex 206c84a641..e8b01a504c 100644--- a/library/ml/src/main/rust/src/maml2/parity.rs+++ b/library/ml/src/main/rust/src/maml2/parity.rs@@ -24,10 +24,10 @@ use crate::weights::{self, Tensor as WeightTensor}; fn v1_table() -> Option<(Vec<u8>, Vec<WeightTensor>)> {     // The test binary runs with CWD = the crate dir; the asset path is     // relative to the workspace root. `CARGO_MANIFEST_DIR` is the crate dir,-    // so walk up four levels (src/main/rust → ml → library → root).+    // so walk up five levels (src/main/rust → main → src → ml → library → root).     let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))         .ancestors()-        .nth(4)+        .nth(5)         .expect("workspace root")         .to_path_buf();     let path = root.join("speech/src/main/assets/supertonic/supertonic_ve.maml");@@ -50,7 +50,7 @@ fn v1_table() -> Option<(Vec<u8>, Vec<WeightTensor>)> { fn v2_plan() -> Option<crate::nets::Plan> {     let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))         .ancestors()-        .nth(4)+        .nth(5)         .expect("workspace root")         .to_path_buf();     let path = root.join("speech/src/main/assets/supertonic/supertonic_ve.maml2");@@ -72,7 +72,7 @@ fn v2_plan() -> Option<crate::nets::Plan> { fn lowering_proves_every_weight_read() {     let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))         .ancestors()-        .nth(4)+        .nth(5)         .expect("workspace root")         .to_path_buf();     let path = root.join("speech/src/main/assets/supertonic/supertonic_ve.maml2");@@ -153,16 +153,25 @@ fn lowered_plan_schedules_like_v1() { /// Skips quietly when either asset is absent. #[test] fn v2_plan_matches_v1_bit_exact() {-    let Some((v1data, tensors)) = v1_table() else {-        return;-    };-    let source = crate::nets::tests::Shapes::new(tensors.len());-    let v1plan = supertonic_sampler::build(&source, 49, 55).expect("build v1");+    // The v1 plan must be built against the real `Offsets` table: the+    // `Shapes` stub hands back tensor indices as addresses, which read+    // wrong weights on a real blob (NaN within an op or two). Real+    // addresses, real weights, same interpreter, same inputs.     let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))         .ancestors()-        .nth(4)+        .nth(5)         .expect("workspace root")         .to_path_buf();+    let v1path = root.join("speech/src/main/assets/supertonic/supertonic_ve.maml");+    let v1bytes = match std::fs::read(&v1path) {+        Ok(bytes) => bytes,+        Err(e) if e.kind() == std::io::ErrorKind::NotFound => return,+        Err(e) => panic!("cannot read {}: {e}", v1path.display()),+    };+    let v1parsed = weights::Weights::parse(&v1bytes, weights::graph::SUPERTONIC_VE)+        .expect("parse the v1 asset");+    let v1data = v1parsed.data().to_vec();+    let v1plan = supertonic_sampler::build(&v1parsed.offsets(), 49, 55).expect("build v1");     let path = root.join("speech/src/main/assets/supertonic/supertonic_ve.maml2");     let bytes = match std::fs::read(&path) {         Ok(bytes) => bytes,
library/ml/src/main/rust/src/vulkan/parity_maml2.rs
diff --git a/library/ml/src/main/rust/src/vulkan/parity_maml2.rs b/library/ml/src/main/rust/src/vulkan/parity_maml2.rsindex d1c784b914..ca5d7b49e7 100644--- a/library/ml/src/main/rust/src/vulkan/parity_maml2.rs+++ b/library/ml/src/main/rust/src/vulkan/parity_maml2.rs@@ -73,11 +73,12 @@ fn v2_sampler_on_device_agrees_with_the_reference() {     let inputs = sampler_inputs();     let refs: Vec<&[f32]> = inputs.iter().map(|v| v.as_slice()).collect();     // The blob in the plan's own address space: the bridge payloads laid out-    // as the resolved offsets address them (fp16 concatenated, then-    // quantized). NOT the v1 data section — v1 file offsets and bridge-    // cursors are different address spaces, and running the v2 plan against-    // the v1 blob reads every weight from the wrong address (all-zeros-    // output on both host and device, which the oracle below refuses).+    // in tensor order at 16-aligned placements (v1's scheme), so an fp16+    // element offset and a quant word offset both land without rebasing.+    // NOT the v1 data section — v1 file offsets and bridge placements are+    // different address spaces, and running the v2 plan against the v1 blob+    // reads every weight from the wrong address (all-zeros output on both+    // host and device, which the oracle below refuses).     let blob = bridge.blob();     let host = run_multi(&plan, &blob, &refs).expect("the interpreter runs the v2 plan");     // The zero oracle: `report` (unlike `matches`) prints rather than