Skip to content

Commit

Permalink
Merge pull request #35 from dlyongemallo/expose_qiskit_plugin
Browse files Browse the repository at this point in the history
Explose zxpass as a Qiskit transpiler plugin.
  • Loading branch information
dlyongemallo authored Apr 7, 2024
2 parents 68f1ba9 + 780abc2 commit da65b86
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
__pycache__/

# Distribution / packaging
build/
dist/
*.egg-info/

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ zxpass = ZXPass(my_optimize)
pass_manager = PassManager(zxpass)
my_qc = pass_manager.run(qc)
```

The transpiler is also exposed as a pass manager stage plugin at the optimization stage.

```python
from qiskit import transpile

zx_qc = transpile(qc, optimization_method="zxpass")
```

## Running benchmarks

To perform some benchmarks based on the [QASMBench](https://github.com/pnnl/QASMBench) suite, run the following:
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ Issues = "https://github.com/dlyongemallo/qiskit-zx-transpiler/issues"
[tool.setuptools.packages.find]
include = ["zxpass"]

[project.entry-points."qiskit.transpiler.optimization"]
zxpass = "zxpass.plugin:ZXPlugin"
29 changes: 29 additions & 0 deletions zxpass/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ZX transpiler pass for Qiskit
# Copyright (C) 2023 David Yonge-Mallo
#
# 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.

from qiskit.transpiler.basepasses import TransformationPass
from qiskit.transpiler.preset_passmanagers.plugin import PassManagerStagePlugin
from qiskit.transpiler import PassManagerConfig, PassManager

from typing import Optional

from .zxpass import ZXPass


class ZXPlugin(PassManagerStagePlugin):
def pass_manager(
self, pass_manager_config: PassManagerConfig, optimization_level: Optional[int] = None
) -> PassManager:
return PassManager([ZXPass()])

0 comments on commit da65b86

Please sign in to comment.