Enable YuE2 CUDA graphs and expose stage timings
Browse files- pipeline.py +5 -0
- yue_worker.py +2 -1
pipeline.py
CHANGED
|
@@ -288,6 +288,7 @@ def generate_all(source: str, instrument: str, styles: dict[str, str], seed: int
|
|
| 288 |
outputs = {name: None for name in VARIANTS}
|
| 289 |
errors = {}
|
| 290 |
durations = {}
|
|
|
|
| 291 |
drum_count = 0
|
| 292 |
drums_midi = None
|
| 293 |
|
|
@@ -301,6 +302,7 @@ def generate_all(source: str, instrument: str, styles: dict[str, str], seed: int
|
|
| 301 |
metadata = {"instrument": instrument, "source_sha256": digest,
|
| 302 |
"source_seconds": round(duration, 3),
|
| 303 |
"result_seconds": dict(durations), "drum_hits": drum_count,
|
|
|
|
| 304 |
"errors": dict(errors), "complete": complete,
|
| 305 |
"source_timing_preserved": ["instrument", "instrument_drums", "contour"],
|
| 306 |
"yue_vocal_absence_guaranteed": False,
|
|
@@ -346,6 +348,9 @@ def generate_all(source: str, instrument: str, styles: dict[str, str], seed: int
|
|
| 346 |
if raw.is_file():
|
| 347 |
try:
|
| 348 |
deliver(name, raw)
|
|
|
|
|
|
|
|
|
|
| 349 |
except (ValueError, RuntimeError, OSError) as error:
|
| 350 |
errors[name] = str(error)
|
| 351 |
else:
|
|
|
|
| 288 |
outputs = {name: None for name in VARIANTS}
|
| 289 |
errors = {}
|
| 290 |
durations = {}
|
| 291 |
+
yue_timing = {}
|
| 292 |
drum_count = 0
|
| 293 |
drums_midi = None
|
| 294 |
|
|
|
|
| 302 |
metadata = {"instrument": instrument, "source_sha256": digest,
|
| 303 |
"source_seconds": round(duration, 3),
|
| 304 |
"result_seconds": dict(durations), "drum_hits": drum_count,
|
| 305 |
+
"yue_timing": dict(yue_timing),
|
| 306 |
"errors": dict(errors), "complete": complete,
|
| 307 |
"source_timing_preserved": ["instrument", "instrument_drums", "contour"],
|
| 308 |
"yue_vocal_absence_guaranteed": False,
|
|
|
|
| 348 |
if raw.is_file():
|
| 349 |
try:
|
| 350 |
deliver(name, raw)
|
| 351 |
+
receipt = folder / name / "yue.json"
|
| 352 |
+
if receipt.is_file():
|
| 353 |
+
yue_timing[name] = json.loads(receipt.read_text())["timing"]
|
| 354 |
except (ValueError, RuntimeError, OSError) as error:
|
| 355 |
errors[name] = str(error)
|
| 356 |
else:
|
yue_worker.py
CHANGED
|
@@ -24,7 +24,7 @@ def run(request_path: Path, output: Path) -> None:
|
|
| 24 |
pipe = YuE2Pipeline.from_pretrained(
|
| 25 |
"m-a-p/YuE2-3B", vae="m-a-p/YuE2-Vae",
|
| 26 |
revision=YUE_REV, vae_revision=VAE_REV,
|
| 27 |
-
device="cuda", backend="torch
|
| 28 |
offload_ar=False, memory_budget_gib=44, progress=True,
|
| 29 |
)
|
| 30 |
try:
|
|
@@ -44,6 +44,7 @@ def run(request_path: Path, output: Path) -> None:
|
|
| 44 |
sf.write(target / "raw.wav", audio, song.sample_rate, subtype="FLOAT")
|
| 45 |
(target / "yue.json").write_text(json.dumps({
|
| 46 |
"model": "m-a-p/YuE2-3B", "revision": YUE_REV,
|
|
|
|
| 47 |
"vae_revision": VAE_REV, "duration_s": len(audio) / song.sample_rate,
|
| 48 |
"truncated": song.truncated, "timing": song.timing,
|
| 49 |
"source_timeline": False, "vocal_absence_guaranteed": False,
|
|
|
|
| 24 |
pipe = YuE2Pipeline.from_pretrained(
|
| 25 |
"m-a-p/YuE2-3B", vae="m-a-p/YuE2-Vae",
|
| 26 |
revision=YUE_REV, vae_revision=VAE_REV,
|
| 27 |
+
device="cuda", backend="torch", quantization="none",
|
| 28 |
offload_ar=False, memory_budget_gib=44, progress=True,
|
| 29 |
)
|
| 30 |
try:
|
|
|
|
| 44 |
sf.write(target / "raw.wav", audio, song.sample_rate, subtype="FLOAT")
|
| 45 |
(target / "yue.json").write_text(json.dumps({
|
| 46 |
"model": "m-a-p/YuE2-3B", "revision": YUE_REV,
|
| 47 |
+
"backend": "torch", "seed": request["seed"],
|
| 48 |
"vae_revision": VAE_REV, "duration_s": len(audio) / song.sample_rate,
|
| 49 |
"truncated": song.truncated, "timing": song.timing,
|
| 50 |
"source_timeline": False, "vocal_absence_guaranteed": False,
|