hpcaitech/Open-Sora · error · NotImplementedError
resize(mode={mode}) not implemented.
Error message
resize(mode={mode}) not implemented. What it means
The resize() helper in dc_ae's vo_ops only supports the bilinear/bicubic family (via antialiased interpolate) and 'nearest'/'area' modes. Any other mode string (e.g. 'linear', 'trilinear', 'nearest-exact', or a typo like 'neareast') reaches the else branch and raises NotImplementedError.
Source
Thrown at opensora/models/dc_ae/models/nn/vo_ops.py:231
def resize(
x: torch.Tensor,
size: Optional[Any] = None,
scale_factor: Optional[list[float]] = None,
mode: str = "bicubic",
align_corners: Optional[bool] = False,
) -> torch.Tensor:
if mode in {"bilinear", "bicubic"}:
return F.interpolate(
x,
size=size,
scale_factor=scale_factor,
mode=mode,
align_corners=align_corners,
)
elif mode in {"nearest", "area"}:
return F.interpolate(x, size=size, scale_factor=scale_factor, mode=mode)
else:
raise NotImplementedError(f"resize(mode={mode}) not implemented.")
def build_kwargs_from_config(config: dict, target_func: Callable) -> dict[str, Any]:
valid_keys = list(signature(target_func).parameters)
kwargs = {}
for key in config:
if key in valid_keys:
kwargs[key] = config[key]
return kwargs
if __name__ == "__main__":
test_chunked_interpolate()
View on GitHub (pinned to 7ad6a96a13)
Solutions
- Change mode to one of the supported values: 'nearest', 'area', 'bilinear', or 'bicubic'
- Check the config/dict that supplies the mode string for typos
- If you truly need another mode, call F.interpolate directly instead of this wrapper
Example fix
// before y = resize(x, scale_factor=2.0, mode="trilinear") // after y = resize(x, scale_factor=2.0, mode="nearest")
Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {"bilinear", "bicubic", "nearest", "area"}
assert mode in SUPPORTED, f"unsupported resize mode {mode!r}; choose from {SUPPORTED}" Type guard
def is_supported_resize_mode(mode: str) -> bool:
return mode in {"bilinear", "bicubic", "nearest", "area"} Try / catch
try:
y = resize(x, mode=mode, ...)
except NotImplementedError:
y = F.interpolate(x, mode="nearest", ...) # explicit fallback Prevention
- Centralize resample mode strings in one constants module
- Reject unknown mode strings at config-load time
- Keep mode names lowercase and short-form
When it happens
Trigger: Calling resize(x, mode=...) with a mode not in {bilinear, bicubic, nearest, area} (and whatever antialias variants the earlier branches accept), typically from a model forward pass where the resample mode comes from a config.
Common situations: Copying a resample mode string from another library (e.g. torch.nn.Upsample's 'linear'/'trilinear' or diffusers' 'nearest-exact') into an opensora dc_ae config; typos in YAML configs.
Related errors
- ConvPixelUnshuffle downsample is not supported for video
- ConvPixelShuffle upsample is not supported for video
- Downsample during project_in is not supported for video
- Upsample during project_out is not supported for video
- local_module {local_module} is not supported
AI-assisted analysis of hpcaitech/Open-Sora@7ad6a96a13 (2026-08-28).
Data as JSON: /api/errors/2caa7624299c7a60.
Report an issue: GitHub.