MCPcopy Create free account
hub / github.com/NVlabs/LongLive / _inject_error_buffer

Method _inject_error_buffer

model/diffusion.py:397–428  ·  view source on GitHub ↗

Inject errors into the clean prefix (E_img). 2D (position-bucketed): the i-th LOCAL prefix block draws from ``buckets[(i, *)]`` with a RANDOM timestep — the clean prefix is the product of full ODE integration so its accumulated error can come from any noise level, bu

(self, clean_latent_aug, index, batch_size, num_frame)

Source from the content-addressed store, hash-verified

395
396
397 def _inject_error_buffer(self, clean_latent_aug, index, batch_size, num_frame):
398 """Inject errors into the clean prefix (E_img).
399
400 2D (position-bucketed): the i-th LOCAL prefix block draws from
401 ``buckets[(i, *)]`` with a RANDOM timestep — the clean prefix is
402 the product of full ODE integration so its accumulated error can
403 come from any noise level, but its magnitude scales with the
404 block's global position. Note ``skip_block_0`` is interpreted in
405 the GLOBAL frame: only the very first SP rank may skip its block 0.
406
407 1D (timestep-bucketed): falls back to SVI ``sample_global``.
408 """
409 block_size = self.num_frame_per_block
410 num_blocks = num_frame // block_size
411 result = clean_latent_aug.clone()
412 for b in range(batch_size):
413 for blk in range(num_blocks):
414 if self.er_skip_block_0 and (self.er_block_offset + blk) == 0:
415 continue
416 if self.er_num_blocks > 0:
417 err = self.error_buffer.sample_pos_any_t(
418 blk, device=result.device, dtype=result.dtype
419 )
420 else:
421 err = self.error_buffer.sample_global(
422 device=result.device, dtype=result.dtype
423 )
424 if err is not None:
425 start = blk * block_size
426 end = start + block_size
427 result[b, start:end] = result[b, start:end] + err
428 return result
429
430 def _inject_latent_error_buffer(self, clean_latent, index, batch_size, num_frame):
431 """Inject errors into clean_latent before noising (E_vid).

Callers 1

generator_lossMethod · 0.95

Calls 2

sample_pos_any_tMethod · 0.80
sample_globalMethod · 0.80

Tested by

no test coverage detected