MusicForge's picture
Mirror from aufklarer/Stable-Audio-3-DiT-Medium-MLX-8bit
d1d04ee verified
|
Raw History Blame Contribute Delete
4.07 kB
---
license: other
license_name: stability-ai-community-license
license_link: https://stability.ai/license
language:
- en
tags:
- mlx
- audio
- text-to-audio
- music
- sfx
- latent-diffusion
- inpainting
- dit
- stable-audio-3
- quantized
- int8
base_model: stabilityai/stable-audio-3-optimized
library_name: mlx
pipeline_tag: text-to-audio
---
# Stable-Audio-3-DiT-Medium-MLX-8bit
- [speech-swift](https://github.com/soniqo/speech-swift) β€” Apple SDK
- [soniqo.audio](https://soniqo.audio) β€” website
- [blog](https://soniqo.audio/blog) β€” blog
MLX port of [Stability AI Stable Audio 3 (optimized)](https://huggingface.co/stabilityai/stable-audio-3-optimized).
Latent-diffusion text-to-audio with **mask-based inpainting** and continuation, with the DiT denoiser quantized to **INT8** for Apple Silicon.
## What's in this bundle
| Component | Format | Notes |
|---|---|---|
| DiT (Medium, 1.4B) | **INT8** | Diffusion Transformer denoiser, group-size 64 |
| SAME-L encoder | FP32 | Audio β†’ latents (codec is precision-sensitive β€” differential attention cancels in FP16) |
| SAME-L decoder | FP32 | Latents β†’ 44.1 kHz stereo waveform |
| T5Gemma text encoder | FP16 | Prompt conditioning |
Codec stays FP32 because the SAME differential attention catastrophically cancels in FP16 (per Stability's own MLX runtime). T5Gemma stays FP16 β€” it's small relative to the DiT and quantization gives no speed-up on the short prompt encode pass.
## Files
| File | Size | Format |
|---|---|---|
| `dit_medium/model.safetensors` | 1 GB | int8 |
| `same_l_encoder/model.safetensors` | 2 GB | fp32 |
| `same_l_decoder/model.safetensors` | 2 GB | fp32 |
| `t5gemma/model.safetensors` | 541 MB | fp16 |
## Capabilities
- **Text-to-audio** generation (music + SFX depending on DiT specialisation)
- **Inpainting / region editing** via masked latent diffusion
- **Audio continuation** from a short prompt clip
- **Variable-length** generation up to several minutes
The `DiT-Small-Music-*` variant is music-specialised; `DiT-Small-SFX-*` is sound-effects specialised; `DiT-Medium-*` is the higher-quality general model.
## Usage
This bundle is the quantized weights only β€” inference uses Stability AI's official pure-MLX runtime at [`stable-audio-3/optimized/mlx`](https://github.com/Stability-AI/stable-audio-3/tree/main/optimized/mlx). At load time, each `(base.weight, base.scales, base.biases)` triplet is dequantized via `mlx.core.dequantize` back to FP16; codec and T5Gemma load as-is.
```python
from huggingface_hub import snapshot_download
import mlx.core as mx
bundle = snapshot_download("aufklarer/Stable-Audio-3-DiT-Medium-MLX-8bit")
def load_component(comp_dir):
w = dict(mx.load(f"{comp_dir}/model.safetensors"))
bases = {k[:-7] for k in w if k.endswith(".scales")
if f"{k[:-7]}.weight" in w and f"{k[:-7]}.biases" in w}
out = {}
for k, v in w.items():
if k.endswith((".scales", ".biases")) and k.rsplit(".", 1)[0] in bases:
continue
if k.endswith(".weight") and k[:-7] in bases:
base = k[:-7]
out[k] = mx.dequantize(w[f"{base}.weight"], w[f"{base}.scales"],
w[f"{base}.biases"], group_size=64, bits=8)
else:
out[k] = v
return out
```
Plug the rehydrated dict into the matching model class from `stable-audio-3/optimized/mlx/models/defs/`.
## Source
- Upstream weights: [stabilityai/stable-audio-3-optimized](https://huggingface.co/stabilityai/stable-audio-3-optimized) (Stability AI Community License)
- Text encoder lineage: [google/t5gemma-b-b-ul2](https://huggingface.co/google/t5gemma-b-b-ul2) (Gemma Terms of Use)
- Paper: [Stable Audio 3 β€” Stability AI](https://arxiv.org/abs/2605.17991)
## License
**Stability AI Community License** β€” free for non-commercial research and for commercial use up to the revenue threshold defined by Stability AI; see the [license text](https://stability.ai/license). T5Gemma component additionally inherits the **Gemma Terms of Use**.