Modern Apps git

← Modern-Apps.git

translate: drop ncnn

Commit
0819363b7258119d8e62b679e6e57640fc1978d4
Author
vayun-mathur <[email protected]>
When
2026-08-29 04:03 UTC (3 months ago)
Parents
e785e1f

Diff

.gitignore
diff --git a/.gitignore b/.gitignoreindex c5d68d672e..883d309581 100644--- a/.gitignore+++ b/.gitignore@@ -50,9 +50,6 @@ tmp/ target/ dist/ -# Small100 quantized binaries > 100MB — do not commit, fetch via quantize_small100.sh or R2-scripts/translate/quantized/- # Nutrition database asset — large binary, regenerate with scripts/generate_food_db.py health/src/main/assets/food.bin health/src/main/assets/food.bin.br
SUPPLY_CHAIN_RISKS.md
diff --git a/SUPPLY_CHAIN_RISKS.md b/SUPPLY_CHAIN_RISKS.mdindex c8bdcf3d30..1c3c4bc7ba 100644--- a/SUPPLY_CHAIN_RISKS.md+++ b/SUPPLY_CHAIN_RISKS.md@@ -72,7 +72,11 @@ So a clean install both transcribes and speaks with no network at all.  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.+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, OCR, speech synthesis and translation turn off rather than falling back to CPU.++**ncnn is gone from the tree.** `:translate` was its last consumer, and SMaLL-100 now runs on `:library:ml` too, so `libncnn_android.so` is in no APK here and the self-built `com.github.vayun-mathur:ncnn-android` AAR — a JitPack fork of a third-party runtime, built from a local checkout and resolved through `mavenLocal()` — has left the supply chain entirely. `mavenLocal()` went with it: it existed only so a freshly built ncnn resolved ahead of a rate-limited JitPack, and a local repository ahead of the remotes means any coordinate in `~/.m2` silently outranks the pinned one. The JitPack declaration stays, scoped to `com.github.*`, for `Stockfish-Library` and `com.github.luben:zstd-jni`.++The port also removed the only two tagged-memory faults this tree has seen, both inside `libncnn_android.so`, and cut the translation model's download from **1.14 GB across seven files to 320 MB across two** — ncnn could not quantise the 131M-parameter embedding, so the shipped model was fp16 and carried it twice; the `.maml` is int8 per output channel and carries it once, because it is tied. Upstream is **`alirezamsh/small100`** (MIT), a **build-host** dependency pinned by revision and file SHA-256 in `scripts/ml/fetch_small100.py`. Nothing about the model is built locally any more.  Notably **offline after first launch**: `astronomy`, `calendar`, `clock`, `contacts` (only `libphonenumber` locally), `files`, `notes` (Room + Ink), `things`, `camera` (on-device MediaPipe Selfie Segmentation on `:library:ml`), `pdf` (Rust `libpdf_render.so`), `music` (Media3 ExoPlayer + local scan), `games/*`, `passwords` (biometric + KeePass), `library/*`, `health` (including food search, which ships its database in the APK). @@ -82,7 +86,7 @@ Notably **offline after first launch**: `astronomy`, `calendar`, `clock`, `conta  ### Build Infrastructure -- **Maven repositories**: `google()` (filtered), `mavenCentral()`, `gradlePluginPortal()` in `build-logic/settings`, plus **`https://jitpack.io`** in root `settings.gradle.kts`. JitPack builds **two** personal forks: `Stockfish-Library` (games:chess) and `ncnn-android` (`speech` and `translate` only, now that `camera`, `photos`, `pdf` and `library:ocr` have all moved to `:library:ml`). `nanojson` was vendored to `:third_party:nanojson` (✅ mitigation #2). JitPack remains a reproducible-build SPOF for both.+- **Maven repositories**: `google()` (filtered), `mavenCentral()`, `gradlePluginPortal()` in `build-logic/settings`, plus **`https://jitpack.io`** in root `settings.gradle.kts`, scoped to `com.github.*`. JitPack now serves **one** personal fork, `Stockfish-Library` (games:chess), plus `com.github.luben:zstd-jni`; `ncnn-android` is gone with ncnn itself (✅ above), and `mavenLocal()` — which existed only to resolve it — is gone with it. `nanojson` was vendored to `:third_party:nanojson` (✅ mitigation #2). JitPack remains a reproducible-build SPOF for Stockfish. - **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 ✅).
camera/build.gradle.kts
diff --git a/camera/build.gradle.kts b/camera/build.gradle.ktsindex d31d696919..a69c953393 100644--- a/camera/build.gradle.kts+++ b/camera/build.gradle.kts@@ -46,7 +46,7 @@ dependencies {     // On-device portrait segmentation. MediaPipe Selfie Segmentation (Apache-2.0) on our     // own Vulkan compute runtime; see camera/src/main/assets/README.md.     //-    // ncnn is gone from this app entirely: PortraitSegmenter was its only user, so-    // libncnn_android.so is no longer in the APK.+    // ncnn is gone from the whole tree, not just this app: `:translate` was the last consumer and+    // it now runs SMaLL-100 on `:library:ml` too, so `libncnn_android.so` is in no APK here.     implementation(project(":library:ml")) }
camera/src/main/java/com/vayunmathur/camera/util/BokehAnalyzer.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/BokehAnalyzer.kt b/camera/src/main/java/com/vayunmathur/camera/util/BokehAnalyzer.ktindex 915b2c47f6..a5e6452379 100644--- a/camera/src/main/java/com/vayunmathur/camera/util/BokehAnalyzer.kt+++ b/camera/src/main/java/com/vayunmathur/camera/util/BokehAnalyzer.kt@@ -27,8 +27,8 @@ class BokehAnalyzer(     // Guard for the native handle and buffer fields – analyze() runs on bokehExecutor     // while close() runs on the main composable's DisposableEffect. Without mutual     // exclusion, close() destroys the net while the GPU is still reading the buffers it-    // owns → the SEGV_MTESERR tagged fault this used to hit in libncnn_android.so. The-    // model changed; the hazard did not.+    // owns  the SEGV_MTESERR tagged fault this used to hit in libncnn_android.so. The+    // runtime changed and ncnn has since left the tree entirely; the hazard did not.     private val lock = Any()     private var prevMask: FloatArray? = null     private var blurTemp: FloatArray? = null
gradle/libs.versions.toml
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex f583a54906..5304af23e7 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -134,7 +134,6 @@ appauth = "0.11.1"  # Own libraries (vayun-mathur, via JitPack) stockfishLibrary = "1.1.0"-ncnnAndroid = "1.8.0"  # AppStore – Play install via Aurora gplayapi = "3.6.4"@@ -315,7 +314,6 @@ appauth = { group = "net.openid", name = "appauth", version.ref = "appauth" }  # Own libraries (vayun-mathur, via JitPack) stockfish-library = { module = "com.github.vayun-mathur:Stockfish-Library", version.ref = "stockfishLibrary" }-ncnn-android = { module = "com.github.vayun-mathur:ncnn-android", version.ref = "ncnnAndroid" }  # AppStore – Play install via Aurora auroraoss-gplayapi = { module = "com.auroraoss:gplayapi", version.ref = "gplayapi" }
scripts/translate/quant_check.py
diff --git a/scripts/translate/quant_check.py b/scripts/translate/quant_check.pydeleted file mode 100644index 7902b061c0..0000000000--- a/scripts/translate/quant_check.py+++ /dev/null@@ -1,131 +0,0 @@-#!/usr/bin/env python3-"""-Parity / quality check for quantized Small100 ncnn models.--Compares int4/int8 quantized ncnn .bin sizes and inspects param quantize terms.-For deeper quality: optional HF reference translation if transformers installed.--Usage:-  python scripts/translate/quant_check.py --bundle /path/to/bundle/upload \-         --quantized scripts/translate/quantized/int4--Requires: none for size checks; transformers + sentencepiece for BLEU (optional).-"""-import argparse-import hashlib-import json-import os-import re-import sys-from pathlib import Path--def sha256_file(p: Path) -> str:-    h = hashlib.sha256()-    with open(p, "rb") as f:-        for chunk in iter(lambda: f.read(1 << 20), b""):-            h.update(chunk)-    return h.hexdigest()--def parse_quant_terms(param_path: Path):-    terms = {}-    with open(param_path) as f:-        lines = f.readlines()-    if not lines:-        return terms-    # first line: magic + layer count-    for line in lines[1:]:-        parts = line.split()-        if not parts:-            continue-        name = parts[1] if len(parts) > 1 else "?"-        # extract 18= term (quantize term) and 6= scale nibble-        m = re.search(r"18=(\d+)", line)-        if m:-            terms[name] = int(m.group(1))-    return terms--def main():-    ap = argparse.ArgumentParser()-    ap.add_argument("--bundle", type=Path, default=Path.home() / ".claude/jobs/1dfd8c6b/tmp/small100/bundle/upload",-                    help="fp16 original bundle")-    ap.add_argument("--quantized", type=Path, default=Path("scripts/translate/quantized/int4"),-                    help="quantized bundle dir")-    ap.add_argument("--all-variants", action="store_true", help="check all quantized variants")-    args = ap.parse_args()--    bundle = args.bundle-    qdir = args.quantized-    if not bundle.exists():-        print(f"bundle not found: {bundle}", file=sys.stderr)-        sys.exit(1)--    def report_one(label: str, bdir: Path):-        print(f"\n=== {label}: {bdir} ===")-        if not bdir.exists():-            print(f"  MISSING DIR {bdir}")-            return-        for fname in ["encoder.ncnn.param", "encoder.ncnn.bin", "decoder.ncnn.param", "decoder.ncnn.bin",-                       "sentencepiece.bpe.model", "vocab.txt", "pos_weights.f32.bin"]:-            p = bdir / fname-            if not p.exists():-                print(f"  MISSING {fname}")-                continue-            sz = p.stat().st_size-            print(f"  {fname:30s} {sz/1e6:7.1f} MB")-        # quant terms-        for comp in ["encoder.ncnn.param", "decoder.ncnn.param"]:-            pp = bdir / comp-            if not pp.exists():-                continue-            terms = parse_quant_terms(pp)-            if terms:-                # 18=401 => bits=4 block=64 (bits*100 + blockcode 1), 18=801 => bits=8 block=64-                uniq = sorted(set(terms.values()))-                print(f"  {comp} quantize_terms: {uniq} ({len(terms)} quantized layers)")-                # decode-                for v in uniq:-                    bits = v // 100-                    block_code = v % 100-                    block = [32, 64, 128][block_code] if block_code < 3 else f"code={block_code}"-                    print(f"    term {v} => bits={bits} block={block}")-            else:-                print(f"  {comp}: no quantized terms (fp16 or unquantized)")--    # fp16 baseline-    report_one("FP16 baseline", bundle)-    if args.all_variants:-        base = qdir.parent if qdir.name.startswith("int") else qdir-        if base.exists():-            for sub in sorted(base.iterdir()):-                if sub.is_dir():-                    report_one(f"Variant {sub.name}", sub)-    else:-        report_one(f"Quantized {qdir.name}", qdir)--    # Try optional HF translation parity on a few sentences-    try:-        from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer-        import torch-        print("\n=== HF reference translation sample (EN->ES) ===")-        model_id = "alirezamsh/small100"-        tok = M2M100Tokenizer.from_pretrained(model_id)-        model = M2M100ForConditionalGeneration.from_pretrained(model_id)-        model.eval()-        sentences = [-            "Hello, how are you?",-            "The weather is nice today.",-            "I love machine translation.",-        ]-        for s in sentences:-            tok.src_lang = "en"-            encoded = tok(s, return_tensors="pt")-            generated = model.generate(**encoded, forced_bos_token_id=tok.get_lang_id("es"))-            out = tok.batch_decode(generated, skip_special_tokens=True)[0]-            print(f"  EN: {s}")-            print(f"  ES: {out}")-    except Exception as e:-        print(f"\n=== HF check skipped: {e} ===")-        print("Install transformers+torch+sentencepiece for BLEU parity check.")--if __name__ == "__main__":-    main()
scripts/translate/quantize_small100.sh
diff --git a/scripts/translate/quantize_small100.sh b/scripts/translate/quantize_small100.shdeleted file mode 100755index 8c13ac9598..0000000000--- a/scripts/translate/quantize_small100.sh+++ /dev/null@@ -1,89 +0,0 @@-#!/usr/bin/env bash-# Quantizes SMaLL-100 ncnn bundle via ncnn weight-only block quantization.-#-# Inputs:  fp16 bundle dir from `/tmp/small100/bundle/upload/` or R2 download-#          containing encoder.ncnn.{param,bin} + decoder.ncnn.{param,bin}-# Outputs: quantized bundle under scripts/translate/quantized/int4/ and int8/-#-# Requires host tools built via:-#   cmake -DNCNN_BUILD_TOOLS=ON -DNCNN_WEIGHT_QUANT=ON -DNCNN_INT8=ON ... \-#   && make ncnnllm2table ncnnllm2int -j-#-# Usage:-#   ./scripts/translate/quantize_small100.sh [bundle_dir] [out_root]-#   bundle_dir defaults to $HOME/.claude/jobs/.../bundle/upload if present,-#   else scripts/translate/bundle (user-provided).-#   out_root defaults to scripts/translate/quantized-set -euo pipefail--SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"-REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"--# Resolve input bundle: arg > canonical job output > fallback-DEFAULT_BUNDLE="/Users/vayun/.claude/jobs/1dfd8c6b/tmp/small100/bundle/upload"-BUNDLE="${1:-}"-if [[ -z "$BUNDLE" ]]; then-  if [[ -d "$DEFAULT_BUNDLE" ]]; then-    BUNDLE="$DEFAULT_BUNDLE"-  else-    BUNDLE="$SCRIPT_DIR/bundle"-  fi-fi--OUT_ROOT="${2:-$SCRIPT_DIR/quantized}"-TOOLS="/Users/vayun/Documents/ncnn-android/build-host/tools/quantize"--if [[ ! -f "$BUNDLE/encoder.ncnn.param" ]]; then-  echo "bundle not found: $BUNDLE does not contain encoder.ncnn.param" >&2-  exit 1-fi-for bin in ncnnllm2int ncnnllm2table; do-  if [[ ! -x "$TOOLS/$bin" ]]; then-    echo "missing tool $TOOLS/$bin — build host tools first:" >&2-    echo "  mkdir -p /tmp/ncnn-host && cd /tmp/ncnn-host && cmake -DNCNN_BUILD_TOOLS=ON -DNCNN_WEIGHT_QUANT=ON -DNCNN_INT8=ON -DNCNN_BUILD_EXAMPLES=OFF ... <ncnn-android-root> && make ncnnllm2int ncnnllm2table -j" >&2-    exit 1-  fi-done--mkdir -p "$OUT_ROOT/int4" "$OUT_ROOT/int8" "$OUT_ROOT/int4-128"--echo "=== Original sizes ==="-ls -lh "$BUNDLE"/encoder.ncnn.bin "$BUNDLE"/decoder.ncnn.bin-du -sh "$BUNDLE"--quant_one() {-  local bits="$1" block="$2" method="$3" in_param="$4" in_bin="$5" out_param="$6" out_bin="$7"-  echo ""-  echo "--- Quantizing $(basename "$in_param") bits=$bits block=$block method=$method ---"-  "$TOOLS/ncnnllm2int" "$in_param" "$in_bin" "$out_param" "$out_bin" method="$method" bits="$bits" block="$block"-  echo " -> $(du -h "$out_bin" | cut -f1) $out_bin"-}--# int4 mseclip block=64 — best size/quality without calibration data (auto-dequant in ncnn with NCNN_WEIGHT_QUANT=ON)-quant_one 4 64 mseclip "$BUNDLE/encoder.ncnn.param" "$BUNDLE/encoder.ncnn.bin" "$OUT_ROOT/int4/encoder.ncnn.param" "$OUT_ROOT/int4/encoder.ncnn.bin"-quant_one 4 64 mseclip "$BUNDLE/decoder.ncnn.param" "$BUNDLE/decoder.ncnn.bin" "$OUT_ROOT/int4/decoder.ncnn.param" "$OUT_ROOT/int4/decoder.ncnn.bin"-# copy supporting files (fp32/fp16, not quantized)-cp -v "$BUNDLE/sentencepiece.bpe.model" "$BUNDLE/vocab.txt" "$BUNDLE/pos_weights.f32.bin" "$OUT_ROOT/int4/"--# int4 mseclip block=128 — smaller scales overhead-quant_one 4 128 mseclip "$BUNDLE/encoder.ncnn.param" "$BUNDLE/encoder.ncnn.bin" "$OUT_ROOT/int4-128/encoder.ncnn.param" "$OUT_ROOT/int4-128/encoder.ncnn.bin"-quant_one 4 128 mseclip "$BUNDLE/decoder.ncnn.param" "$BUNDLE/decoder.ncnn.bin" "$OUT_ROOT/int4-128/decoder.ncnn.param" "$OUT_ROOT/int4-128/decoder.ncnn.bin"-cp -v "$BUNDLE/sentencepiece.bpe.model" "$BUNDLE/vocab.txt" "$BUNDLE/pos_weights.f32.bin" "$OUT_ROOT/int4-128/"--# int8 mseclip block=64 — quality fallback-quant_one 8 64 mseclip "$BUNDLE/encoder.ncnn.param" "$BUNDLE/encoder.ncnn.bin" "$OUT_ROOT/int8/encoder.ncnn.param" "$OUT_ROOT/int8/encoder.ncnn.bin"-quant_one 8 64 mseclip "$BUNDLE/decoder.ncnn.param" "$BUNDLE/decoder.ncnn.bin" "$OUT_ROOT/int8/decoder.ncnn.param" "$OUT_ROOT/int8/decoder.ncnn.bin"-cp -v "$BUNDLE/sentencepiece.bpe.model" "$BUNDLE/vocab.txt" "$BUNDLE/pos_weights.f32.bin" "$OUT_ROOT/int8/"--echo ""-echo "=== Final size report ==="-echo "fp16 original: $(du -sh "$BUNDLE" | cut -f1) ($(ls -lh "$BUNDLE"/encoder.ncnn.bin "$BUNDLE"/decoder.ncnn.bin | awk '{print $5}' | paste -sd+ -))"-echo "int4 b64:      $(du -sh "$OUT_ROOT/int4" | cut -f1)  encoder=$(du -h "$OUT_ROOT/int4/encoder.ncnn.bin" | cut -f1) decoder=$(du -h "$OUT_ROOT/int4/decoder.ncnn.bin" | cut -f1)"-echo "int4 b128:     $(du -sh "$OUT_ROOT/int4-128" | cut -f1)  encoder=$(du -h "$OUT_ROOT/int4-128/encoder.ncnn.bin" | cut -f1) decoder=$(du -h "$OUT_ROOT/int4-128/decoder.ncnn.bin" | cut -f1)"-echo "int8 b64:      $(du -sh "$OUT_ROOT/int8" | cut -f1)  encoder=$(du -h "$OUT_ROOT/int8/encoder.ncnn.bin" | cut -f1) decoder=$(du -h "$OUT_ROOT/int8/decoder.ncnn.bin" | cut -f1)"-echo ""-echo "Quantized params embed Embed still fp16 (131M * fp16 = 262M per net); only Gemm+MHA quantized."-echo "Compat: ncnn loader auto-dequantizes if built with -DNCNN_WEIGHT_QUANT=ON (AAR: src/main/cpp/CMakeLists.txt)."-echo ""-echo "Next: parity / BLEU validation via scripts/translate/quant_check.py and upload via upload_small100_r2.sh:"-echo "  ./scripts/translate/upload_small100_r2.sh $OUT_ROOT/int4 --prefix small100-int4/"
scripts/translate/upload_small100_r2.sh
diff --git a/scripts/translate/upload_small100_r2.sh b/scripts/translate/upload_small100_r2.shindex 3df14555e4..39be7b3c60 100755--- a/scripts/translate/upload_small100_r2.sh+++ b/scripts/translate/upload_small100_r2.sh@@ -1,76 +1,66 @@ #!/usr/bin/env bash-# Uploads the Small100 ncnn bundle (fp16 or int4 quantized) to R2 bucket `maps`,-# served at https://data.vayunmathur.com/models/small100/ (or subpath).+# Uploads the SMaLL-100 bundle to R2 bucket `maps`, served at+# https://data.vayunmathur.com/models/small100/ (or subpath). #-# Credentials are read from the environment (never hardcoded). Run from trusted shell:+# Two files, ~320 MB: small100.maml (318.3 MiB, int8, graph id 15) and tokenizer.bin (1.7 MB).+# Build both with `python scripts/ml/fetch_small100.py`, which writes them to build/small100/ and+# prints the SHA-256 that Small100Model.kt pins.+#+# This replaced a seven-file ncnn bundle of 1.14 GB. Nothing here converts anything any more: the+# fp16-vs-int4 quantisation notes that used to live in this header described `ncnnllm`, whose int4+# multi-head attention crashed with a tagged-memory fault on the target device, and the conversion+# now happens in scripts/ml/maml_convert.py from the fp32 checkpoint.+#+# Credentials are read from the environment (never hardcoded). Run from a trusted shell: # #   export AWS_ACCESS_KEY_ID=...        # R2 access key id #   export AWS_SECRET_ACCESS_KEY=...    # R2 secret #   export R2_ENDPOINT=https://<account>.r2.cloudflarestorage.com-#   ./scripts/translate/upload_small100_r2.sh <bundle_dir> [--prefix small100/]-#   # int4 quantized:-#   ./scripts/translate/upload_small100_r2.sh scripts/translate/quantized/int4-#-# <bundle_dir> must contain: encoder.ncnn.{param,bin}, decoder.ncnn.{param,bin},-# sentencepiece.bpe.model, vocab.txt, pos_weights.f32.bin-#-# Quantization notes:-# - int4 weight-only block quant (ncnnllm): 680 MB vs 1.14 GB fp16, term 401=bits4 b64 mseclip-# - Embed stays fp16 (131M*fp16=262MB per net); Gemm+MHA quantized (36+13 layers)-# - AAR must be built with -DNCNN_WEIGHT_QUANT=ON (src/main/cpp/CMakeLists.txt + build.gradle.kts)-# - After upload, update Small100Model.kt SHA256 via: shasum -a 256 bundle/* | cut -d' ' -f1+#   ./scripts/translate/upload_small100_r2.sh build/small100 [--prefix small100/] set -euo pipefail- BUNDLE="" PREFIX="small100/"+FILES=(small100.maml tokenizer.bin) while [[ $# -gt 0 ]]; do   case "$1" in     --prefix) PREFIX="$2"; shift 2;;     --prefix=*) PREFIX="${1#--prefix=}"; shift;;     -h|--help)       echo "usage: upload_small100_r2.sh <bundle_dir> [--prefix small100/]"-      echo "  default prefix small100/ (int4 replaces current); use small100-int4/ for side-by-side"+      echo "  default prefix small100/; use another for a side-by-side rollout"       exit 0;;     *) BUNDLE="$1"; shift;;   esac done- if [[ -z "$BUNDLE" ]]; then   echo "usage: upload_small100_r2.sh <bundle_dir> [--prefix small100/]" >&2   exit 1 fi- : "${AWS_ACCESS_KEY_ID:?set AWS_ACCESS_KEY_ID}" : "${AWS_SECRET_ACCESS_KEY:?set AWS_SECRET_ACCESS_KEY}" : "${R2_ENDPOINT:?set R2_ENDPOINT}" export AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION:-auto}"--# Validate-for f in encoder.ncnn.param encoder.ncnn.bin decoder.ncnn.param decoder.ncnn.bin sentencepiece.bpe.model vocab.txt pos_weights.f32.bin; do+# Validate. Exactly these two: an extra file left over from an older bundle would be synced up and+# then downloaded by every client for nothing.+for f in "${FILES[@]}"; do   if [[ ! -f "$BUNDLE/$f" ]]; then-    echo "missing $BUNDLE/$f" >&2+    echo "missing $BUNDLE/$f - run: python scripts/ml/fetch_small100.py" >&2     exit 1   fi done- echo "=== Local bundle $BUNDLE (upload to s3://maps/models/$PREFIX) ===" ls -lh "$BUNDLE"-echo "SHA256:"-for f in encoder.ncnn.param encoder.ncnn.bin decoder.ncnn.param decoder.ncnn.bin; do-  echo "  $f $(shasum -a 256 "$BUNDLE/$f" | cut -d' ' -f1)"-done- # Normalize prefix to end with / [[ "$PREFIX" != */ ]] && PREFIX="$PREFIX/"- aws s3 sync "$BUNDLE" "s3://maps/models/$PREFIX" \   --endpoint-url "$R2_ENDPOINT" --checksum-algorithm CRC32- echo "--- uploaded objects s3://maps/models/$PREFIX ---" aws s3 ls "s3://maps/models/$PREFIX" --endpoint-url "$R2_ENDPOINT"- echo ""-echo "If you replaced small100/ with int4, also update Small100Model.kt FILES SHA256:"-for f in encoder.ncnn.param encoder.ncnn.bin decoder.ncnn.param decoder.ncnn.bin sentencepiece.bpe.model vocab.txt pos_weights.f32.bin; do+echo "Small100Model.kt FILES must pin these:"+for f in "${FILES[@]}"; do   printf '  %s: %s\n' "$f" "$(shasum -a 256 "$BUNDLE/$f" | cut -d' ' -f1)" done+echo ""+echo "The seven ncnn objects this replaced are removed from an installed app by"+echo "Small100Model.deleteRetired; delete them from the bucket by hand once clients have rolled."
settings.gradle.kts
diff --git a/settings.gradle.kts b/settings.gradle.ktsindex 154a04d262..90730c62df 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -17,16 +17,18 @@ pluginManagement { dependencyResolutionManagement {     repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)     repositories {-        // Local maven first so freshly built ncnn-android:1.4.0 (Small100) resolves-        // even when JitPack is rate-limited (429) or hasn't yet built the tag.-        mavenLocal()         google()         mavenCentral()-        // JitPack serves only the two personal forks that live there: Stockfish-Library-        // (games:chess) and ncnn-android. Scoped to com.github.* because JitPack answers-        // unknown coordinates with 401/429 rather than 404, and Gradle treats that as a hard+        // JitPack serves only the personal forks that live there: Stockfish-Library+        // (games:chess) and com.github.luben:zstd-jni. Scoped to com.github.* because JitPack+        // answers unknown coordinates with 401/429 rather than 404, and Gradle treats that as a hard         // failure — an unscoped JitPack breaks resolution of anything Central hasn't yet         // propagated (e.g. a freshly published artifact).+        //+        // `mavenLocal()` used to come first, so that a freshly built ncnn-android resolved even+        // when JitPack was rate-limited. Nothing is built locally now that SMaLL-100 runs on+        // `:library:ml`, and a local repository ahead of the remotes is a supply-chain hazard of+        // its own: any coordinate in `~/.m2` silently wins over the pinned one.         maven("https://jitpack.io") {             content { includeGroupByRegex("com\\.github\\..*") }         }