Murli-V1.6-Code / RULEBOOK_V1_6.md
ViuAI's picture
Fix RTX 3090 OOM & dynamo recompiles: disable default compile, batch_size=32, expandable_segments, keep fused AdamW & foreach EMA
475653d verified
|
Raw History Blame Contribute Delete
7.36 kB

Murli V1.6 — Strict Engineering Rulebook, Target & Work Log

Local Workspace: Murli_V1_6/ (strictly isolated from TTS_10M/, Murli_V1_5/, Murli_V2/)
Hugging Face Repo: ViuAI/Murli-V1.6-Code
Target: Studio-Grade 2026 Single-Speaker Only-Hindi TTS (syspin_male_01 (49.28h @ 53.1 dB SNR, 22 shards)), Zero Robotic Tone, Natural Prosody, Android ONNX Opset-17 Ready (max_steps = 350,000, max_epochs = 600).


1. Non-Negotiable Strict Rules (Learned from V1.0 & V1.5)

  1. Strict Speaker & Language Hygiene: Default V1.6 pretraining targets Single-Speaker Only-Hindi (0 = syspin_male_01, hindi_50h, 49.28h @ 53.1 dB SNR, language="hi"), while preserving explicit integer speaker_id conditioning in ProsodyAndAlignmentModule and HybridDiTCFMVectorField (AdaLN-Zero) for optional multi-speaker runs (--all_speakers / --target_speakers). Untrained speaker IDs must be rejected at inference if absent from checkpoint["speaker_to_id"].
  2. No Flat Token-Constant F0 Staircase (V1.5 Bug #1): After duration expansion ([B, T_mel, D]), refine prosody with a Conv1D Frame-Level Prosody Predictor / Smoother supervised against smoothed frame log_f0 and energy targets so long vowels bend naturally instead of staying flat.
  3. 2026 Hybrid DiT + ConvNeXt-V2 CFM Backbone (V1.5 Bug #2): Replace V1.5's purely local ConvNeXt CFM (~0.75s receptive field) with a Hybrid ConvNeXt-V2 + RoPE Self-Attention DiT Vector Field (AdaLN-Zero) so the model shapes full-sentence storytelling intonation arcs while staying compact (~32–36M params) and 100% opset-17 Android ONNX exportable.
  4. Fixed Hindi Schwa Deletion Rules (V1.5 Bug #3): Fix 3-syllable CVCV+long-vowel medial schwa retention (मुरली → mʊɾliː, लकड़ी → ləkɽiː) BEFORE V1.6 pretraining starts, and cover them in automated unit tests.
  5. Natural Inference & Clause Transitions (V1.5 Bug #4):
    • Default ODE inference: steps=48, cfg_scale=1.3, temperature=0.90, speed=0.92, min_frames=2 (and Android configurable steps=16–32).
    • Keep per-sentence splitting in narrate.py with subtle -68 dB room-floor pauses (120ms inter-sentence, 260ms inter-paragraph) — never splice 0x0000 dead silence and never merge multi-sentence paragraphs past punctuation (! / ।).
  6. Zero-Guess Dataset & Cache Hygiene:
    • Verify exact speaker counts/hours across ALL shards (HfFileSystem) before launching GPU runs.
    • Maintain transcript-disjoint train/validation split, AudioConfig + tokenizer versioned disk cache keys, deterministic pool-based duration bucketing, and numba FP32 MAS.
  7. Checkpoint & Recovery Discipline:
    • Count step by completed optimizer updates only; save model + optimizer + scaler + step + epoch + offset + best_val_cfm + RNG atomically.
    • Auto-backup checkpoints (murli_v16_step_XXXXXX.pt + murli_v16_best.pt) and test WAVs (samples/sample_step_XXXXXX_spk*.wav) every --hf_backup_every / --sample_every steps to Hugging Face.
  8. Test Before Push Rule: Run full local CPU unit, training-continuity, schwa-G2P, and ONNX Runtime parity tests (python -m unittest discover -s tests -p "test_*.py" -v) after every change before pushing to ViuAI/Murli-V1.6-Code.

2. Architecture & Task Plan

  • Task 1 — Workspace & Rulebook: Create isolated Murli_V1_6/ folder and strict RULEBOOK_V1_6.md.
  • Task 2 — Config & Fixed Hindi G2P: Write config.py (Speaker map 0..2, Hybrid DiT+ConvNeXt dims, Natural Smooth defaults) and fix 3-syllable medial schwa deletion in data/text_cleaner.py (मुरली → mʊɾliː, लकड़ी → ləkɽiː, लड़का → ləɽkaː).
  • Task 3 — 2026 Hybrid DiT + Frame-Prosody Acoustic Model (37.75M Params):
    • models/prosody_aligner.py: SpeakerEmbedding + FrameProsodyRefiner supervised on frame f0_target & energy_target.
    • models/flow_matching.py: HybridDiTCFMVectorField (12 ConvNeXt-V2 blocks + 4 RoPE AdaLNZeroDiTBlock layers conditioned on t + speaker_emb).
    • models/tts_engine.py: Wired speaker_ids & frame_prosody_loss end-to-end.
  • Task 4 — Multi-Speaker (108.8+h) Dataset, Trainer & ONNX Exporter:
    • data/dataset.py, train.py, narrate.py, export_onnx.py built with deterministic duration bucketing, multi-speaker sample generation, HF checkpoint backup, and opset-17 ONNX verification.
  • Task 5 — Full Verification & HF Repo Push: Passed 3/3 unit, schwa-IPA, 3-speaker resume continuity, and ONNX parity tests (52.324s); pushed to ViuAI/Murli-V1.6-Code.

3. Work Log (Chronological)

  • 2026-12-01 (Init): Initialized isolated Murli_V1_6/ workspace and authored RULEBOOK_V1_6.md.
  • 2026-12-01 (G2P & Model): Fixed medial schwa rule in data/text_cleaner.py, built FrameProsodyRefiner + HybridDiTCFMVectorField (37.75M acoustic params with 4 RoPE AdaLNZeroDiTBlock attention layers).
  • 2026-12-01 (Data & Exporter): Added 3-speaker mapping (0=syspin_male_01, 1=kalita_rasa_male_01, 2=iisc_f_hindi_female_spk001), duration bucketing, multi-speaker test WAV uploader, and opset-17 Android ONNX exporter (frontend=51.99 MiB, cfm_step=82.11 MiB).
  • 2026-12-01 (Verify & Release): python -m unittest discover -s tests -p "test_*.py" -v → Ran 3 tests in 52.324s — OK. Ready for 108.8+h training on ViuAI/Murli-V1.6-Code.
  • 2026-12-01 (Speed Tuning): Removed full-tensor FP32 allocation in ConvNeXt1DBlock GRN (layers.py) and added prefetch_factor=4 + float32_matmul_precision("high") in train.py.
  • 2026-12-01 (13:19 Audit & Verification): Verified user hardening edits (ज्ञान→gjaːn̪, मतलब→mət̪ləb, प्रगति→pɾəgət̪ɪ, English "3.5 percent", 150 Hz F0 non-zero separation, corrupt audio skip + --strict_dataset, batched B>1 padded synthesis, cfm_step.onnx reduced to 69.71 MiB). test_v16.py → Ran 3 tests in 49.749s — OK. Pushed to ViuAI/Murli-V1.6-Code.
  • 2026-12-01 (Host RAM Fix): Added use_threads=False + pa.default_memory_pool().release_unused() in dataset.py and lowered prefetch_factor=2 in train.py to eliminate 100% host RAM thrashing across DataLoader workers.
  • 2026-12-01 (1.0x Sequential Cache Warmup): Diagnosed random 72-shard Parquet row-group read amplification (13% GPU / 100% Host RAM in Vast.ai dashboard). Added warm_cache_by_shard() (dataset.py, wired in train.py) so each Parquet shard is read sequentially once before GPU training starts.
  • 2026-12-01 (Spawn Warmup Hang Fix): Fixed Linux fork() + PyTorch/OpenMP mutex deadlock & RAM spike inside warm_cache_by_shard by switching to mp.get_context("spawn") (max_workers=2, torch.set_num_threads(1)) with per-shard live as_completed logging.
  • 2026-12-01 (RTX 3090 Fast & OOM-Safe Config): Kept fused=True AdamW on CUDA, vectorized _foreach_* EMA updates, and PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True, while disabling default torch.compile (avoids 8x dynamic-shape recompiles) and using batch_size=32, lr=2.5e-4, warmup_steps=2000, max_steps=300,000, max_epochs=600 for zero-OOM ~72+ cl/s throughput on 24GB RTX 3090.