Modern Apps git

← Modern-Apps.git

library:ml: rename the weights container from .vkml to .maml

Commit
b30c7011cce99cb77cf6ce24d5cacfb53ac7251f
Author
vayun-mathur <[email protected]>
When
2026-08-27 23:55 UTC (3 months ago)
Parents
31d599e

Diff

SUPPLY_CHAIN_RISKS.md
diff --git a/SUPPLY_CHAIN_RISKS.md b/SUPPLY_CHAIN_RISKS.mdindex bb4f6ee2dd..01066fb649 100644--- a/SUPPLY_CHAIN_RISKS.md+++ b/SUPPLY_CHAIN_RISKS.md@@ -57,12 +57,12 @@ So a clean install transcribes with no network, but speaking still needs one voi  `photos` **semantic search no longer needs a second app**. It previously delegated image/text embedding to the OpenAssistant app over IPC, so search only worked if OpenAssistant was installed, recent enough, and had finished a ~452 MB SigLIP2 download. It now runs **TinyCLIP-ViT-8M/16 Text-3M** int8 in-process from `photos/src/main/assets/clip/model_int8.onnx` (24 MB), with the CLIP BPE table in `clip/bpe_simple_vocab_16e6.txt`. Upstream is **`onnx-community/TinyCLIP-ViT-8M-16-Text-3M-YFCC15M-ONNX`** (MIT, an ONNX export of `wkcn/TinyCLIP-ViT-8M-16-Text-3M-YFCC15M`) — a **build-host** dependency only. The int8 export costs almost nothing in fidelity (measured cosine vs fp32: 0.998 image, 0.9995 text, same latency), because TinyCLIP is a plain ViT and quantizes cleanly. The trade-off accepted here is accuracy in absolute terms: TinyCLIP-8M scores 41.1% zero-shot ImageNet-1k against SigLIP2-base's high-70s, so single-concept queries are noticeably weaker than the IPC path it replaces. -`camera` and `photos` **no longer bundle two unattributable models**. Both `erdnet.{param,bin}` (portrait segmentation) and `u2netp.ncnn.{param,bin}` (subject segmentation) were added in a single commit (`72dde80df`, "make apps smaller") with no upstream URL, no license and no conversion recipe, and neither was ever listed here. They are replaced by fp16 `.vkml` weights converted from **Apache-2.0** ONNX exports, run on `:library:ml` — our own Vulkan compute runtime — rather than on ncnn:+`camera` and `photos` **no longer bundle two unattributable models**. Both `erdnet.{param,bin}` (portrait segmentation) and `u2netp.ncnn.{param,bin}` (subject segmentation) were added in a single commit (`72dde80df`, "make apps smaller") with no upstream URL, no license and no conversion recipe, and neither was ever listed here. They are replaced by fp16 `.maml` weights converted from **Apache-2.0** ONNX exports, run on `:library:ml` — our own Vulkan compute runtime — rather than on ncnn: -- `camera/src/main/assets/selfie_segmentation.vkml` (211 KB, was 1.63 MB) from **`onnx-community/mediapipe_selfie_segmentation`**. A deliberate model *change*, not a port: erdnet was Caffe-derived from nihui's ncnn demo family and had no obtainable ONNX, so it could not be attributed or rebuilt at all. Bokeh masks therefore differ from before.-- `photos/src/main/assets/u2netp.vkml` (2.15 MB, was 2.26 MB) from **`BritishWerewolf/U-2-Netp`**. The same network re-sourced — the ncnn model's op inventory (Convolution 119, Pooling 33, Interp 38) matches the ONNX exactly.+- `camera/src/main/assets/selfie_segmentation.maml` (211 KB, was 1.63 MB) from **`onnx-community/mediapipe_selfie_segmentation`**. A deliberate model *change*, not a port: erdnet was Caffe-derived from nihui's ncnn demo family and had no obtainable ONNX, so it could not be attributed or rebuilt at all. Bokeh masks therefore differ from before.+- `photos/src/main/assets/u2netp.maml` (2.15 MB, was 2.26 MB) from **`BritishWerewolf/U-2-Netp`**. The same network re-sourced — the ncnn model's op inventory (Convolution 119, Pooling 33, Interp 38) matches the ONNX exactly. -Both are **build-host** dependencies only, pinned by upstream revision *and* file SHA-256 in `scripts/ml/fetch_and_convert.sh`, with provenance in a `README.md` beside each asset and the source ONNX SHA-256 baked into each `.vkml` header. If either vanished, shipped builds keep working. The ONNX itself is not vendored: it is twice the size and nothing reads it at run time.+Both are **build-host** dependencies only, pinned by upstream revision *and* file SHA-256 in `scripts/ml/fetch_and_convert.sh`, with provenance in a `README.md` beside each asset and the source ONNX SHA-256 baked into each `.maml` header. If either vanished, shipped builds keep working. The ONNX itself is not vendored: it is twice the size and nothing reads it at run time.  The trade-off accepted is **GPU-only**: `:library:ml` needs Vulkan 1.1 plus `VK_KHR_shader_float16_int8`, which was promoted to core only in Vulkan 1.2 and so is optional at the 1.1 floor minSdk 31 guarantees. On a device without it, portrait bokeh, auto-select-subject and OCR turn off rather than falling back to CPU. `camera`, `photos` and `pdf` shed ncnn entirely as a result, so `libncnn_android.so` is in none of those APKs, leaving `speech` and `translate` as its only consumers. @@ -78,7 +78,7 @@ Notably **offline after first launch**: `astronomy`, `calendar`, `clock`, `conta - **Launch icon generator**: `build-logic/src/main/kotlin/LauncherIconGen.kt` downloads `https://raw.githubusercontent.com/google/material-design-icons/819d786.../symbols/android/{icon}/...24px.xml` at build time, cached under `~/.gradle/material-symbols-cache`. Build needs GitHub availability on first (uncached) build. ⚠️ Not yet mitigated. - **Alpha toolchain**: `agp = 9.4.0-alpha04`, `composeBom = 2026.06.01` (future-dated), `navigation3 = 1.2.0-alpha05`, `material3 = 1.5.0-alpha23`, `biometric = 1.4.0-alpha07`, `camerax = 1.7.0-alpha02`, `datastore = 1.3.0-alpha09`. ⚠️ Stable release branch should pin stable versions (not yet done). - **Version drift**: `okhttp 4.12.0` (2y old, 5.x exists) ⚠️ still pinned. `ktor` fully removed (`:messages` migrated to `:library:network` ✅) and `mediapipe tasks-vision` unified at `0.10.35` (camera inline `0.10.14` removed ✅).-- **Vendored third_party**: `third_party/nanojson/` (vendored `TeamNewPipe/nanojson`, was JitPack — ✅ mitigation #2), `third_party/om-file-format-sys/` (C + Rust bindings for `open-meteo/om-file-format` GPL-2.0-only) patched for reproducible `readdir` sort, `maps/src/main/cpp/sqlite3.c` amalgamation (SQLite NDK workaround), `youpipe/extractor/` full NewPipe Extractor GPLv3. The two unattributable `RapidAI/RapidOCR` ncnn conversions that were in `library/ocr/src/main/assets/` are **gone**: PP-OCRv5 detection and recognition are now `.vkml`, converted from PaddlePaddle's own Apache-2.0 ONNX exports and each SHA-256-pinned in `scripts/ml/fetch_and_convert.sh`.+- **Vendored third_party**: `third_party/nanojson/` (vendored `TeamNewPipe/nanojson`, was JitPack — ✅ mitigation #2), `third_party/om-file-format-sys/` (C + Rust bindings for `open-meteo/om-file-format` GPL-2.0-only) patched for reproducible `readdir` sort, `maps/src/main/cpp/sqlite3.c` amalgamation (SQLite NDK workaround), `youpipe/extractor/` full NewPipe Extractor GPLv3. The two unattributable `RapidAI/RapidOCR` ncnn conversions that were in `library/ocr/src/main/assets/` are **gone**: PP-OCRv5 detection and recognition are now `.maml`, converted from PaddlePaddle's own Apache-2.0 ONNX exports and each SHA-256-pinned in `scripts/ml/fetch_and_convert.sh`.  All versions in `gradle/libs.versions.toml`. Rust versions unified in root `/Cargo.toml` (workspace resolver 2, mirrors Gradle catalog) – see `/scripts/rust-deps-count.sh`. 
camera/build.gradle.kts
diff --git a/camera/build.gradle.kts b/camera/build.gradle.ktsindex cdd85faead..d31d696919 100644--- a/camera/build.gradle.kts+++ b/camera/build.gradle.kts@@ -15,10 +15,10 @@ android {         applicationId = "com.vayunmathur.camera"     }     androidResources {-        // selfie_segmentation.vkml is read straight out of the APK by SelfieSegmenter, so+        // selfie_segmentation.maml is read straight out of the APK by SelfieSegmenter, so         // leave it uncompressed: fp16 weights barely deflate, and a compressed asset would         // have to be inflated into a heap buffer before it could be uploaded.-        noCompress += "vkml"+        noCompress += "maml"     } } 
camera/src/main/assets/README.md
diff --git a/camera/src/main/assets/README.md b/camera/src/main/assets/README.mdindex 5b0e41d239..d2586175c6 100644--- a/camera/src/main/assets/README.md+++ b/camera/src/main/assets/README.md@@ -1,6 +1,6 @@ # `:camera` bundled model assets -## `selfie_segmentation.vkml`+## `selfie_segmentation.maml`  Apache-2.0, from https://huggingface.co/onnx-community/mediapipe_selfie_segmentation @ `be49485c8e027524be38591817fc5cd31bd9d00e` (`onnx/model.onnx`, 462,352 B fp32,@@ -8,8 +8,8 @@ SHA-256 `3241ac4a…4531aad`) — an ONNX export of Google's MediaPipe Selfie Segmentation, the model purpose-built for exactly this job.  Not the ONNX itself: `scripts/ml/fetch_and_convert.sh` converts it to the fp16-`.vkml` weights container that `:library:ml` reads, which is half the size and the-only form anything here loads. The source ONNX SHA-256 is in the `.vkml` header, so+`.maml` weights container that `:library:ml` reads, which is half the size and the+only form anything here loads. The source ONNX SHA-256 is in the `.maml` header, so a shipped asset traces back to this line without needing the ONNX on disk.  Run at 256×256 RGB, rescale 1/255 and **no** mean/std (`do_normalize: false`
camera/src/main/assets/selfie_segmentation.maml
diff --git a/camera/src/main/assets/selfie_segmentation.vkml b/camera/src/main/assets/selfie_segmentation.mamlsimilarity index 99%rename from camera/src/main/assets/selfie_segmentation.vkmlrename to camera/src/main/assets/selfie_segmentation.mamlindex 613247ef46..3c62b9472d 100644Binary files a/camera/src/main/assets/selfie_segmentation.vkml and b/camera/src/main/assets/selfie_segmentation.maml differ
library/ml/src/main/java/com/vayunmathur/library/ml/Faces.kt
diff --git a/library/ml/src/main/java/com/vayunmathur/library/ml/Faces.kt b/library/ml/src/main/java/com/vayunmathur/library/ml/Faces.ktindex 25439f4862..6f7927a29a 100644--- a/library/ml/src/main/java/com/vayunmathur/library/ml/Faces.kt+++ b/library/ml/src/main/java/com/vayunmathur/library/ml/Faces.kt@@ -52,7 +52,7 @@ data class DetectedFaceBox(  * [NativeSegmenter] about why the lock lives with the caller's threading rather than here.  *  * @param context used only to read the asset; not retained.- * @param assetName the `.vkml` in the app's assets.+ * @param assetName the `.maml` in the app's assets.  */ class FaceDetector(context: Context, assetName: String = DEFAULT_ASSET) : AutoCloseable { @@ -140,7 +140,7 @@ class FaceDetector(context: Context, assetName: String = DEFAULT_ASSET) : AutoCl      companion object {         /** What `:photos` ships. */-        const val DEFAULT_ASSET: String = "scrfd_500m.vkml"+        const val DEFAULT_ASSET: String = "scrfd_500m.maml"         private const val TAG = "FaceDetector"         private const val FLOATS_PER_FACE = 9     }@@ -155,7 +155,7 @@ class FaceDetector(context: Context, assetName: String = DEFAULT_ASSET) : AutoCl  * Not thread-safe: [embed] and [close] must not overlap.  *  * @param context used only to read the asset; not retained.- * @param assetName the `.vkml` in the app's assets.+ * @param assetName the `.maml` in the app's assets.  */ class FaceEmbedder(context: Context, assetName: String = DEFAULT_ASSET) : AutoCloseable { @@ -187,7 +187,7 @@ class FaceEmbedder(context: Context, assetName: String = DEFAULT_ASSET) : AutoCl      companion object {         /** What `:photos` ships. */-        const val DEFAULT_ASSET: String = "w600k_mbf.vkml"+        const val DEFAULT_ASSET: String = "w600k_mbf.maml"         /** Length of the embedding MobileFaceNet produces. */         const val EMBEDDING_LENGTH = 512         private const val TAG = "FaceEmbedder"
library/ml/src/main/java/com/vayunmathur/library/ml/MlNative.kt
diff --git a/library/ml/src/main/java/com/vayunmathur/library/ml/MlNative.kt b/library/ml/src/main/java/com/vayunmathur/library/ml/MlNative.ktindex 0dc2bf4929..7cc215a34b 100644--- a/library/ml/src/main/java/com/vayunmathur/library/ml/MlNative.kt+++ b/library/ml/src/main/java/com/vayunmathur/library/ml/MlNative.kt@@ -32,7 +32,7 @@ internal object MlNative {     }      /**-     * Bring up MediaPipe Selfie Segmentation from a `.vkml` blob. Returns 0 on failure.+     * Bring up MediaPipe Selfie Segmentation from a `.maml` blob. Returns 0 on failure.      *      * Failure is expected and normal on a device without `VK_KHR_shader_float16_int8`,      * which is a Vulkan 1.2 promotion and so optional at the 1.1 floor minSdk 31
library/ml/src/main/java/com/vayunmathur/library/ml/Segmentation.kt
diff --git a/library/ml/src/main/java/com/vayunmathur/library/ml/Segmentation.kt b/library/ml/src/main/java/com/vayunmathur/library/ml/Segmentation.ktindex c220ce08d9..86b9e54e9e 100644--- a/library/ml/src/main/java/com/vayunmathur/library/ml/Segmentation.kt+++ b/library/ml/src/main/java/com/vayunmathur/library/ml/Segmentation.kt@@ -60,7 +60,7 @@ internal class NativeSegmenter(         0L     } else {         try {-            // `.vkml` is `noCompress` in both apps, so this is a straight copy out of the+            // `.maml` is `noCompress` in both apps, so this is a straight copy out of the             // mapped APK rather than an inflate into a second buffer.             create(context.assets.open(assetName).use { it.readBytes() })         } catch (e: Throwable) {
library/ml/src/main/java/com/vayunmathur/library/ml/SelfieSegmenter.kt
diff --git a/library/ml/src/main/java/com/vayunmathur/library/ml/SelfieSegmenter.kt b/library/ml/src/main/java/com/vayunmathur/library/ml/SelfieSegmenter.ktindex 2f11c64e73..e82f1eae69 100644--- a/library/ml/src/main/java/com/vayunmathur/library/ml/SelfieSegmenter.kt+++ b/library/ml/src/main/java/com/vayunmathur/library/ml/SelfieSegmenter.kt@@ -20,7 +20,7 @@ import android.graphics.Bitmap  * Not thread-safe: [segment] and [close] must not overlap.  *  * @param context used only to read the asset; not retained.- * @param assetName the `.vkml` in the app's assets.+ * @param assetName the `.maml` in the app's assets.  */ class SelfieSegmenter(context: Context, assetName: String = DEFAULT_ASSET) : AutoCloseable { @@ -41,6 +41,6 @@ class SelfieSegmenter(context: Context, assetName: String = DEFAULT_ASSET) : Aut      companion object {         /** What `:camera` ships. */-        const val DEFAULT_ASSET: String = "selfie_segmentation.vkml"+        const val DEFAULT_ASSET: String = "selfie_segmentation.maml"     } }
library/ml/src/main/java/com/vayunmathur/library/ml/SubjectSegmenter.kt
diff --git a/library/ml/src/main/java/com/vayunmathur/library/ml/SubjectSegmenter.kt b/library/ml/src/main/java/com/vayunmathur/library/ml/SubjectSegmenter.ktindex 989ba8e1cd..88b9d96c47 100644--- a/library/ml/src/main/java/com/vayunmathur/library/ml/SubjectSegmenter.kt+++ b/library/ml/src/main/java/com/vayunmathur/library/ml/SubjectSegmenter.kt@@ -24,7 +24,7 @@ import android.graphics.Bitmap  * Not thread-safe: [segment] and [close] must not overlap.  *  * @param context used only to read the asset; not retained.- * @param assetName the `.vkml` in the app's assets.+ * @param assetName the `.maml` in the app's assets.  */ class SubjectSegmenter(context: Context, assetName: String = DEFAULT_ASSET) : AutoCloseable { @@ -45,6 +45,6 @@ class SubjectSegmenter(context: Context, assetName: String = DEFAULT_ASSET) : Au      companion object {         /** What `:photos` ships. */-        const val DEFAULT_ASSET: String = "u2netp.vkml"+        const val DEFAULT_ASSET: String = "u2netp.maml"     } }
library/ml/src/main/java/com/vayunmathur/library/ml/TextRecognizer.kt
diff --git a/library/ml/src/main/java/com/vayunmathur/library/ml/TextRecognizer.kt b/library/ml/src/main/java/com/vayunmathur/library/ml/TextRecognizer.ktindex 864c390cf0..31686725cc 100644--- a/library/ml/src/main/java/com/vayunmathur/library/ml/TextRecognizer.kt+++ b/library/ml/src/main/java/com/vayunmathur/library/ml/TextRecognizer.kt@@ -29,7 +29,7 @@ data class RecognizedLine(  *  * Replaces the ncnn PP-OCR path. The detector is DBNet over a PP-HGNetV2 backbone and the  * recogniser is a PP-LCNetV3 backbone into a two-block transformer with a CTC head, both- * converted to `.vkml` by `scripts/ml/ppocr_fold.py`. The recogniser is the **latin** model+ * converted to `.maml` by `scripts/ml/ppocr_fold.py`. The recogniser is the **latin** model  * - 836 characters covering Latin-script languages, no CJK - which is what keeps it under  * 4 MB.  *@@ -122,8 +122,8 @@ class TextRecognizer(      private companion object {         private const val TAG = "TextRecognizer"-        const val DETECTION_ASSET = "ppocr_det.vkml"-        const val RECOGNITION_ASSET = "ppocr_rec.vkml"+        const val DETECTION_ASSET = "ppocr_det.maml"+        const val RECOGNITION_ASSET = "ppocr_rec.maml"         const val DICTIONARY_ASSET = "ppocr_keys.txt"          /** Text, then eight quad coordinates, then confidence, then the vertical flag. */
library/ml/src/main/rust/Cargo.toml
diff --git a/library/ml/src/main/rust/Cargo.toml b/library/ml/src/main/rust/Cargo.tomlindex b868ef63ae..2c9033ee19 100644--- a/library/ml/src/main/rust/Cargo.toml+++ b/library/ml/src/main/rust/Cargo.toml@@ -15,7 +15,7 @@ # nothing, so the only native code shipped is our own. # # There is no graph interpreter: each net's forward pass is hardcoded Rust in `nets/`,-# so a `.vkml` file carries ordered tensors and no topology. See `src/weights.rs`.+# so a `.maml` file carries ordered tensors and no topology. See `src/weights.rs`.  [package] name = "modelrunner"@@ -23,12 +23,12 @@ version = "0.1.0" edition = "2021" publish = false license = "GPL-2.0-only"-description = "Vulkan compute ML runtime: .vkml weights in, segmentation mask out"+description = "Vulkan compute ML runtime: .maml weights in, segmentation mask out"  [lib] name = "modelrunner" # cdylib for the JNI surface; rlib so the host test binary can link it and exercise-# the `.vkml` reader and the CPU preprocessing without a device.+# the `.maml` reader and the CPU preprocessing without a device. crate-type = ["cdylib", "rlib"]  [dependencies]
library/ml/src/main/rust/shaders/conv.comp
diff --git a/library/ml/src/main/rust/shaders/conv.comp b/library/ml/src/main/rust/shaders/conv.compindex e90cd5c9bf..62b4d67af6 100644--- a/library/ml/src/main/rust/shaders/conv.comp+++ b/library/ml/src/main/rust/shaders/conv.comp@@ -13,7 +13,7 @@ //! the accumulator's initial value rather than a separate op. //! //! Weights are ONNX's layout verbatim, `[m, in_c / group, kh, kw]` row-major, so-//! `vkml_convert.py` transposes nothing and there is no layout to disagree about.+//! `maml_convert.py` transposes nothing and there is no layout to disagree about. //! //! # What this deliberately does not do //!
library/ml/src/main/rust/src/bridge.rs
diff --git a/library/ml/src/main/rust/src/bridge.rs b/library/ml/src/main/rust/src/bridge.rsindex e354244902..3145ee7039 100644--- a/library/ml/src/main/rust/src/bridge.rs+++ b/library/ml/src/main/rust/src/bridge.rs@@ -124,7 +124,7 @@ fn build<'l>(     graph_id: u32, ) -> Result<Handle, String> {     // The blob arrives as bytes rather than a path because an asset lives inside the APK-    // and has no filesystem path unless it is extracted first. Both `.vkml` files are+    // and has no filesystem path unless it is extracted first. Both `.maml` files are     // `noCompress`, so Kotlin's read is a straight copy out of the mapped APK.     let bytes = env         .convert_byte_array(&weights)
library/ml/src/main/rust/src/lib.rs
diff --git a/library/ml/src/main/rust/src/lib.rs b/library/ml/src/main/rust/src/lib.rsindex 2461676bd8..ed18cf5dae 100644--- a/library/ml/src/main/rust/src/lib.rs+++ b/library/ml/src/main/rust/src/lib.rs@@ -7,7 +7,7 @@ //! //! # Layout //!-//! * [`weights`] — the `.vkml` reader. Ordered tensors, no topology.+//! * [`weights`] — the `.maml` reader. Ordered tensors, no topology. //! * [`nets`] — the two hardcoded forward passes, and the small compiler that packs //!   their activations into one arena and resolves every offset. //! * [`preprocess`] — bitmap to fp16 NCHW, and the fp16 conversions.@@ -32,7 +32,7 @@ //! # Host builds //! //! Everything except the Vulkan and JNI layers compiles and tests on the host, so-//! `cargo test` builds **both** networks in full, checks the `.vkml` round trip, the+//! `cargo test` builds **both** networks in full, checks the `.maml` round trip, the //! arena arithmetic and the preprocessing, with no device and no asset.  pub mod nets;
library/ml/src/main/rust/src/nets/mobilefacenet.rs
diff --git a/library/ml/src/main/rust/src/nets/mobilefacenet.rs b/library/ml/src/main/rust/src/nets/mobilefacenet.rsindex 031d52633a..394276f996 100644--- a/library/ml/src/main/rust/src/nets/mobilefacenet.rs+++ b/library/ml/src/main/rust/src/nets/mobilefacenet.rs@@ -17,7 +17,7 @@ //!   which carries the slope tensor's index. The slope is per *channel*, so a shader //!   that broadcast one value would still produce a plausible-looking embedding. //! * **The final `Gemm` is a convolution here, not an inner product.** Its weight is-//!   `[512, 3136]` over a flattened `64 x 7 x 7`, and `scripts/ml/vkml_convert.py`+//!   `[512, 3136]` over a flattened `64 x 7 x 7`, and `scripts/ml/maml_convert.py` //!   reshapes that to `[512, 64, 7, 7]` — a kernel covering the whole spatial extent, //!   which the existing `conv.comp` computes exactly. That is why there is no //!   `InnerProduct` pipeline.@@ -42,7 +42,7 @@ pub const EMBEDDING: u32 = 512; /// `PRelu` slopes at one. pub const TENSORS: usize = 134; -/// Hands out `.vkml` tensor indices in the order the layers appear.+/// Hands out `.maml` tensor indices in the order the layers appear. /// /// Unlike [`super::selfie`]'s, this cannot be a counter that steps by two: a `PRelu` /// contributes one tensor and a convolution two, so the two kinds are asked for@@ -213,7 +213,7 @@ mod tests {      #[test]     fn the_op_inventory_matches_the_onnx() {-        // The counts `scripts/ml/vkml_convert.py` asserts against the ONNX itself. The+        // The counts `scripts/ml/maml_convert.py` asserts against the ONNX itself. The         // 49 convolutions include the `Gemm`, which is lowered as one, so the export's         // 49 `Conv` plus 1 `Gemm` is 50 dispatches here.         let plan = plan();
library/ml/src/main/rust/src/nets/mod.rs
diff --git a/library/ml/src/main/rust/src/nets/mod.rs b/library/ml/src/main/rust/src/nets/mod.rsindex 6b74a852d0..b1fdf39f9d 100644--- a/library/ml/src/main/rust/src/nets/mod.rs+++ b/library/ml/src/main/rust/src/nets/mod.rs@@ -4,7 +4,7 @@ //! //! Each network is code: [`u2netp::build`] and [`selfie::build`] call [`Builder`] in //! the order the ONNX nodes run. There is no operator table, no name lookup and no-//! topology in the weights file — a `.vkml` is ordered tensors and nothing else.+//! topology in the weights file — a `.maml` is ordered tensors and nothing else. //! //! But the *shape* of the pass being code does not mean the offsets should be. So a //! builder call records a [`Node`] against symbolic tensor ids, and [`Builder::finish`]@@ -85,7 +85,7 @@ pub enum Act {     Sigmoid,     /// ONNX `PRelu`: `x < 0 ? slope[c] * x : x`, one slope per output channel.     ///-    /// Unlike the others this carries state — the slope's position in the `.vkml`+    /// Unlike the others this carries state — the slope's position in the `.maml`     /// tensor table, which [`Builder`] resolves to an offset like any other weight and     /// passes down in [`Push::act_weight`]. A plain `Relu` is the same thing at slope     /// zero, and is kept separate because it needs no memory traffic at all.@@ -407,7 +407,7 @@ impl Plan { /// An indirection purely so the net modules are host-testable: the real /// implementation is [`crate::weights::Weights`], and [`tests::Shapes`] is a stub that /// only checks the shapes it is asked for. That lets `cargo test` build both networks-/// in full with no `.vkml` on disk.+/// in full with no `.maml` on disk. pub trait WeightSource {     /// The fp16 element offset of tensor `index`, which must have shape `dims`.     fn shaped(&self, index: usize, dims: &[u32]) -> Result<u32, String>;@@ -555,7 +555,7 @@ pub struct Builder<'a> { }  /// Arena allocations are aligned to this many fp16 elements, i.e. 16 bytes — the same-/// boundary `.vkml` aligns its tensors to.+/// boundary `.maml` aligns its tensors to. const ALIGN_ELEMS: u32 = 8;  impl<'a> Builder<'a> {@@ -612,7 +612,7 @@ impl<'a> Builder<'a> {     /// A convolution, with ONNX's semantics: weights `[m, in_c/group, kh, kw]`, pads     /// `[top, left, bottom, right]`, output size floor-divided.     ///-    /// `weight_index` and `bias_index` are positions in the `.vkml` tensor table, so a+    /// `weight_index` and `bias_index` are positions in the `.maml` tensor table, so a     /// net module reads as the ordered list of layers that it is.     #[allow(clippy::too_many_arguments)]     pub fn conv(@@ -895,7 +895,7 @@ impl<'a> Builder<'a> {      /// Layer normalisation over the channel axis, with a per-channel affine.     ///-    /// `weight_index` is the gamma tensor's position in the `.vkml` table; beta follows+    /// `weight_index` is the gamma tensor's position in the `.maml` table; beta follows     /// it, the way a convolution's bias follows its weight.     pub fn layer_norm(&mut self, input: Id, weight_index: usize, epsilon: f32) -> Id {         let shape = self.shape_of(input);@@ -1684,7 +1684,7 @@ pub(crate) mod tests {     /// It hands back the tensor index as the offset, which is meaningless as an     /// address but makes the plan reproducible, and it records every shape it was     /// asked for so a test can assert the whole ordered layer table without a-    /// `.vkml`.+    /// `.maml`.     pub struct Shapes {         pub asked: std::cell::RefCell<Vec<(usize, Vec<u32>)>>,         pub count: usize,
library/ml/src/main/rust/src/nets/ppocr_det.rs
diff --git a/library/ml/src/main/rust/src/nets/ppocr_det.rs b/library/ml/src/main/rust/src/nets/ppocr_det.rsindex 234c9024f4..5c8c11d3b4 100644--- a/library/ml/src/main/rust/src/nets/ppocr_det.rs+++ b/library/ml/src/main/rust/src/nets/ppocr_det.rs@@ -73,7 +73,7 @@ const HEAD: u32 = 24; /// in-bounds taps — position-dependent, and therefore not a bias. Folding anyway biases /// the border of every feature map and compounds down the backbone. ///-/// They are scalars, so they live here rather than in the `.vkml`, which holds tensors:+/// They are scalars, so they live here rather than in the `.maml`, which holds tensors: /// putting a one-element tensor in the table for each would shift the whole ordered table. const AFFINES: [(f32, f32); 14] = [     (0.6775133, -0.22914815),@@ -92,7 +92,7 @@ const AFFINES: [(f32, f32); 14] = [     (0.93593925, 0.16590087), ]; -/// Hands out `.vkml` tensor indices in the order the layers appear. Every folded layer is+/// Hands out `.maml` tensor indices in the order the layers appear. Every folded layer is /// a convolution with a weight and a bias, so this steps by two throughout. struct Layers {     next: usize,
library/ml/src/main/rust/src/nets/ppocr_rec.rs
diff --git a/library/ml/src/main/rust/src/nets/ppocr_rec.rs b/library/ml/src/main/rust/src/nets/ppocr_rec.rsindex 22fea1171a..03fe48c194 100644--- a/library/ml/src/main/rust/src/nets/ppocr_rec.rs+++ b/library/ml/src/main/rust/src/nets/ppocr_rec.rs@@ -87,7 +87,7 @@ pub const FFN: u32 = 240; /// Logits per timestep, which is the CTC label space and not a free choice. pub const LOGITS: u32 = crate::post::ctc::LOGITS as u32; -/// Tensors the `.vkml` must hold: 56 folded layers, each a weight and a bias.+/// Tensors the `.maml` must hold: 56 folded layers, each a weight and a bias. /// /// 33 backbone convolutions (of which 4 are the two squeeze-excite blocks' squeeze and /// expand), 2 into the sequence, 8 per transformer block, the final layer norm, and 4 in@@ -108,7 +108,7 @@ pub const TENSORS: usize = 112; /// map at a 3x3 kernel — and it compounds. ncnn's conversion of this model runs all 100 of /// these as explicit elementwise ops; sixteen is what is left after the exact ones fold. ///-/// They are scalars, so they live here rather than in the `.vkml`, which holds tensors.+/// They are scalars, so they live here rather than in the `.maml`, which holds tensors. const AFFINES: [(f32, f32); 16] = [     (0.15316115, -0.25247484),     (0.1658402, -0.41049767),@@ -128,7 +128,7 @@ const AFFINES: [(f32, f32); 16] = [     (3.71384, -0.29614934), ]; -/// Hands out `.vkml` tensor indices in the order the layers appear. Every folded layer is+/// Hands out `.maml` tensor indices in the order the layers appear. Every folded layer is /// a weight followed by a bias, including the layer norms, whose gamma and beta land in /// the same pair. struct Layers {
library/ml/src/main/rust/src/nets/reference.rs
diff --git a/library/ml/src/main/rust/src/nets/reference.rs b/library/ml/src/main/rust/src/nets/reference.rsindex ad69c3e8e4..44ecb50005 100644--- a/library/ml/src/main/rust/src/nets/reference.rs+++ b/library/ml/src/main/rust/src/nets/reference.rs@@ -93,7 +93,7 @@ fn through_f16(value: f32) -> f32 {  /// Run `plan` on the host and return its outputs, in [`Plan::outputs`] order. ///-/// `weights` is the `.vkml` data section verbatim — the same bytes the device gets —+/// `weights` is the `.maml` data section verbatim — the same bytes the device gets — /// so this accepts [`crate::weights::Weights::data`] and a shipped asset directly. /// `inputs` is one fp32 slice per [`Plan::inputs`] entry; each is rounded to fp16 on /// the way in, exactly as an upload would.@@ -780,7 +780,7 @@ fn nchw(p: &Push, c: u32, y: u32, x: u32) -> u32 {     (c * p.out_h + y) * p.out_w + x } -/// Lay tensors out the way `.vkml` does: 16-byte aligned, fp16, in index order.+/// Lay tensors out the way `.maml` does: 16-byte aligned, fp16, in index order. fn pack(tensors: &[(Vec<u32>, Vec<f32>)]) -> Result<(Vec<u32>, Vec<u8>), String> {     let mut offsets = Vec::with_capacity(tensors.len());     let mut data: Vec<u8> = Vec::new();@@ -804,7 +804,7 @@ fn pack(tensors: &[(Vec<u32>, Vec<f32>)]) -> Result<(Vec<u32>, Vec<u8>), String> /// /// Unlike [`super::tests::Shapes`], which hands back the tensor index as a stand-in /// offset, this lays the tensors out for real — 16-byte aligned fp16 in index order,-/// exactly as `vkml_convert.py` writes them — so a plan built against it can actually+/// exactly as `maml_convert.py` writes them — so a plan built against it can actually /// be run. pub struct Given {     offsets: Vec<u32>,@@ -813,7 +813,7 @@ pub struct Given { }  impl Given {-    /// Lay out `(dims, values)` pairs in `.vkml` index order.+    /// Lay out `(dims, values)` pairs in `.maml` index order.     pub fn new(tensors: &[(Vec<u32>, Vec<f32>)]) -> Result<Given, String> {         let (offsets, data) = pack(tensors)?;         let lengths = tensors.iter().map(|(_, v)| v.len() as u64).collect();@@ -2105,9 +2105,9 @@ mod tests {             .collect();          // A voice is a runtime download rather than a bundled asset, so the vocoder's-        // `.vkml` is given by path instead of being looked up in the tree.+        // `.maml` is given by path instead of being looked up in the tree.         if graph == "vits_dec" {-            let path = std::env::var("PARITY_VKML").expect("PARITY_VKML");+            let path = std::env::var("PARITY_MAML").expect("PARITY_MAML");             let bytes = std::fs::read(&path).unwrap_or_else(|e| panic!("{path}: {e}"));             let weights = crate::weights::Weights::parse(&bytes, crate::weights::graph::VITS_DEC)                 .expect("the vocoder asset parses");@@ -2120,11 +2120,11 @@ mod tests {          let (path, id) = match graph.as_str() {             "ppocr_rec" => (-                "library/ocr/src/main/assets/ppocr_rec.vkml",+                "library/ocr/src/main/assets/ppocr_rec.maml",                 crate::weights::graph::PPOCR_REC,             ),             "ppocr_det" => (-                "library/ocr/src/main/assets/ppocr_det.vkml",+                "library/ocr/src/main/assets/ppocr_det.maml",                 crate::weights::graph::PPOCR_DET,             ),             other => panic!("no parity probe for {other}"),@@ -2156,7 +2156,7 @@ mod tests {         std::fs::write(path, out).expect("writes");     } -    /// The shipped `.vkml` for `name`, or `None` if it is not checked out.+    /// The shipped `.maml` for `name`, or `None` if it is not checked out.     fn asset(name: &str) -> Option<Vec<u8>> {         let mut dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));         while !dir.join("settings.gradle.kts").is_file() {@@ -2267,7 +2267,7 @@ mod tests {     #[test]     #[ignore = "runs the full shipped nets; minutes in a debug build"]     fn the_shipped_selfie_net_produces_a_usable_mask() {-        let Some(bytes) = asset("camera/src/main/assets/selfie_segmentation.vkml") else {+        let Some(bytes) = asset("camera/src/main/assets/selfie_segmentation.maml") else {             return;         };         let weights = crate::weights::Weights::parse(&bytes, crate::weights::graph::SELFIE)@@ -2283,7 +2283,7 @@ mod tests {     #[test]     #[ignore = "runs the full shipped nets; minutes in a debug build"]     fn the_shipped_u2netp_net_produces_a_usable_mask() {-        let Some(bytes) = asset("photos/src/main/assets/u2netp.vkml") else {+        let Some(bytes) = asset("photos/src/main/assets/u2netp.maml") else {             return;         };         let weights = crate::weights::Weights::parse(&bytes, crate::weights::graph::U2NETP)@@ -2299,7 +2299,7 @@ mod tests {     #[test]     #[ignore = "runs the full shipped nets; minutes in a debug build"]     fn the_shipped_scrfd_net_produces_usable_detection_maps() {-        let Some(bytes) = asset("photos/src/main/assets/scrfd_500m.vkml") else {+        let Some(bytes) = asset("photos/src/main/assets/scrfd_500m.maml") else {             return;         };         let weights = crate::weights::Weights::parse(&bytes, crate::weights::graph::SCRFD)@@ -2339,7 +2339,7 @@ mod tests {     #[test]     #[ignore = "runs the full shipped nets; minutes in a debug build"]     fn the_shipped_mobilefacenet_net_embeds_two_faces_differently() {-        let Some(bytes) = asset("photos/src/main/assets/w600k_mbf.vkml") else {+        let Some(bytes) = asset("photos/src/main/assets/w600k_mbf.maml") else {             return;         };         let weights = crate::weights::Weights::parse(&bytes, crate::weights::graph::MOBILEFACENET)@@ -2379,7 +2379,7 @@ mod tests {     #[test]     #[ignore = "runs the full shipped nets; minutes in a debug build"]     fn the_shipped_ppocr_det_net_produces_a_usable_probability_map() {-        let Some(bytes) = asset("library/ocr/src/main/assets/ppocr_det.vkml") else {+        let Some(bytes) = asset("library/ocr/src/main/assets/ppocr_det.maml") else {             return;         };         let weights = crate::weights::Weights::parse(&bytes, crate::weights::graph::PPOCR_DET)
library/ml/src/main/rust/src/nets/scrfd.rs
diff --git a/library/ml/src/main/rust/src/nets/scrfd.rs b/library/ml/src/main/rust/src/nets/scrfd.rsindex faa363d9c1..c8e43a88ab 100644--- a/library/ml/src/main/rust/src/nets/scrfd.rs+++ b/library/ml/src/main/rust/src/nets/scrfd.rs@@ -64,7 +64,7 @@ const NECK: u32 = 16; /// Channels inside each head. const HEAD: u32 = 64; -/// Hands out `.vkml` tensor indices in the order the layers appear. Every layer here is+/// Hands out `.maml` tensor indices in the order the layers appear. Every layer here is /// a convolution, so this steps by two throughout — unlike /// [`super::mobilefacenet`]'s, which has `PRelu` slopes to interleave. struct Layers {@@ -81,7 +81,7 @@ impl Layers {  /// The backbone's 14 depthwise/pointwise pairs, as `(stride, output channels)`. ///-/// Read off `vkml_convert.py --print-layers`. The stem convolution before them is+/// Read off `maml_convert.py --print-layers`. The stem convolution before them is /// written out at its call site because it is the only dense one. const TRUNK: [(u32, u32); 14] = [     (1, 16),@@ -256,7 +256,7 @@ mod tests {      #[test]     fn the_op_inventory_matches_the_onnx() {-        // The counts `scripts/ml/vkml_convert.py` asserts against the ONNX itself.+        // The counts `scripts/ml/maml_convert.py` asserts against the ONNX itself.         let plan = plan();         assert_eq!(dispatches(&plan, Kind::Conv), 60);         assert_eq!(dispatches(&plan, Kind::Add), 4);
library/ml/src/main/rust/src/nets/selfie.rs
diff --git a/library/ml/src/main/rust/src/nets/selfie.rs b/library/ml/src/main/rust/src/nets/selfie.rsindex aa3fc7f607..862af3642b 100644--- a/library/ml/src/main/rust/src/nets/selfie.rs+++ b/library/ml/src/main/rust/src/nets/selfie.rs@@ -7,9 +7,9 @@ //! to 128x128, then a 2x2 transposed convolution to 256x256 and a sigmoid. //! //! Unlike U^2-Netp this graph is irregular, so it is written out layer by layer against-//! the ordered `.vkml` indices, with the three repeated shapes ([`squeeze_excite`],+//! the ordered `.maml` indices, with the three repeated shapes ([`squeeze_excite`], //! [`inverted_residual`], [`final_block`]) factored out. The layer table it is-//! transcribed from is `vkml_convert.py --print-layers` on the pinned ONNX.+//! transcribed from is `maml_convert.py --print-layers` on the pinned ONNX. //! //! # Three things about it that are easy to get wrong //!@@ -37,7 +37,7 @@ pub const SIZE: u32 = 256; /// Tensors in the file: 55 layers, weight and bias each. pub const TENSORS: usize = 110; -/// Hands out `.vkml` tensor indices in the order the layers appear. See+/// Hands out `.maml` tensor indices in the order the layers appear. See /// [`super::u2netp`] for why this is a counter. struct Layers {     next: usize,@@ -204,7 +204,7 @@ mod tests {      #[test]     fn the_op_inventory_matches_the_onnx() {-        // The counts `scripts/ml/vkml_convert.py` asserts against the ONNX itself.+        // The counts `scripts/ml/maml_convert.py` asserts against the ONNX itself.         let plan = plan();         assert_eq!(dispatches(&plan, Kind::Conv), 54);         assert_eq!(dispatches(&plan, Kind::ConvTranspose), 1);
library/ml/src/main/rust/src/nets/u2netp.rs
diff --git a/library/ml/src/main/rust/src/nets/u2netp.rs b/library/ml/src/main/rust/src/nets/u2netp.rsindex b6143abfc7..e49d7a47d6 100644--- a/library/ml/src/main/rust/src/nets/u2netp.rs+++ b/library/ml/src/main/rust/src/nets/u2netp.rs@@ -47,9 +47,9 @@ const OUT: u32 = 64; /// Tensors in the file: 119 layers, weight and bias each. pub const TENSORS: usize = 238; -/// Hands out `.vkml` tensor indices in the order the layers appear.+/// Hands out `.maml` tensor indices in the order the layers appear. ///-/// The whole contract with `scripts/ml/vkml_convert.py` is this order, so it is+/// The whole contract with `scripts/ml/maml_convert.py` is this order, so it is /// consumed by a counter rather than written out per layer: a counter cannot /// accidentally skip or repeat an index, and [`Builder::finish`] rejects a pass that /// did not consume the file exactly.@@ -298,7 +298,7 @@ mod tests {      #[test]     fn the_op_inventory_matches_the_onnx() {-        // These are the counts `scripts/ml/vkml_convert.py` asserts against the ONNX+        // These are the counts `scripts/ml/maml_convert.py` asserts against the ONNX         // itself, rederived here from the RSU structure. If the two ever disagree, one         // of them is wrong about the network.         let plan = plan();@@ -329,7 +329,7 @@ mod tests {     #[test]     fn the_layer_table_matches_the_onnx_export() {         // Spot-checks at the boundaries the structure is derived from, taken from-        // `vkml_convert.py --print-layers` on the pinned ONNX. Every one of these is a+        // `maml_convert.py --print-layers` on the pinned ONNX. Every one of these is a         // place a miscounted block would first show up.         let source = Shapes::new(TENSORS);         let _ = build(&source);
library/ml/src/main/rust/src/nets/vits_dec.rs
diff --git a/library/ml/src/main/rust/src/nets/vits_dec.rs b/library/ml/src/main/rust/src/nets/vits_dec.rsindex de6d531e0e..7bb55861fb 100644--- a/library/ml/src/main/rust/src/nets/vits_dec.rs+++ b/library/ml/src/main/rust/src/nets/vits_dec.rs@@ -78,14 +78,14 @@ const SLOPE: f32 = 0.1; /// and duller, which no shape or range check would notice. const FINAL_SLOPE: f32 = 0.01; -/// Tensors the `.vkml` must hold: 23 layers, each a weight and a bias.+/// Tensors the `.maml` must hold: 23 layers, each a weight and a bias. /// /// `conv_pre`, three transposed convolutions, `3 * 2` convolutions per stage, and /// `conv_post` — `(1 + 3 + 18 + 1) * 2`. `conv_post` carries no bias in the export, so the /// converter writes a zero one and the runtime stays uniform. pub const TENSORS: usize = 46; -/// Hands out `.vkml` tensor indices in the order the layers appear.+/// Hands out `.maml` tensor indices in the order the layers appear. struct Layers {     next: usize, }
library/ml/src/main/rust/src/preprocess.rs
diff --git a/library/ml/src/main/rust/src/preprocess.rs b/library/ml/src/main/rust/src/preprocess.rsindex 535e217118..1634276d0a 100644--- a/library/ml/src/main/rust/src/preprocess.rs+++ b/library/ml/src/main/rust/src/preprocess.rs@@ -404,7 +404,7 @@ fn lerp_f32(a: f32, b: f32, t: f32) -> f32 { /// /// Hand-written because Rust's `f16` is not stable on the toolchain this repo pins /// (`rust-toolchain.toml`), and because a `half` dependency would be a whole crate for-/// two functions. Weights are converted by numpy in `scripts/ml/vkml_convert.py`; this+/// two functions. Weights are converted by numpy in `scripts/ml/maml_convert.py`; this /// is only for the input, whose values sit in roughly `-2.2..2.2` after normalisation. pub fn f32_to_f16(value: f32) -> u16 {     let bits = value.to_bits();
library/ml/src/main/rust/src/weights.rs
diff --git a/library/ml/src/main/rust/src/weights.rs b/library/ml/src/main/rust/src/weights.rsindex cab53f19b4..3c47af4d9b 100644--- a/library/ml/src/main/rust/src/weights.rs+++ b/library/ml/src/main/rust/src/weights.rs@@ -1,8 +1,8 @@-//! The `.vkml` reader.+//! The `.maml` reader. //!-//! `.vkml` is a **weights container only** — ordered tensors, no operators and no+//! `.maml` is a **weights container only** — ordered tensors, no operators and no //! topology — because each network's forward pass is hardcoded in [`crate::nets`]-//! rather than interpreted. See `scripts/ml/vkml_convert.py`, which writes it, for+//! rather than interpreted. See `scripts/ml/maml_convert.py`, which writes it, for //! the byte layout; this is the other half of that contract. //! //! Two consequences worth stating plainly:@@ -15,8 +15,8 @@ //!   in the file and its offset in device memory. That is the reason the format is //!   one contiguous blob. -/// `b"VKML"`, little-endian, at offset 0.-const MAGIC: [u8; 4] = *b"VKML";+/// `b"MAML"`, little-endian, at offset 0.+const MAGIC: [u8; 4] = *b"MAML"; /// Bumped when the layout below changes incompatibly. const FORMAT_VERSION: u32 = 1; const HEADER_BYTES: usize = 64;@@ -25,7 +25,7 @@ const DTYPE_F16: u32 = 0; /// Every tensor starts on this boundary, so an offset is a valid fp16 index too. const ALIGNMENT: u32 = 16; -/// Graph ids, shared with `GRAPHS` in `scripts/ml/vkml_convert.py`.+/// Graph ids, shared with `GRAPHS` in `scripts/ml/maml_convert.py`. pub mod graph {     /// MediaPipe Selfie Segmentation, 256x256.     pub const SELFIE: u32 = 1;@@ -67,7 +67,7 @@ impl Tensor {     } } -/// A parsed `.vkml` file: the tensor table, and the data section to upload.+/// A parsed `.maml` file: the tensor table, and the data section to upload. #[derive(Debug)] pub struct Weights {     /// Which network this file is for. See [`graph`].@@ -87,10 +87,10 @@ impl Weights {     /// the symptom would be a driver reset, not an error.     pub fn parse(bytes: &[u8], expect_graph: u32) -> Result<Weights, String> {         if bytes.len() < HEADER_BYTES {-            return Err(format!("{} bytes is shorter than a .vkml header", bytes.len()));+            return Err(format!("{} bytes is shorter than a .maml header", bytes.len()));         }         if bytes[0..4] != MAGIC {-            return Err("not a .vkml file (bad magic)".into());+            return Err("not a .maml file (bad magic)".into());         }         let version = u32(bytes, 4);         if version != FORMAT_VERSION {
library/ml/src/main/rust/tests/assets.rs
diff --git a/library/ml/src/main/rust/tests/assets.rs b/library/ml/src/main/rust/tests/assets.rsindex d03b206942..47a42df1f0 100644--- a/library/ml/src/main/rust/tests/assets.rs+++ b/library/ml/src/main/rust/tests/assets.rs@@ -1,10 +1,10 @@-//! Builds both forward passes against the `.vkml` files actually committed to+//! Builds both forward passes against the `.maml` files actually committed to //! `camera/` and `photos/`. //! //! Everything in `src/nets` is unit-tested against a stub weight source, which proves //! the two passes are self-consistent but not that they agree with the converter. This //! is the test that closes that: it parses the shipped assets and walks all 348 tensors-//! through `Weights::shaped`, so a converter that reordered a layer, a `.vkml` rebuilt+//! through `Weights::shaped`, so a converter that reordered a layer, a `.maml` rebuilt //! from a moved upstream, or a miscounted RSU block fails here — naming the tensor. //! //! Given that nothing checks the *numbers* this runtime produces (correctness is@@ -38,12 +38,12 @@ fn load(relative: &str, graph_id: u32) -> Weights {         )     });     Weights::parse(&bytes, graph_id)-        .unwrap_or_else(|e| panic!("{} is not a usable .vkml: {e}", path.display()))+        .unwrap_or_else(|e| panic!("{} is not a usable .maml: {e}", path.display())) }  #[test] fn the_shipped_selfie_asset_builds_the_selfie_forward_pass() {-    let weights = load("camera/src/main/assets/selfie_segmentation.vkml", graph::SELFIE);+    let weights = load("camera/src/main/assets/selfie_segmentation.maml", graph::SELFIE);     assert_eq!(weights.len(), selfie::TENSORS);     let plan = selfie::build(&weights).expect("the shipped asset matches nets::selfie");     assert!(!plan.ops.is_empty());@@ -51,7 +51,7 @@ fn the_shipped_selfie_asset_builds_the_selfie_forward_pass() {  #[test] fn the_shipped_u2netp_asset_builds_the_u2netp_forward_pass() {-    let weights = load("photos/src/main/assets/u2netp.vkml", graph::U2NETP);+    let weights = load("photos/src/main/assets/u2netp.maml", graph::U2NETP);     assert_eq!(weights.len(), u2netp::TENSORS);     let plan = u2netp::build(&weights).expect("the shipped asset matches nets::u2netp");     assert!(!plan.ops.is_empty());@@ -59,7 +59,7 @@ fn the_shipped_u2netp_asset_builds_the_u2netp_forward_pass() {  #[test] fn the_shipped_mobilefacenet_asset_builds_the_mobilefacenet_forward_pass() {-    let weights = load("photos/src/main/assets/w600k_mbf.vkml", graph::MOBILEFACENET);+    let weights = load("photos/src/main/assets/w600k_mbf.maml", graph::MOBILEFACENET);     assert_eq!(weights.len(), mobilefacenet::TENSORS);     let plan =         mobilefacenet::build(&weights).expect("the shipped asset matches nets::mobilefacenet");@@ -68,7 +68,7 @@ fn the_shipped_mobilefacenet_asset_builds_the_mobilefacenet_forward_pass() {  #[test] fn the_shipped_scrfd_asset_builds_the_scrfd_forward_pass() {-    let weights = load("photos/src/main/assets/scrfd_500m.vkml", graph::SCRFD);+    let weights = load("photos/src/main/assets/scrfd_500m.maml", graph::SCRFD);     assert_eq!(weights.len(), scrfd::TENSORS);     let plan = scrfd::build(&weights, scrfd::LONG_SIDE, scrfd::LONG_SIDE)         .expect("the shipped asset matches nets::scrfd");@@ -80,7 +80,7 @@ fn the_scrfd_pass_builds_at_every_letterbox_shape_a_photo_can_produce() {     // The detector is compiled per shape, so the whole family has to lower — not just     // the square case. These are the short sides a 640-long-side letterbox rounds to for     // aspect ratios from 1:1 to about 3:1, which covers any real photo.-    let weights = load("photos/src/main/assets/scrfd_500m.vkml", graph::SCRFD);+    let weights = load("photos/src/main/assets/scrfd_500m.maml", graph::SCRFD);     for short in (scrfd::EXTENT_MULTIPLE..=scrfd::LONG_SIDE).step_by(32) {         for (height, width) in [(short, scrfd::LONG_SIDE), (scrfd::LONG_SIDE, short)] {             let plan = scrfd::build(&weights, height, width)@@ -92,7 +92,7 @@ fn the_scrfd_pass_builds_at_every_letterbox_shape_a_photo_can_produce() {  #[test] fn the_shipped_ppocr_det_asset_builds_the_ppocr_det_forward_pass() {-    let weights = load("library/ocr/src/main/assets/ppocr_det.vkml", graph::PPOCR_DET);+    let weights = load("library/ocr/src/main/assets/ppocr_det.maml", graph::PPOCR_DET);     assert_eq!(weights.len(), ppocr_det::TENSORS);     let plan = ppocr_det::build(&weights, ppocr_det::LONG_SIDE, ppocr_det::LONG_SIDE)         .expect("the shipped asset matches nets::ppocr_det");@@ -105,7 +105,7 @@ fn the_shipped_ppocr_det_asset_builds_the_ppocr_det_forward_pass() {  #[test] fn the_shipped_ppocr_rec_asset_builds_the_ppocr_rec_forward_pass() {-    let weights = load("library/ocr/src/main/assets/ppocr_rec.vkml", graph::PPOCR_REC);+    let weights = load("library/ocr/src/main/assets/ppocr_rec.maml", graph::PPOCR_REC);     assert_eq!(weights.len(), ppocr_rec::TENSORS);     // Building against the real file checks every one of the 112 tensors' shapes, because     // `Builder::weight` asks for each by index *and* dimensions — so a converter that@@ -123,7 +123,7 @@ fn the_shipped_ppocr_rec_asset_builds_the_ppocr_rec_forward_pass() { fn the_shipped_ppocr_rec_asset_builds_at_every_padded_line_width() {     // A line crop is resized to 48 tall and padded to a multiple of 8, so the plan has to     // lower at whatever width the batcher lands on.-    let weights = load("library/ocr/src/main/assets/ppocr_rec.vkml", graph::PPOCR_REC);+    let weights = load("library/ocr/src/main/assets/ppocr_rec.maml", graph::PPOCR_REC);     for width in [8u32, 64, 160, 320, 640, 1024] {         let plan = ppocr_rec::build(&weights, width)             .unwrap_or_else(|e| panic!("at width {width}: {e}"));@@ -153,7 +153,7 @@ fn the_shipped_character_dictionary_matches_the_recogniser_label_space() { fn neither_asset_will_load_as_the_other_network() {     // The `graph_id` in the header exists for exactly this: the two files are both     // ordered fp16 tensor tables, so without it a swapped asset would parse.-    let selfie = repo_root().join("camera/src/main/assets/selfie_segmentation.vkml");+    let selfie = repo_root().join("camera/src/main/assets/selfie_segmentation.maml");     let bytes = std::fs::read(selfie).expect("the selfie asset");     assert!(Weights::parse(&bytes, graph::U2NETP).is_err()); }@@ -166,9 +166,9 @@ fn report_the_device_memory_each_net_needs() {     for (name, weights, arena) in [         (             "selfie",-            load("camera/src/main/assets/selfie_segmentation.vkml", graph::SELFIE),+            load("camera/src/main/assets/selfie_segmentation.maml", graph::SELFIE),             selfie::build(&load(-                "camera/src/main/assets/selfie_segmentation.vkml",+                "camera/src/main/assets/selfie_segmentation.maml",                 graph::SELFIE,             ))             .expect("selfie")@@ -176,16 +176,16 @@ fn report_the_device_memory_each_net_needs() {         ),         (             "u2netp",-            load("photos/src/main/assets/u2netp.vkml", graph::U2NETP),-            u2netp::build(&load("photos/src/main/assets/u2netp.vkml", graph::U2NETP))+            load("photos/src/main/assets/u2netp.maml", graph::U2NETP),+            u2netp::build(&load("photos/src/main/assets/u2netp.maml", graph::U2NETP))                 .expect("u2netp")                 .arena_elems,         ),         (             "mobilefacenet",-            load("photos/src/main/assets/w600k_mbf.vkml", graph::MOBILEFACENET),+            load("photos/src/main/assets/w600k_mbf.maml", graph::MOBILEFACENET),             mobilefacenet::build(&load(-                "photos/src/main/assets/w600k_mbf.vkml",+                "photos/src/main/assets/w600k_mbf.maml",                 graph::MOBILEFACENET,             ))             .expect("mobilefacenet")@@ -193,9 +193,9 @@ fn report_the_device_memory_each_net_needs() {         ),         (             "scrfd@640",-            load("photos/src/main/assets/scrfd_500m.vkml", graph::SCRFD),+            load("photos/src/main/assets/scrfd_500m.maml", graph::SCRFD),             scrfd::build(-                &load("photos/src/main/assets/scrfd_500m.vkml", graph::SCRFD),+                &load("photos/src/main/assets/scrfd_500m.maml", graph::SCRFD),                 scrfd::LONG_SIDE,                 scrfd::LONG_SIDE,             )
library/ocr/build.gradle.kts
diff --git a/library/ocr/build.gradle.kts b/library/ocr/build.gradle.ktsindex 74ce66d745..5c0fe1ff0a 100644--- a/library/ocr/build.gradle.kts+++ b/library/ocr/build.gradle.kts@@ -3,7 +3,7 @@ plugins { } dependencies {     // On-device OCR via PP-OCRv5 on the Vulkan compute runtime in `:library:ml`. Both-    // models ship as `.vkml` in this module's assets and the whole detect-crop-recognise+    // models ship as `.maml` in this module's assets and the whole detect-crop-recognise     // pipeline is Rust; consumers only see the OcrEngine API.     //     // `implementation` is enough even though `:library:ml` supplies `libmodelrunner.so`:
library/ocr/src/main/assets/README.md
diff --git a/library/ocr/src/main/assets/README.md b/library/ocr/src/main/assets/README.mdindex 0a9d7a279f..efdb1a5109 100644--- a/library/ocr/src/main/assets/README.md+++ b/library/ocr/src/main/assets/README.md@@ -1,18 +1,18 @@ # `:library:ocr` bundled model assets -## `ppocr_det.vkml` — text detection+## `ppocr_det.maml` — text detection  Apache-2.0, from https://huggingface.co/PaddlePaddle/PP-OCRv5_mobile_det_onnx @ `e6f4fa85f00e168c862bc462aebca69eef9b3d3d` (`inference.onnx`, 4,826,518 B fp32, SHA-256 `a4319856…597b6e61d`) — the official PaddleOCR export of PP-OCRv5 mobile-detection. The source ONNX SHA-256 is in the `.vkml` header, so a shipped asset traces+detection. The source ONNX SHA-256 is in the `.maml` header, so a shipped asset traces back to this line.  Rebuild with `./scripts/ml/fetch_and_convert.sh`.  ### It is folded, not copied -Unlike every other `.vkml`, this one is **not** the ONNX's tensors verbatim. The export+Unlike every other `.maml`, this one is **not** the ONNX's tensors verbatim. The export is PP-HGNetV2 as `paddle2onnx` spells it, and every convolution arrives as a chain:      Conv (no bias) → Add(bias) → Mul(scalar) → Add(scalar)@@ -72,7 +72,7 @@ The space is deliberately **not** in the file — no entry in it is whitespace  text editor or a line-ending conversion cannot silently eat it. `post::ctc::Dictionary` appends it. -## `ppocr_rec.vkml` - text recognition+## `ppocr_rec.maml` - text recognition Apache-2.0, from https://huggingface.co/PaddlePaddle/latin_PP-OCRv5_mobile_rec_onnx @ `89d3a50e2c27e2e7cceeab0e944c25c807d5db4f` (`inference.onnx`, 8,042,023 B fp32, SHA-256 `78881130.dd121498`) - the official export of the **latin** PP-OCRv5 mobile
library/ocr/src/main/assets/ppocr_det.maml
diff --git a/library/ocr/src/main/assets/ppocr_det.vkml b/library/ocr/src/main/assets/ppocr_det.mamlsimilarity index 99%rename from library/ocr/src/main/assets/ppocr_det.vkmlrename to library/ocr/src/main/assets/ppocr_det.mamlindex e9cd46b9fa..a7b3a71f7c 100644Binary files a/library/ocr/src/main/assets/ppocr_det.vkml and b/library/ocr/src/main/assets/ppocr_det.maml differ
library/ocr/src/main/assets/ppocr_rec.maml
diff --git a/library/ocr/src/main/assets/ppocr_rec.vkml b/library/ocr/src/main/assets/ppocr_rec.mamlsimilarity index 99%rename from library/ocr/src/main/assets/ppocr_rec.vkmlrename to library/ocr/src/main/assets/ppocr_rec.mamlindex 7f91915941..81343442ec 100644Binary files a/library/ocr/src/main/assets/ppocr_rec.vkml and b/library/ocr/src/main/assets/ppocr_rec.maml differ
library/ocr/src/main/java/com/vayunmathur/library/ocr/OcrEngine.kt
diff --git a/library/ocr/src/main/java/com/vayunmathur/library/ocr/OcrEngine.kt b/library/ocr/src/main/java/com/vayunmathur/library/ocr/OcrEngine.ktindex 0d8fbbbc76..8c09864663 100644--- a/library/ocr/src/main/java/com/vayunmathur/library/ocr/OcrEngine.kt+++ b/library/ocr/src/main/java/com/vayunmathur/library/ocr/OcrEngine.kt@@ -12,7 +12,7 @@ import kotlinx.coroutines.withContext  * compute runtime in `:library:ml`.  *  * Detection is DBNet over a PP-HGNetV2 backbone; recognition is a PP-LCNetV3 backbone into a- * two-block transformer with a CTC head. Both are converted ahead of time to `.vkml` by+ * two-block transformer with a CTC head. Both are converted ahead of time to `.maml` by  * `scripts/ml/ppocr_fold.py` and shipped in this module's assets. The recogniser is the  * **latin** model (836-char dict covering 47 Latin-script languages; no CJK) for a much  * smaller footprint.
photos/build.gradle.kts
diff --git a/photos/build.gradle.kts b/photos/build.gradle.ktsindex 1b826683f4..9435d7c8f1 100644--- a/photos/build.gradle.kts+++ b/photos/build.gradle.kts@@ -19,10 +19,10 @@ android {         // uncompressed: int8 weights barely deflate, and a compressed asset would have to be         // inflated into a 24 MB heap buffer before ORT could open it.         noCompress += "onnx"-        // The three .vkml files are read straight out of the APK for the same reason: fp16+        // The three .maml files are read straight out of the APK for the same reason: fp16         // weights barely deflate, and a compressed asset would have to be inflated into a         // heap buffer — 6.6 MB for the face embedder — before it could be uploaded.-        noCompress += "vkml"+        noCompress += "maml"     } } 
photos/src/main/assets/README.md
diff --git a/photos/src/main/assets/README.md b/photos/src/main/assets/README.mdindex 0ebd02aca3..1fe63ba5fd 100644--- a/photos/src/main/assets/README.md+++ b/photos/src/main/assets/README.md@@ -1,6 +1,6 @@ # `:photos` bundled model assets -## `u2netp.vkml` — salient-object detection+## `u2netp.maml` — salient-object detection  Apache-2.0, from https://huggingface.co/BritishWerewolf/U-2-Netp @ `7112208dbac3a3642496c8d54e2f0f9bb3dc1dc8` (`onnx/model.onnx`, 4,574,861 B fp32,@@ -8,8 +8,8 @@ SHA-256 `309c8469…4c76f4ddd8`) — U²-Net *portable*, the small variant of th salient-object detector.  Not the ONNX itself: `scripts/ml/fetch_and_convert.sh` converts it to the fp16-`.vkml` weights container that `:library:ml` reads. The source ONNX SHA-256 is in-the `.vkml` header, so a shipped asset traces back to this line.+`.maml` weights container that `:library:ml` reads. The source ONNX SHA-256 is in+the `.maml` header, so a shipped asset traces back to this line.  Run at 320×320 RGB, ImageNet mean/std, output a 320×320 saliency map through a sigmoid. Consumed by `SubjectSegmenter` from `MlSegmentation.kt` for@@ -25,14 +25,14 @@ letterbox, which would change existing behaviour.  ## The face models -`scrfd_500m.vkml` (face detection) and `w600k_mbf.vkml` (face embedding) are+`scrfd_500m.maml` (face detection) and `w600k_mbf.maml` (face embedding) are InsightFace's **buffalo_s** pack, from https://huggingface.co/immich-app/buffalo_s @ `0ff1751885575e62e084dff70549ce24a11fa5dc`:  | asset | source ONNX | SHA-256 | |---|---|---|-| `scrfd_500m.vkml` | `detection/model.onnx`, 2,524,817 B | `5e4447f5…d8b4ea3a` |-| `w600k_mbf.vkml` | `recognition/model.onnx`, 13,616,099 B | `9cc6e4a7…b319eb4f` |+| `scrfd_500m.maml` | `detection/model.onnx`, 2,524,817 B | `5e4447f5…d8b4ea3a` |+| `w600k_mbf.maml` | `recognition/model.onnx`, 13,616,099 B | `9cc6e4a7…b319eb4f` |  **Licence: InsightFace's own, which permits non-commercial research use only** — https://github.com/deepinsight/insightface/tree/master/python-package#license. This is@@ -43,11 +43,11 @@ no upstream URL and no licence recorded at all; re-sourcing them from a licensed export makes the constraint visible rather than introducing it.  SCRFD runs at 640 on the long side with the short side padded to a multiple of 32, so-its `.vkml` is the only one whose graph is dynamically shaped. MobileFaceNet runs at a+its `.maml` is the only one whose graph is dynamically shaped. MobileFaceNet runs at a fixed 112×112 and returns a 512-d embedding.  Two nodes are rewritten during conversion rather than needing a shader — see-`scripts/ml/vkml_convert.py`: MobileFaceNet's final `Gemm` becomes a `[512, 64, 7, 7]`+`scripts/ml/maml_convert.py`: MobileFaceNet's final `Gemm` becomes a `[512, 64, 7, 7]` convolution kernel, and the `BatchNormalization` after it is folded into that layer's weight and bias. 
photos/src/main/assets/scrfd_500m.maml
diff --git a/photos/src/main/assets/scrfd_500m.vkml b/photos/src/main/assets/scrfd_500m.mamlsimilarity index 99%rename from photos/src/main/assets/scrfd_500m.vkmlrename to photos/src/main/assets/scrfd_500m.mamlindex a99004a647..cdcc4584dc 100644Binary files a/photos/src/main/assets/scrfd_500m.vkml and b/photos/src/main/assets/scrfd_500m.maml differ
photos/src/main/assets/u2netp.maml
diff --git a/photos/src/main/assets/u2netp.vkml b/photos/src/main/assets/u2netp.mamlsimilarity index 99%rename from photos/src/main/assets/u2netp.vkmlrename to photos/src/main/assets/u2netp.mamlindex bf616636cf..da8d9147b7 100644Binary files a/photos/src/main/assets/u2netp.vkml and b/photos/src/main/assets/u2netp.maml differ
photos/src/main/assets/w600k_mbf.maml
diff --git a/photos/src/main/assets/w600k_mbf.vkml b/photos/src/main/assets/w600k_mbf.mamlsimilarity index 99%rename from photos/src/main/assets/w600k_mbf.vkmlrename to photos/src/main/assets/w600k_mbf.mamlindex 330209f9bc..07b7ab2068 100644Binary files a/photos/src/main/assets/w600k_mbf.vkml and b/photos/src/main/assets/w600k_mbf.maml differ
photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.ktindex 197f62212d..be30944718 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.kt@@ -71,7 +71,7 @@ fun PeoplePage(     val scanned by galleryViewModel.faceScannedCount.collectAsState()     val target by galleryViewModel.indexTargetCount.collectAsState()     // Off the main thread: `modelsAvailable` brings the models up, and on `:library:ml`-    // that means parsing two `.vkml` blobs and uploading 7.9 MB to the GPU. Doing it in a+    // that means parsing two `.maml` blobs and uploading 7.9 MB to the GPU. Doing it in a     // bare `remember { }` blocked the first composition of this screen for as long as     // that took.     val modelsAvailable by produceState(initialValue = false, context) {
photos/src/main/java/com/vayunmathur/photos/util/FaceRecognizer.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/FaceRecognizer.kt b/photos/src/main/java/com/vayunmathur/photos/util/FaceRecognizer.ktindex a677eafbba..3ed8367b73 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/FaceRecognizer.kt+++ b/photos/src/main/java/com/vayunmathur/photos/util/FaceRecognizer.kt@@ -32,7 +32,7 @@ import kotlin.math.sqrt  *  4. Matching — cosine similarity clusters faces of the same person  *     (see [CLUSTER_THRESHOLD]).  *- * The models ship as `.vkml` assets in this app. They are **GPU-only**: on a device+ * The models ship as `.maml` assets in this app. They are **GPU-only**: on a device  * without Vulkan fp16 compute [modelsAvailable] is false and people clustering turns off,  * rather than falling back to a second implementation.  */
scripts/ml/fetch_and_convert.sh
diff --git a/scripts/ml/fetch_and_convert.sh b/scripts/ml/fetch_and_convert.shindex 8b269fa789..8ff5581644 100644--- a/scripts/ml/fetch_and_convert.sh+++ b/scripts/ml/fetch_and_convert.sh@@ -1,14 +1,14 @@ #!/usr/bin/env bash #-# Refresh the bundled `.vkml` weights that `:library:ml` runs, from the ONNX exports+# Refresh the bundled `.maml` weights that `:library:ml` runs, from the ONNX exports # they are converted from. #-#   camera/src/main/assets/selfie_segmentation.vkml   MediaPipe Selfie Segmentation-#   photos/src/main/assets/u2netp.vkml                U^2-Net portable (saliency)-#   photos/src/main/assets/scrfd_500m.vkml            SCRFD 500M (face detection)-#   photos/src/main/assets/w600k_mbf.vkml             MobileFaceNet (face embedding)-#   library/ocr/src/main/assets/ppocr_det.vkml        PP-OCRv5 mobile (text detection)-#   library/ocr/src/main/assets/ppocr_rec.vkml        PP-OCRv5 mobile latin (text recognition)+#   camera/src/main/assets/selfie_segmentation.maml   MediaPipe Selfie Segmentation+#   photos/src/main/assets/u2netp.maml                U^2-Net portable (saliency)+#   photos/src/main/assets/scrfd_500m.maml            SCRFD 500M (face detection)+#   photos/src/main/assets/w600k_mbf.maml             MobileFaceNet (face embedding)+#   library/ocr/src/main/assets/ppocr_det.maml        PP-OCRv5 mobile (text detection)+#   library/ocr/src/main/assets/ppocr_rec.maml        PP-OCRv5 mobile latin (text recognition) # # The first two are Apache-2.0. The two face models are InsightFace's buffalo_s pack # under InsightFace's own licence, which permits **non-commercial research use only** —@@ -16,21 +16,21 @@ # shipped as ncnn `.param`/`.bin`, re-sourced from a licensed ONNX export so the # provenance is recorded rather than absent. #-# No ONNX is vendored: it is 2x the size of the fp16 `.vkml` we actually ship and+# No ONNX is vendored: it is 2x the size of the fp16 `.maml` we actually ship and # nothing reads it at run time. So this is the only record of where the weights came # from, alongside the README.md next to each asset and the source ONNX SHA-256 baked-# into each `.vkml` header.+# into each `.maml` header. # # The conversion is deliberately not a graph import. `:library:ml` hardcodes each-# forward pass in Rust, so `.vkml` carries ordered tensors and nothing else, and-# vkml_convert.py pins a digest over the whole ordered layer table - an upstream+# forward pass in Rust, so `.maml` carries ordered tensors and nothing else, and+# maml_convert.py pins a digest over the whole ordered layer table - an upstream # re-export that reorders or re-pads one layer fails here rather than shipping a-# net that infers nonsense. See scripts/ml/vkml_convert.py.+# net that infers nonsense. See scripts/ml/maml_convert.py. # # The digest pins *structure*, not weight values. For the two folded models it is worth # also running scripts/ml/onnx_parity.py, which checks the numbers against onnxruntime; # it is how two silently-wrong folds were found. See that script's header.-# net that infers nonsense. See scripts/ml/vkml_convert.py.+# net that infers nonsense. See scripts/ml/maml_convert.py. # #   ./scripts/ml/fetch_and_convert.sh            # verify pinned hashes, rebuild assets #   ./scripts/ml/fetch_and_convert.sh --update   # re-download and rewrite hashes@@ -40,21 +40,21 @@ set -euo pipefail  # repo-relative-dest  graph  sha256(onnx)  url  [converter] #-# The converter defaults to vkml_convert.py. PP-OCRv5 uses ppocr_fold.py instead: its+# The converter defaults to maml_convert.py. PP-OCRv5 uses ppocr_fold.py instead: its # export spells every convolution as a chain of constant Add/Mul/HardSigmoid nodes that-# has to be folded first, and doing that inside vkml_convert.py would make "the tensors+# has to be folded first, and doing that inside maml_convert.py would make "the tensors # verbatim" stop being true for every other model. See that script's header. # # Pinned to a commit rather than to `main`: the file SHA-256 below would catch a # silent upstream change anyway, but a pinned revision means --update tells you the # upstream *revision* that moved, not just that some bytes differ. MODELS=(-  "camera/src/main/assets/selfie_segmentation.vkml selfie 3241ac4ad8aa35bdaf33946776db29f7c283a413aa0b0dacb9483594b4531aad https://huggingface.co/onnx-community/mediapipe_selfie_segmentation/resolve/be49485c8e027524be38591817fc5cd31bd9d00e/onnx/model.onnx"-  "photos/src/main/assets/u2netp.vkml             u2netp 309c8469258dda742793dce0ebea8e6dd393174f89934733ecc8b14c76f4ddd8 https://huggingface.co/BritishWerewolf/U-2-Netp/resolve/7112208dbac3a3642496c8d54e2f0f9bb3dc1dc8/onnx/model.onnx"-  "photos/src/main/assets/scrfd_500m.vkml         scrfd  5e4447f50245bbd7966bd6c0fa52938c61474a04ec7def48753668a9d8b4ea3a https://huggingface.co/immich-app/buffalo_s/resolve/0ff1751885575e62e084dff70549ce24a11fa5dc/detection/model.onnx"-  "photos/src/main/assets/w600k_mbf.vkml          mobilefacenet 9cc6e4a75f0e2bf0b1aed94578f144d15175f357bdc05e815e5c4a02b319eb4f https://huggingface.co/immich-app/buffalo_s/resolve/0ff1751885575e62e084dff70549ce24a11fa5dc/recognition/model.onnx"-  "library/ocr/src/main/assets/ppocr_det.vkml     ppocr_det a431985659dc921974177a95adcfbb90fd9e51989a5e04d70d0b75f597b6e61d https://huggingface.co/PaddlePaddle/PP-OCRv5_mobile_det_onnx/resolve/e6f4fa85f00e168c862bc462aebca69eef9b3d3d/inference.onnx ppocr_fold.py"-  "library/ocr/src/main/assets/ppocr_rec.vkml     ppocr_rec 7888113072263cb471b93f66dd5e2ad70548dc526fa1ace760d0d973dd121498 https://huggingface.co/PaddlePaddle/latin_PP-OCRv5_mobile_rec_onnx/resolve/89d3a50e2c27e2e7cceeab0e944c25c807d5db4f/inference.onnx ppocr_fold.py"+  "camera/src/main/assets/selfie_segmentation.maml selfie 3241ac4ad8aa35bdaf33946776db29f7c283a413aa0b0dacb9483594b4531aad https://huggingface.co/onnx-community/mediapipe_selfie_segmentation/resolve/be49485c8e027524be38591817fc5cd31bd9d00e/onnx/model.onnx"+  "photos/src/main/assets/u2netp.maml             u2netp 309c8469258dda742793dce0ebea8e6dd393174f89934733ecc8b14c76f4ddd8 https://huggingface.co/BritishWerewolf/U-2-Netp/resolve/7112208dbac3a3642496c8d54e2f0f9bb3dc1dc8/onnx/model.onnx"+  "photos/src/main/assets/scrfd_500m.maml         scrfd  5e4447f50245bbd7966bd6c0fa52938c61474a04ec7def48753668a9d8b4ea3a https://huggingface.co/immich-app/buffalo_s/resolve/0ff1751885575e62e084dff70549ce24a11fa5dc/detection/model.onnx"+  "photos/src/main/assets/w600k_mbf.maml          mobilefacenet 9cc6e4a75f0e2bf0b1aed94578f144d15175f357bdc05e815e5c4a02b319eb4f https://huggingface.co/immich-app/buffalo_s/resolve/0ff1751885575e62e084dff70549ce24a11fa5dc/recognition/model.onnx"+  "library/ocr/src/main/assets/ppocr_det.maml     ppocr_det a431985659dc921974177a95adcfbb90fd9e51989a5e04d70d0b75f597b6e61d https://huggingface.co/PaddlePaddle/PP-OCRv5_mobile_det_onnx/resolve/e6f4fa85f00e168c862bc462aebca69eef9b3d3d/inference.onnx ppocr_fold.py"+  "library/ocr/src/main/assets/ppocr_rec.maml     ppocr_rec 7888113072263cb471b93f66dd5e2ad70548dc526fa1ace760d0d973dd121498 https://huggingface.co/PaddlePaddle/latin_PP-OCRv5_mobile_rec_onnx/resolve/89d3a50e2c27e2e7cceeab0e944c25c807d5db4f/inference.onnx ppocr_fold.py" )  if [ ! -f settings.gradle.kts ]; then@@ -97,7 +97,7 @@ for entry in "${MODELS[@]}"; do   graph="$2"   want="$3"   url="$4"-  converter="${5:-vkml_convert.py}"+  converter="${5:-maml_convert.py}"   onnx="${work}/${graph}.onnx"    echo "Downloading ${graph} from ${url}..."@@ -109,7 +109,7 @@ for entry in "${MODELS[@]}"; do   elif [ "$update" = 1 ]; then     printf '  CHANGED  %-8s\n             was %s\n             now %s\n' "$graph" "$want" "$got"     echo "             ^ update the pin for ${graph} in this script, then re-pin the"-    echo "               layer digest with vkml_convert.py --print-digest"+    echo "               layer digest with maml_convert.py --print-digest"     fail=1   else     printf '  MISMATCH %-8s\n             want %s\n             got  %s\n' "$graph" "$want" "$got"
scripts/ml/maml_convert.py
diff --git a/scripts/ml/vkml_convert.py b/scripts/ml/maml_convert.pysimilarity index 97%rename from scripts/ml/vkml_convert.pyrename to scripts/ml/maml_convert.pyindex 5b3e62f00d..c9b01ca6ec 100644--- a/scripts/ml/vkml_convert.py+++ b/scripts/ml/maml_convert.py@@ -1,8 +1,8 @@ #!/usr/bin/env python3-"""ONNX to `.vkml`, the weights container `:library:ml` reads.+"""ONNX to `.maml`, the weights container `:library:ml` reads.  `:library:ml` is not a graph interpreter: each network's forward pass is hardcoded-Rust in `library/ml/src/main/rust/src/nets/`. So a `.vkml` file carries **only+Rust in `library/ml/src/main/rust/src/nets/`. So a `.maml` file carries **only ordered tensors** — no operators, no topology, no names. The Rust net module indexes the tensor table positionally. @@ -39,9 +39,9 @@ byte layout). ONNX tensor layout is preserved verbatim — `[M, C/group, kH, kW] `Conv`, `[C, M/group, kH, kW]` for `ConvTranspose` — so nothing here has to agree with the shaders about a transpose. -    ./scripts/ml/vkml_convert.py --check model.onnx --graph u2netp-    ./scripts/ml/vkml_convert.py model.onnx --graph u2netp -o out.vkml-    ./scripts/ml/vkml_convert.py model.onnx --graph u2netp --print-layers+    ./scripts/ml/maml_convert.py --check model.onnx --graph u2netp+    ./scripts/ml/maml_convert.py model.onnx --graph u2netp -o out.maml+    ./scripts/ml/maml_convert.py model.onnx --graph u2netp --print-layers """  import argparse@@ -53,13 +53,13 @@ import numpy as np import onnx from onnx import numpy_helper, shape_inference -# --- .vkml ---------------------------------------------------------------------+# --- .maml --------------------------------------------------------------------- # # One contiguous blob, so the whole file becomes one VkBuffer and one staging # upload. Little-endian throughout; every device we target is. # #   header, 64 bytes-#     0   4   magic b"VKML"+#     0   4   magic b"MAML" #     4   4   u32 format version #     8   4   u32 graph id — the runtime rejects a file built for another net #    12   4   u32 tensor count@@ -76,7 +76,7 @@ from onnx import numpy_helper, shape_inference #    28   4   u32 element count # #   data, fp16, each tensor padded to ALIGNMENT-MAGIC = b"VKML"+MAGIC = b"MAML" FORMAT_VERSION = 1 HEADER_BYTES = 64 TENSOR_ENTRY_BYTES = 32@@ -200,7 +200,7 @@ class Layer:         self.op = op         self.name = name         self._key = key-        # Where this layer's tensors start in the `.vkml` table, and how many it has.+        # Where this layer's tensors start in the `.maml` table, and how many it has.         # The Rust indexes by tensor, and with `PRelu` in the mix that is no longer         # `2 * layer` — so --print-layers reports it rather than leaving a transcriber         # to count.@@ -540,7 +540,7 @@ def main():     parser = argparse.ArgumentParser(description=SPEC.splitlines()[0])     parser.add_argument("onnx")     parser.add_argument("--graph", required=True, choices=sorted(GRAPHS))-    parser.add_argument("-o", "--out", help="where to write the .vkml")+    parser.add_argument("-o", "--out", help="where to write the .maml")     parser.add_argument("--check", action="store_true", help="validate only")     parser.add_argument("--print-layers", action="store_true")     parser.add_argument("--print-digest", action="store_true")
scripts/ml/onnx_parity.py
diff --git a/scripts/ml/onnx_parity.py b/scripts/ml/onnx_parity.pyindex e62aa86844..b0f06f66ca 100644--- a/scripts/ml/onnx_parity.py+++ b/scripts/ml/onnx_parity.py@@ -1,5 +1,5 @@ #!/usr/bin/env python3-"""Check a `.vkml` forward pass against onnxruntime, numerically.+"""Check a `.maml` forward pass against onnxruntime, numerically.  Nothing else in this repo compares the *numbers* `:library:ml` produces against the export they came from. The per-op fixtures in `nets::reference` check each op against hand@@ -17,7 +17,7 @@ So this exists, and is worth running whenever `ppocr_fold.py` or a net module ch  # How to run it -    ./scripts/ml/fetch_and_convert.sh                       # produce the .vkml first+    ./scripts/ml/fetch_and_convert.sh                       # produce the .maml first     python scripts/ml/onnx_parity.py <graph> <inference.onnx> [--width N]  It writes a scratch directory, runs onnxruntime, then asks the Rust reference interpreter@@ -27,7 +27,7 @@ for the same tensor and reports the difference. `onnxruntime` is an extra depend  # What "agreeing" means -`.vkml` is fp16, so the two cannot agree exactly. The bar is that the difference is no+`.maml` is fp16, so the two cannot agree exactly. The bar is that the difference is no larger than fp16 weight quantisation alone accounts for, which this script measures by running onnxruntime a second time with every weight rounded through fp16. A difference materially above that line is a bug, not precision.@@ -122,12 +122,12 @@ def main():     parser.add_argument("graph", choices=sorted(PROBE))     parser.add_argument("onnx")     parser.add_argument("--width", type=int, default=64)-    parser.add_argument("--vkml", help="the .vkml, for a graph that is a runtime download")+    parser.add_argument("--maml", help="the .maml, for a graph that is a runtime download")     args = parser.parse_args()      onnxruntime.set_default_logger_severity(3)     model = onnx.load(args.onnx)-    work = tempfile.mkdtemp(prefix="vkml_parity_")+    work = tempfile.mkdtemp(prefix="maml_parity_")      cut = SUBGRAPH.get(args.graph)     if cut is not None:@@ -158,8 +158,8 @@ def main():      environment = dict(os.environ, PARITY_DIR=work, PARITY_GRAPH=args.graph)     environment["PARITY_WIDTH"] = str(args.width)-    if args.vkml:-        environment["PARITY_VKML"] = os.path.abspath(args.vkml)+    if args.maml:+        environment["PARITY_MAML"] = os.path.abspath(args.maml)     subprocess.run(         [             "cargo", "test", "--release", "-p", "modelrunner", "--lib",
scripts/ml/ppocr_fold.py
diff --git a/scripts/ml/ppocr_fold.py b/scripts/ml/ppocr_fold.pyindex 70d36c0d08..89456c95ac 100644--- a/scripts/ml/ppocr_fold.py+++ b/scripts/ml/ppocr_fold.py@@ -1,5 +1,5 @@ #!/usr/bin/env python3-"""Fold a PP-OCRv5 `paddle2onnx` export into `.vkml`, ahead of time.+"""Fold a PP-OCRv5 `paddle2onnx` export into `.maml`, ahead of time.  PP-OCRv5's official ONNX (Apache-2.0, `PaddlePaddle/PP-OCRv5_*_onnx`) is PP-HGNetV2 as `paddle2onnx` spells it, which is not a form `:library:ml` can lower. Every convolution@@ -18,12 +18,12 @@ gates. Everything else is constant.  # Why this is a separate script -`vkml_convert.py`'s contract is that a `.vkml` is the ONNX's tensors *verbatim*, so the+`maml_convert.py`'s contract is that a `.maml` is the ONNX's tensors *verbatim*, so the Rust can index them positionally and nothing has to agree about a rewrite. Teaching it to constant-fold a graph would make that contract "verbatim, except for these seven rewrites", and the rewrites would then run on every model it converts. -So the fold happens here instead, once, ahead of time. The output is a `.vkml` whose+So the fold happens here instead, once, ahead of time. The output is a `.maml` whose tensors are the folded weights and biases, and the input is the official export with its SHA-256 recorded in the header exactly as before. Provenance is unchanged; only the place the arithmetic happens moves.@@ -48,7 +48,7 @@ convolutions and nothing else. Rather than depend on that, those are emitted as `Affine` op the runtime runs as an elementwise pass. There are a couple of dozen, and detection runs once per OCR request rather than per frame. -    ./scripts/ml/ppocr_fold.py det.onnx --graph ppocr_det -o out.vkml+    ./scripts/ml/ppocr_fold.py det.onnx --graph ppocr_det -o out.maml     ./scripts/ml/ppocr_fold.py det.onnx --graph ppocr_det --print-graph """ @@ -62,14 +62,14 @@ import onnx from onnx import numpy_helper  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))-import vkml_convert  # noqa: E402  (needs the path above)+import maml_convert  # noqa: E402  (needs the path above)  # ONNX `HardSigmoid` defaults to alpha 0.2; Paddle's hard-swish uses 1/6. Both appear in # these graphs, so the value is read per node and checked rather than assumed. HARDSWISH_ALPHA = 1.0 / 6.0 TOLERANCE = 1e-4 -# Ops that only rearrange or relabel, and are therefore aliases in `.vkml`'s layout.+# Ops that only rearrange or relabel, and are therefore aliases in `.maml`'s layout. # # This runtime's tensors are `[c, h, w]` with batch always 1, and `nets::ppocr_rec` keeps a # transformer's sequence as `[d_model, 1, T]` precisely so that the export's reshapes and@@ -117,7 +117,7 @@ def normalise(model):     """Strip `Identity`, fold the constant affine chains, and return the ops and tensors.      Returns `(ops, layers, tensors)`: the normalised op list for transcription, the-    `Layer` records the digest is taken over, and the fp16 tensors in `.vkml` order.+    `Layer` records the digest is taken over, and the fp16 tensors in `.maml` order.     """     graph = model.graph     inits = {i.name: numpy_helper.to_array(i) for i in graph.initializer}@@ -214,7 +214,7 @@ def normalise(model):             f"g={attrs['group'].i if 'group' in attrs else 1} act={act}"         )         layers.append(-            vkml_convert.Layer(len(layers), node.op_type, output, key, first, 2)+            maml_convert.Layer(len(layers), node.op_type, output, key, first, 2)         )         ops.append(             Op(@@ -246,7 +246,7 @@ def normalise(model):             f"Linear w={list(kernel.shape)} b={list(bias.shape)} "             f"k=[1, 1] d=[1, 1] p=[0, 0, 0, 0] s=[1, 1] g=1 act={act}"         )-        layers.append(vkml_convert.Layer(len(layers), "MatMul", output, key, first, 2))+        layers.append(maml_convert.Layer(len(layers), "MatMul", output, key, first, 2))         ops.append(             Op("Linear", [source], output, w=list(kernel.shape), act=act, t=first)         )@@ -257,7 +257,7 @@ def normalise(model):         tensors.append(np.array(gamma, dtype=np.float32).flatten())         tensors.append(np.array(beta, dtype=np.float32).flatten())         key = f"LayerNorm c={gamma.size} eps={epsilon:.9g}"-        layers.append(vkml_convert.Layer(len(layers), "LayerNorm", output, key, first, 2))+        layers.append(maml_convert.Layer(len(layers), "LayerNorm", output, key, first, 2))         ops.append(Op("LayerNorm", [source], output, c=int(gamma.size), eps=epsilon, t=first))      def absorb(cursor, weight, bias, channels, is_transpose):@@ -829,8 +829,8 @@ def fold_batch_norm(node, inits, weight, bias, op_type): def main():     parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])     parser.add_argument("onnx")-    parser.add_argument("--graph", required=True, choices=sorted(vkml_convert.GRAPHS))-    parser.add_argument("-o", "--out", help="where to write the .vkml")+    parser.add_argument("--graph", required=True, choices=sorted(maml_convert.GRAPHS))+    parser.add_argument("-o", "--out", help="where to write the .maml")     parser.add_argument("--print-graph", action="store_true", help="dump the folded ops")     parser.add_argument("--print-layers", action="store_true")     parser.add_argument("--print-digest", action="store_true")@@ -850,10 +850,10 @@ def main():         for layer in layers:             print(f"{layer.index:4d} t{layer.first_tensor:<4d} {layer.key()}  # {layer.name}") -    digest = vkml_convert.layer_table_digest(layers)+    digest = maml_convert.layer_table_digest(layers)     if args.print_digest:         print(f'    "{args.graph}": "{digest}",')-    pinned = vkml_convert.EXPECTED_DIGEST.get(args.graph, "")+    pinned = maml_convert.EXPECTED_DIGEST.get(args.graph, "")     if digest != pinned and not args.print_digest:         raise SystemExit(             f"layer table digest {digest}\n           pinned  {pinned}\n"@@ -862,8 +862,8 @@ def main():             "re-pin with --print-digest."         ) -    blob, count = vkml_convert.build(-        layers, tensors, vkml_convert.GRAPHS[args.graph], onnx_sha256+    blob, count = maml_convert.build(+        layers, tensors, maml_convert.GRAPHS[args.graph], onnx_sha256     )     if args.out:         with open(args.out, "wb") as f: