aboutsummaryrefslogtreecommitdiffstats
path: root/MACOS_ARM64.md
diff options
context:
space:
mode:
authorKai Li (李凯) <tsinghua.kaili@gmail.com>2026-08-14 15:15:16 +0800
committerGitHub <noreply@github.com>2026-08-14 15:15:16 +0800
commitb17bf536b11fa527cddce5dd6694c4b04a44d3f6 (patch)
tree3e17a3facbbb1d9a53bf8e0d2837238745d049ce /MACOS_ARM64.md
parent4f3ff075428b261f43e94b92b081553ee87791ec (diff)
parent802f429831f257c7e6295594c39ccfc864cd490f (diff)
downloadapollo-gfx803-b17bf536b11fa527cddce5dd6694c4b04a44d3f6.tar.gz
Merge pull request #41 from Djshinshin/codex/chunked-inference
Thanks for implementing configurable chunk batching in response to the review feedback. I reviewed the latest changes, and this now addresses the requested behavior. The validation, bounded-memory design, overlap-add handling, and documentation look good. Keeping `--chunk-batch-size=1` as the default is reasonable given the backend-specific memory and throughput tradeoff. The 20/20 test suite passes, and the MPS validation results are clearly documented. I have no further changes requested and approve this PR. Please mark the PR as ready for review. Once it is out of draft, I will merge it.
Diffstat (limited to 'MACOS_ARM64.md')
-rw-r--r--MACOS_ARM64.md68
1 files changed, 66 insertions, 2 deletions
diff --git a/MACOS_ARM64.md b/MACOS_ARM64.md
index 6802116..dc33865 100644
--- a/MACOS_ARM64.md
+++ b/MACOS_ARM64.md
@@ -26,6 +26,28 @@ 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 \
+ --chunk-batch-size=2
+```
+
+`--chunk-batch-size` controls how many chunks are transferred and processed in
+one model forward pass. The default of `1` minimizes accelerator memory; larger
+values keep memory bounded by a fixed batch but may trade additional memory for
+throughput. 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 +79,43 @@ 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.
+
+The same public 12-second input was also used to compare chunk batch sizes on
+MPS. In this Apple M3 run, batching did not improve MPS performance and should
+therefore remain an explicit memory/throughput choice rather than a universal
+speed claim:
+
+| Chunk batch size | End-to-end time | Peak memory footprint |
+| ---: | ---: | ---: |
+| 1 | 11.76 s | 4.65 GiB |
+| 2 | 12.28 s | 10.48 GiB |
+
+Both outputs were float32 PCM, stereo, 44.1 kHz, exactly 12 seconds long, and
+finite. Batch sizes 1 and 2 differed by at most `1.04308128356934e-06`, with
+RMSE `3.84001256540259e-08` and correlation `0.999999999999966`. CUDA may have
+different throughput characteristics, but it was not available for local
+hardware validation.
+
## Device behavior
- `auto` preserves CUDA as the first choice, then selects MPS, then CPU.
@@ -80,7 +139,12 @@ 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.
+- Larger chunk batches can reduce the number of model forward passes but use
+ more accelerator memory. They are not guaranteed to improve every backend;
+ the tested MPS configuration was slower with batch size 2.
- 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.