sgl-project/sglang · error · Error

Previous frame size does not match current delta payload

Error message

Previous frame size does not match current delta payload

What it means

For float32 inputs, deterministic_all_reduce packs elements into vectors of P::size; if out.numel() is not divisible by that pack width it throws 'size must be multiple of d'.

Source

Thrown at python/sglang/multimodal_gen/apps/realtime_webui/decoder_worker.js:34

  }
  const stream = new Blob([payload]).stream().pipeThrough(new DecompressionStream("gzip"));
  return new Uint8Array(await new Response(stream).arrayBuffer());
}

async function restoreDeltaGzipFrames(header, payload) {
  const frameBytes = Number(header.bytes_per_frame);
  const count = Number(header.num_frames);
  const expectedSize = frameBytes * count;
  const restored = await gunzipBytes(payload);
  if (restored.length !== expectedSize) {
    throw new Error(`delta payload size mismatch: expected ${expectedSize}, got ${restored.length}`);
  }

  let previous = header.delta_reference === "previous-frame" ? lastFrame : null;
  if (header.delta_reference === "previous-frame") {
    if (!previous) throw new Error("Missing previous frame for delta payload");
    if (previous.byteLength !== frameBytes) {
      throw new Error("Previous frame size does not match current delta payload");
    }
  }

  for (let f = 0; f < count; f++) {
    const offset = f * frameBytes;
    if (previous) {
      for (let i = 0; i < frameBytes; i++) restored[offset + i] ^= previous[i];
    }
    previous = restored.slice(offset, offset + frameBytes);
  }
  lastFrame = previous;
  return restored;
}

function rawFramesToRgbaBuffers(header, payload) {
  const width = Number(header.width);
  const height = Number(header.height);
  const channels = Number(header.channels);

View on GitHub (pinned to 0132848349)

Solutions

  1. Pad the tensor to a multiple of the pack width and slice afterwards
  2. Round model dims (hidden size) to a multiple of 8
  3. Use RCCL fallback for this tensor

Example fix

# before
det_ar(x)  # x.numel() % 4 != 0
# after
pad = (-x.numel()) % 4
det_ar(torch.nn.functional.pad(x.flatten(), (0, pad)))[:x.numel()]
Defensive patterns

Strategy: validation

Validate before calling

d = 4  # fp32 pack width on ROCm
assert out.numel() % d == 0, f'size must be multiple of {d}'

Prevention

When it happens

Trigger: Calling deterministic_all_reduce on a float32 tensor whose element count is not a multiple of the pack width.

Common situations: Non-multiple-of-pack hidden sizes or sliced tensors; fp32 master-weight reductions with odd lengths.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/48f1b7407d6a194e. Report an issue: GitHub.