Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d653c5a
Update llvm, 2025 Q3
paul0403 Jul 17, 2025
bdf648c
Merge remote-tracking branch 'origin/main' into llvm_update_2025Q3
paul0403 Jul 22, 2025
8e6f2e6
patch mhlo std::sort bug
paul0403 Jul 22, 2025
c104695
update enzyme version
paul0403 Jul 22, 2025
f3b4f65
GreedyRewriteConfig.stuff = blah -> GreedyRewriteConfig.setStuff(blah)
paul0403 Jul 22, 2025
b76c38b
bufferization.to_memref -> bufferization.to_buffer
paul0403 Jul 22, 2025
e1ecd75
gep inbounds update
paul0403 Jul 22, 2025
cab23c8
arith.contant[int, float]op builder arg order swap
paul0403 Jul 22, 2025
06e9c28
`lookupOrCreateFn` takes in builder
paul0403 Jul 22, 2025
e44f5b3
gep inbounds flag seems to not need `()`
paul0403 Jul 22, 2025
cc077c1
bufferization.to_tensor op now needs the result type to be explicit
paul0403 Jul 22, 2025
b214802
two missed builder passing into `lookupOrCreateFn`
paul0403 Jul 22, 2025
8919702
things with bufferization
paul0403 Jul 22, 2025
d4d2548
update creations of GEPOp to use LLVM::GEPNoWrapFlags::inbounds
paul0403 Jul 22, 2025
6ac0a96
getStridedElementPtr taking in rewriter as first instead of last arg
paul0403 Jul 22, 2025
f6832cf
`catalyst::convertToDestinationPassingStyle` returns `LogicalResult`
paul0403 Jul 22, 2025
6f17313
propagate logical result for funcop insert/eraseArgument in a few mor…
paul0403 Jul 22, 2025
4b70caf
`getBackwardSlice()` now returns logical result
paul0403 Jul 22, 2025
85202c8
lit test. "to_memref" -> "to_buffer"
paul0403 Jul 22, 2025
05eb3de
a few more to_memref->to_buffer lit tests
paul0403 Jul 22, 2025
dc53788
pipeline printer now wraps lines at round brakets
paul0403 Jul 22, 2025
7c65d90
small fix for a warnings as errors in CI
paul0403 Jul 22, 2025
9325efb
apply_registered_pass op now takes in dict as options instead of strings
paul0403 Jul 23, 2025
4b08c5a
fix a test
paul0403 Jul 23, 2025
dba5a26
change a lit test for new dict option format
paul0403 Jul 23, 2025
3a8fdce
do not nest attr helper under a new context
paul0403 Jul 23, 2025
5d1a132
another pytest needs a manual ir.Context (the test for pass options)
paul0403 Jul 23, 2025
3a63e65
try suppressing nanobind warnings in CI for `make dialects`
paul0403 Jul 23, 2025
ca34f47
revert makefile nb suppress warnings
paul0403 Jul 23, 2025
bb4db28
ignore nanobind warnings in the dialects' python bindings' cmake
paul0403 Jul 23, 2025
edaf215
Merge remote-tracking branch 'origin/main' into llvm_update_2025Q3
paul0403 Jul 24, 2025
114eb0d
patch mlir bufferization segfault
paul0403 Jul 24, 2025
29069d6
changelog
paul0403 Jul 24, 2025
ec19eb9
update llvm patch to deal with nullptr deference instead of revert
paul0403 Jul 24, 2025
513f644
is CI not patching??
paul0403 Jul 24, 2025
8205845
revert patch
paul0403 Jul 25, 2025
eaff36b
use python match-case
paul0403 Jul 25, 2025
eb82dc4
Merge remote-tracking branch 'origin/main' into llvm_update_2025Q3
paul0403 Jul 25, 2025
9938f42
Merge remote-tracking branch 'origin/main' into llvm_update_2025Q3
paul0403 Jul 26, 2025
b93b059
codefactor complex method
paul0403 Jul 26, 2025
60814fd
codecov
paul0403 Jul 26, 2025
89ad730
pylint again
paul0403 Jul 26, 2025
cb48513
patch in wheels scripts
paul0403 Jul 26, 2025
96906d7
forgot a patch in wheels
paul0403 Jul 26, 2025
2038103
unify enzyme patch to also use git apply
paul0403 Jul 28, 2025
522bb02
Update frontend/catalyst/passes/pass_api.py
paul0403 Jul 28, 2025
d82d7ac
check int inside non overflowing range
paul0403 Jul 28, 2025
0b17c6c
remove unitattr from util
paul0403 Jul 28, 2025
dc072e1
remove patch checks in wheels scripts
paul0403 Jul 28, 2025
81b0ab6
mlir::sort
paul0403 Jul 28, 2025
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
6 changes: 3 additions & 3 deletions .dep-versions
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# To update JAX version alongside compatible dependency tags, run the following script:
# python3 .github/workflows/set_dep_versions.py {JAX_version}
jax=0.6.2
mhlo=617a9361d186199480c080c9e8c474a5e30c22d1
llvm=179d30f8c3fddd3c85056fd2b8e877a4a8513158
enzyme=v0.0.180
mhlo=1dd2e71331014ae0373f6bf900ce6be393357190
llvm=f8cb7987c64dcffb72414a40560055cb717dbf74
enzyme=v0.0.186

# Always remove custom PL/LQ versions before release.

Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/build-wheel-linux-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ jobs:
ref: ${{ needs.constants.outputs.llvm_version }}
path: ${{ github.workspace }}/mlir/llvm-project

- name: Patch LLVM Source
if: steps.cache-mhlo-source.outputs.cache-hit != 'true'
run: |
cd $GITHUB_WORKSPACE/mlir/llvm-project
git apply $GITHUB_WORKSPACE/mlir/patches/llvm-bufferization-segfault.patch

- name: Clone MHLO Submodule
if: steps.cache-mhlo-source.outputs.cache-hit != 'true'
uses: actions/checkout@v4
Expand All @@ -122,6 +128,7 @@ jobs:
cd $GITHUB_WORKSPACE/mlir/mlir-hlo
git apply $GITHUB_WORKSPACE/mlir/patches/mhlo-remove-shardy.patch
git apply $GITHUB_WORKSPACE/mlir/patches/mhlo-add-back-necessary-passes.patch
git apply $GITHUB_WORKSPACE/mlir/patches/mhlo-rename-sort.patch

- name: Clone Enzyme Submodule
if: steps.cache-enzyme-source.outputs.cache-hit != 'true'
Expand All @@ -134,9 +141,8 @@ jobs:
- name: Patch Enzyme Source
if: steps.cache-enzyme-source.outputs.cache-hit != 'true'
run: |
export TARGET_FILE=$GITHUB_WORKSPACE/mlir/Enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp
export PATCH_FILE=$GITHUB_WORKSPACE/mlir/patches/enzyme-nvvm-fabs-intrinsics.patch
patch -p1 $TARGET_FILE $PATCH_FILE
cd $GITHUB_WORKSPACE/mlir/Enzyme
git apply $GITHUB_WORKSPACE/mlir/patches/enzyme-nvvm-fabs-intrinsics.patch

# Cache external project builds
- name: Restore LLVM Build
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/build-wheel-linux-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ jobs:
ref: ${{ needs.constants.outputs.llvm_version }}
path: ${{ github.workspace }}/mlir/llvm-project

- name: Patch LLVM Source
if: steps.cache-mhlo-source.outputs.cache-hit != 'true'
run: |
cd $GITHUB_WORKSPACE/mlir/llvm-project
git apply $GITHUB_WORKSPACE/mlir/patches/llvm-bufferization-segfault.patch

- name: Clone MHLO Submodule
if: steps.cache-mhlo-source.outputs.cache-hit != 'true'
uses: actions/checkout@v4
Expand All @@ -141,6 +147,7 @@ jobs:
cd $GITHUB_WORKSPACE/mlir/mlir-hlo
git apply $GITHUB_WORKSPACE/mlir/patches/mhlo-remove-shardy.patch
git apply $GITHUB_WORKSPACE/mlir/patches/mhlo-add-back-necessary-passes.patch
git apply $GITHUB_WORKSPACE/mlir/patches/mhlo-rename-sort.patch

- name: Clone Enzyme Submodule
if: steps.cache-enzyme-source.outputs.cache-hit != 'true'
Expand All @@ -153,9 +160,8 @@ jobs:
- name: Patch Enzyme Source
if: steps.cache-enzyme-source.outputs.cache-hit != 'true'
run: |
export TARGET_FILE=$GITHUB_WORKSPACE/mlir/Enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp
export PATCH_FILE=$GITHUB_WORKSPACE/mlir/patches/enzyme-nvvm-fabs-intrinsics.patch
patch -p1 $TARGET_FILE $PATCH_FILE
cd $GITHUB_WORKSPACE/mlir/Enzyme
git apply $GITHUB_WORKSPACE/mlir/patches/enzyme-nvvm-fabs-intrinsics.patch

# Cache external project builds
- name: Restore LLVM Build
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/build-wheel-macos-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ jobs:
ref: ${{ needs.constants.outputs.llvm_version }}
path: ${{ github.workspace }}/mlir/llvm-project

- name: Patch LLVM Source
if: steps.cache-mhlo-source.outputs.cache-hit != 'true'
run: |
cd $GITHUB_WORKSPACE/mlir/llvm-project
git apply $GITHUB_WORKSPACE/mlir/patches/llvm-bufferization-segfault.patch

- name: Clone MHLO Submodule
if: steps.cache-mhlo-source.outputs.cache-hit != 'true'
uses: actions/checkout@v4
Expand All @@ -127,6 +133,7 @@ jobs:
cd $GITHUB_WORKSPACE/mlir/mlir-hlo
git apply $GITHUB_WORKSPACE/mlir/patches/mhlo-remove-shardy.patch
git apply $GITHUB_WORKSPACE/mlir/patches/mhlo-add-back-necessary-passes.patch
git apply $GITHUB_WORKSPACE/mlir/patches/mhlo-rename-sort.patch

- name: Clone Enzyme Submodule
if: steps.cache-enzyme-source.outputs.cache-hit != 'true'
Expand All @@ -139,9 +146,8 @@ jobs:
- name: Patch Enzyme Source
if: steps.cache-enzyme-source.outputs.cache-hit != 'true'
run: |
export TARGET_FILE=$GITHUB_WORKSPACE/mlir/Enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp
export PATCH_FILE=$GITHUB_WORKSPACE/mlir/patches/enzyme-nvvm-fabs-intrinsics.patch
patch -p1 $TARGET_FILE $PATCH_FILE
cd $GITHUB_WORKSPACE/mlir/Enzyme
git apply $GITHUB_WORKSPACE/mlir/patches/enzyme-nvvm-fabs-intrinsics.patch

# Cache external project builds
- name: Restore LLVM Build
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ clean-plugin:
clean-llvm:
$(MAKE) -C mlir clean-llvm

reset-llvm:
$(MAKE) -C mlir reset-llvm

clean-mhlo:
$(MAKE) -C mlir clean-mhlo

Expand Down
10 changes: 10 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
* The JAX version used by Catalyst is updated to 0.6.2.
[(#1897)](https://github.com/PennyLaneAI/catalyst/pull/1897)

* The version of LLVM, mlir-hlo, and Enzyme used by Catalyst has been updated.
[(#1916)](https://github.com/PennyLaneAI/catalyst/pull/1916)

The LLVM version has been updated to
[commit f8cb798](https://github.com/llvm/llvm-project/tree/f8cb7987c64dcffb72414a40560055cb717dbf74).
The mlir-hlo version has been updated to
[commit 1dd2e71](https://github.com/tensorflow/mlir-hlo/tree/1dd2e71331014ae0373f6bf900ce6be393357190).
The Enzyme version has been updated to
[v0.0.186](https://github.com/EnzymeAD/Enzyme/releases/tag/v0.0.186).

<h3>Deprecations 👋</h3>

<h3>Bug fixes 🐛</h3>
Expand Down
56 changes: 56 additions & 0 deletions frontend/catalyst/jax_extras/lowering.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from __future__ import annotations

import logging
import textwrap

import jax
from jax._src.dispatch import jaxpr_replicas
Expand All @@ -38,6 +39,7 @@

import catalyst
from catalyst.logging import debug_logger
from catalyst.utils.exceptions import CompileError
from catalyst.utils.patching import Patcher

# pylint: disable=protected-access
Expand Down Expand Up @@ -165,3 +167,57 @@ def custom_lower_jaxpr_to_module(
worklist += [*op.body.operations]

return ctx.module, ctx.context


def get_mlir_attribute_from_pyval(value):
"""
Given a value of any type, construct an mlir attribute of corresponding type.

We set up the context and location outside because recursive calls to this function
will segfault if multiple `Context()`s are instantiated.
"""

attr = None
match value:
case bool():
attr = ir.BoolAttr.get(value)

case int():
if -9223372036854775808 <= value < 0: # 2**63
attr = ir.IntegerAttr.get(ir.IntegerType.get_signed(64), value)
elif 0 <= value < 18446744073709551616: # = 2**64
attr = ir.IntegerAttr.get(ir.IntegerType.get_signless(64), value)
else:
raise CompileError(
textwrap.dedent(
"""
Large interger attributes currently not supported in MLIR,
see https://github.com/llvm/llvm-project/issues/128072
"""
)
)

case float():
attr = ir.FloatAttr.get(ir.F64Type.get(), value)

case str():
attr = ir.StringAttr.get(value)

case list() | tuple():
element_attrs = [get_mlir_attribute_from_pyval(elem) for elem in value]
attr = ir.ArrayAttr.get(element_attrs)

case dict():
named_attrs = {}
for k, v in value.items():
if not isinstance(k, str):
raise CompileError(
f"Dictionary keys for MLIR DictionaryAttr must be strings, got: {type(k)}"
)
named_attrs[k] = get_mlir_attribute_from_pyval(v)
attr = ir.DictAttr.get(named_attrs)

case _:
raise CompileError(f"Cannot convert Python type {type(value)} to an MLIR attribute.")

return attr
6 changes: 5 additions & 1 deletion frontend/catalyst/jax_primitives_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ def transform_named_sequence_lowering(jax_ctx: mlir.LoweringRuleContext, pipelin
for _pass in pipeline:
options = _pass.get_options()
apply_registered_pass_op = ApplyRegisteredPassOp(
result=transform_mod_type, target=target, pass_name=_pass.name, options=options
result=transform_mod_type,
target=target,
pass_name=_pass.name,
options=options,
dynamic_options={},
)
target = apply_registered_pass_op.result
transform_yield_op = YieldOp(operands_=[]) # pylint: disable=unused-variable
Expand Down
26 changes: 11 additions & 15 deletions frontend/catalyst/passes/pass_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import pennylane as qml

from catalyst.jax_extras.lowering import get_mlir_attribute_from_pyval
from catalyst.tracing.contexts import EvaluationContext

PipelineDict: TypeAlias = dict[str, dict[str, str]]
Expand Down Expand Up @@ -286,23 +287,18 @@ def __init__(self, name: str, *options: list[str], **valued_options: dict[str, s

def get_options(self):
"""
Stringify options according to what mlir-opt expects.

ApplyRegisteredPassOp expects options to be a single StringAttr
which follows the same format as the one used with mlir-opt.

https://mlir.llvm.org/docs/Dialects/Transform/#transformapply_registered_pass-transformapplyregisteredpassop

Options passed to a pass are specified via the syntax {option1=value1 option2=value2 ...},
i.e., use space-separated key=value pairs for each option.
Build a dictionary mapping option names to MLIR attributes.
ApplyRegisteredPassOp expects options to be a dictionary from strings to attributes.
See https://github.com/llvm/llvm-project/pull/143159
"""
options_dict = {}
for option in self.options:
options_dict[str(option)] = get_mlir_attribute_from_pyval(True)

https://mlir.llvm.org/docs/Tutorials/MlirOpt/#running-a-pass-with-options
for option, value in self.valued_options.items():
options_dict[str(option)] = get_mlir_attribute_from_pyval(value)

Experimentally we found that single-options also work without values.
"""
retval = " ".join(f"{str(option)}" for option in self.options)
retval2 = " ".join(f"{str(key)}={str(value)}" for key, value in self.valued_options.items())
return " ".join([retval, retval2]).strip()
return options_dict

def __repr__(self):
return (
Expand Down
2 changes: 1 addition & 1 deletion frontend/test/lit/test_mlir_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_pass_options():
"""Is the option in the generated MLIR?"""

@qjit(target="mlir")
# CHECK: options = "an-option maxValue=1"
# CHECK: options = {"an-option" = true, "maxValue" = 1 : i64}
@catalyst.passes.apply_pass("some-pass", "an-option", maxValue=1)
@qml.qnode(qml.device("null.qubit", wires=1))
def example():
Expand Down
Loading