From 0a91c5fe084bb4643410c52f72a12001871f8ec6 Mon Sep 17 00:00:00 2001 From: Djshinshin <129614060+Djshinshin@users.noreply.github.com> Date: Fri, 14 Aug 2026 14:46:38 +0800 Subject: Add chunked inference for long audio --- MACOS_ARM64.md | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'MACOS_ARM64.md') diff --git a/MACOS_ARM64.md b/MACOS_ARM64.md index 6802116..bc6c417 100644 --- a/MACOS_ARM64.md +++ b/MACOS_ARM64.md @@ -26,6 +26,25 @@ python inference.py \ --out_wav=apollo_mps_smoke.wav ``` +Full-file inference is the default. To bound accelerator memory for longer +audio, opt in to chunking and an overlap crossfade: + +```bash +python inference.py \ + --device=mps \ + --checkpoint=models/pytorch_model.bin \ + --in_wav=long_input.wav \ + --out_wav=long_output.wav \ + --chunk-seconds=6 \ + --overlap-seconds=1 +``` + +Only one chunk is transferred to the selected accelerator at a time. The last +chunk is padded for inference and cropped back to its original size; normalized +linear crossfades preserve the exact input frame count. The overlap may be zero +but must not exceed half the chunk duration. Inputs no longer than the requested +chunk use the original full-file path. + If `--checkpoint` is omitted, inference downloads the official `JusperLee/Apollo` `pytorch_model.bin` from Hugging Face. Custom checkpoints must be existing local files; arbitrary remote repositories are rejected @@ -57,6 +76,27 @@ correlation of `0.999999991468`. The input SHA-256 remained unchanged: 3c9a053913c3016b493ddc0b92e21a4e682e8fb5f872dafc945154155bddf771 ``` +## Chunked validation reference + +A separate MPS check concatenated the same public fixture twice to create a +12-second input, then compared full-file inference with 6-second chunks and a +1-second overlap. The derived test input SHA-256 was +`3e4a91f95975054bc092637176bb60bcb4bbd1469b8f8e92c14eb6e4ad0431c2`; +the repository fixture itself was not modified. + +| Mode | End-to-end time | Peak memory footprint | +| --- | ---: | ---: | +| Full file | 10.22 s | 10.36 GiB | +| 6 s chunks, 1 s overlap | 12.59 s | 5.39 GiB | + +The chunked run reduced the measured peak memory footprint by 48.0%. Both +outputs were float32 PCM, stereo, 44.1 kHz, exactly 12 seconds long, and finite. +Compared with full-file output, the chunked output had maximum absolute +difference `0.7703997492790222`, RMSE `0.027596083317049432`, and correlation +`0.9835697382563144`. At the two tested chunk starts, output sample differences +from the full-file result were at most `3.3527612686157227e-08`. These objective +checks do not establish that the two versions are perceptually equivalent. + ## Device behavior - `auto` preserves CUDA as the first choice, then selects MPS, then CPU. @@ -80,7 +120,9 @@ correlation of `0.999999991468`. The input SHA-256 remained unchanged: machine. - Training and dataset evaluation still contain CUDA-specific configuration; this change only makes the public inference entry point device-agnostic. -- There is no long-audio chunking or crossfade in this change. Long inputs may - require substantially more memory. +- Chunking reduces accelerator memory demand but also limits model context and + can produce a different result from full-file inference. Crossfades reduce + boundary discontinuities but do not replace listening tests for seam or + musical-consistency artifacts. - A successful technical smoke test is not a listening-quality review and does not prove that information missing from a lossy source was truly recovered. -- cgit v1.2.3