#463 · Deep Learning · Medium
⊣ Solve on deep-ml.comImplement unified history injection for autoregressive video diffusion. Given the current noisy latent chunk, a set of clean history latents from previously generated chunks, and blending weights, inject the history context into the current chunk's denoising process.
def history_injection(
current_latent: list[list[float]],
history_latents: list[list[list[float]]],
blend_weights: list[float],
injection_mask: list[float]
) -> list[list[float]]:
if not history_latents:
return current_latent
T, D = len(current_latent), len(current_latent[0])
weighted = [[0.0] * D for _ in range(T)]
total_w = 0.0
for latent, w in zip(history_latents, blend_weights):
for t in range(min(len(latent), T)):
for d in range(D):
weighted[t][d] += w * latent[t][d]
total_w += w
if total_w > 0:
weighted = [[v / total_w for v in row] for row in weighted]
return [[(1 - injection_mask[t]) * current_latent[t][d] + injection_mask[t] * weighted[t][d]
for d in range(D)] for t in range(T)]injection_mask controls where history information is injected. Values near 1 give more weight to history (for overlap regions), while values near 0 preserve the current denoising trajectory (for new frames).