{"record":{"id":"2d0c6341acc7ead5","repo":"unslothai/unsloth","slug":"minimax-h3-was-trained-on-aspect-ratios-from-1-4-t","errorCode":null,"errorMessage":"MiniMax-H3 was trained on aspect ratios from 1:4 to 4:1; this clip is {aspect_width:g}x{aspect_height:g} ({ratio:.2f}:1). Crop it first.","messagePattern":"MiniMax-H3 was trained on aspect ratios from 1:4 to 4:1; this clip is (.+?)x(.+?) \\((.+?):1\\)\\. Crop it first\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/training/diffusion_h3_clips.py","lineNumber":158,"sourceCode":"def h3_train_canvas(\n    aspect_width: float,\n    aspect_height: float,\n    short_edge: int = H3_CANVAS_SHORT_EDGE,\n    max_pixels: Optional[int] = None,\n) -> tuple[int, int]:\n    \"\"\"MiniMax-H3's canvas rule, as ``(width, height)``.\n\n    Identical arithmetic to the pipeline's ``resolve_canvas_size`` (which returns\n    ``(height, width)``), re-expressed here so the trainer can size a dataset before any\n    diffusers import. ``short_edge`` is the run's ``resolution``; the area cap scales with it\n    so a smaller training canvas keeps the released aspect budget rather than the released\n    pixel count.\n    \"\"\"\n    if aspect_width <= 0 or aspect_height <= 0:\n        raise ValueError(f\"The aspect ratio must be positive, got {aspect_width}:{aspect_height}.\")\n    ratio = aspect_width / aspect_height\n    if not H3_MIN_ASPECT_RATIO <= ratio <= H3_MAX_ASPECT_RATIO:\n        raise ValueError(\n            f\"MiniMax-H3 was trained on aspect ratios from 1:4 to 4:1; this clip is \"\n            f\"{aspect_width:g}x{aspect_height:g} ({ratio:.2f}:1). Crop it first.\"\n        )\n    if max_pixels is None:\n        # The released cap, rescaled to the requested short edge: (1344/768) * short_edge^2.\n        max_pixels = int(H3_CANVAS_MAX_PIXELS * (short_edge / H3_CANVAS_SHORT_EDGE) ** 2)\n    if ratio >= 1.0:\n        width, height = short_edge * ratio, float(short_edge)\n    else:\n        width, height = float(short_edge), short_edge / ratio\n    area = width * height\n    if area > max_pixels:\n        scale = math.sqrt(max_pixels / area)\n        width, height = width * scale, height * scale\n\n    def snap(value: float) -> int:\n        return max(H3_CANVAS_MULTIPLE, round(value / H3_CANVAS_MULTIPLE) * H3_CANVAS_MULTIPLE)\n","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/training/diffusion_h3_clips.py#L140-L176","documentation":"Raised by the H3 canvas helper when the clip's aspect ratio falls outside H3_MIN_ASPECT_RATIO..H3_MAX_ASPECT_RATIO (1:4 to 4:1), the range MiniMax-H3 was trained on. The model has no representation for more extreme ratios, so the trainer requires the clip to be cropped first rather than silently training on out-of-distribution geometry.","triggerScenarios":"Passing an aspect pair like 1000:200 (5:1) or a 9:16-vs-1:10 extreme — any ratio < 0.25 or > 4.0; ultra-wide screen recordings or tall phone videos beyond 4:1 mixed into a dataset.","commonSituations":"Datasets scraped from phone screenshots, cinematic ultra-wide crops, or split-screen captures; an automated pipeline that never checks aspect before training; letterboxed videos counted at full canvas ratio.","solutions":["Crop the clip to within 1:4..4:1 (center-crop the long edge) before adding it to the dataset.","Exclude the offending clip from the training set if cropping would destroy its content.","Add an aspect-ratio precheck during dataset ingestion so bad clips are reported by name."],"exampleFix":"# before\nw, h = h3_canvas_size(2048, 400, short_edge=768)  # 5.12:1 -> ValueError\n\n# after\n# center-crop width to at most 4x height first\ncrop_w = min(2048, 400 * 4)\nw, h = h3_canvas_size(crop_w, 400, short_edge=768)","handlingStrategy":"validation","validationCode":"MIN_AR, MAX_AR = 1 / 4, 4.0\n\ndef aspect_trainable(w: int, h: int) -> bool:\n    return MIN_AR <= w / h <= MAX_AR","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Center-crop extreme clips to <= 4:1 / >= 1:4 during dataset prep.","Run an aspect precheck over the dataset so failures surface per-clip with names, not mid-training."],"tags":["video","aspect-ratio","dataset","minimax-h3"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}