Skip to content
ExplanationDraftUnreviewed

CPU data prefetching starvation in compiled Vocalsynth training

Recorded 2026-11-25. Moving Run 7.2 from L40S to RTX 5090 with torch.compile, FlexAttention, and 2D fixed-grid sequence packing failed to raise median throughput (27.36–30.65 TFLOP/s, ~14.6% MFU), while brief bursts hit 71–73 TFLOP/s (~35% MFU) immediately after 1,000-step pauses. Cross-checking Dashboard time-series data against the prefetcher implementation indicates that CPU data loading and collation are starving the GPU for over half of wall-clock training time, alongside a lower realistic GPU ceiling (~72 TFLOP/s) than earlier roofline estimates assumed.

Observed anomaly across runs

In Run #7.2.5 (SkyPilot, NVIDIA GeForce RTX 5090, compile = true, max_batch_frames = 52,000, 20,000 updates over 6.18 h), Dashboard metrics (attempt_id = 84) show a sharp bimodal split rather than uniform GPU execution:

  • Overall steady state sits at 27.4–30.7 TFLOP/s: Across 2,000 sampled points of train/flops_per_second, median throughput is 30.65 TFLOP/s (19.91 TFLOP/s at p10, 32.45 TFLOP/s at p90). Across the 500-point summary query, median throughput is 27.36 TFLOP/s (0.83–0.88 s/step typical, dropping to 1.3–1.4 s/step at p10).
  • All 14 high-throughput spikes align with 1,000-step pauses: Every single log window exceeding 60 TFLOP/s (61.4–73.0 TFLOP/s, ~0.37 s/step) appeared at step 10, 2010, 3010, 4010, 6010, 8010, 10010, 11010, 13010, 14010, 15010, 16010, 18010, 19010. Each of those steps immediately followed a ~90 s render_interval = 1000 and checkpoint_interval = 1000 pause (wall_dt = 96.21 s around step 3010).

Cross-checking three neighboring runs in the Dashboard database reinforces the same pattern:

  • Run #7.2.3 (Modal A100-40GB, max_batch_frames = 52,000): Median throughput dropped to 18.20 TFLOP/s (p10 = 14.09 TFLOP/s), while unstarved peak reached 71.24 TFLOP/s (~3.9x gap).
  • Run #7.2.4 (Modal A100-40GB, max_batch_frames = 80,000): Raising max_batch_frames from 52,000 to 80,000 reduced the number of batches the CPU needed to prepare per second and lifted median throughput from 18.20 to 42.22 TFLOP/s, while unstarved peak stayed at 73.73 TFLOP/s.
  • Run #8.2.2 (Modal L40S, 244 Chia slices, max_batch_frames = 16,000): With only 244 short slices (~21.5 min total audio), throughput stayed flat at 78.92 TFLOP/s median (p10 = 78.58 TFLOP/s, max = 79.46 TFLOP/s) with no starvation drops.

Suspected CPU data-pipeline mechanism

Inspecting BatchPrefetcher and collate_packed explains why the GPU runs at ~72 TFLOP/s after a pause and then collapses back to ~30 TFLOP/s:

  1. Queue prefill during pauses masks the CPU bottleneck for a few steps: During the ~90 s render + checkpoint stop at every 1,000 steps, the GPU stops consuming batches while the background thread refills queue.Queue(maxsize=6). Once training resumes, the GPU consumes those prebuilt batches at its unstarved speed (~0.37 s/step, ~71–73 TFLOP/s). After the 6-slot buffer drains, the main training loop blocks in prefetcher.next() waiting for CPU preparation.
  2. Hardcoded 2 GiB LRU cache thrashes on M4Singer audio_features: _ItemLRUCache caps deserialized rows in memory at _PREFETCH_CACHE_MAX_BYTES = 2 * 1024**3 (2 GiB). M4Singer’s 24.93 h training split carries 1024-dimensional audio_features on every frame alongside mel, f0, and alignments, so the deserialized working set exceeds 2 GiB. Every miss triggers cross-process HDF5 reads via pool.map(_fetch_cache_item, missing) (whereas Chia’s 244 slices in Run #8.2.2 fit completely inside 2 GiB after epoch 1, eliminating cache misses).
  3. Single-threaded synchronous collation and pinning: Although BatchPrefetcher spawns up to 4 worker processes (min(4, max(1, os.cpu_count() or 1))) to fetch raw rows, a single background thread (self.thread) runs _collate_groups serially. For each 52,000-frame microbatch, collate_packed allocates output tensors, normalizes Mel frames, computes F0 and timing features, copies 1024-d audio_features, and pins 15 tensors (pin_memory()). That serial CPU loop cannot sustain one 52,000-frame batch every 0.37 s.

Realistic unstarved GPU ceiling

Even when the prefetch queue is full, both RTX 5090 (73.04 TFLOP/s, ~34.9% MFU) and A100-40GB (71.24–73.73 TFLOP/s, ~23% MFU) plateau near ~72 TFLOP/s on Run #7.2 rather than reaching 110–160 TFLOP/s:

  • Nominal vs. sustained bandwidth: RTX 5090’s 1,792 GB/s GDDR7 specification represents peak theoretical bandwidth, whereas real compiled kernels typically sustain 70%–80%.
  • Narrow sub-modules and dual-path graph: Alongside the width = 512 DiT, dual-path updates in steps.py run both label and audio forward and backward passes plus audio_ref, PhoneEncoder (width = 256), ConditionedResidualAdapter (512 to 64), gradient clipping, and AdamW.
  • Windowed FlexAttention and block-mask construction: Windowed 256-frame attention (head_width = 64) and per-forward create_attention_block_mask calls lower effective step-level arithmetic intensity relative to isolated FFN projections.

Eliminating CPU starvation is therefore expected to raise RTX 5090 median throughput from ~30 TFLOP/s to roughly 65–73 TFLOP/s (cutting a 20,000-step 7.2 run from ~6.2 h to roughly 2.3–2.6 h), while pushing MFU past ~35% requires scaling model width (width >= 1024) rather than further micro-tuning at width = 512.

Hypotheses and validation plan

Before rewriting the data pipeline, run a short diagnostic benchmark (20–50 steps on RTX 5090 or A100 using the 7.2 config) to measure each stage directly:

  1. Instrument wait vs. compute time: Log prefetcher.next() blocking duration, _prefetch_missing HDF5 read time, collate_packed CPU time, and pin_memory() time per update so the ~0.5–1.0 s/step stall is decomposed into measured fractions rather than inferred from render spikes.
  2. Test scaled or RAM-resident item caching: Make _PREFETCH_CACHE_MAX_BYTES configurable (or size it from host RAM) and verify on >= 32 GB RAM instances whether eliminating 2 GiB LRU evictions removes the 19–20 TFLOP/s (p10) stalls.
  3. Test multi-process collation: Move collate_packed into worker processes (or use shared-memory tensor buffers / a multi-worker PyTorch DataLoader with pin_memory on the main prefetch thread) and check whether BatchPrefetcher keeps the queue full without blocking RTX 5090 at ~0.37 s/step.
  4. Verify steady-state throughput and CPU provisioning: Measure median train/flops_per_second across 200 consecutive steps without render pauses (validation_interval = 0 during the micro-benchmark) and record minimum required vCPU cores and host RAM for Cloud GPU selection.

Type to search…

↑↓ navigate↵ selectEsc close