Add torch211-cxx11-cu130-aarch64-linux SM110 artifact
Browse files- build/torch211-cxx11-cu130-aarch64-linux/__init__.py +404 -0
- build/torch211-cxx11-cu130-aarch64-linux/_diffusion_step_ops_cuda_7781728.abi3.so +3 -0
- build/torch211-cxx11-cu130-aarch64-linux/_ops.py +6 -0
- build/torch211-cxx11-cu130-aarch64-linux/diffusion_step_ops/__init__.py +14 -0
- build/torch211-cxx11-cu130-aarch64-linux/metadata.json +22 -0
build/torch211-cxx11-cu130-aarch64-linux/__init__.py
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FlashRT diffusion step helper kernels."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing import Optional
|
| 6 |
+
|
| 7 |
+
import torch
|
| 8 |
+
|
| 9 |
+
from ._ops import add_op_namespace_prefix, ops
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def _check_same_shape(a: torch.Tensor, b: torch.Tensor, c: torch.Tensor | None = None) -> None:
|
| 13 |
+
if a.shape != b.shape:
|
| 14 |
+
raise RuntimeError("input tensors must have the same shape")
|
| 15 |
+
if c is not None and a.shape != c.shape:
|
| 16 |
+
raise RuntimeError("output tensor must have the same shape as inputs")
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
@torch.library.register_fake(add_op_namespace_prefix("add_bf16_out"))
|
| 20 |
+
def _add_bf16_out_fake(a: torch.Tensor, b: torch.Tensor, out: torch.Tensor) -> None:
|
| 21 |
+
_check_same_shape(a, b, out)
|
| 22 |
+
return None
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
@torch.library.register_fake(add_op_namespace_prefix("euler_step_bf16_out"))
|
| 26 |
+
def _euler_step_bf16_out_fake(
|
| 27 |
+
latent: torch.Tensor,
|
| 28 |
+
velocity: torch.Tensor,
|
| 29 |
+
dt: float,
|
| 30 |
+
out: torch.Tensor,
|
| 31 |
+
) -> None:
|
| 32 |
+
_check_same_shape(latent, velocity, out)
|
| 33 |
+
return None
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
@torch.library.register_fake(add_op_namespace_prefix("cfg_combine_into_residual_bf16"))
|
| 37 |
+
def _cfg_combine_into_residual_bf16_fake(
|
| 38 |
+
residual: torch.Tensor,
|
| 39 |
+
v_cond: torch.Tensor,
|
| 40 |
+
v_uncond: torch.Tensor,
|
| 41 |
+
beta: float,
|
| 42 |
+
) -> None:
|
| 43 |
+
_check_same_shape(residual, v_cond, v_uncond)
|
| 44 |
+
return None
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
@torch.library.register_fake(add_op_namespace_prefix("cfg_combine_into_residual_fp16"))
|
| 48 |
+
def _cfg_combine_into_residual_fp16_fake(
|
| 49 |
+
residual: torch.Tensor,
|
| 50 |
+
v_cond: torch.Tensor,
|
| 51 |
+
v_uncond: torch.Tensor,
|
| 52 |
+
beta: float,
|
| 53 |
+
) -> None:
|
| 54 |
+
_check_same_shape(residual, v_cond, v_uncond)
|
| 55 |
+
return None
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
@torch.library.register_fake(add_op_namespace_prefix("teacher_force_first_frame_bf16"))
|
| 59 |
+
def _teacher_force_first_frame_bf16_fake(
|
| 60 |
+
video_latent: torch.Tensor,
|
| 61 |
+
cond_latent: torch.Tensor,
|
| 62 |
+
) -> None:
|
| 63 |
+
if video_latent.dim() != 5:
|
| 64 |
+
raise RuntimeError("video_latent must have shape (B, C, T, H, W)")
|
| 65 |
+
if cond_latent.shape != (
|
| 66 |
+
video_latent.shape[0],
|
| 67 |
+
video_latent.shape[1],
|
| 68 |
+
video_latent.shape[3],
|
| 69 |
+
video_latent.shape[4],
|
| 70 |
+
):
|
| 71 |
+
raise RuntimeError("cond_latent must have shape (B, C, H, W)")
|
| 72 |
+
return None
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
@torch.library.register_fake(add_op_namespace_prefix("motus_decode_postprocess_bf16_to_fp32"))
|
| 76 |
+
def _motus_decode_postprocess_bf16_to_fp32_fake(
|
| 77 |
+
decoded: torch.Tensor,
|
| 78 |
+
out: torch.Tensor,
|
| 79 |
+
) -> None:
|
| 80 |
+
if decoded.dim() != 5:
|
| 81 |
+
raise RuntimeError("decoded must have shape (B, C, T_in, H, W)")
|
| 82 |
+
if decoded.shape[2] < 2:
|
| 83 |
+
raise RuntimeError("decoded T_in must be >= 2")
|
| 84 |
+
expected = (decoded.shape[0], decoded.shape[1], decoded.shape[2] - 1, decoded.shape[3], decoded.shape[4])
|
| 85 |
+
if out.shape != expected:
|
| 86 |
+
raise RuntimeError("out must have shape (B, C, T_in - 1, H, W)")
|
| 87 |
+
return None
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
@torch.library.register_fake(add_op_namespace_prefix("cast_bf16_to_fp32"))
|
| 91 |
+
def _cast_bf16_to_fp32_fake(src: torch.Tensor, dst: torch.Tensor) -> None:
|
| 92 |
+
if src.shape != dst.shape:
|
| 93 |
+
raise RuntimeError("src and dst must have the same shape")
|
| 94 |
+
return None
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
@torch.library.register_fake(add_op_namespace_prefix("pack_tail_bf16"))
|
| 98 |
+
def _pack_tail_bf16_fake(tail: torch.Tensor, flat_dim: int, out: torch.Tensor) -> None:
|
| 99 |
+
if tail.dim() != 1 or out.shape != (flat_dim,) or flat_dim < tail.numel():
|
| 100 |
+
raise RuntimeError("pack_tail_bf16 expects tail (N,), flat_dim >= N, out (flat_dim,)")
|
| 101 |
+
return None
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
@torch.library.register_fake(add_op_namespace_prefix("add_bias_zero_tail_bf16"))
|
| 105 |
+
def _add_bias_zero_tail_bf16_fake(
|
| 106 |
+
input: torch.Tensor,
|
| 107 |
+
bias: torch.Tensor,
|
| 108 |
+
valid_cols: int,
|
| 109 |
+
out: torch.Tensor,
|
| 110 |
+
) -> None:
|
| 111 |
+
if (
|
| 112 |
+
input.dim() != 2
|
| 113 |
+
or bias.shape != (input.shape[1],)
|
| 114 |
+
or out.shape != input.shape
|
| 115 |
+
or valid_cols < 0
|
| 116 |
+
or valid_cols > input.shape[1]
|
| 117 |
+
):
|
| 118 |
+
raise RuntimeError(
|
| 119 |
+
"add_bias_zero_tail_bf16 expects input/out (rows, cols), "
|
| 120 |
+
"bias (cols,), valid_cols in [0, cols]"
|
| 121 |
+
)
|
| 122 |
+
return None
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
@torch.library.register_fake(add_op_namespace_prefix("extract_tail_f32_to_bf16"))
|
| 126 |
+
def _extract_tail_f32_to_bf16_fake(
|
| 127 |
+
flat: torch.Tensor,
|
| 128 |
+
tail_numel: int,
|
| 129 |
+
out: torch.Tensor,
|
| 130 |
+
) -> None:
|
| 131 |
+
if flat.dim() != 1 or tail_numel <= 0 or tail_numel > flat.numel() or out.shape != (tail_numel,):
|
| 132 |
+
raise RuntimeError(
|
| 133 |
+
"extract_tail_f32_to_bf16 expects flat (N,), tail_numel in [1, N], out (tail_numel,)"
|
| 134 |
+
)
|
| 135 |
+
return None
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
@torch.library.register_fake(add_op_namespace_prefix("add_bias_pair_bf16"))
|
| 139 |
+
def _add_bias_pair_bf16_fake(
|
| 140 |
+
input: torch.Tensor,
|
| 141 |
+
bias_a: torch.Tensor,
|
| 142 |
+
bias_b: torch.Tensor,
|
| 143 |
+
out: torch.Tensor,
|
| 144 |
+
) -> None:
|
| 145 |
+
if (
|
| 146 |
+
input.dim() != 2
|
| 147 |
+
or bias_a.shape != (input.shape[1],)
|
| 148 |
+
or bias_b.shape != bias_a.shape
|
| 149 |
+
or out.shape != input.shape
|
| 150 |
+
):
|
| 151 |
+
raise RuntimeError(
|
| 152 |
+
"add_bias_pair_bf16 expects input/out (rows, hidden) and biases (hidden,)"
|
| 153 |
+
)
|
| 154 |
+
return None
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
@torch.library.register_fake(add_op_namespace_prefix("unipc_step_f32_bf16"))
|
| 158 |
+
def _unipc_step_f32_bf16_fake(
|
| 159 |
+
sample: torch.Tensor,
|
| 160 |
+
velocity: torch.Tensor,
|
| 161 |
+
prev_m1: torch.Tensor,
|
| 162 |
+
prev_m2: torch.Tensor,
|
| 163 |
+
prev_last_sample: torch.Tensor,
|
| 164 |
+
sigma: float,
|
| 165 |
+
corrector_order: int,
|
| 166 |
+
predictor_order: int,
|
| 167 |
+
c_sample: float,
|
| 168 |
+
c_last: float,
|
| 169 |
+
c_prev_m1: float,
|
| 170 |
+
c_prev_m2: float,
|
| 171 |
+
c_curr_m: float,
|
| 172 |
+
p_sample: float,
|
| 173 |
+
p_curr_m: float,
|
| 174 |
+
p_prev_m1: float,
|
| 175 |
+
next_sample: torch.Tensor,
|
| 176 |
+
current_m: torch.Tensor,
|
| 177 |
+
current_last_sample: torch.Tensor,
|
| 178 |
+
) -> None:
|
| 179 |
+
del (
|
| 180 |
+
sigma,
|
| 181 |
+
corrector_order,
|
| 182 |
+
predictor_order,
|
| 183 |
+
c_sample,
|
| 184 |
+
c_last,
|
| 185 |
+
c_prev_m1,
|
| 186 |
+
c_prev_m2,
|
| 187 |
+
c_curr_m,
|
| 188 |
+
p_sample,
|
| 189 |
+
p_curr_m,
|
| 190 |
+
p_prev_m1,
|
| 191 |
+
)
|
| 192 |
+
for tensor in (
|
| 193 |
+
velocity,
|
| 194 |
+
prev_m1,
|
| 195 |
+
prev_m2,
|
| 196 |
+
prev_last_sample,
|
| 197 |
+
next_sample,
|
| 198 |
+
current_m,
|
| 199 |
+
current_last_sample,
|
| 200 |
+
):
|
| 201 |
+
if tensor.shape != sample.shape:
|
| 202 |
+
raise RuntimeError("all UniPC tensors must have the same shape")
|
| 203 |
+
return None
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def add_bf16(a: torch.Tensor, b: torch.Tensor, *, out: Optional[torch.Tensor] = None) -> torch.Tensor:
|
| 207 |
+
"""Return ``a + b`` for contiguous BF16 CUDA tensors."""
|
| 208 |
+
|
| 209 |
+
if out is None:
|
| 210 |
+
out = torch.empty_like(a)
|
| 211 |
+
ops.add_bf16_out(a, b, out)
|
| 212 |
+
return out
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
def euler_step_bf16(
|
| 216 |
+
latent: torch.Tensor,
|
| 217 |
+
velocity: torch.Tensor,
|
| 218 |
+
dt: float,
|
| 219 |
+
*,
|
| 220 |
+
out: Optional[torch.Tensor] = None,
|
| 221 |
+
) -> torch.Tensor:
|
| 222 |
+
"""Return ``latent + velocity * dt`` for BF16 CUDA tensors."""
|
| 223 |
+
|
| 224 |
+
if out is None:
|
| 225 |
+
out = torch.empty_like(latent)
|
| 226 |
+
ops.euler_step_bf16_out(latent, velocity, float(dt), out)
|
| 227 |
+
return out
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
def cfg_combine_into_residual_bf16(
|
| 231 |
+
residual: torch.Tensor,
|
| 232 |
+
v_cond: torch.Tensor,
|
| 233 |
+
v_uncond: torch.Tensor,
|
| 234 |
+
beta: float,
|
| 235 |
+
) -> torch.Tensor:
|
| 236 |
+
"""In-place ``residual += v_uncond + beta * (v_cond - v_uncond)``."""
|
| 237 |
+
|
| 238 |
+
ops.cfg_combine_into_residual_bf16(residual, v_cond, v_uncond, float(beta))
|
| 239 |
+
return residual
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
def cfg_combine_into_residual_fp16(
|
| 243 |
+
residual: torch.Tensor,
|
| 244 |
+
v_cond: torch.Tensor,
|
| 245 |
+
v_uncond: torch.Tensor,
|
| 246 |
+
beta: float,
|
| 247 |
+
) -> torch.Tensor:
|
| 248 |
+
"""FP16 variant of classifier-free guidance residual combine."""
|
| 249 |
+
|
| 250 |
+
ops.cfg_combine_into_residual_fp16(residual, v_cond, v_uncond, float(beta))
|
| 251 |
+
return residual
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
def teacher_force_first_frame_bf16(video_latent: torch.Tensor, cond_latent: torch.Tensor) -> torch.Tensor:
|
| 255 |
+
"""Copy ``cond_latent[:, :, :, :]`` into ``video_latent[:, :, 0, :, :]``."""
|
| 256 |
+
|
| 257 |
+
ops.teacher_force_first_frame_bf16(video_latent, cond_latent)
|
| 258 |
+
return video_latent
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
def motus_decode_postprocess_bf16_to_fp32(
|
| 262 |
+
decoded: torch.Tensor,
|
| 263 |
+
*,
|
| 264 |
+
out: Optional[torch.Tensor] = None,
|
| 265 |
+
) -> torch.Tensor:
|
| 266 |
+
"""Drop the first frame and map BF16 decoded latents from [-1, 1] to [0, 1]."""
|
| 267 |
+
|
| 268 |
+
if out is None:
|
| 269 |
+
out = torch.empty(
|
| 270 |
+
(decoded.shape[0], decoded.shape[1], decoded.shape[2] - 1, decoded.shape[3], decoded.shape[4]),
|
| 271 |
+
device=decoded.device,
|
| 272 |
+
dtype=torch.float32,
|
| 273 |
+
)
|
| 274 |
+
ops.motus_decode_postprocess_bf16_to_fp32(decoded, out)
|
| 275 |
+
return out
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
def cast_bf16_to_fp32(src: torch.Tensor, *, out: Optional[torch.Tensor] = None) -> torch.Tensor:
|
| 279 |
+
"""Cast a BF16 CUDA tensor to FP32."""
|
| 280 |
+
|
| 281 |
+
if out is None:
|
| 282 |
+
out = torch.empty_like(src, dtype=torch.float32)
|
| 283 |
+
ops.cast_bf16_to_fp32(src, out)
|
| 284 |
+
return out
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
def pack_tail_bf16(
|
| 288 |
+
tail: torch.Tensor,
|
| 289 |
+
flat_dim: int,
|
| 290 |
+
*,
|
| 291 |
+
out: Optional[torch.Tensor] = None,
|
| 292 |
+
) -> torch.Tensor:
|
| 293 |
+
"""Place a BF16 tail at the end of a zero-filled flat BF16 tensor."""
|
| 294 |
+
|
| 295 |
+
if out is None:
|
| 296 |
+
out = torch.empty((flat_dim,), device=tail.device, dtype=tail.dtype)
|
| 297 |
+
ops.pack_tail_bf16(tail, int(flat_dim), out)
|
| 298 |
+
return out
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def add_bias_zero_tail_bf16(
|
| 302 |
+
input: torch.Tensor,
|
| 303 |
+
bias: torch.Tensor,
|
| 304 |
+
valid_cols: int,
|
| 305 |
+
*,
|
| 306 |
+
out: Optional[torch.Tensor] = None,
|
| 307 |
+
) -> torch.Tensor:
|
| 308 |
+
"""Add a column bias and zero columns at or beyond ``valid_cols``."""
|
| 309 |
+
|
| 310 |
+
if out is None:
|
| 311 |
+
out = torch.empty_like(input)
|
| 312 |
+
ops.add_bias_zero_tail_bf16(input, bias, int(valid_cols), out)
|
| 313 |
+
return out
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
def extract_tail_f32_to_bf16(
|
| 317 |
+
flat: torch.Tensor,
|
| 318 |
+
tail_numel: int,
|
| 319 |
+
*,
|
| 320 |
+
out: Optional[torch.Tensor] = None,
|
| 321 |
+
) -> torch.Tensor:
|
| 322 |
+
"""Extract the final ``tail_numel`` FP32 values and cast them to BF16."""
|
| 323 |
+
|
| 324 |
+
if out is None:
|
| 325 |
+
out = torch.empty((tail_numel,), device=flat.device, dtype=torch.bfloat16)
|
| 326 |
+
ops.extract_tail_f32_to_bf16(flat, int(tail_numel), out)
|
| 327 |
+
return out
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
def add_bias_pair_bf16(
|
| 331 |
+
input: torch.Tensor,
|
| 332 |
+
bias_a: torch.Tensor,
|
| 333 |
+
bias_b: torch.Tensor,
|
| 334 |
+
*,
|
| 335 |
+
out: Optional[torch.Tensor] = None,
|
| 336 |
+
) -> torch.Tensor:
|
| 337 |
+
"""Add two BF16 row-broadcast biases with BF16 rounding after each add."""
|
| 338 |
+
|
| 339 |
+
if out is None:
|
| 340 |
+
out = torch.empty_like(input)
|
| 341 |
+
ops.add_bias_pair_bf16(input, bias_a, bias_b, out)
|
| 342 |
+
return out
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
def unipc_step_f32_bf16(
|
| 346 |
+
sample: torch.Tensor,
|
| 347 |
+
velocity: torch.Tensor,
|
| 348 |
+
prev_m1: torch.Tensor,
|
| 349 |
+
prev_m2: torch.Tensor,
|
| 350 |
+
prev_last_sample: torch.Tensor,
|
| 351 |
+
sigma: float,
|
| 352 |
+
corrector_order: int,
|
| 353 |
+
predictor_order: int,
|
| 354 |
+
corrector_coefficients: tuple[float, float, float, float, float],
|
| 355 |
+
predictor_coefficients: tuple[float, float, float],
|
| 356 |
+
*,
|
| 357 |
+
next_sample: Optional[torch.Tensor] = None,
|
| 358 |
+
current_m: Optional[torch.Tensor] = None,
|
| 359 |
+
current_last_sample: Optional[torch.Tensor] = None,
|
| 360 |
+
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 361 |
+
"""Run one UniPC predictor/corrector update."""
|
| 362 |
+
|
| 363 |
+
if len(corrector_coefficients) != 5:
|
| 364 |
+
raise RuntimeError("corrector_coefficients must have five values")
|
| 365 |
+
if len(predictor_coefficients) != 3:
|
| 366 |
+
raise RuntimeError("predictor_coefficients must have three values")
|
| 367 |
+
if next_sample is None:
|
| 368 |
+
next_sample = torch.empty_like(sample)
|
| 369 |
+
if current_m is None:
|
| 370 |
+
current_m = torch.empty_like(sample)
|
| 371 |
+
if current_last_sample is None:
|
| 372 |
+
current_last_sample = torch.empty_like(sample)
|
| 373 |
+
ops.unipc_step_f32_bf16(
|
| 374 |
+
sample,
|
| 375 |
+
velocity,
|
| 376 |
+
prev_m1,
|
| 377 |
+
prev_m2,
|
| 378 |
+
prev_last_sample,
|
| 379 |
+
float(sigma),
|
| 380 |
+
int(corrector_order),
|
| 381 |
+
int(predictor_order),
|
| 382 |
+
*map(float, corrector_coefficients),
|
| 383 |
+
*map(float, predictor_coefficients),
|
| 384 |
+
next_sample,
|
| 385 |
+
current_m,
|
| 386 |
+
current_last_sample,
|
| 387 |
+
)
|
| 388 |
+
return next_sample, current_m, current_last_sample
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
__all__ = [
|
| 392 |
+
"add_bf16",
|
| 393 |
+
"add_bias_pair_bf16",
|
| 394 |
+
"add_bias_zero_tail_bf16",
|
| 395 |
+
"cast_bf16_to_fp32",
|
| 396 |
+
"cfg_combine_into_residual_bf16",
|
| 397 |
+
"cfg_combine_into_residual_fp16",
|
| 398 |
+
"euler_step_bf16",
|
| 399 |
+
"extract_tail_f32_to_bf16",
|
| 400 |
+
"motus_decode_postprocess_bf16_to_fp32",
|
| 401 |
+
"pack_tail_bf16",
|
| 402 |
+
"teacher_force_first_frame_bf16",
|
| 403 |
+
"unipc_step_f32_bf16",
|
| 404 |
+
]
|
build/torch211-cxx11-cu130-aarch64-linux/_diffusion_step_ops_cuda_7781728.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d9d2a596cc388ab0c75f5fcd0a7e38eca3b151599d82b05a39b6775ae09c7eb6
|
| 3 |
+
size 396160
|
build/torch211-cxx11-cu130-aarch64-linux/_ops.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _diffusion_step_ops_cuda_7781728
|
| 3 |
+
ops = torch.ops._diffusion_step_ops_cuda_7781728
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
return f"_diffusion_step_ops_cuda_7781728::{op_name}"
|
build/torch211-cxx11-cu130-aarch64-linux/diffusion_step_ops/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ctypes
|
| 2 |
+
import importlib.util
|
| 3 |
+
import sys
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
def _import_from_path(file_path: Path):
|
| 7 |
+
path_hash = '{:x}'.format(ctypes.c_size_t(hash(file_path.absolute())).value)
|
| 8 |
+
spec = importlib.util.spec_from_file_location(path_hash, file_path)
|
| 9 |
+
module = importlib.util.module_from_spec(spec)
|
| 10 |
+
sys.modules[path_hash] = module
|
| 11 |
+
spec.loader.exec_module(module)
|
| 12 |
+
return module
|
| 13 |
+
|
| 14 |
+
globals().update(vars(_import_from_path(Path(__file__).parent.parent / '__init__.py')))
|
build/torch211-cxx11-cu130-aarch64-linux/metadata.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "diffusion-step-ops",
|
| 3 |
+
"id": "_diffusion_step_ops_cuda_7781728",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"11.0"
|
| 11 |
+
]
|
| 12 |
+
},
|
| 13 |
+
"digest": {
|
| 14 |
+
"algorithm": "sha256",
|
| 15 |
+
"files": {
|
| 16 |
+
"__init__.py": "lvwbHfo6cUQionduscBmfSl+ZhbJzxT01i/P3PWooTc=",
|
| 17 |
+
"_diffusion_step_ops_cuda_7781728.abi3.so": "2dKllsw4irDHX1/NCn447KOxUVmdgrBaObZ3WuCcfrY=",
|
| 18 |
+
"_ops.py": "cGxBwOkH9nkP1cXNz1BWlQvGREsetkzMkeXWj0qGoYc=",
|
| 19 |
+
"diffusion_step_ops/__init__.py": "v6p5XMfQzddhi1fLSAw4HX9CyS0rQsidvu9VsT01xi4="
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
}
|