Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
4 changes: 4 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,10 @@

<h4>Other improvements</h4>

* An xDSL `Universe` containing all custom dialects and passes has been registered as an entry point, allowing
usage of PennyLane's dialects and passes with xDSL's command-line tools
[(#8372)](https://github.com/PennyLaneAI/pennylane/pull/8372)

* Two new `draw` and `generate_mlir_graph` functions have been introduced in the `qml.compiler.python_compiler.visualization` module
to visualize circuits with the new unified compiler framework when xDSL and/or Catalyst compilation passes are applied.
[(#8040)](https://github.com/PennyLaneAI/pennylane/pull/8040)
Expand Down
8 changes: 8 additions & 0 deletions pennylane/compiler/python_compiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@
# limitations under the License.
"""Python Compiler API for integration of Catalyst with xDSL."""

from xdsl.universe import Universe

from .compiler import Compiler
from .parser import QuantumParser
from .pass_api import compiler_transform
from .visualization import QMLCollector

from .dialects import get_universe_dialects
from .transforms import get_universe_passes

# Universe is used to expose custom dialects and transforms to xDSL
XDSL_UNIVERSE = Universe(all_dialects=get_universe_dialects(), all_passes=get_universe_passes())


__all__ = [
"Compiler",
Expand Down
16 changes: 16 additions & 0 deletions pennylane/compiler/python_compiler/dialects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,20 @@
from .transform import Transform


def get_universe_dialects():
"""Get a mapping between all available dialect names to dialect classes. This
is used to initialize the PennyLane-xDSL universe, which is needed to make the
dialects readily available to xDSL command-line tools."""
return {
"catalyst": Catalyst,
"mbqc": MBQC,
"quantum": Quantum,
"qec": QEC,
# Dialects available in xDSL already cannot be added to the universe, since
# the "multiverse" cannot have duplicate dialects
# "stablehlo": StableHLO,
# "transform": Transform,
}


__all__ = ["Catalyst", "MBQC", "Quantum", "QEC", "StableHLO", "Transform"]
16 changes: 16 additions & 0 deletions pennylane/compiler/python_compiler/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@
)


def get_universe_passes():
"""Get a mapping between all available pass names to pass classes. This is used
to initialize the PennyLane-xDSL universe, which is needed to make the passes
readily available to xDSL command-line tools."""
return {
"combine-global-phases": CombineGlobalPhasesPass,
"convert-to-mbqc-formalism": ConvertToMBQCFormalismPass,
"decompose-graph-state": DecomposeGraphStatePass,
"diagonalize-final-measurements": DiagonalizeFinalMeasurementsPass,
"xdsl-cancel-inverses": IterativeCancelInversesPass,
"measurements-from-samples": MeasurementsFromSamplesPass,
"xdsl-merge-rotations": MergeRotationsPass,
"null-decompose-graph-state": NullDecomposeGraphStatePass,
}


__all__ = [
# Quantum
"combine_global_phases_pass",
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ pl-device-test = "pennylane.devices.tests:cli"
"default.qutrit.mixed" = "pennylane.devices.default_qutrit_mixed:DefaultQutritMixed"
"default.tensor" = "pennylane.devices.default_tensor:DefaultTensor"

[project.entry-points."xdsl.universe"]
"pennylane" = "pennylane.compiler.python_compiler:XDSL_UNIVERSE"

[project.entry-points."console_scripts"]
"pl-device-test" = "pennylane.devices.tests:cli"

Expand Down