Buckets:
| import"../chunks/DsnmJJEf.js";import{i as J,h as N,C as z,H as t,D as o,E as I,s as C,a as F}from"../chunks/BLbO27j4.js";import{p as G,o as V,s as e,f as X,a as T,b as q,c as n,d as w,n as r,r as s}from"../chunks/jDjavuwI.js";import{E as P}from"../chunks/DFZbkwCk.js";const Z='{"title":"AutoencoderSAME","local":"autoencodersame","sections":[{"title":"AutoencoderSAME","local":"diffusers.AutoencoderSAME","sections":[],"depth":2},{"title":"SAMETransformerResamplingBlock","local":"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock","sections":[],"depth":2},{"title":"AutoencoderSAMEOutput","local":"diffusers.models.autoencoders.autoencoder_same.AutoencoderSAMEOutput","sections":[],"depth":2},{"title":"AutoencoderSAMEDecoderOutput","local":"diffusers.models.autoencoders.autoencoder_same.AutoencoderSAMEDecoderOutput","sections":[],"depth":2}],"depth":1}';var j=w('<meta name="hf:doc:metadata"/>'),Y=w(`<p></p> <!> <!> <p>The <strong>SAME</strong> (Semantically-Aligned Music Encoder) autoencoder is used by <a href="https://stability.ai/news/stable-audio-3" rel="nofollow">Stable Audio 3</a> to compress stereo audio waveforms into a compact latent sequence and reconstruct them.</p> <p>The encoder stacks <code>SAMETransformerResamplingBlock</code> modules, each of which groups a fixed number of audio | |
| patch frames and produces one learnable output token via a differential transformer. The decoder inverts this | |
| process, expanding each latent token back to a patch of audio frames.</p> <p>A soft-norm bottleneck (<code>SoftNormBottleneck</code>) normalises latents before and after the diffusion model, | |
| providing stable training dynamics.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Semantically-Aligned Music Encoder (SAME) autoencoder from <em>Stable Audio 3</em> (<a href="https://arxiv.org/abs/2605.17991" rel="nofollow">arXiv 2605.17991</a>).</p> <p>The model consists of:</p> <ul><li><strong>Patch embedding</strong> — reshapes stereo audio into non-overlapping patches, trading time for channels (<code>patch_size ×</code> downsample, no learned params).</li> <li><strong>Encoder TRB stack</strong> — <code>SAMETransformerResamplingBlock</code> blocks that further downsample by a factor of <code>∏(encoder_strides)</code>.</li> <li><strong>Soft-norm bottleneck</strong> — learnable affine normalisation with running std.</li> <li><strong>Decoder TRB stack</strong> — mirrors the encoder in reverse.</li> <li><strong>Unpatch</strong> — reshapes channels back into the time dimension.</li></ul> <p>Total downsampling ratio: <code>patch_size × ∏(encoder_strides)</code>.</p> <p>The default hyperparameters match the <strong>SAME-S</strong> checkpoint (<code>stabilityai/SAME-S</code>). To load <strong>SAME-L</strong> (<code>stabilityai/SAME-L</code>, used by SA3 Medium) pass <code>encoder_channels=256, encoder_transformer_depths=(12,)</code>.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Encode stereo audio to latents.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Decode latents back to stereo audio.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Encode and immediately decode <em>sample</em> (reconstruction).</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Core building block of SAME.</p> <p><strong>Encoder mode</strong> (stride S): | |
| Groups S consecutive input frames into one segment, appends a single learnable output embedding, then runs D | |
| transformer layers over the full flattened segment sequence and keeps only the output embedding → downsample by | |
| S.</p> <p><strong>Decoder mode</strong> (stride S): | |
| Groups 1 input frame with S learnable output embeddings, runs D transformer layers over the full flattened | |
| sequence, then keeps the S output embeddings → upsample by S.</p> <p>Attention uses an overlapping <em>sliding-window</em> band mask over the flattened segment sequence: each token attends to <code>sliding_window * (stride + 1)</code> neighbours on each side. RoPE is computed over the full sequence length. This | |
| matches the reference implementation exactly (a single non-overlapping chunk would only match for one segment).</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Output of <a href="/docs/diffusers/pr_14921/en/api/models/autoencoder_same#diffusers.AutoencoderSAME.encode">AutoencoderSAME.encode()</a>.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Output of <a href="/docs/diffusers/pr_14921/en/api/models/autoencoder_same#diffusers.AutoencoderSAME.decode">AutoencoderSAME.decode()</a>.</p></div> <!> <p></p>`,1);function K(y,k){G(k,!1),V(()=>{new URLSearchParams(window.location.search).get("fw")}),J();var p=Y();N("4zyhqf",a=>{var f=j();C(f,"content",Z),T(a,f)});var h=e(X(p),2);z(h,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var g=e(h,2);t(g,{title:"AutoencoderSAME",local:"autoencodersame",headingTag:"h1"});var _=e(g,8);t(_,{title:"AutoencoderSAME",local:"diffusers.AutoencoderSAME",headingTag:"h2"});var d=e(_,2),A=n(d);o(A,{name:"class diffusers.AutoencoderSAME",anchor:"diffusers.AutoencoderSAME",source:"https://github.com/huggingface/diffusers/blob/vr_14921/src/diffusers/models/autoencoders/autoencoder_same.py#L608",parameters:[{name:"audio_channels",val:": int = 2"},{name:"patch_size",val:": int = 256"},{name:"encoder_channels",val:": int = 128"},{name:"encoder_c_mults",val:": typing.List[int] = (6,)"},{name:"encoder_strides",val:": typing.List[int] = (16,)"},{name:"encoder_transformer_depths",val:": typing.List[int] = (6,)"},{name:"latent_dim",val:": int = 256"},{name:"use_differential_attention",val:": bool = True"},{name:"dim_heads",val:": int = 64"},{name:"ff_mult",val:": int = 3"},{name:"sliding_window",val:": int = 1"},{name:"encoder_sinusoidal_blocks",val:": typing.List[int] = (0,)"},{name:"decoder_sinusoidal_blocks",val:": typing.List[int] = (0,)"},{name:"sampling_rate",val:": int = 44100"}],parametersDescription:[{anchor:"diffusers.AutoencoderSAME.audio_channels",description:"<strong>audio_channels</strong> — Number of audio channels (2 for stereo).",name:"audio_channels"},{anchor:"diffusers.AutoencoderSAME.patch_size",description:`<strong>patch_size</strong> — Non-overlapping patch size applied before the TRB encoder | |
| (and reversed after the TRB decoder). Contributes <code>patch_size ×</code> to the total downsampling ratio. | |
| Production value: 256.`,name:"patch_size"},{anchor:"diffusers.AutoencoderSAME.encoder_channels",description:`<strong>encoder_channels</strong> — Base channel count for the TRB. 128 for SAME-S, | |
| 256 for SAME-L.`,name:"encoder_channels"},{anchor:"diffusers.AutoencoderSAME.encoder_c_mults",description:`<strong>encoder_c_mults</strong> — Channel multiplier for each TRB level (one entry per | |
| TRB). Both SAME-S and SAME-L use <code>(6,)</code> — a single TRB whose hidden dimension is <code>encoder_channels × 6</code>.`,name:"encoder_c_mults"},{anchor:"diffusers.AutoencoderSAME.encoder_strides",description:`<strong>encoder_strides</strong> — Down-/up-sampling stride for each TRB level. Both | |
| SAME-S and SAME-L use <code>(16,)</code> — one TRB with stride 16.`,name:"encoder_strides"},{anchor:"diffusers.AutoencoderSAME.encoder_transformer_depths",description:`<strong>encoder_transformer_depths</strong> — Transformer layers per TRB level. | |
| 6 for SAME-S, 12 for SAME-L.`,name:"encoder_transformer_depths"},{anchor:"diffusers.AutoencoderSAME.latent_dim",description:"<strong>latent_dim</strong> — Dimensionality of the latent space. 256 for both variants.",name:"latent_dim"},{anchor:"diffusers.AutoencoderSAME.use_differential_attention",description:`<strong>use_differential_attention</strong> — If <code>True</code>, use differential attention | |
| inside each TRB transformer block (default on for SAME-S/L).`,name:"use_differential_attention"},{anchor:"diffusers.AutoencoderSAME.dim_heads",description:"<strong>dim_heads</strong> — Attention head dimension. 64 for production SAME-S/L.",name:"dim_heads"},{anchor:"diffusers.AutoencoderSAME.ff_mult",description:"<strong>ff_mult</strong> — SwiGLU feed-forward expansion factor.",name:"ff_mult"},{anchor:"diffusers.AutoencoderSAME.sliding_window",description:`<strong>sliding_window</strong> — Sliding-window half-width (in latents) for the band-mask | |
| attention. Production SAME-S/L use 1.`,name:"sliding_window"},{anchor:"diffusers.AutoencoderSAME.encoder_sinusoidal_blocks",description:`<strong>encoder_sinusoidal_blocks</strong> — Per-TRB count of trailing transformer layers | |
| that use <code>sin</code> FFN gating in the encoder (SAME-L: <code>(0,)</code>).`,name:"encoder_sinusoidal_blocks"},{anchor:"diffusers.AutoencoderSAME.decoder_sinusoidal_blocks",description:`<strong>decoder_sinusoidal_blocks</strong> — Per-TRB count of trailing transformer layers | |
| that use <code>sin</code> FFN gating in the decoder (SAME-L: <code>(8,)</code>).`,name:"decoder_sinusoidal_blocks"},{anchor:"diffusers.AutoencoderSAME.sampling_rate",description:"<strong>sampling_rate</strong> — Audio sample rate in Hz (e.g. 44100).",name:"sampling_rate"}]});var b=e(A,12);P(b,{anchor:"diffusers.AutoencoderSAME.example",children:(a,f)=>{F(a,{code:"JTIzJTIwU0FNRS1TJTIwKDEwOCUyME0lMjBwYXJhbXMlMkMlMjB1c2VkJTIwYnklMjBTQTMlMjBzbWFsbCUyMG1vZGVscyklMjBtb2RlbCUyMCUzRCUyMEF1dG9lbmNvZGVyU0FNRSgpJTIwJTIzJTIwZGVmYXVsdCUyMHZhbHVlcyUwQSUwQSUyMyUyMFNBTUUtTCUyMCg4NTIlMjBNJTIwcGFyYW1zJTJDJTIwdXNlZCUyMGJ5JTIwU0EzJTIwTWVkaXVtKSUyMG1vZGVsJTIwJTNEJTIwQXV0b2VuY29kZXJTQU1FKGVuY29kZXJfY2hhbm5lbHMlM0QyNTYlMkMlMEFlbmNvZGVyX3RyYW5zZm9ybWVyX2RlcHRocyUzRCgxMiUyQykp",highlighted:`<span class="hljs-comment"># SAME-S (108 M params, used by SA3 small models) model = AutoencoderSAME() # default values</span> | |
| <span class="hljs-comment"># SAME-L (852 M params, used by SA3 Medium) model = AutoencoderSAME(encoder_channels=256,</span> | |
| encoder_transformer_depths=(<span class="hljs-number">12</span>,))`,lang:"python",wrap:!1})},$$slots:{default:!0}});var i=e(b,2),x=n(i);o(x,{name:"encode",anchor:"diffusers.AutoencoderSAME.encode",source:"https://github.com/huggingface/diffusers/blob/vr_14921/src/diffusers/models/autoencoders/autoencoder_same.py#L733",parameters:[{name:"sample",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderSAME.encode.sample",description:"<strong>sample</strong> — <code>(B, audio_channels, T)</code> waveform tensor.",name:"sample"},{anchor:"diffusers.AutoencoderSAME.encode.return_dict",description:"<strong>return_dict</strong> — If <code>True</code> return an <code>AutoencoderSAMEOutput</code>.",name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Latent tensor of shape <code>(B, latent_dim, T // downsampling_ratio)</code> (wrapped in | |
| <code>AutoencoderSAMEOutput</code> when <em>return_dict</em> is <code>True</code>).</p> | |
| `}),r(2),s(i);var c=e(i,2),B=n(c);o(B,{name:"decode",anchor:"diffusers.AutoencoderSAME.decode",source:"https://github.com/huggingface/diffusers/blob/vr_14921/src/diffusers/models/autoencoders/autoencoder_same.py#L758",parameters:[{name:"latents",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderSAME.decode.latents",description:"<strong>latents</strong> — <code>(B, latent_dim, T_latent)</code> latent tensor.",name:"latents"},{anchor:"diffusers.AutoencoderSAME.decode.return_dict",description:"<strong>return_dict</strong> — If <code>True</code> return an <code>AutoencoderSAMEDecoderOutput</code>.",name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Waveform tensor of shape <code>(B, audio_channels, T_latent × downsampling_ratio)</code> (wrapped in | |
| <code>AutoencoderSAMEDecoderOutput</code> when <em>return_dict</em> is <code>True</code>).</p> | |
| `}),r(2),s(c);var S=e(c,2),R=n(S);o(R,{name:"forward",anchor:"diffusers.AutoencoderSAME.forward",source:"https://github.com/huggingface/diffusers/blob/vr_14921/src/diffusers/models/autoencoders/autoencoder_same.py#L783",parameters:[{name:"sample",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderSAME.forward.sample",description:"<strong>sample</strong> — <code>(B, audio_channels, T)</code> waveform tensor.",name:"sample"},{anchor:"diffusers.AutoencoderSAME.forward.return_dict",description:"<strong>return_dict</strong> — If <code>True</code> return an <code>AutoencoderSAMEDecoderOutput</code>.",name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>Reconstructed waveform (same shape as <em>sample</em>, possibly longer due to padding), wrapped in | |
| <code>AutoencoderSAMEDecoderOutput</code> when <em>return_dict</em> is <code>True</code>.</p> | |
| `}),r(2),s(S),s(d);var M=e(d,2);t(M,{title:"SAMETransformerResamplingBlock",local:"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock",headingTag:"h2"});var l=e(M,2),D=n(l);o(D,{name:"class diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock",anchor:"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock",source:"https://github.com/huggingface/diffusers/blob/vr_14921/src/diffusers/models/autoencoders/autoencoder_same.py#L294",parameters:[{name:"in_channels",val:": int"},{name:"out_channels",val:": int"},{name:"stride",val:": int"},{name:"mode",val:": str = 'encoder'"},{name:"transformer_depth",val:": int = 3"},{name:"dim_heads",val:": int = 128"},{name:"use_differential",val:": bool = True"},{name:"ff_mult",val:": int = 3"},{name:"sliding_window",val:": int = 1"},{name:"sinusoidal_blocks",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock.in_channels",description:"<strong>in_channels</strong> — Number of input channels.",name:"in_channels"},{anchor:"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock.out_channels",description:"<strong>out_channels</strong> — Number of output channels.",name:"out_channels"},{anchor:"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock.stride",description:"<strong>stride</strong> — Down-/up-sampling factor.",name:"stride"},{anchor:"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock.mode",description:"<strong>mode</strong> — <code>"encoder"</code> or <code>"decoder"</code>.",name:"mode"},{anchor:"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock.transformer_depth",description:"<strong>transformer_depth</strong> — Number of <code>TransformerBlock</code> layers.",name:"transformer_depth"},{anchor:"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock.dim_heads",description:"<strong>dim_heads</strong> — Attention head dimension.",name:"dim_heads"},{anchor:"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock.use_differential",description:"<strong>use_differential</strong> — Whether to use differential attention.",name:"use_differential"},{anchor:"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock.ff_mult",description:"<strong>ff_mult</strong> — Feed-forward expansion factor.",name:"ff_mult"},{anchor:"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock.sliding_window",description:"<strong>sliding_window</strong> — Sliding-window half-width in latents (band half-width is <code>sliding_window * (stride + 1)</code>).",name:"sliding_window"},{anchor:"diffusers.models.autoencoders.autoencoder_same.SAMETransformerResamplingBlock.sinusoidal_blocks",description:"<strong>sinusoidal_blocks</strong> — Number of trailing transformer layers that use <code>sin</code> FFN gating instead of SiLU.",name:"sinusoidal_blocks"}]}),r(8),s(l);var v=e(l,2);t(v,{title:"AutoencoderSAMEOutput",local:"diffusers.models.autoencoders.autoencoder_same.AutoencoderSAMEOutput",headingTag:"h2"});var u=e(v,2),L=n(u);o(L,{name:"class diffusers.models.autoencoders.autoencoder_same.AutoencoderSAMEOutput",anchor:"diffusers.models.autoencoders.autoencoder_same.AutoencoderSAMEOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14921/src/diffusers/models/autoencoders/autoencoder_same.py#L52",parameters:[{name:"latents",val:": Tensor"}]}),r(2),s(u);var E=e(u,2);t(E,{title:"AutoencoderSAMEDecoderOutput",local:"diffusers.models.autoencoders.autoencoder_same.AutoencoderSAMEDecoderOutput",headingTag:"h2"});var m=e(E,2),U=n(m);o(U,{name:"class diffusers.models.autoencoders.autoencoder_same.AutoencoderSAMEDecoderOutput",anchor:"diffusers.models.autoencoders.autoencoder_same.AutoencoderSAMEDecoderOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14921/src/diffusers/models/autoencoders/autoencoder_same.py#L59",parameters:[{name:"sample",val:": Tensor"}]}),r(2),s(m);var O=e(m,2);I(O,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/autoencoder_same.md"}),r(2),T(y,p),q()}export{K as component}; | |
Xet Storage Details
- Size:
- 17.8 kB
- Xet hash:
- 305b66dc98cc84c555550f0faacfadafa604ea900d0a8f7762de00de6853034f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.