Skip to content
Open
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
df8b97b
Migrate unified compiler to Catalyst
mudit2812 Nov 17, 2025
9536707
Fixing migration artifacts; linting
mudit2812 Nov 17, 2025
1453aae
Fix CI errors; Ignore unified compiler in coverage reports
mudit2812 Nov 17, 2025
efc0f88
Test out how graphviz is installed
mudit2812 Nov 17, 2025
10cd749
Lint some more
mudit2812 Nov 17, 2025
27de22d
Merge branch 'main' into migrate-unified-compiler
mudit2812 Nov 17, 2025
f7aa2b6
[skip ci] Skip CI
mudit2812 Nov 17, 2025
012f58b
[skip ci] Skip CI
mudit2812 Nov 17, 2025
f0a0c90
Merge branch 'migrate-unified-compiler' of https://github.com/PennyLa…
mudit2812 Nov 17, 2025
c98755e
Try installing graphviz with apt
mudit2812 Nov 17, 2025
bb5bd00
Fix codefactor complaints
mudit2812 Nov 17, 2025
1448472
Merge branch 'main' into migrate-unified-compiler
mudit2812 Nov 17, 2025
5e745f5
Try appeasing codefactor again
mudit2812 Nov 17, 2025
0409933
Try appeasing codefactor once again
mudit2812 Nov 17, 2025
e786a12
Pylint suppression
mudit2812 Nov 17, 2025
4ae10ff
Reduce complexity of stablehlo.reduce and stablehlo.dynamic_broadcast…
mudit2812 Nov 17, 2025
dc41a7b
Fix some failures
mudit2812 Nov 18, 2025
58b13e4
Try change to graphviz installation
mudit2812 Nov 18, 2025
4e5f904
Merge branch 'main' into migrate-unified-compiler
mudit2812 Nov 18, 2025
637d2cf
Try installing graphviz with pip
mudit2812 Nov 18, 2025
091c5e1
Merge branch 'main' into migrate-unified-compiler
mudit2812 Nov 18, 2025
64e0fd4
Try installing graphviz with both apt and pip
mudit2812 Nov 18, 2025
dc15d3a
Add utils file to remove conftest imports
mudit2812 Nov 18, 2025
e7e33d6
Merge branch 'main' into migrate-unified-compiler
mudit2812 Nov 18, 2025
f919e8d
Remove unused imports
mudit2812 Nov 18, 2025
005ba9f
Add graphviz dependencies to lightning.kokkos testing workflow
mudit2812 Nov 18, 2025
6117189
Update cookbook
mudit2812 Nov 18, 2025
6961324
Migrate all changelog entries from PennyLane
mudit2812 Nov 18, 2025
0fdbb46
Merge branch 'main' into migrate-unified-compiler
mudit2812 Nov 18, 2025
a868bc3
Add EOF new line to .codecov.yml
mudit2812 Nov 18, 2025
8f00b2f
change changelog entry slightly
mudit2812 Nov 18, 2025
22a6e6e
Merge branch 'main' into migrate-unified-compiler
mudit2812 Nov 20, 2025
a63412d
basic cl
andrijapau Nov 20, 2025
82b023a
Trigger CI
andrijapau Nov 20, 2025
efdea51
Merge branch 'migrate-unified-compiler' into feature/graph-visualization
andrijapau Nov 20, 2025
248b7bd
feat: add `DAGBuilder` abstract base class and `PyDotDAGBuilder` conc…
andrijapau Nov 20, 2025
b4a321d
Merge branch 'main' into migrate-unified-compiler
mudit2812 Nov 26, 2025
09be3af
feat: add `nodes`, `clusters` and `edges` properties to DAGBuilders (…
andrijapau Nov 26, 2025
4cbe02a
Remove reference to 'remove-chained-self-inverses'
mudit2812 Nov 26, 2025
c5f08c3
Remove leftover references to pennylane.compiler.python_compiler
mudit2812 Nov 27, 2025
251832a
feat: add `ConstructCircuitDAG` director pattern (#2214)
andrijapau Nov 28, 2025
f8cd095
fix: rename `id` to `uid` (#2246)
andrijapau Nov 28, 2025
43acb6f
fix: rename id to uid in FakeDAGBuilder
andrijapau Nov 28, 2025
f87de2a
format: black and isort
andrijapau Nov 28, 2025
fe76357
Streamline circuit inspection utilities (#2237)
jzaia18 Dec 1, 2025
fc2ce0e
Merge branch 'migrate-unified-compiler' into feature/graph-visualization
andrijapau Dec 1, 2025
5f2028d
feat: add cluster visualization for `FuncOp` and `DeviceInitOp` opera…
andrijapau Dec 5, 2025
c5b9337
fix: use standard cluster label rather than "label" nodes (#2285)
andrijapau Dec 10, 2025
8f6563e
feat: add cluster visualization for `WhileOp`, `IfOp`, `ForOp` (#2234)
andrijapau Dec 10, 2025
3179d95
feat: visualize static operators and measurements as nodes (#2218)
andrijapau Dec 10, 2025
017a93a
Merge branch 'main' into feature/graph-visualization
andrijapau Dec 10, 2025
53923a6
Apply suggestion from @andrijapau
andrijapau Dec 10, 2025
126f585
Revert "Apply suggestion from @andrijapau"
andrijapau Dec 10, 2025
4bef8af
clean up merge
andrijapau Dec 10, 2025
1555917
Apply suggestion from @andrijapau
andrijapau Dec 10, 2025
993722f
Apply suggestion from @andrijapau
andrijapau Dec 10, 2025
527e9b0
Apply suggestion from @andrijapau
andrijapau Dec 10, 2025
248594c
Apply suggestion from @andrijapau
andrijapau Dec 10, 2025
8c32850
Apply suggestion from @andrijapau
andrijapau Dec 10, 2025
feb3ef3
Apply suggestion from @andrijapau
andrijapau Dec 10, 2025
b3d9a0b
remove transform.py
andrijapau Dec 10, 2025
f88ccc3
restore frontend/catalyst/compiler.py
andrijapau Dec 10, 2025
26fddb8
restore frontend/catalyst/jit.py
andrijapau Dec 10, 2025
324bbda
restore frontend/test/pytest/python_interface/conftest.py
andrijapau Dec 10, 2025
8bf4c17
restore test_python_compiler.py
andrijapau Dec 10, 2025
e8ef2c3
change tests
andrijapau Dec 10, 2025
37fe1d9
Merge branch 'main' into feature/graph-visualization
andrijapau Dec 11, 2025
8add091
fix: remove pytest.mark.unit as it isnt recognized
andrijapau Dec 12, 2025
32c9ca9
Merge branch 'main' into feature/graph-visualization
andrijapau Dec 12, 2025
da1b55c
Merge branch 'main' into feature/graph-visualization
andrijapau Dec 12, 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
10 changes: 10 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

<h3>New features since last release</h3>

* Compiled programs can be visualized.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entry should probably be significantly more descriptive since it's a pretty big new feature

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - just a place holder for now 😄

[(#2213)](https://github.com/PennyLaneAI/catalyst/pull/2213)
[(#2229)](https://github.com/PennyLaneAI/catalyst/pull/2229)
[(#2214)](https://github.com/PennyLaneAI/catalyst/pull/2214)
[(#2246)](https://github.com/PennyLaneAI/catalyst/pull/2246)
[(#2231)](https://github.com/PennyLaneAI/catalyst/pull/2231)
[(#2285)](https://github.com/PennyLaneAI/catalyst/pull/2285)
[(#2234)](https://github.com/PennyLaneAI/catalyst/pull/2234)
[(#2218)](https://github.com/PennyLaneAI/catalyst/pull/2218)

* Catalyst now features a unified compilation framework, which enables users and developers to design
and implement compilation passes in Python in addition to C++, on the same Catalyst IR. The Python
interface relies on the xDSL library to represent and manipulate programs (analogous to the MLIR library
Expand Down
8 changes: 4 additions & 4 deletions frontend/catalyst/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,11 @@ def to_llvmir(*args, stdin=None, options: Optional[CompileOptions] = None):


def to_mlir_opt(
*args, stdin=None, options: Optional[CompileOptions] = None, using_python_compiler=False
*args, stdin=None, options: Optional[CompileOptions] = None, using_unified_compiler=False
):
"""echo ${input} | catalyst --tool=opt *args *opts -"""
# Check if we need to use the Python interface for xDSL passes
if using_python_compiler:
if using_unified_compiler:
# Use the Python interface path for xDSL passes
# pylint: disable-next=import-outside-toplevel
from catalyst.python_interface import Compiler as UnifiedCompiler
Expand Down Expand Up @@ -547,7 +547,7 @@ def check_nested_operations(op):
return False

@debug_logger
def is_using_python_compiler(self, mlir_module=None):
def is_using_unified_compiler(self, mlir_module=None):
"""Returns true if we need the Python interface path.

This happens when:
Expand Down Expand Up @@ -649,7 +649,7 @@ def run(self, mlir_module, *args, **kwargs):
Returns:
(str): filename of shared object
"""
using_python_compiler = self.is_using_python_compiler(mlir_module)
using_python_compiler = self.is_using_unified_compiler(mlir_module)
workspace = args[0] if args else kwargs.get("workspace")
module_name = str(mlir_module.operation.attributes["sym_name"]).replace('"', "")
ir = mlir_module.operation.get_asm(
Expand Down
6 changes: 3 additions & 3 deletions frontend/catalyst/jit.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,13 +582,13 @@ def mlir_opt(self):
"""Obtain the MLIR representation after optimization"""
if not self.mlir_module:
return None
using_python_compiler = self.compiler.is_using_python_compiler(self.mlir_module)
using_unified_compiler = self.compiler.is_using_unified_compiler(self.mlir_module)
stdin = self.mlir_module.operation.get_asm(
print_generic_op_form=using_python_compiler,
print_generic_op_form=using_unified_compiler,
enable_debug_info=self.compile_options.use_nameloc,
)
return to_mlir_opt(
stdin=stdin, options=self.compile_options, using_python_compiler=using_python_compiler
stdin=stdin, options=self.compile_options, using_unified_compiler=using_unified_compiler
)

@debug_logger
Expand Down
25 changes: 25 additions & 0 deletions frontend/catalyst/python_interface/dialects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,35 @@

"""This submodule contains xDSL dialects for the unified compiler."""

from .catalyst import Catalyst
from .mbqc import MBQC
from .qec import QEC
from .quantum import Quantum
from .stablehlo import StableHLO
from .transform import Transform

__all__ = ["Catalyst", "MBQC", "Quantum", "QEC", "StableHLO", "Transform"]

# Copyright 2025 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""This submodule contains xDSL dialects for the unified compiler."""

from .catalyst import Catalyst

Check notice on line 42 in frontend/catalyst/python_interface/dialects/__init__.py

View check run for this annotation

codefactor.io / CodeFactor

frontend/catalyst/python_interface/dialects/__init__.py#L42

Import "from .catalyst import Catalyst" should be placed at the top of the module (wrong-import-position)
from .mbqc import MBQC

Check notice on line 43 in frontend/catalyst/python_interface/dialects/__init__.py

View check run for this annotation

codefactor.io / CodeFactor

frontend/catalyst/python_interface/dialects/__init__.py#L43

Import "from .mbqc import MBQC" should be placed at the top of the module (wrong-import-position)
from .qec import QEC

Check notice on line 44 in frontend/catalyst/python_interface/dialects/__init__.py

View check run for this annotation

codefactor.io / CodeFactor

frontend/catalyst/python_interface/dialects/__init__.py#L44

Import "from .qec import QEC" should be placed at the top of the module (wrong-import-position)
from .quantum import Quantum

Check notice on line 45 in frontend/catalyst/python_interface/dialects/__init__.py

View check run for this annotation

codefactor.io / CodeFactor

frontend/catalyst/python_interface/dialects/__init__.py#L45

Import "from .quantum import Quantum" should be placed at the top of the module (wrong-import-position)
from .stablehlo import StableHLO

Check notice on line 46 in frontend/catalyst/python_interface/dialects/__init__.py

View check run for this annotation

codefactor.io / CodeFactor

frontend/catalyst/python_interface/dialects/__init__.py#L46

Import "from .stablehlo import StableHLO" should be placed at the top of the module (wrong-import-position)

__all__ = ["Catalyst", "MBQC", "Quantum", "QEC", "StableHLO"]
122 changes: 122 additions & 0 deletions frontend/catalyst/python_interface/dialects/transform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Copyright 2025 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
This file contains an updated version of the transform dialect.
As of the time of writing, xDSL uses the MLIR released with LLVM's
version 20.1.7. However, https://github.com/PennyLaneAI/catalyst/pull/1916
will be updating MLIR where the transform dialect has the
`apply_registered_pass` operation re-defined.

See the following changelog on the above PR

Things related to transform.apply_registered_pass op:

It now takes in a dynamic_options

[MLIR][Transform] Allow ApplyRegisteredPassOp to take options as
a param llvm/llvm-project#142683. We don't need to use this as all our pass options are static.
https://github.com/llvm/llvm-project/pull/142683

The options it takes in are now dictionaries instead of strings
[MLIR][Transform] apply_registered_pass op's options as a dict llvm/llvm-project#143159
https://github.com/llvm/llvm-project/pull/143159

This file will re-define the apply_registered_pass operation in xDSL
and the transform dialect.

Once xDSL moves to a newer version of MLIR, these changes should
be contributed upstream.
"""

from xdsl.dialects.builtin import Dialect
from xdsl.dialects.transform import ApplyRegisteredPassOp as xApplyRegisteredPassOp
from xdsl.dialects.transform import (
DictionaryAttr,
StringAttr,
)
from xdsl.dialects.transform import Transform as xTransform
from xdsl.dialects.transform import (
TransformHandleType,
irdl_op_definition,
operand_def,
prop_def,
result_def,
)
from xdsl.ir import Attribute, SSAValue
from xdsl.irdl import IRDLOperation, ParsePropInAttrDict


# pylint: disable=line-too-long
@irdl_op_definition
class ApplyRegisteredPassOp(IRDLOperation):
"""
See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformapply_registered_pass-transformapplyregisteredpassop).
"""

name = "transform.apply_registered_pass"

options = prop_def(DictionaryAttr, default_value=DictionaryAttr({}))
pass_name = prop_def(StringAttr)
target = operand_def(TransformHandleType)
result = result_def(TransformHandleType)
# While this assembly format doesn't match
# the one in upstream MLIR,
# this is because xDSL currently lacks CustomDirectives
# https://mlir.llvm.org/docs/DefiningDialects/Operations/#custom-directives
# https://github.com/xdslproject/xdsl/pull/4829
# However, storing the property in the attribute should still work
# specially when parsing and printing in generic format.
# Which is how Catalyst and XDSL currently communicate at the moment.
# TODO: Add test.
assembly_format = "$pass_name `to` $target attr-dict `:` functional-type(operands, results)"
irdl_options = [ParsePropInAttrDict()]

def __init__(
self,
pass_name: str | StringAttr,
target: SSAValue,
options: dict[str | StringAttr, Attribute | str | bool | int] | None = None,
):
if isinstance(pass_name, str):
pass_name = StringAttr(pass_name)

if isinstance(options, dict):
options = DictionaryAttr(options)

super().__init__(
properties={
"pass_name": pass_name,
"options": options,
},
operands=[target],
result_types=[target.type],
)


# Copied over from xDSL's sources
# the main difference will be the use
# of a different ApplyRegisteredPassOp
operations = list(xTransform.operations)
del operations[operations.index(xApplyRegisteredPassOp)]
operations.append(ApplyRegisteredPassOp)

Transform = Dialect(
"transform",
[
*operations,
],
[
*xTransform.attributes,
],
)
Loading
Loading