)]}'
{
  "commit": "3a74322847c75c55ce480592f0f982e7f393eff2",
  "tree": "a141427c600318164bfb9547e9e4275965ac20df",
  "parents": [
    "957e6b5fdddb3e86a4d107d6bf23f6d76aee0d53"
  ],
  "author": {
    "name": "Florian Walbroel",
    "email": "walbroel@roofline.ai",
    "time": "Thu Nov 12 17:42:03 2026 +0100"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Thu Nov 12 17:42:03 2026 +0100"
  },
  "message": "[GlobalOptimization] change pass ordering so img2col convolutions in quantized conv models will result in integer math (#25099)\n\nAddresses https://github.com/iree-org/iree/issues/25034\n\nMove im2col after the late QDQ conversion and remove the redundant early\nQDQ pass, so biased QDQ convolutions convert to integer matmuls after\nbias detachment and transpose normalization. Move input demotion\nafterward and extend it to generic contractions, preserving f32\naccumulation.\n\nFour changes make the single conversion hold up:\n\n- Unit-dim folding shrinks a 1x1 dequantize to rank 0 and leaves an\n`expand_shape` between it and the matmul. Reshape fusion by expansion\nnow handles an empty reassociation for ops without loops, for every op\nit supports and in both directions. Only operands that must span every\nloop (inits, and the value operand of quantize/dequantize) gain the new\nunit dims; scalar parameters stay broadcasts.\n- A quantized convolution with a weight zero point needs the sum of\nevery input window. With QDQ conversion before im2col, that sum\nre-gathered every window in its own dispatch and cost about as much as\nthe im2col itself. The window sum now reads like a ones-filter\nconvolution, and `ConvertConvToIm2Col` rewrites a convolution without\noutput-channel reuse when its gather is identical to that of another\nrewritten convolution. CSE merges the gathers and the sum becomes a row\nreduction over the shared im2col result. Unshared pooling and depthwise\nconvolutions, dynamic gather shapes and plain matmul sums are\nunaffected.\n- With im2col after generalization and unit-dim folding, a strided\nconvolution with a unit window is left with an input access such as `(c,\noh * 2, ow * 2)`, which no longer passes the convolution interface\ncheck. im2col skipped it, and the strided access kept the op from being\ndata-tiled (the regression reported in review for strided 1x1 shortcut\nconvolutions). `ConvertConvToIm2Col` now matches on the indexing maps:\nan input, a filter and an output, with filter and output maps that are\nprojected permutations and an input map that is not one but is a sum of\nloops scaled by positive constants. Plain contractions, named matmuls\nand elementwise ops are left alone; the output-channel reuse and\nshared-gather rules are unchanged.\n- Unit-dim folding skips named contractions, so the generic that the QDQ\nconversion creates from an M \u003d 1 matmul kept its unit loop when\ncontractions are not generalized. Unit-dim folding now runs on the\nfunction again after the QDQ conversion.\n\nThe demotion pass classifies by the contraction and convolution\ninterfaces and does one rewrite. The multiply-accumulate body check\nstays because the convolution interface only inspects indexing maps;\nwithout it a mul+max pooling-like generic would be demoted.\n\nPipeline regression tests require integer im2col and i8×i8→i32\ncontractions for biased NHWC/NCHW convolutions, that the window sum\nreads the shared gather, and cover generic demotion.\n\nPerformance on Apple M4 with llvm-cpu, data tiling and all ukernels,\n`--task_topology_performance_level\u003dperformance`, median of medians.\nNCHW, C_in 16, 28x28 input, C_out 32, activation scale 0.125 and zero\npoint −1, per-channel weight scale 0.0625 and zero point 2. \"Float\" is\nthis branch with `--iree-global-opt-enable-qdq-to-integer-math\u003dfalse`.\n\n| Case | 1 worker integer | 1 worker float | 4 workers integer | 4\nworkers float |\n|---|---:|---:|---:|---:|\n| 3x3 symmetric | 0.103 ms | 0.117 ms | 0.057 ms | 0.062 ms |\n| 3x3 activation zero point only | 0.095 ms | 0.118 ms | 0.052 ms |\n0.063 ms |\n| 3x3 weight zero point only | 0.063 ms | 0.119 ms | 0.042 ms | 0.070 ms\n|\n| 3x3 both zero points | 0.065 ms | 0.116 ms | 0.041 ms | 0.063 ms |\n| 5x5 both zero points | 0.125 ms | 0.241 ms | 0.060 ms | 0.098 ms |\n| 7x7 both zero points | 0.197 ms | 0.369 ms | 0.081 ms | 0.194 ms |\n| matmul 676x144x32, both zero points | 0.056 ms | 0.149 ms | 0.045 ms |\n0.074 ms |\n\nThe gather merges for NCHW and NHWC with stride 2, dilation 2 and batch\n2. The integer output is bit-identical to the float path on the tested\ninputs; the scales are powers of two, so this does not exercise\nrounding.\n\n### Comparison against main\n\n`main` at b4f03e34f7 against this branch, same machine and runtime flags\nas above, default task topology restricted to the 4 performance cores,\nmedian of 5 repetitions. All cases use\n`--iree-global-opt-use-im2col-for-convs`; \"DT\" adds\n`--iree-opt-data-tiling`, \"DT + UK\" also adds\n`--iree-llvmcpu-enable-ukernels\u003dall`. Shortcut cases are 1x1 QDQ\nconvolutions with bias and relu, written as channels in → out, input\nheight, stride.\n\n| QDQ case | No DT: main → PR | DT: main → PR | DT + UK: main → PR |\n|---|---:|---:|---:|\n| shortcut 256 → 512, 56x56, stride 1 | 14.9 → 14.9 ms | 2.35 → 0.79 ms\n| 2.38 → 0.79 ms |\n| shortcut 512 → 1024, 28x28, stride 1 | 15.9 → 15.9 ms | 2.15 → 0.66 ms\n| 2.15 → 0.66 ms |\n| shortcut 1024 → 2048, 14x14, stride 1 | 14.2 → 14.8 ms | 2.11 → 0.55\nms | 2.13 → 0.55 ms |\n| shortcut 256 → 512, 56x56, stride 2 | 3.99 → 4.26 ms | 0.67 → 0.22 ms\n| 0.68 → 0.22 ms |\n| shortcut 512 → 1024, 28x28, stride 2 | 5.70 → 6.01 ms | 0.71 → 0.20 ms\n| 0.71 → 0.20 ms |\n| shortcut 1024 → 2048, 14x14, stride 2 | 4.01 → 4.35 ms | 0.70 → 0.16\nms | 0.71 → 0.16 ms |\n| NHWC 1x1, 512 → 1024, 28x28, stride 2 | 0.71 → 1.23 ms | 0.70 → 0.19\nms | 0.70 → 0.19 ms |\n| NCHW 3x3, 64 → 64, 56x56, stride 1, pad 1 | 5.20 → 5.56 ms | 0.92 →\n0.52 ms | 0.92 → 0.54 ms |\n\nWith data tiling these cases take 0.23x to 0.59x of the time on `main`,\nbecause they now run as `i8 x i8 -\u003e i32` matmuls. Without data tiling\nthe integer matmul is not faster than the float one: most cases are\nwithin 8%, and the NHWC 1x1 stride 2 case is 1.7x slower.\n\nThe run covered 237 case and configuration pairs (quantized and float\nconvolutions, shortcuts, linear layers, each with and without im2col,\ndata tiling and ukernels). 192 compile to byte-identical modules on both\nsides. The other 45 are the 8 QDQ cases above and 7 float convolutions\nwith bias, in the three im2col configurations; the float ones are within\nnoise of `main`. No case loses data tiling. The full ResNet-50 from the\nreview has not been re-measured.\n\nCompiled with:\n\n```sh\nbuild/tools/iree-compile input.mlir \\\n  --iree-hal-target-backends\u003dllvm-cpu \\\n  --iree-llvmcpu-target-cpu\u003dhost \\\n  --iree-global-opt-use-im2col-for-convs \\\n  --iree-opt-data-tiling \\\n  --iree-llvmcpu-enable-ukernels\u003dall \\\n  -o model.vmfb\n```\n\nAssisted by Codex\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\n---------\n\nSigned-off-by: Florian Walbroel \u003cwalbroel@roofline.ai\u003e\nCo-authored-by: Claude Fable 5.2 \u003cnoreply@anthropic.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "0631b0afe1e1bb135d711f68a92b5010fdaccf78",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Dialect/LinalgExt/Transforms/ReshapeFusion.cpp",
      "new_id": "8a0203865cf01586bb1ff20d045f351c7bcf1cdd",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Dialect/LinalgExt/Transforms/ReshapeFusion.cpp"
    },
    {
      "type": "modify",
      "old_id": "0b10e7fcd5edbe1ebf0be5f0bc7f8b1109c749cc",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Dialect/LinalgExt/Transforms/test/reshape_fusion.mlir",
      "new_id": "43f4e575dfc9a2443f5348e113516ea2863bd740",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Dialect/LinalgExt/Transforms/test/reshape_fusion.mlir"
    },
    {
      "type": "modify",
      "old_id": "9676ed0b2e33d6f59d249b98b297d2464bff61d3",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/GlobalOptimization/ConvertConvToIm2Col.cpp",
      "new_id": "b716212d04dd06b3725c55d2ba43c3c3671abb78",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/ConvertConvToIm2Col.cpp"
    },
    {
      "type": "modify",
      "old_id": "320093c77980e0b5ef1c36bf803d45808fb50ffa",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/GlobalOptimization/ConvertQDQToIntegerMath.cpp",
      "new_id": "be8aa0f6609fc0500b14a9ca8283ebdd165babb6",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/ConvertQDQToIntegerMath.cpp"
    },
    {
      "type": "modify",
      "old_id": "b9ab017512b4d1f7d889cd39a85ce0a11f8a4d2f",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/GlobalOptimization/DemoteContractionInputs.cpp",
      "new_id": "972f56a3884b80e63cf3a81f08683a23f7e919e2",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/DemoteContractionInputs.cpp"
    },
    {
      "type": "modify",
      "old_id": "dbedea49cfa40d978a1031afd2eee3f8cba86021",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/GlobalOptimization/Passes.cpp",
      "new_id": "9a7831290436fe1f0a6bf24b87ba0b48d540cd5a",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/Passes.cpp"
    },
    {
      "type": "modify",
      "old_id": "2d8d25181a39dd7f83c96e28243261d1bf956e29",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/GlobalOptimization/Passes.td",
      "new_id": "f0a3c3b7049cf82eeb250ff1356e3c48e3dfa4b0",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/Passes.td"
    },
    {
      "type": "modify",
      "old_id": "a6969acd5b13ccb6e980dc68d8a9f38d94bcd507",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/GlobalOptimization/test/BUILD.bazel",
      "new_id": "da05aa597c59b00fd14b9bccc0f2efadac63db49",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/test/BUILD.bazel"
    },
    {
      "type": "modify",
      "old_id": "9a05aee2cd091ae8134a5f9bb7c598e51103428b",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/GlobalOptimization/test/CMakeLists.txt",
      "new_id": "d490876e95d0839ddf93b632a426be83292bb3b3",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/test/CMakeLists.txt"
    },
    {
      "type": "modify",
      "old_id": "58430e0220926907ffef35d72f7f2591af8c6bed",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/GlobalOptimization/test/conv_to_im2col.mlir",
      "new_id": "5740528606654230a73a6b8e3021d2820e8e9092",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/test/conv_to_im2col.mlir"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "002adc3aba743cb3c2baa1447c0cc3919a1ef9be",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/test/conv_to_im2col_pipeline.mlir"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "ff1a73966af6451ee67b8909cf06db5504673969",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/test/convert_qdq_to_integer_math_biased_pipeline.mlir"
    },
    {
      "type": "modify",
      "old_id": "3575ced51a30a7dabaed6f281026a7b05e4e1d51",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/GlobalOptimization/test/convert_qdq_to_integer_math_maps.mlir",
      "new_id": "ac3f36dd8b896758adca14883d57a81d7c4d2e78",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/test/convert_qdq_to_integer_math_maps.mlir"
    },
    {
      "type": "modify",
      "old_id": "bdcd34beb8374ffd8838bf0a42faa8f78672351c",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/GlobalOptimization/test/convert_qdq_to_integer_math_pipeline.mlir",
      "new_id": "a4871d2df673598048a331e1e8d7898530e259dd",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/test/convert_qdq_to_integer_math_pipeline.mlir"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "f855786cb4f3a6e4039875a222b0a503a8116c89",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/test/demote_generic_contraction_inputs.mlir"
    },
    {
      "type": "modify",
      "old_id": "c23d41b702b15a4089a11e22e229ea714621eacd",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/GlobalOptimization/test/propagate_affine_quantization.mlir",
      "new_id": "ee3aa739686fbcb2f8c0c582d3fe3f36f0fe00f2",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/test/propagate_affine_quantization.mlir"
    },
    {
      "type": "modify",
      "old_id": "6367f334fcbcfd9cf67e8bd9ba9bb1cb13eb9b9d",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/GlobalOptimization/test/transformation_pipeline.mlir",
      "new_id": "fcee720991802923e086b9510b8ebdbf72b05ecd",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/GlobalOptimization/test/transformation_pipeline.mlir"
    }
  ]
}
