"""Assemble actual pipeline outputs without fabricated comparison imagery.""" import hashlib import html import json from pathlib import Path from PIL import Image, ImageDraw, ImageFont def main(): root = Path("comparisons/optimization-r3") root.mkdir(parents=True, exist_ok=True) cases = ["product", "portrait", "holdout-detail", "edit"] groups = [ ("Exact Q/K fusion + FC2 tuning", "optimization-r3-qk", "qk-fc2-native-norm"), ( "Lossless packed weights + exact tuning", "optimization-r3-compact", "qk-fc2-native-norm", ), ( "Full-width fusion: exact pixels, memory tradeoff", "optimization-r3-deployment", "qk-fc2", ), ] parts = [ 'MiniMax H3: measured comparisons', "

MiniMax H3: measured image comparisons

Actual saved model outputs, matched prompts, seeds, canvas and reference inputs. Each linked gallery includes native-resolution crops, vertical stacks, and RGB differences amplified eight times.

Exact means no additional change relative to the MLX BF16 recipe on these cases. FP32-decoder and CUDA comparisons are linked separately below.

", ] records = [] font = ImageFont.truetype("/System/Library/Fonts/Supplemental/Arial.ttf", 21) for title, folder, variant in groups: paths = [Path("comparisons") / folder / case / variant for case in cases] if not all( (p / "metrics.json").exists() and (p / "grid.png").exists() for p in paths ): raise FileNotFoundError(f"Incomplete final gallery: {folder}") parts.append(f"

{html.escape(title)}

") images = [] for case, path in zip(cases, paths, strict=True): rel = Path("..") / folder / case / variant metrics = json.loads((path / "metrics.json").read_text()) records.append( { "group": title, "case": case, "gallery": str(path / "index.html"), "metrics_sha256": hashlib.sha256( (path / "metrics.json").read_bytes() ).hexdigest(), "grid_sha256": hashlib.sha256( (path / "grid.png").read_bytes() ).hexdigest(), "pixel_identical": all( r["pixel_identical"] for r in metrics["rows"] ), } ) parts.append( f'

{html.escape(case)}

Full gallery, detail crops and 8× difference · vertical stackMatched {html.escape(case)} control and candidate images' ) images.append((case, Image.open(path / "grid.png").convert("RGB"))) width = max(im.width for _, im in images) canvas = Image.new( "RGB", (width, sum(im.height + 38 for _, im in images)), (16, 21, 29) ) draw = ImageDraw.Draw(canvas) y = 0 for case, im in images: draw.text((12, y + 6), case, font=font, fill="white") canvas.paste(im, (0, y + 38)) y += im.height + 38 stack = root / f"{folder}-all-cases.png" canvas.save(stack) parts.append( f'

Download the four-case comparison stack

' ) parts.append( '

Earlier precision-loss examples

These are earlier experiments, retained to show actual quality differences. Their timings are not pooled with this campaign.

' ) (root / "index.html").write_text("\n".join(parts)) (root / "gallery.json").write_text(json.dumps(records, indent=2) + "\n") if not all(r["pixel_identical"] for r in records): raise ValueError("An advertised exact gallery changes pixels") print(f"Wrote {len(records)} audited image comparisons and three four-case stacks") if __name__ == "__main__": main()