Skip to content

Deploy Audiocraft Musicgen on Amazon SageMaker using SageMaker Endpoints for Async Inference.

License

Notifications You must be signed in to change notification settings

aws-samples/inference-audiocraft-musicgen-on-amazon-sagemaker

Inference Audiocraft Musicgen on Amazon SageMaker

Deploy Audiocraft Musicgen on Amazon SageMaker using SageMaker Endpoints for Async Inference.

👉 Blog: Inference AudioCraft MusicGen models using Amazon SageMaker

This solution demonstrates deploying AudioCraft MusicGen models from HuggingFace on Amazon SageMaker. MusicGen models take natural language text as input prompt and generate music as output.

MusicGen Models

AudioCraft consists of three models: MusicGen, AudioGen, and EnCodec. This repo aims to deploy MusicGen models on Amazon SageMaker for Asynchronous inferencing.

Solution Overview

Solution Overview

  1. The user invokes the SageMaker Asynchronous endpoint using a SageMaker Studio Notebook.
  2. The input payload is uploaded to an S3 bucket for inference. The payload consists of both the prompt and the music generation parameters. The generated music will be downloaded from the S3 bucket.
  3. The facebook/musicgen-large model will be deployed to a SageMaker Asynchronous endpoint. This endpoint will be used to infer for music generation.
  4. The HuggingFace Inference Containers image will be used as a base image. We will use an image that supports PyTorch 2.1.0 with a HuggingFace transformers framework.
  5. The SageMaker HuggingFaceModel will be deployed to a SageMaker Asynchronous endpoint.
  6. The HuggingFace model, facebook/musicgen-large in the scope of this blog, will be uploaded to S3 during the deployment. Also, during the inference, the generated outputs will be uploaded to S3.
  7. Amazon SNS topics to notify the success and failure are defined as a part of SageMaker Asynchronous inference configuration.

Asynchronous Inference Sequence flow for huggingface model facebook/musicgen-large on Amazon SageMaker

Async inference endpoint sequence flow

Deployment and inference notebooks

The deployment notebooks used in this repo uses Huggingface as model provider for the musicgen models. The corresponding deployment and inference noteboks for the respective models are tablulated below.

Huggingace Model ID Deploy Notebook Inference Notebook
facebook/musicgen-large Deploy Inference
facebook/musicgen-medium Deploy Inference
facebook/musicgen-small Deploy Inference

References

Security

See CONTRIBUTING for more information.

Citation

@inproceedings{copet2023simple,
    title={Simple and Controllable Music Generation},
    author={Jade Copet and Felix Kreuk and Itai Gat and Tal Remez and David Kant and Gabriel Synnaeve and Yossi Adi and Alexandre DĂ©fossez},
    booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
    year={2023},
}

License

This library is licensed under the MIT-0 License. See the LICENSE file.