text
stringlengths
0
5.54k
Enable sliced VAE decoding.
When this option is enabled, the VAE will split the input tensor in slices to compute decoding in several
steps. This is useful to save some memory and allow larger batch sizes.
disable_vae_slicing
<
source
>
(
)
Disable sliced VAE decoding. If enable_vae_slicing was previously invoked, this method will go back to
computing decoding in one step.
enable_xformers_memory_efficient_attention
<
source
>
(
attention_op: typing.Optional[typing.Callable] = None
)
Parameters
attention_op (Callable, optional) —
Override the default None operator for use as op argument to the
memory_efficient_attention()
function of xFormers.
Enable memory efficient attention as implemented in xformers.
When this option is enabled, you should observe lower GPU memory usage and a potential speed up at inference
time. Speed up at training time is not guaranteed.
Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.
Examples:
Copied
>>> import torch
>>> from diffusers import DiffusionPipeline
>>> from xformers.ops import MemoryEfficientAttentionFlashAttentionOp
>>> pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16)
>>> pipe = pipe.to("cuda")
>>> pipe.enable_xformers_memory_efficient_attention(attention_op=MemoryEfficientAttentionFlashAttentionOp)
>>> # Workaround for not accepting attention shape using VAE for Flash Attention
>>> pipe.vae.enable_xformers_memory_efficient_attention(attention_op=None)
disable_xformers_memory_efficient_attention
<
source
>
(
)
Disable memory efficient attention as implemented in xformers.
enable_vae_tiling
<
source
>
(
)
Enable tiled VAE decoding.
When this option is enabled, the VAE will split the input tensor into tiles to compute decoding and encoding in
several steps. This is useful to save a large amount of memory and to allow the processing of larger images.
disable_vae_tiling
<
source
>
(
)
Disable tiled VAE decoding. If enable_vae_tiling was previously invoked, this method will go back to
computing decoding in one step.
enable_model_cpu_offload