fix(train): make phoonnx_train.export_onnx work on torch>=2.6#140
fix(train): make phoonnx_train.export_onnx work on torch>=2.6#140JarbasAl wants to merge 1 commit into
Conversation
The piper-derived VITS exporter broke on modern torch. Three fixes so it can convert any piper/phoonnx checkpoint to ONNX: - torch.onnx.export(dynamo=False) — VITS has data-dependent control flow that the new dynamo exporter rejects; use the legacy tracer. - force weights_only=False when loading the Lightning checkpoint (torch 2.6 flipped the default to True, which rejects pickled hparams like PosixPath). Loading a checkpoint to export it is inherently trusted. - export on CPU (model_g.cpu()) so the model and the dummy inputs share a device when CUDA is present. Verified end-to-end: exported HirCoir/piper-sorah-neuronal -> ONNX with the expected piper inputs [input, input_lengths, scales] and non-silent audio. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
I've completed the automated review of your changes. 📑I've aggregated the results of the automated checks for this PR below. 📋 Repo HealthI've checked the repo's reflexes (aka build speed). ⚡ Latest Version: ✅ 🏷️ Release PreviewThe release preview is now complete. 🏁 Current:
🚀 Release Channel Compatibility Predicted next version:
🔍 LintI've checked the pulse of your pull request. 💓 ❌ ruff: issues found — see job log 🔒 Security (pip-audit)Scanning the horizon for any zero-day threats. 🌅 ✅ No known vulnerabilities found (61 packages scanned). 📊 CoverageCharting the progress of our testing efforts. 📉 ❌ 31.6% total coverage Files below 80% coverage (37 files)
Full report: download the ⚖️ License CheckEnsuring our licenses are OSI-approved. ✅ ❌ License violations detected (43 packages) — review required before merging. License distribution: 14× MIT License, 7× Apache Software License, 5× MIT, 3× Apache-2.0, 2× BSD-3-Clause, 2× ISC License (ISCL), 1× 3-Clause BSD License, 1× Apache Software License; BSD License, +8 more Full breakdown — 43 packages
Copyright (c) 2022 Phil Ewels Permission is hereby granted, free of charge, to any person obtaining a copy The above copyright notice and this permission notice shall be included in all THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR Policy: Apache 2.0 (universal donor). StrongCopyleft / NetworkCopyleft / WeakCopyleft / Other / Error categories fail. MPL allowed. 🔨 Build TestsTesting the recipe! Did the build turn out okay? 👨🍳 ✅ All versions pass
Automating the boring stuff so you don't have to! 🚀 |
The piper-derived VITS ONNX exporter (
phoonnx_train/export_onnx.py) was broken on modern torch. Three fixes so it can convert any piper/phoonnx checkpoint to ONNX again:torch.onnx.export(dynamo=False)— VITS has data-dependent control flow that torch 2.x's new dynamo exporter rejects (GuardOnDataDependentSymNode); use the legacy tracer.weights_only=Falsewhen loading the Lightning checkpoint — torch 2.6 flippedtorch.load's default toTrue, which rejects the pickled hparams (pathlib.PosixPath). Loading a checkpoint to export it is inherently trusted.model_g.cpu()) so the model and the dummy inputs share a device when CUDA is present.Verified
Exported
HirCoir/piper-sorah-neuronalend-to-end → ONNX with the expected piper inputs[input, input_lengths, scales]and non-silent audio. (No automated test added — it needs a checkpoint fixture + a compiledmonotonic_align, which isn't available in CI; the change is a 3-line torch-compat fix to a CLI export tool.)Split out of the Matcha work as its own small PR; unblocks converting community piper checkpoints to ONNX.
🤖 Generated with Claude Code