Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/glm-4k-frame-400.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### GLM-5.3-Flash answers a very short 4K video with 400, not a retried 503

- A GLM frame pair can't pass the vision tower's 32,000 patches on any Mac. A clip of three frame pairs or fewer (about 3 seconds) with frames of about 6.3 megapixels or more (4K and up; since the long-video fit, also such a clip shrunk to the prepared-pixel cap) was refused there as a retriable 503, so the coordinator tried it on other GLM Macs, which refused it the same way. It is now a 400 (`invalid_media`, "lower the video's resolution"), before any tower work, on a Mac and on a pair's leader. An operator's lower `DARKBLOOM_VISION_MAX_TOWER_PATCHES` limit stays a retriable 503, since another Mac can serve the frame.
8 changes: 7 additions & 1 deletion docs/architecture/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,13 @@ the cap at the per-video ceiling, which bounds what renders.
loads) keeps the artifact's budget and the refusal; on a pair only the leader's
setting counts, so mixed-version pairs agree.
Processor refusals are deterministic 400s; tower and MLX faults keep the
retriable refusal. Media requests are excluded from prefix lookup and capture
retriable refusal. A frame pair past the tower's native 32,000 patches
(`GLM5NextVisionBudget.maximumFramePatches`: a clip of three pairs or fewer,
about 3 seconds, of 4K-class frames, even shrunk to the prepared cap) is refused
on every Mac, so it is a 400 `invalid_media` too
(`VisionTowerBudget.glm5FrameLimits`, before any tower work, on a Mac and a
pair's leader); a lower operator limit (`DARKBLOOM_VISION_MAX_TOWER_PATCHES`)
stays retriable. Media requests are excluded from prefix lookup and capture
(`CBv2Request.permitsHybridCheckpoint`), so no KV is reused across images or videos, and
they decode without MTP speculation. A GLM slot serves media only when its
engine accepts prepared causal media (`EngineV2Bridge.servesGLM5NextMedia`); the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@ extension VisionTowerBudget {
else {
throw EngineV2VisionPrefillError.invalidVisionGrid(mediaIndex: 0)
}
// Every Mac refuses a frame past the native limit (a 4K clip of a few
// pairs), so it is the request's fault; an operator's lower limit is
// this Mac's own and stays retriable.
guard patches <= GLM5NextVisionBudget.maximumFramePatches else {
throw EngineV2VisionPrefillError.unsupportedMedia(
"GLM frame exceeds the tower's \(GLM5NextVisionBudget.maximumFramePatches)-patch limit; "
+ "lower the video's resolution")
}
let maximumPatches = min(
GLM5NextVisionBudget.maximumFramePatches,
limits.operatorMaxPatches ?? GLM5NextVisionBudget.maximumFramePatches)
guard patches <= maximumPatches else {
throw EngineV2VisionPrefillError.towerBudgetExceeded(
"GLM frame exceeds native/operator patch limit")
"GLM frame exceeds operator patch limit")
}
func bytes(_ dimensions: [Int]) throws -> Int {
var value = 4 // Conservative FP32 intermediates, including prepared pixels.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,3 +674,52 @@ struct GLM5NextLongVideoFitTests {
#expect(try GLM5NextVisionBudget.fittingLongVideos(small, environment: [:]).videoMaximumTokens == 240_000)
}
}

/// `glm5FrameLimits` on `grid`'s one frame: "plans"; "400" for
/// `unsupportedMedia`, which the scheduler answers as the request's fault;
/// "503" for `towerBudgetExceeded`, the retriable construction refusal;
/// anything else as itself.
private func frameOutcome(_ grid: GLM5NextVisionGrid, operatorMaxPatches: Int? = nil) throws -> String {
let configuration = try visionConfiguration()
let limits = VisionTowerBudget.Limits(
maxBufferBytes: 1 << 40, attentionElementBytes: 4, headFactor: 1, operatorMaxPatches: operatorMaxPatches)
do {
_ = try VisionTowerBudget.glm5FrameLimits(
grid: THW(1, grid.height, grid.width), configuration: configuration, limits: limits)
return "plans"
} catch let error as EngineV2VisionPrefillError {
switch error {
case .unsupportedMedia where EngineV2VisionPrefill.clientFault(for: error) != nil: return "400"
case .towerBudgetExceeded where EngineV2VisionPrefill.clientFault(for: error) == nil: return "503"
default: return String(describing: error)
}
}
}

@Suite("GLM5Next frames past the native tower limit")
struct GLM5NextFrameLimitTests {
/// GLM's tower takes at most 32,000 patches a frame pair on every Mac. A
/// 4K clip of one or a few pairs passes it: 2 frames render 156 x 276 =
/// 43,056 patches, and 6 frames, shrunk to the prepared cap, 3 pairs of
/// 146 x 260 = 37,960. Every provider refuses those, so the refusal is the
/// request's fault, a 400 the coordinator does not retry elsewhere.
@Test func aFramePastTheNativeLimitIsTheRequestsFault() throws {
for frames in [2, 6] {
let plan = try GLM5NextMediaGeometry.resizePlan(
width: 3840, height: 2160, frames: frames, patchSize: 14, minimumTokens: 16, maximumTokens: 28_532)
#expect(plan.grid.height * plan.grid.width > GLM5NextVisionBudget.maximumFramePatches)
#expect(try frameOutcome(plan.grid) == "400")
}
#expect(try frameOutcome(.init(temporal: 1, height: 160, width: 202)) == "400")
}

/// An operator's lower limit (`DARKBLOOM_VISION_MAX_TOWER_PATCHES`) is
/// this Mac's own: another can serve the frame, so it stays retriable.
/// Within both limits the frame plans.
@Test func anOperatorsLowerLimitStaysRetriable() throws {
let frame = try GLM5NextVisionGrid(temporal: 1, height: 100, width: 200)
#expect(try frameOutcome(frame, operatorMaxPatches: 16_000) == "503")
#expect(try frameOutcome(frame) == "plans")
#expect(try frameOutcome(.init(temporal: 1, height: 160, width: 200)) == "plans")
}
}
Loading