Two artifacts are included: base INT4 and trained_v1 (the deterministic J recipe).
These audio-only models keep the existing CLAP architecture and ORT block-128
integer INT4 recipe (MatMulNBits, accuracy level 4).
| Artifact | Method | Teacher top-10 overlap | Near-distance MAE |
|---|---|---|---|
audio_model_int4.onnx |
Original quantization | 81.24% | 0.011450 |
audio_model_int4_trained_v1.onnx |
Deterministic J: relative pair-distance loss + 0.3 output cosine | 92.76% | 0.004062 |
Measured against FP32 teacher embeddings on 1,966 drums + 2,048 NSynth samples. New J improves near/mid/far distance accuracy over A; their neighbor-overlap scores are nearly tied. Trained v1 scores 92.755% / 0.004062. Two independent four-epoch runs produced identical ONNX bytes, checkpoint tensors, optimizer states, and evaluation results. Pure pairwise exponents 0–2 and neighborhood KL reached 92.16–92.34% overlap; anchoring helped more than stronger near weighting. Lower learning rates did not improve the best overlap. One seed and reused validation: these are teacher-fidelity results, not perceptual-quality claims.
Input: float32 input_features [1,1,1001,64], mono audio resampled to 48 kHz,
first 10 seconds, pinned ClapProcessor with padding="repeatpad".
Output: normalized float32 embedding [1,512]. Use an ONNX Runtime build
supporting com.microsoft::MatMulNBits.
Reference environment: Python 3.13, CUDA 12.8 PyTorch, RTX 3080 Ti. Install
pip install -r requirements.txt in a fresh environment.
python quantize.py
python training.py
quantize.py downloads/caches the pinned FP32 graph from
bdrgon/clap-htsat-unfused-audio-embedder-onnx
and creates the original INT4 artifact, checking its SHA-256.
training.py downloads the pinned drums
and NSynth Parquet datasets through
the HF cache, creates FP32 teacher targets, then trains from the original pinned
LAION weights. It runs the initial epoch (LR 1e-5), resets Adam, and runs three
more epochs (cosine 3e-6 to 3e-7), batch 32. Each epoch uses 15,746 drums plus
20,000 rotating NSynth notes. The script regenerates sample selections and neighbor-aware batch orders in
RAM using streams derived from one RANDOM_SEED (20261018), with a final-output hash check for reproducibility. Named stream offsets preserve the original v1
sampling, holdout, initialization, and per-epoch seeds. Changing the root seed
changes the experiment and will no longer match the pinned v1 output hash.
No dataset audio or teacher vectors are distributed here. Three empty drum rows
were excluded; exact training/validation waveform overlap is excluded.
J minimizes weighted squared pair-distance error plus 0.3 pointwise cosine loss.
Weights are min(100, (0.684377 / max(dt, 0.0199575))**2), normalized by their sum;
dt is teacher cosine distance. Quantization is simulated during training.
Checkpoints and caches stay under --work-dir; completed epochs resume on rerun.
Use --dataset-cache PATH, --model-cache PATH, or --offline as needed. The
final export undergoes FP32 parity, full 4,014-row verification,
and exact SHA-256 comparison to the deterministic J reference. Strict PyTorch
algorithms, fixed seeds, disabled TF32, and CUBLAS_WORKSPACE_CONFIG=:4096:8
enforce determinism. Bicubic resize uses the original CUDA forward and a CPU
backward because its CUDA backward is nondeterministic; the exported architecture
is unchanged. Byte equality was verified on the reference hardware/software;
other platforms or versions may differ and will fail the J hash check.
training.py is self-contained: it fetches the pinned models and both datasets,
creates and verifies the original INT4 baseline, builds teacher caches, trains,
and evaluates the new export. It does not import quantize.py or read experiment
folders. It streams the pinned Parquet audio once when selections are needed,
hashes decoded waveforms, applies the original split/rotation rules, and retains
only the resulting metadata in memory. Neighbor-aware orders are computed from
teacher embeddings on the GPU. No recipe, sample-index, or batch-order files are
written. Existing feature/teacher caches skip the corpus-indexing pass; they are reused
without comparing their contents against hardcoded hashes.
Dataset downloads still use the HF cache; feature/teacher caches, checkpoints,
and exports remain on disk for resumability. These outputs default to ~/.cache/clap-int4/trained-v1.
Use --work-dir PATH to choose another location. Historical A remains a comparison
only (92.80% overlap, near-distance MAE 0.004089).
Budget roughly 6 GiB training VRAM, 25–35 GiB RAM, and ample disk for the full NSynth download and feature caches. With verified caches, each J run took 33–35 minutes, including approximately 23 minutes of training. A fresh end-to-end run, rebuilding all teacher caches from the local HF dataset cache, took about 2 hours 43 minutes on the HDD and reproduced the same ONNX bytes and all four model/optimizer checkpoints exactly. HDD reads occur during staging; epoch batches come from RAM.
Only the expected final trained-model hash is pinned in training.py.
Each run writes its provenance, checkpoints, and verification report to --work-dir.
audio_model_int4.onnx 20 MiBaudio_model_int4_trained_v1.onnx 20 MiBlaion/clap-htsat-unfused