Stability-AI/generative-models · error · NotImplementedError
NotImplementedError
Error message
NotImplementedError
What it means
VideoDepthModel/VideoUNet.forward raises NotImplementedError when time_context is passed: the forward path in this variant does not implement separate time-context injection. Passing a non-None time_context therefore aborts immediately as an explicitly unsupported code path.
Source
Thrown at sgm/modules/diffusionmodules/video_model.py:582
get_alpha,
merge_strategy,
self.mix_factor,
apply_sigmoid=apply_sigmoid_to_merge,
)
def forward(
self,
x: th.Tensor,
context: Optional[th.Tensor] = None,
# cam: Optional[th.Tensor] = None,
time_context: Optional[th.Tensor] = None,
timesteps: Optional[int] = None,
image_only_indicator: Optional[th.Tensor] = None,
conv_view: Optional[th.Tensor] = None,
conv_motion: Optional[th.Tensor] = None,
):
if time_context is not None:
raise NotImplementedError
_, _, h, w = x.shape
if exists(context):
context = rearrange(context, "b t ... -> (b t) ...")
if self.use_spatial_context:
time_context = repeat(context[:, 0], "b ... -> (b n) ...", n=h * w)
x = super().forward(
x,
)
x = rearrange(x, "b c h w -> b (h w) c")
x_mix = x
num_frames = th.arange(timesteps, device=x.device)
num_frames = repeat(num_frames, "t -> b t", b=x.shape[0] // timesteps)
num_frames = rearrange(num_frames, "b t -> (b t)")
t_emb = timestep_embedding(num_frames, self.in_channels, repeat_only=False)View on GitHub (pinned to e8cd657656)
Solutions
- Pass time_context=None (omit it) and rely on the model's internal spatial/temporal context handling.
- If you need time-context conditioning, use a model variant whose forward implements it, or patch forward to consume time_context.
- Restructure so temporal information is folded into `context` instead of `time_context`.
Example fix
// before out = model(x, t, context=ctx, time_context=t_ctx) // after out = model(x, t, context=ctx) # time_context not supported by this forward
Defensive patterns
Strategy: try-catch
Validate before calling
if time_context is not None:
raise TypeError("This forward does not support time_context; fold it into context") Try / catch
try:
out = model(x, t, context=ctx, time_context=t_ctx)
except NotImplementedError:
logger.warning("time_context unsupported; retrying without it")
out = model(x, t, context=ctx) Prevention
- Check the forward signature of the exact model class before passing optional context tensors.
- Gate time_context usage behind a feature check/version check of the codebase.
- Merge temporal conditioning into `context` rather than passing time_context.
When it happens
Trigger: Calling model(x, timesteps, context=..., time_context=...) with a real tensor for time_context, e.g. reusing a call signature from a different video model version that supported split spatial/temporal context.
Common situations: Migrating code from an older/other SGM fork where time_context was supported, plugging a text/temporal encoder output into time_context, or a wrapper passing time_context unconditionally (even None it's fine; only non-None triggers).
Related errors
- NotImplementedError
- unsupported dimensions: {dims}
- unknown merge strategy {self.merge_strategy}
- unknown merge strategy {merge_strategy}
- input has {x.ndim} dims but target_dims is {target_dims}, wh
AI-assisted analysis of Stability-AI/generative-models@e8cd657656 (2026-08-29).
Data as JSON: /api/errors/affb9d5481aa9484.
Report an issue: GitHub.