Template Components
The ComfyUI ACE Step template includes: In the Docker Image:- ComfyUI
- ComfyUI API Wrapper
- Stable Diffusion 1.5 (for benchmarking)
- PyWorker (comfyui-json worker)
- Provisioning Script for custom configuration
- Adds cron job to remove older output files (older than 24 hours) if available disk space is less than 512MB
- Adds benchmarking workflow file
- Downloads ACE Step v1 3.5B model (
checkpoints/ace_step_v1_3.5b.safetensors)
Before using this template, familiarize yourself with the Serverless Documentation and Getting Started With Serverless guide. Learn more about ACE Step v1 3.5B on Hugging Face.
Environment Variables
Required for S3 Storage
The API wrapper manages asset uploads to S3-compatible storage. Configure these variables in your Account Settings:S3_ACCESS_KEY_ID(string): Access key ID for S3-compatible storageS3_SECRET_ACCESS_KEY(string): Secret access key for S3-compatible storageS3_BUCKET_NAME(string): Bucket name for S3-compatible storageS3_ENDPOINT_URL(string): Endpoint URL for S3-compatible storageS3_REGION(string): Optional region for S3-compatible storage
These S3 values can be overridden on a per-request basis in the request payload.
Optional Configuration
WEBHOOK_URL(string): Optional webhook to call after generation completion or failurePYWORKER_REPO(string): Custom PyWorker git repository URL (default: https://github.com/vast-ai/pyworker)PYWORKER_REF(string): Git reference to checkout from PyWorker repository
Store sensitive information like API keys in the ‘Environment Variables’ section of your Account Settings. These will be available in all instances you create.
Worker Startup Process
When a worker is first started with this template, the following will happen:- Docker image is downloaded if not already cached on the host machine
- Worker (Docker container) is created on the host machine
- Template on-start script is executed:
- Docker image entrypoint is executed
- Download and run provisioning script (remotely stored Bash script)
- Start supervisord (ComfyUI & API wrapper process manager)
- Current version of Vast PyWorker bootstrapping script is downloaded and executed
- ComfyUI and API Wrapper become available
- PyWorker begins benchmarking
- Benchmarking completes and worker score is sent to the serverless system
- Ready (hot): Worker is fully initialized and immediately available to process requests. You pay for idle time.
- Inactive (cold): Worker is shut down to save costs. You pay only for storage.
Benchmarking
An ACE Step music generation benchmark runs when each worker initializes to validate GPU performance and identify underperforming machines. The benchmark file is downloaded on first start and stored in the pyworker directory atworkers/comfyui-json/misc/benchmark.json. The workflow is static but a random seed will be generated for each benchmarking run.
Performance expectations:
- Benchmark duration should remain consistent across identical GPU models
- Significant variation (>20%) may indicate thermal, power, or configuration issues
Understanding Worker Scores
The benchmarking system calculates a performance score for each worker that determines how requests are distributed: How scoring works:- Each benchmark is assigned a baseline complexity score of
100(representing 100% of the work) - If a worker completes the benchmark in 100 seconds, it receives a score of
1.0(it processes 1% of the work per second) - If a worker completes the same benchmark in 50 seconds, it receives a score of
2.0(twice as fast) - If a worker completes the same benchmark in 200 seconds, it receives a score of
0.5(half as fast)
- Faster workers (higher scores) receive more requests proportionally
- To serve 1 request per second on average with score-1.0 workers, you need 100 workers
- With score-2.0 workers, you only need 50 workers for the same throughput
- The system automatically balances load based on these scores
If you choose to use your own worker code, it’s recommended to implement a custom benchmark that closely matches the music generation workflows you intend to process.
Endpoints
The ComfyUI ACE Step template provides endpoints for executing workflows and generating music. After obtaining a worker address from the/route/ endpoint (see route documentation), you can send requests to the following endpoints.
/generate/sync
The primary endpoint for submitting ComfyUI workflows. This endpoint accepts complete, user-defined ComfyUI workflows in JSON format and processes them synchronously.Request Structure
Input
payload:
input:request_id(string): Optional unique identifier for tracking the requestworkflow_json(object): Complete ComfyUI workflow graph in JSON formats3(object): Optional S3 configuration overrideaccess_key_id(string)secret_access_key(string)endpoint_url(string)bucket_name(string)region(string)
webhook(object): Optional webhook configurationurl(string): Webhook URL to call after generationextra_params(object): Additional parameters to include in webhook payload
The string
"__RANDOM_INT__" in your workflow will be replaced with a random integer prior to posting the workflow to ComfyUI, allowing for varied outputs without manually specifying different seeds.Outputs
id(string): Unique identifier for the requeststatus(string): Request status -completed,failed,processing,generating, orqueuedmessage(string): Human-readable status messagecomfyui_response(object): Detailed response from ComfyUI including:prompt: The workflow that was executedoutputs: Generated outputs organized by node IDstatus: Execution status with completion messages and timestampsmeta: Metadata about the executionexecution_details: Progress updates and timing information with detailed progress_updates array showing generation progress
output(array): Array of output objects, each containing:filename(string): Name of the generated file (e.g., “ComfyUI_00006_.mp3”)local_path(string): Path to file on workerurl(string): Pre-signed URL for downloading the generated audio asset (if S3 is configured)type(string): Output type (e.g., “output”)subfolder(string): Subfolder within output directory (e.g., “audio”)node_id(string): ComfyUI node that produced this outputoutput_type(string): Type of output (e.g., “audio”)
timings(object): Timing information for the request
JSON
Ensure that the ACE Step model and any required custom nodes are already installed before sending a request. This template pre-installs the ACE Step v1 3.5B model during first boot.
Testing Before Deployment
Although this template is designed for serverless deployment, you can test it as an interactive instance first. To access ComfyUI and the API wrapper:- Start an interactive instance with this template
- Connect via SSH with port forwarding:
- Access ComfyUI at http://localhost:18188
- Access the API Wrapper documentation at http://localhost:18288/docs
About ACE Step v1 3.5B
ACE Step v1 3.5B is a text-to-music generation model that creates audio from text prompts including lyrics and musical style tags. The model generates music up to 180 seconds in length with high-quality audio output. Key features:- Text-to-music generation with lyrics support
- Musical style control via tags (genre, instruments, tempo, mood)
- Adjustable lyrics strength parameter
- High-quality MP3 audio output
- Supports up to 180 seconds of audio generation