{"record":{"id":"48f1b7407d6a194e","repo":"sgl-project/sglang","slug":"previous-frame-size-does-not-match-current-delta-p","errorCode":null,"errorMessage":"Previous frame size does not match current delta payload","messagePattern":"Previous frame size does not match current delta payload","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/apps/realtime_webui/decoder_worker.js","lineNumber":34,"sourceCode":"  }\n  const stream = new Blob([payload]).stream().pipeThrough(new DecompressionStream(\"gzip\"));\n  return new Uint8Array(await new Response(stream).arrayBuffer());\n}\n\nasync function restoreDeltaGzipFrames(header, payload) {\n  const frameBytes = Number(header.bytes_per_frame);\n  const count = Number(header.num_frames);\n  const expectedSize = frameBytes * count;\n  const restored = await gunzipBytes(payload);\n  if (restored.length !== expectedSize) {\n    throw new Error(`delta payload size mismatch: expected ${expectedSize}, got ${restored.length}`);\n  }\n\n  let previous = header.delta_reference === \"previous-frame\" ? lastFrame : null;\n  if (header.delta_reference === \"previous-frame\") {\n    if (!previous) throw new Error(\"Missing previous frame for delta payload\");\n    if (previous.byteLength !== frameBytes) {\n      throw new Error(\"Previous frame size does not match current delta payload\");\n    }\n  }\n\n  for (let f = 0; f < count; f++) {\n    const offset = f * frameBytes;\n    if (previous) {\n      for (let i = 0; i < frameBytes; i++) restored[offset + i] ^= previous[i];\n    }\n    previous = restored.slice(offset, offset + frameBytes);\n  }\n  lastFrame = previous;\n  return restored;\n}\n\nfunction rawFramesToRgbaBuffers(header, payload) {\n  const width = Number(header.width);\n  const height = Number(header.height);\n  const channels = Number(header.channels);","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/apps/realtime_webui/decoder_worker.js#L16-L52","documentation":"Raised when the stored previous frame's byte length differs from the size implied by the incoming delta payload, meaning the delta grid no longer aligns with the reference frame. Typically caused by a resolution change without a preceding keyframe or by corrupted stream data.","triggerScenarios":"Calling deterministic_all_reduce on a float32 tensor whose element count is not a multiple of the pack width.","commonSituations":"Non-multiple-of-pack hidden sizes or sliced tensors; fp32 master-weight reductions with odd lengths.","solutions":["Pad the tensor to a multiple of the pack width and slice afterwards","Round model dims (hidden size) to a multiple of 8","Use RCCL fallback for this tensor"],"exampleFix":"# before\ndet_ar(x)  # x.numel() % 4 != 0\n# after\npad = (-x.numel()) % 4\ndet_ar(torch.nn.functional.pad(x.flatten(), (0, pad)))[:x.numel()]","handlingStrategy":"validation","validationCode":"d = 4  # fp32 pack width on ROCm\nassert out.numel() % d == 0, f'size must be multiple of {d}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pad fp32 tensors before deterministic allreduce","Round model dims to pack multiples"],"tags":["rocm","allreduce","deterministic","alignment","float32"],"backgroundTag":"size-alignment-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","contentChangedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}