Skip to content

feat(train): Super-MAS Triton-GPU MAS accelerator (opt-in、 推論影響ゼロ) - #582

Merged
ayutaz merged 3 commits into
devfrom
feat/super-mas-triton-gpu
Jun 27, 2026
Merged

feat(train): Super-MAS Triton-GPU MAS accelerator (opt-in、 推論影響ゼロ)#582
ayutaz merged 3 commits into
devfrom
feat/super-mas-triton-gpu

Conversation

@ayutaz

@ayutaz ayutaz commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

学習時の Monotonic Alignment Search (MAS) を Cython から Triton-GPU カーネル (Super-MAS, arXiv:2409.07704, Park et al., 2024) に opt-in で dispatch できるようにしました。 公式 docker stack (Python 3.13 + torch 2.11.0+cu128 + Triton 3.6.0) 上の RTX 4070 Ti SUPER 実測で MAS 単独 38-187x 高速化。 ただし MAS は 1 step 全体の 0.42 % しか占有しない ことが実測で判明したため、 end-to-end の学習短縮効果は 約 0.37 % とマージナル。 推論経路と ONNX グラフへの影響はゼロ、 既存 Cython は CPU / package 未導入 / 環境変数で disable 時のフォールバックとして温存。

Affected Components

  • Python (src/python/, pyproject.toml)
  • Rust (src/rust/)
  • C# (src/csharp/)
  • C++ (src/cpp/, CMakeLists.txt)
  • Go (src/go/)
  • WASM/npm (src/wasm/)
  • Docker (docker/)
  • CI/CD (.github/workflows/)
  • Documentation (docs/, README*)

Type

  • Bug fix
  • New feature
  • Refactoring
  • Documentation
  • CI/CD
  • Dependencies

Risk Level

  • patch — bug fix / internal refactor / docs only
  • minor — new feature / additive API / no breaking change
  • major — breaking change (API removal, schema migration, behavior reversal)

Contract Impact

  • None (Python/runtime-internal change only)

推論経路への影響なし、 ONNX グラフ・cross-runtime contract に変更なし。 学習時 SynthesizerTrn.forward 内 1 箇所 (models.py:964) のみで dispatch される。

変更内容

機能名 動作 これがないと起こること
Super-MAS dispatcher super_monotonic_align.maximum_path が利用可能 + CUDA tensor + torch.cuda.is_available() のすべて満たすときのみ Triton kernel に分岐、 それ以外は既存 Cython パスへフォールバック 学習時 MAS が常に CPU Cython 実装で動作し、 GPU 学習で大規模バッチ時のボトルネックが解消されない
upstream の入力破壊への防御 _maximum_path_super_mas 内で value.clone() してから kernel へ渡す。 入力 neg_cent は不変 upstream は value を in-place 変更するため、 caller の neg_cent が壊れて学習 loop が破綻
dtype / device 透過 float32 化して kernel に渡し、 戻り値を caller の dtype に cast。 device は caller の tensor に従う Cython パスとの契約 (shape / dtype / device 保持) が崩れ、 既存 callsite と非互換
env による強制 disable PIPER_DISABLE_SUPER_MAS=1/true/yes/TRUE/Yes で import 時に _super_mas_fn = None を強制。 再現性デバッグ / bit-identical 比較に利用 A/B 比較やデバッグ時に Cython へ強制復帰できず原因切り分けができない
optional extra (commit SHA pin) pyproject.tomlsuper-mas = ["super-monotonic-align @ git+...@<sha>"] を追加。 unpinned HEAD ではなく 特定 commit SHA で pin (再現性 + supply-chain hygiene)。 train extra には含めず完全 opt-in デフォルト install で git fetch が走り、 CI / Windows native などネットワーク制約環境で install 失敗。 unpinned だと再現性が崩れ過去 ckpt の bit-identical 再学習不能
dispatcher テスト _use_super_mas predicate / _maximum_path_super_mas wrapper / 公開 maximum_path() の if 分岐統合点 / env import-time 動作 (subprocess) を網羅。 subprocess test は os.environ.copy() で親 env 継承 + PYTHONPATH 明示 prepend dispatcher の wiring 漏れや env が効かない regression を CI が検出できない。 hand-built env では Windows SystemRoot override や piper_train import 失敗のリスク

設計判断

  • 3 段安全網で opt-in を確実に: (1) package 未導入 → Cython、 (2) CPU tensor → Cython (Windows native や CPU-only CI で安全)、 (3) PIPER_DISABLE_SUPER_MAS=1 → 強制 Cython。 デフォルト挙動は完全に Cython 不変
  • PyPI 非配布のため train extra には含めず分離: upstream は GitHub のみで配布。 git+https を train に混ぜると pip install piper-train[train] 時にネットワーク fetch が必須となり、 CI / offline 環境で fail する。 [super-mas] を独立 extra にすることで「明示的に opt-in した時のみ git+ install」となる
  • commit SHA で pin (HEAD 直追従を回避): upstream HEAD は将来移動するため、 unpinned 参照だと過去の学習 run の再現性が壊れる。 SHA pin により kernel revision を学習成果と紐付け、 bump は手動 re-validation 後にのみ行う運用に
  • bit-identical を主張しない: upstream README は "algorithmic equivalence" のみ表明 (bit-identical は明示保証なし、 加えて max_neg_val edge case を修正済)。 docstring / CLAUDE.md でも「algorithmic equivalence」と明記して過剰な主張を避ける
  • _use_super_mas を independent predicate に切り出し: maximum_path() 内に直接書かず関数化することで、 テスト時に predicate のみを mock 可能。 GPU 不在環境でも dispatcher 分岐の wiring を検証できる
  • value.detach().to(float32).contiguous().clone(): upstream は value を in-place 変更するため clone 必須。 detach は autograd graph から切る (MAS は学習時 torch.no_grad() 配下で呼ばれるが明示する)、 contiguous は Triton kernel が strided memory を扱えない可能性に備える
  • subprocess test は os.environ.copy() ベース: hand-built env では (a) Windows SystemRoot を case-insensitive で上書きする可能性、 (b) editable-install されていない piper_train を subprocess から見つけられない、 の 2 リスクがあった。 親 env 継承 + PYTHONPATH 明示 prepend で両方解消

ベンチマーク

計測環境: RTX 4070 Ti SUPER (16GB Ada Lovelace) + WSL2 Ubuntu + Python 3.13.14 + torch 2.11.0+cu128 + Triton 3.6.0 (piper-plus 公式 docker stack と一致)

MAS 単独 (synthetic, B=20, T=64-400, S=4T)

triton.testing.do_bench(rep=50, warmup=5)、 MAS のみの wall-time 比較。

Shape (B, T, S) Triton (ms) Cython (ms) Speedup
(20, 64, 256) 0.20 7.41 37.7x
(20, 128, 512) 1.00 66.61 66.5x
(20, 192, 768) 6.29 87.42 13.9x (※ outlier)
(20, 256, 1024) 1.32 246.98 186.8x
(20, 400, 1600) 3.66 417.88 114.1x
  • 頻出する T=64-128 範囲で 38-67x、 大行列 T=256-400 で 114-187x
  • T=192 は単発測定の outlier (Triton autotune cache warm-up タイミング依存)

End-to-end (実 SynthesizerTrn 1 step, B=8, T=128, T_y=512)

forward + backward + optimizer.step 1 step を Triton ON / Cython OFF で各 30 回計測 (warmup 15)。 MAS 呼び出しを patch して MAS 部分のみの wall-time も同時計測。

項目 Triton ON Cython OFF
MAS median 1.69 ms 15.90 ms
MAS 占有率 (step 内) 0.027 % 0.42 %

実測値から計算した end-to-end 短縮: 0.42 % × (1 − 1/9.4) ≈ 0.37 %

= 1 epoch 8h53m に対して 約 2 分短縮 にとどまる。 これは Glow-TTS 論文の「MAS は学習全体の 2% 未満」推定とも整合的 (実測ではむしろ更に低い 0.42%)。

つまり: MAS 単独では大幅高速化するが、 学習 step 全体に占める MAS の割合が小さいため、 1 epoch wall-clock の短縮は実用上マージナル。 大バッチ + 長文 dataset (T=400+) で MAS 占有率がわずかに上がる可能性はあるが、 桁が変わるほどではない。 本 PR の意義は wall-clock 短縮よりも (a) CPU↔GPU 転送オーバーヘッド除去、 (b) 大バッチ時の MAS スパイク解消、 (c) GPU bound にできる範囲を広げる、 にある。

Test Plan

  • cd src/python && uv run --no-sync pytest tests/test_monotonic_align.py tests/test_super_mas_dispatch.py --no-cov -v で 29 件 (既存 8 + 新規 21) すべて pass
  • uv run --no-sync ruff check src/python/piper_train/vits/monotonic_align/__init__.py src/python/tests/test_super_mas_dispatch.py で lint clean
  • uv run --no-sync ruff format --check src/python/piper_train/vits/monotonic_align/__init__.py src/python/tests/test_super_mas_dispatch.py で format clean
  • 環境変数なしで python -c "from piper_train.vits import monotonic_align; print(monotonic_align._SUPER_MAS_DISABLED)"False を返す
  • PIPER_DISABLE_SUPER_MAS=1 環境で同コマンドが True を返し、 _super_mas_fn is None になる
  • (GPU 環境で実施推奨) pip install "piper-train[super-mas]" 後に短い学習 step を回し、 既存 Cython 結果と SECS / loss が乖離しないことを確認 (本 PR の merge 後の follow-up でも可)

Checklist

  • Tests pass locally
  • No GPL/LGPL dependencies added (License Policy)
  • Documentation updated (if applicable)

Related Issues

なし (docs/research/architecture-replacement-survey-2026-06-27.md §4.1.1 で adopt 推奨されていた候補の 1 件目)

ayutaz added 2 commits June 27, 2026 15:51
arXiv:2409.07706 (Park et al., 2024) の Triton kernel に dispatch することで
学習時 MAS を 19-72x 高速化。 既存 Cython は CPU / package 未導入 /
PIPER_DISABLE_SUPER_MAS=1 時のフォールバックとして温存し、 学習・推論の
互換性を破壊しない。 SynthesizerTrn.forward の唯一の MAS 呼び出し点
(models.py:964) を通じて自動 dispatch される。

- monotonic_align/__init__.py: _use_super_mas() で CUDA tensor +
  package available + cuda.is_available() を判定、 該当時のみ
  _maximum_path_super_mas() に分岐 (upstream は input を破壊変更するため
  clone + float32 + int32 mask cast)
- pyproject.toml: super-mas optional extra (git+https のみ、 PyPI 非配布)
- test_super_mas_dispatch.py: dispatcher 選択 4 件 + Cython fallback 2 件 +
  Super-MAS wrapper contract 3 件 (clone / dtype / int32 mask、 全て mock で
  GPU/Triton 非依存)
- CLAUDE.md: 学習補助セクションに opt-in install + env disable を追記

テスト: 既存 8 件 + 新規 8 件 = 16/16 pass (CPU 環境、 GPU テストは skip)
前 commit (5014254) でカバー漏れた 2 領域を補完:

- TestPublicMaximumPathDispatch (2 件): 公開 API maximum_path() 内の
  `if _use_super_mas(): return _maximum_path_super_mas(...)` 分岐自体を
  predicate mock で True/False 両側で検証。 個別ヘルパーは既存テストで
  カバー済だが、 dispatcher の wiring (どちらの関数が実際に呼ばれるか)
  は別契約のため独立テスト化
- TestEnvDisableImportTime (11 件): PIPER_DISABLE_SUPER_MAS の import-time
  動作を subprocess で検証。 truthy (1/true/yes/TRUE/Yes) 5 件 + non-truthy
  (0/false/no/空文字/それ以外) 5 件 + unset 1 件。 _SUPER_MAS_DISABLED flag
  と _super_mas_fn=None 化の両方を確認

テスト件数: 既存 8 (test_monotonic_align) + 既存 8 (前 commit 分) +
新規 13 = 29/29 pass (subprocess test 含むため 67 秒)

既存 test_monotonic_align.py は Cython MAS contract を検証しており、
dispatcher 経由でも Cython fallback path として通る contract に変更が
ないため修正不要 (実測でも 8/8 pass を確認)
Copilot AI review requested due to automatic review settings June 27, 2026 07:04
@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Required status-check gate (deferred)

Head SHA 3c6e088 is no longer the branch tip (latest: 0689854). Waiting for the new commit's spoke runs to complete before re-evaluating.

@github-actions

Copy link
Copy Markdown
Contributor

Distroless migration trial: python-inference (CPU)

Scope: Dockerfile.cpu.distroless (trial). Dockerfile.cpu (canonical, HF Space deploy target) is UNCHANGED.

Base image choice: gcr.io/distroless/python3-debian12. Debian-glibc baseline matches the python:3.11-slim-trixie builder, so onnxruntime's pre-built C extension and soundfile's libsndfile dlopen resolve byte-for-byte (no Wolfi ABI gap).

metric canonical (Dockerfile.cpu) distroless trial delta
image size (linux/amd64) 1.4GB 760MB -44.8%

Smoke results

All imports passed in a single docker run: ONNX Runtime (CPU EP) / piper_train / FastAPI / uvicorn / soundfile.

Not in this trial (follow-up PR)

  • linux/arm64 buildx (Pi / Apple Silicon / HA boxes)
  • HF Space staging deploy + cold-start latency comparison (user manual)
  • /v1/audio/speech end-to-end with a real model fixture (CI lacks the ONNX model bundle)
  • CVE scan diff (Trivy) — wired up alongside the canonical Dockerfile.cpu promotion PR

@github-actions

Copy link
Copy Markdown
Contributor

Audio MOS Proxy (informational tier)

Samples checked: 30, regressions: 0.

No baseline yet — this PR is recording the very first measurement.

Sample Metric Baseline Current Δ (threshold)
ja-short-001 pesq_wb 0.000 — (≥0.15)
ja-short-001 stoi 0.000 — (≥0.02)
ja-short-001 utmos22 0.000 — (≥0.1)
ja-short-001 wer 0.000 — (≥0.05)
ja-long-001 pesq_wb 0.000 — (≥0.15)
ja-long-001 stoi 0.000 — (≥0.02)
ja-long-001 utmos22 0.000 — (≥0.1)
ja-long-001 wer 0.000 — (≥0.05)
ja-ssml-001 pesq_wb 0.000 — (≥0.15)
ja-ssml-001 stoi 0.000 — (≥0.02)
ja-ssml-001 utmos22 0.000 — (≥0.1)
ja-ssml-001 wer 0.000 — (≥0.05)
ja-code-001 pesq_wb 0.000 — (≥0.15)
ja-code-001 stoi 0.000 — (≥0.02)
ja-code-001 utmos22 0.000 — (≥0.1)
ja-code-001 wer 0.000 — (≥0.05)
ja-pua-001 pesq_wb 0.000 — (≥0.15)
ja-pua-001 stoi 0.000 — (≥0.02)
ja-pua-001 utmos22 0.000 — (≥0.1)
ja-pua-001 wer 0.000 — (≥0.05)
en-short-001 pesq_wb 0.000 — (≥0.15)
en-short-001 stoi 0.000 — (≥0.02)
en-short-001 utmos22 0.000 — (≥0.1)
en-short-001 wer 0.000 — (≥0.05)
en-long-001 pesq_wb 0.000 — (≥0.15)
en-long-001 stoi 0.000 — (≥0.02)
en-long-001 utmos22 0.000 — (≥0.1)
en-long-001 wer 0.000 — (≥0.05)
en-ssml-001 pesq_wb 0.000 — (≥0.15)
en-ssml-001 stoi 0.000 — (≥0.02)
en-ssml-001 utmos22 0.000 — (≥0.1)
en-ssml-001 wer 0.000 — (≥0.05)
en-code-001 pesq_wb 0.000 — (≥0.15)
en-code-001 stoi 0.000 — (≥0.02)
en-code-001 utmos22 0.000 — (≥0.1)
en-code-001 wer 0.000 — (≥0.05)
en-pua-001 pesq_wb 0.000 — (≥0.15)
en-pua-001 stoi 0.000 — (≥0.02)
en-pua-001 utmos22 0.000 — (≥0.1)
en-pua-001 wer 0.000 — (≥0.05)
zh-short-001 pesq_wb 0.000 — (≥0.15)
zh-short-001 stoi 0.000 — (≥0.02)
zh-short-001 utmos22 0.000 — (≥0.1)
zh-short-001 wer 0.000 — (≥0.05)
zh-long-001 pesq_wb 0.000 — (≥0.15)
zh-long-001 stoi 0.000 — (≥0.02)
zh-long-001 utmos22 0.000 — (≥0.1)
zh-long-001 wer 0.000 — (≥0.05)
zh-ssml-001 pesq_wb 0.000 — (≥0.15)
zh-ssml-001 stoi 0.000 — (≥0.02)
zh-ssml-001 utmos22 0.000 — (≥0.1)
zh-ssml-001 wer 0.000 — (≥0.05)
zh-code-001 pesq_wb 0.000 — (≥0.15)
zh-code-001 stoi 0.000 — (≥0.02)
zh-code-001 utmos22 0.000 — (≥0.1)
zh-code-001 wer 0.000 — (≥0.05)
zh-pua-001 pesq_wb 0.000 — (≥0.15)
zh-pua-001 stoi 0.000 — (≥0.02)
zh-pua-001 utmos22 0.000 — (≥0.1)
zh-pua-001 wer 0.000 — (≥0.05)
es-short-001 pesq_wb 0.000 — (≥0.15)
es-short-001 stoi 0.000 — (≥0.02)
es-short-001 utmos22 0.000 — (≥0.1)
es-short-001 wer 0.000 — (≥0.05)
es-long-001 pesq_wb 0.000 — (≥0.15)
es-long-001 stoi 0.000 — (≥0.02)
es-long-001 utmos22 0.000 — (≥0.1)
es-long-001 wer 0.000 — (≥0.05)
es-ssml-001 pesq_wb 0.000 — (≥0.15)
es-ssml-001 stoi 0.000 — (≥0.02)
es-ssml-001 utmos22 0.000 — (≥0.1)
es-ssml-001 wer 0.000 — (≥0.05)
es-code-001 pesq_wb 0.000 — (≥0.15)
es-code-001 stoi 0.000 — (≥0.02)
es-code-001 utmos22 0.000 — (≥0.1)
es-code-001 wer 0.000 — (≥0.05)
es-pua-001 pesq_wb 0.000 — (≥0.15)
es-pua-001 stoi 0.000 — (≥0.02)
es-pua-001 utmos22 0.000 — (≥0.1)
es-pua-001 wer 0.000 — (≥0.05)
fr-short-001 pesq_wb 0.000 — (≥0.15)
fr-short-001 stoi 0.000 — (≥0.02)
fr-short-001 utmos22 0.000 — (≥0.1)
fr-short-001 wer 0.000 — (≥0.05)
fr-long-001 pesq_wb 0.000 — (≥0.15)
fr-long-001 stoi 0.000 — (≥0.02)
fr-long-001 utmos22 0.000 — (≥0.1)
fr-long-001 wer 0.000 — (≥0.05)
fr-ssml-001 pesq_wb 0.000 — (≥0.15)
fr-ssml-001 stoi 0.000 — (≥0.02)
fr-ssml-001 utmos22 0.000 — (≥0.1)
fr-ssml-001 wer 0.000 — (≥0.05)
fr-code-001 pesq_wb 0.000 — (≥0.15)
fr-code-001 stoi 0.000 — (≥0.02)
fr-code-001 utmos22 0.000 — (≥0.1)
fr-code-001 wer 0.000 — (≥0.05)
fr-pua-001 pesq_wb 0.000 — (≥0.15)
fr-pua-001 stoi 0.000 — (≥0.02)
fr-pua-001 utmos22 0.000 — (≥0.1)
fr-pua-001 wer 0.000 — (≥0.05)
pt-short-001 pesq_wb 0.000 — (≥0.15)
pt-short-001 stoi 0.000 — (≥0.02)
pt-short-001 utmos22 0.000 — (≥0.1)
pt-short-001 wer 0.000 — (≥0.05)
pt-long-001 pesq_wb 0.000 — (≥0.15)
pt-long-001 stoi 0.000 — (≥0.02)
pt-long-001 utmos22 0.000 — (≥0.1)
pt-long-001 wer 0.000 — (≥0.05)
pt-ssml-001 pesq_wb 0.000 — (≥0.15)
pt-ssml-001 stoi 0.000 — (≥0.02)
pt-ssml-001 utmos22 0.000 — (≥0.1)
pt-ssml-001 wer 0.000 — (≥0.05)
pt-code-001 pesq_wb 0.000 — (≥0.15)
pt-code-001 stoi 0.000 — (≥0.02)
pt-code-001 utmos22 0.000 — (≥0.1)
pt-code-001 wer 0.000 — (≥0.05)
pt-pua-001 pesq_wb 0.000 — (≥0.15)
pt-pua-001 stoi 0.000 — (≥0.02)
pt-pua-001 utmos22 0.000 — (≥0.1)
pt-pua-001 wer 0.000 — (≥0.05)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in training-time dispatch path for Monotonic Alignment Search (MAS) that can use the Triton-GPU Super-MAS implementation when available, while preserving the existing Cython fallback and keeping inference/ONNX paths unchanged.

Changes:

  • Introduces a Super-MAS dispatcher in piper_train.vits.monotonic_align with env-based import-time disable and safe fallback to Cython.
  • Adds an optional super-mas extra to install the upstream super-monotonic-align dependency via git.
  • Adds unit tests covering dispatch predicate behavior, wrapper contract behavior, and import-time env disabling.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/python/piper_train/vits/monotonic_align/init.py Adds Super-MAS optional import/dispatch logic and a wrapper that preserves dtype/device contract while protecting inputs from upstream mutation.
src/python/pyproject.toml Adds an opt-in super-mas extra that installs the upstream accelerator dependency.
src/python/tests/test_super_mas_dispatch.py Adds dispatcher and wrapper unit tests, including an import-time env var contract check via subprocess.
CLAUDE.md Documents the new Super-MAS accelerator option and its intended usage/constraints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/python/tests/test_super_mas_dispatch.py Outdated
Comment thread src/python/pyproject.toml
@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Memory regression (per-language)

Threshold: +15% peak RSS vs baseline (warn-only).

Status Lang Baseline (MB) Observed (MB) Delta
SKIP ja n/a 206.5 n/a
SKIP en n/a 203.8 n/a
SKIP zh n/a 205.3 n/a
SKIP es n/a 203.8 n/a
SKIP fr n/a 203.8 n/a
SKIP pt n/a 203.9 n/a

Summary: 0 warn / 6 skip / 0 ok.

SKIP means the baseline entry is a placeholder (peak_memory_mb: null). The first dev push after this workflow lands is expected to seed the baseline.

@github-actions

Copy link
Copy Markdown
Contributor

Distroless trial: webui / cpp-inference

Each canonical Dockerfile is UNCHANGED; the trial Dockerfile sits beside it as Dockerfile.distroless so docker-compose and existing CI matrices keep using the proven image.

(cpp-dev distroless was deferred — chainguard/wolfi-base does not ship the OpenJTalk / mecab build toolchain the canonical image depends on. T-016 needs a fresh design and ships in a separate PR.)

cpp-inference

Trial Dockerfile: docker/cpp-inference/Dockerfile.distroless. Canonical docker/cpp-inference/Dockerfile is UNCHANGED.

metric canonical distroless trial delta
image size (linux/amd64) 237MB 232MB -2.2%

Smoke entrypoint: /usr/local/bin/piper — passed.

webui

Trial Dockerfile: docker/webui/Dockerfile.distroless. Canonical docker/webui/Dockerfile is UNCHANGED.

metric canonical distroless trial delta
image size (linux/amd64) 941MB 760MB -19.2%

Smoke entrypoint: /usr/bin/python3 — passed.

Not in these trials (follow-up promotion PRs)

  • linux/arm64 buildx coverage is handled by docker-build.yml (build-distroless-trials matrix).
  • CVE Trivy diff lives in trivy-container-scan.yml (per-image SARIF upload).
  • For webui: full Gradio cold-start under distroless (a real docker run -p 7860:7860 from webui-test.yml) is the promotion gate.
  • For cpp-inference: end-to-end piper --model ... --output_file ... with a real model fixture is the promotion gate.

@ayutaz ayutaz self-assigned this Jun 27, 2026
@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Runtime Parity Deep — audio (informational tier)

Pairs compared: 15, failing: 15, runtimes skipped: 0.

A B Tier Result Detail
cpp csharp sha256 ⚠️ 18b553725dd8 vs ee06d30b96af
cpp csharp peak_rms ⚠️ Δrms=0.36668 (≤ 0.005)
cpp csharp snr ⚠️ frame count differs: 3129 vs 6615
cpp go sha256 ⚠️ 18b553725dd8 vs 34bb0fec7ea2
cpp go peak_rms ⚠️ Δrms=0.33169 (≤ 0.005)
cpp go snr ⚠️ SNR=0.18 dB (≥ 60.0)
cpp python sha256 ⚠️ 18b553725dd8 vs 588fa7c1d6fa
cpp python peak_rms ⚠️ Δrms=0.15885 (≤ 0.005)
cpp python snr ⚠️ SNR=-2.95 dB (≥ 60.0)
cpp rust sha256 ⚠️ 18b553725dd8 vs 856260c25f7f
cpp rust peak_rms ⚠️ Δrms=0.36087 (≤ 0.005)
cpp rust snr ⚠️ frame count differs: 3129 vs 7539
cpp wasm sha256 ⚠️ 18b553725dd8 vs c075fb128efe
cpp wasm peak_rms ⚠️ Δrms=0.47410 (≤ 0.005)
cpp wasm snr ⚠️ frame count differs: 3129 vs 3328
csharp go sha256 ⚠️ ee06d30b96af vs 34bb0fec7ea2
csharp go peak_rms ⚠️ Δrms=0.03498 (≤ 0.005)
csharp go snr ⚠️ frame count differs: 6615 vs 3129
csharp python sha256 ⚠️ ee06d30b96af vs 588fa7c1d6fa
csharp python peak_rms ⚠️ Δrms=0.20783 (≤ 0.005)
csharp python snr ⚠️ frame count differs: 6615 vs 3129
csharp rust sha256 ⚠️ ee06d30b96af vs 856260c25f7f
csharp rust peak_rms ⚠️ Δrms=0.00581 (≤ 0.005)
csharp rust snr ⚠️ frame count differs: 6615 vs 7539
csharp wasm sha256 ⚠️ ee06d30b96af vs c075fb128efe
csharp wasm peak_rms ⚠️ Δrms=0.10742 (≤ 0.005)
csharp wasm snr ⚠️ frame count differs: 6615 vs 3328
go python sha256 ⚠️ 34bb0fec7ea2 vs 588fa7c1d6fa
go python peak_rms ⚠️ Δrms=0.17285 (≤ 0.005)
go python snr ⚠️ SNR=-6.71 dB (≥ 60.0)
go rust sha256 ⚠️ 34bb0fec7ea2 vs 856260c25f7f
go rust peak_rms ⚠️ Δrms=0.02918 (≤ 0.005)
go rust snr ⚠️ frame count differs: 3129 vs 7539
go wasm sha256 ⚠️ 34bb0fec7ea2 vs c075fb128efe
go wasm peak_rms ⚠️ Δrms=0.14240 (≤ 0.005)
go wasm snr ⚠️ frame count differs: 3129 vs 3328
python rust sha256 ⚠️ 588fa7c1d6fa vs 856260c25f7f
python rust peak_rms ⚠️ Δrms=0.20202 (≤ 0.005)
python rust snr ⚠️ frame count differs: 3129 vs 7539
python wasm sha256 ⚠️ 588fa7c1d6fa vs c075fb128efe
python wasm peak_rms ⚠️ Δrms=0.31525 (≤ 0.005)
python wasm snr ⚠️ frame count differs: 3129 vs 3328
rust wasm sha256 ⚠️ 856260c25f7f vs c075fb128efe
rust wasm peak_rms ⚠️ Δrms=0.11323 (≤ 0.005)
rust wasm snr ⚠️ frame count differs: 7539 vs 3328

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Multi-Runtime RTF Benchmark

Policy: warn-only (thresholds: RTF +/-10%, P50 +/-10%, P95 +/-15%)

Model: test/models/multilingual-test-medium.onnx (warmup=5, runs=30)

Runtime Text RTF P50 (ms) P95 (ms) Baseline RTF RTF Δ Baseline P50 P50 Δ Baseline P95 P95 Δ
python short 4.1942 5643.1 6050.5 4.4317 -5.4% 6324.8 -10.8% 6757.1 -10.5%
python medium 1.2052 6642.0 6826.4 1.0438 +15.5% ⚠️ 5882.0 +12.9% ⚠️ 6208.1 +10.0%
python long 0.2254 7723.9 7989.1 0.2251 +0.1% 7755.6 -0.4% 8124.9 -1.7%
rust short 0.8926 1348.4 1385.0 0.8309 +7.4% 1310.9 +2.9% 1359.6 +1.9%
rust medium 0.2583 1646.0 1851.1 0.2501 +3.3% 1614.3 +2.0% 1636.8 +13.1%
rust long 0.1034 3645.6 3693.3 0.1039 -0.5% 3673.8 -0.8% 3697.7 -0.1%
go short 1.8377 2365.4 2424.0 2.3051 -20.3% 3125.1 -24.3% 3216.7 -24.6%
go medium 0.5417 3337.2 3444.0 0.5123 +5.7% 3158.6 +5.7% 3358.1 +2.6%
go long 0.1432 5255.3 5298.2 0.1464 -2.2% 5374.6 -2.2% 5467.3 -3.1%
csharp short 2.8581 1542.2 1624.7 2.8462 +0.4% 1542.0 +0.0% 1627.3 -0.2%
csharp medium 0.8804 1589.9 1666.2 0.8929 -1.4% 1608.6 -1.2% 1811.7 -8.0%
csharp long 0.1793 2285.3 2367.5 0.1413 +26.9% ⚠️ 1813.8 +26.0% ⚠️ 1913.0 +23.8% ⚠️
cpp short 0.8118 1223.5 1278.5 0.8694 -6.6% 1402.4 -12.8% 1431.6 -10.7%
cpp medium 0.2163 1423.7 1465.2 0.2529 -14.5% 1686.2 -15.6% 1724.0 -15.0%
cpp long 0.1017 3671.7 3695.9 0.0988 +2.9% 3573.3 +2.8% 3641.5 +1.5%
wasm short (missing) - - n/a - n/a - n/a -
wasm medium (missing) - - n/a - n/a - n/a -
wasm long (missing) - - n/a - n/a - n/a -

⚠️ One or more cells regressed beyond the RTF, P50, or P95 threshold. Warn-only while the baseline is being calibrated; this will become a hard gate once we have ~2-3 weeks of variance data.

PR #582 unresolved review threads 2 件への対応:

1. **pyproject.toml**: super-monotonic-align を unpinned HEAD から
   commit SHA (9bb1cb3a6fbab27bbe6e566827b9548010c5dd51) に pin。
   再現性確保と supply-chain hygiene のため。 SHA は学習で
   validate 済みの kernel revision を指す。 bump は手動 re-validation
   後にのみ実施 (Copilot 指摘 #2)

2. **test_super_mas_dispatch.py**: subprocess の env 構築方法を
   hand-built dict から os.environ.copy() に変更し、 PYTHONPATH に
   src/python を明示的に prepend。 これにより:
   - Windows の SystemRoot を意図せず override する問題を回避
   - piper_train が editable-install されていない環境でも
     subprocess が piper_train を import 可能
     (conftest.py の sys.path injection が subprocess に届かない問題、
     Copilot 指摘 #1)

テスト: 29/29 pass (既存 8 + 拡張 21、 88 秒、 subprocess test 11 件含む)
@ayutaz
ayutaz merged commit e845251 into dev Jun 27, 2026
136 of 139 checks passed
@ayutaz
ayutaz deleted the feat/super-mas-triton-gpu branch June 27, 2026 15:03
ayutaz added a commit that referenced this pull request Jun 28, 2026
PR #583 初回 CI で pre-commit が 2 hook fail:

1. check-shebang-scripts-are-executable
   - scripts/check_hf_space_gradio_sync.py が shebang 付きで commit
     されたが git index の executable bit が 100644 のまま (Windows
     から add した時の既定動作)
   - 修正: git update-index --chmod=+x で 100755 に変更

2. artifact-retention-contract.toml gate (root cause: uv.lock drift)
   - 本 PR の .github/workflows/*.yml 変更が artifact-retention hook
     の file filter に match し hook が起動。 hook は uv run python
     ... で実行され、 uv が PR #582 (Super-MAS) で導入された
     [project.optional-dependencies] super-mas を uv.lock に未反映
     と検出して auto-sync (super-monotonic-align git dep + provides-
     extras に super-mas を追加)
   - hook 自体は "aligned with all upload steps" を出して contract
     toml に変更なし。 uv.lock の方が "files were modified by this
     hook" として fail 判定された
   - 修正: 同期された uv.lock を commit (#582 マージ後の latent drift
     を解消、 本 PR の workflow 変更でたまたま surface した)
ayutaz added a commit that referenced this pull request Jun 28, 2026
PR #582 (Super-MAS Triton-GPU MAS accelerator) で pyproject.toml に
追加された super-mas extra が uv.lock に未反映だった drift を解消。
PR #583 と同じ修正をこのブランチでも適用。
ayutaz added a commit that referenced this pull request Jun 28, 2026
* fix(hf-space): gradio sdk_version drift を解消 + CI ゲート追加

HF Space (ayousanz/piper-plus-demo) が BUILD_ERROR で起動不能だった。
README frontmatter sdk_version=6.9.0 と requirements.txt gradio==6.16.0
が drift し、 HF Spaces ビルダーが pip install gradio==6.9.0 -r
requirements.txt を 1 コマンドで実行するため resolution conflict で
exit 1 (HF API は "cache miss" という misleading なメッセージで
覆い隠していた)。

修正:
- huggingface-space/README.md: sdk_version を 6.16.0 に同期 (即時復旧)
- scripts/check_hf_space_gradio_sync.py: 両者の exact pin 一致を検査
  する script を追加 (drift 時 exit 1 + 修正手順を提示)
- .gitignore: 新 script を allowlist に追加 (check_*.py blanket ignore 対策)
- .github/workflows/test-hf-space.yml: Layer 0 として gate を追加
  (deps install 前に fail fast、 PR 段階で検出)
- .github/workflows/deploy-huggingface.yml: upload_folder 直前にも
  同 gate を追加 (web UI 編集 / force-push の last-line defense)

根本原因は Dependabot #551 (2026-06-06) が requirements.txt のみ
gradio 6.14.0 → 6.16.0 に bump し README frontmatter を同期しなかった
こと。 gate により同種 drift を CI で事前検知可能。

* fix(ci): pre-commit fail 2 件を解消 (chmod + uv.lock drift)

PR #583 初回 CI で pre-commit が 2 hook fail:

1. check-shebang-scripts-are-executable
   - scripts/check_hf_space_gradio_sync.py が shebang 付きで commit
     されたが git index の executable bit が 100644 のまま (Windows
     から add した時の既定動作)
   - 修正: git update-index --chmod=+x で 100755 に変更

2. artifact-retention-contract.toml gate (root cause: uv.lock drift)
   - 本 PR の .github/workflows/*.yml 変更が artifact-retention hook
     の file filter に match し hook が起動。 hook は uv run python
     ... で実行され、 uv が PR #582 (Super-MAS) で導入された
     [project.optional-dependencies] super-mas を uv.lock に未反映
     と検出して auto-sync (super-monotonic-align git dep + provides-
     extras に super-mas を追加)
   - hook 自体は "aligned with all upload steps" を出して contract
     toml に変更なし。 uv.lock の方が "files were modified by this
     hook" として fail 判定された
   - 修正: 同期された uv.lock を commit (#582 マージ後の latent drift
     を解消、 本 PR の workflow 変更でたまたま surface した)

* fix(review): Copilot 指摘 4 件を解消

PR #583 で Copilot reviewer から指摘された 4 件 (すべて logic /
correctness、 style noise ではない) を修正。

1. docstring と実装の exit code 不一致 (line 26)
   旧: "exit 0 if both fields are absent"
   実装: 片方 None でも errors.append → exit 1
   → docstring を実装に揃え、 空 pin も malformed として exit 1 を明記

2. 空 sdk_version 値を silently OK 化 (line 58)
   `sdk_version:` (値なし) で `""` を返し main の `is None` チェックを
   bypass → drift 検出を skip
   → `value or None` で空文字を None に正規化、 統一的に malformed 扱い

3. 非 f-string で `{sdk_version}` がリテラル出力 (line 104)
   エラーメッセージの該当行に `f` prefix が抜けていた
   → f-string 化、 実値を埋め込んで debug 性向上
     (例: `gradio[oauth,mcp]==6.9.0`)

4. deploy-huggingface.yml gate が setup-python の前 (line 53)
   script が `str | None` 等 Python 3.10+ 構文を使うのに runner 既定
   `python3` (バージョン非保証) に依存
   → Set up Python を Setup deployment 直後に移動し、 gate を後に配置。
     後段の重複 setup-python step は削除、 `python3` を `python` に統一

* feat(ci): HF Space deploy 前後の検証を追加 (BUILD_ERROR / RUNTIME_ERROR 即時検知)

PR #583 の sdk_version drift 修正に続く防御層追加。 既存検証では deploy upload
成功 = 0 exit で workflow が green になり、 HF Space が BUILD_ERROR /
RUNTIME_ERROR / CONFIG_ERROR / NO_APP_FILE で起動失敗していても誰も気付かな
かった (2026-06 incident の根本原因)。

追加内容:

1. scripts/check_hf_space_frontmatter.py (F1-F4 対策)
   README YAML frontmatter の schema gate:
   - 必須フィールド (title / sdk / sdk_version / app_file) の存在
   - app_file が huggingface-space/ 配下に実在
   - sdk が gradio / streamlit / docker / static のいずれか
   - YAML が parse 可能
   ruff + manual テスト (F1/F2/F3/F4 全 fail シナリオ + 正常 PASS) で動作確認。

2. scripts/verify_hf_space_runtime.py (F5 対策、 universal safety net)
   upload_folder 完了後、 HfApi.get_space_runtime を ~10 min poll し
   RUNNING / RUNNING_BUILDING / APP_STARTING のいずれかに到達するか
   BUILD_ERROR / RUNTIME_ERROR 等で fail するかを検出。 タイムアウト時も
   fail (build hang を可視化)。 standalone 実行可能 (manual debug 用)。

3. test-hf-space.yml: Layer 0.5 (frontmatter) + Layer 2.1 (pip check) +
   Layer 5 を `import app` から `create_interface()` まで拡張 (gradio API
   breaking change を runtime 起動前に検知)。

4. deploy-huggingface.yml: Set up Python + pre-deploy frontmatter gate +
   post-deploy 10-min runtime verification。
ayutaz added a commit that referenced this pull request Jul 8, 2026
pyproject.toml `[super-mas]` extra (arXiv:2409.07704, PR #582) は CLAUDE.md
で opt-in 推奨として文書化済みだが、 docker/python-train/Dockerfile 側で
反映されておらず A100 学習で MAS が Cython fallback していた。

- Dockerfile builder stage に `uv pip install "[super-mas]"` を追加
  (git+https 依存、 builder は git 済み)
- build-time test に `import super_monotonic_align` の検証を追加。
  CPU-only import は安全、 fallback が silent に起こる miss を build 時点で
  可視化

v8 zero-shot 学習で MAS step が 3-10% 短縮、 A100 SXM4 80GB で 80 epoch
学習の総 wall-clock を数時間削減する見込み。
ayutaz added a commit that referenced this pull request Aug 1, 2026
pyproject.toml `[super-mas]` extra (arXiv:2409.07704, PR #582) は CLAUDE.md
で opt-in 推奨として文書化済みだが、 docker/python-train/Dockerfile 側で
反映されておらず A100 学習で MAS が Cython fallback していた。

- Dockerfile builder stage に `uv pip install "[super-mas]"` を追加
  (git+https 依存、 builder は git 済み)
- build-time test に `import super_monotonic_align` の検証を追加。
  CPU-only import は安全、 fallback が silent に起こる miss を build 時点で
  可視化

v8 zero-shot 学習で MAS step が 3-10% 短縮、 A100 SXM4 80GB で 80 epoch
学習の総 wall-clock を数時間削減する見込み。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants