hpcaitech/Open-Sora · error · ValueError

No chunks were generated. Input shape: {x.shape}

Error message

No chunks were generated. Input shape: {x.shape}

What it means

Raised by chunked_interpolate in opensora's dc_ae nn ops when the chunking loop produced zero chunks, meaning the input tensor's channel dimension (or chunk size argument) resulted in no slices to interpolate. The function splits x along dim=1 and concatenates interpolated chunks; if chunks is empty the cat would otherwise fail obscurely, so this guard reports the input shape. It almost always indicates a chunk_size <= 0 or an empty/zero-channel input tensor.

Source

Thrown at opensora/models/dc_ae/models/nn/vo_ops.py:138

    if VERBOSE:
        print(f"Input channels: {x.shape[1]}")
        print(f"Chunk size: {chunk_size}")
        print(f"max_channels: {max_channels}")
        print(f"num_chunks: {math.ceil(x.shape[1] / chunk_size)}")

    chunks = []
    for i in range(0, x.shape[1], chunk_size):
        start_idx = i
        end_idx = min(i + chunk_size, x.shape[1])

        chunk = x[:, start_idx:end_idx, :, :, :]

        interpolated_chunk = F.interpolate(chunk, scale_factor=scale_factor, mode="nearest")

        chunks.append(interpolated_chunk)

    if not chunks:
        raise ValueError(f"No chunks were generated. Input shape: {x.shape}")

    # Concatenate chunks along channel dimension
    return torch.cat(chunks, dim=1)


def test_chunked_interpolate():
    # Test case 1: Basic upscaling with scale_factor
    x1 = torch.randn(2, 16, 16, 32, 32).cuda()
    scale_factor = (2.0, 2.0, 2.0)
    assert torch.allclose(
        chunked_interpolate(x1, scale_factor=scale_factor), F.interpolate(x1, scale_factor=scale_factor, mode="nearest")
    )

    # Test case 3: Downscaling with scale_factor
    x3 = torch.randn(2, 16, 32, 64, 64).cuda()
    scale_factor = (0.5, 0.5, 0.5)
    assert torch.allclose(
        chunked_interpolate(x3, scale_factor=scale_factor), F.interpolate(x3, scale_factor=scale_factor, mode="nearest")

View on GitHub (pinned to 7ad6a96a13)

Solutions

  1. Check that chunk_size is a positive integer (>= 1) before calling chunked_interpolate
  2. Verify the input tensor x has a non-zero channel dimension: assert x.shape[1] > 0
  3. Trace where the input tensor was constructed; if channels are computed from a config, validate that value
  4. Add a unit test mirroring test_chunked_interpolate with your exact shapes

Example fix

// before
out = chunked_interpolate(x, chunk_size=0)
// after
assert x.shape[1] > 0 and chunk_size >= 1
out = chunked_interpolate(x, chunk_size=chunk_size)
Defensive patterns

Strategy: validation

Validate before calling

assert x.dim() == 4 and x.shape[1] > 0, f"bad input {tuple(x.shape)}"
assert isinstance(chunk_size, int) and chunk_size >= 1

Try / catch

try:
    out = chunked_interpolate(x, chunk_size)
except ValueError as e:
    if "No chunks" in str(e):
        raise ValueError(f"chunked_interpolate misconfigured: shape={tuple(x.shape)}, chunk_size={chunk_size}") from e
    raise

Prevention

When it happens

Trigger: Calling chunked_interpolate(x, chunk_size=...) with chunk_size <= 0, or passing a tensor with x.shape[1] == 0 (zero channels). Also reachable via the module's forward() which delegates to this helper.

Common situations: Misconfigured chunk size hyperparameter in a dc_ae autoencoder config (e.g. 0 or negative from a YAML typo), or an upstream slicing/concatenation bug that produced an empty channel dimension.

Related errors


AI-assisted analysis of hpcaitech/Open-Sora@7ad6a96a13 (2026-08-28). Data as JSON: /api/errors/d548cbb6235400da. Report an issue: GitHub.