| 中文 | English |
This backend is split into three files:
The design is intentionally two-layered:
One frontend request goes through this path:
POST /generate to backend_api.py.POST /generate.backend_worker.py loads or reuses the tokenizer and models, then runs:
backend/generated_audio/ and returns filenames plus metadata./job/{job_id} and /job/{job_id}/track/{track_idx}/mp3|wav.run_backend.shThis is the entry point for local or containerized deployment.
It is responsible for:
GPU_IDSImportant launch controls include:
--gpus: physical GPU ids used by workers--runtime-mode: one_shot or keep_loadedAPI_PORTWORKER_BASE_PORTBASE_MASTER_PORTBASE_SEEDMEGATRON_ARGSbackend_api.pyThis file is the frontend-facing orchestration layer.
It is responsible for:
It does not perform GPU inference itself.
backend_worker.pyThis file is the single-GPU inference runtime.
It is responsible for:
Runtime strategy:
From the backend directory:
cd backend
bash run_backend.sh
Default behavior:
0one_shot modeCommon advanced examples:
bash run_backend.sh --gpus 0
bash run_backend.sh --gpus 0,1
bash run_backend.sh --gpus 0,1 --runtime-mode keep_loaded
Stop all backend processes:
bash run_backend.sh stop
Logs are written to:
backend/logs/api.logbackend/logs/worker_0.logbackend/logs/worker_1.logUseful commands:
tail -f backend/logs/api.log
tail -f backend/logs/worker_0.log
Generated files are written under:
backend/generated_audio/*.wavbackend/generated_audio/*.mp3backend/generated_audio/*.jsonEach request writes:
Pass --gpus to run_backend.sh:
bash run_backend.sh --gpus 0
bash run_backend.sh --gpus 0,1
bash run_backend.sh --gpus 6,7
One worker is started per GPU id. The worker count is derived automatically from the number of ids you provide.
Pass --runtime-mode to run_backend.sh:
bash run_backend.sh --runtime-mode one_shot
bash run_backend.sh --runtime-mode keep_loaded
Guidance:
one_shot: safer default for single-GPU or lower-VRAM setupskeep_loaded: better for higher-memory GPUs and repeated inferenceEdit these values in run_backend.sh:
API_PORTWORKER_BASE_PORTBASE_MASTER_PORTEdit these values in backend_worker.py:
CHECKPOINTS_DIRTOKENIZER_PATHBACKBONE_MODELSSUPERRES_MODELSDECODER_CONFIG_PATHDECODER_CHECKPOINT_PATHThe public model names exposed by /config are intentionally generic:
default_backbonedefault_superresEach worker exposes:
/health/config/generate/download/{filename}The API polls /health to decide whether a worker is idle, busy, or offline.
Check these first:
backend/logs/api.logbackend/logs/worker_0.logGET /statusGET /job/{job_id}Common causes:
Check:
ffmpeg errorsbackend/generated_audio//download/{filename} from the worker