# Prefect Qiskit
[](https://opensource.org/licenses/Apache-2.0)
[](https://github.com/Qiskit-Community/prefect-qiskit/releases)

This library integrates [Prefect](https://www.prefect.io/) with [Qiskit Primitives](https://docs.quantum.ibm.com/api/qiskit/primitives),
which are vendor-agnostic abstractions for quantum computation.
Given the high cost and limited processing time of quantum computation,
fatal errors can disrupt the entire workflow.
This library enhances software fault tolerance
by implementing primitive execution within a Prefect workflow.
For more details, visit the full documentation [here](https://qiskit-community.github.io/prefect-qiskit/).
## Installation
Prefect Qiskit requires Python 3.10 or later.
We encourage install via ``pip``
```bash
pip install prefect-qiskit
```
Pip will handle all dependencies automatically and you will always install the latest version.
## Quantum Computing Workflow
The programming model and syntax are largely consistent with conventional Qiskit primitives,
allowing easy integration of Prefect's powerful job management features
into existing experiment codebases.
The key difference is the use of the `QuantumRuntime` Block,
which implements the Prefect API for quantum computing.
Unlike the conventional pattern that uses primitive class instances to create jobs,
the runtime Block encapsulates vendor-specific job handling
and provides robust error handling during execution.
For example, the following script samples the probability distribution of
the Bell state using the Qiskit Aer simulator.
```python
from prefect import flow, task
from prefect_qiskit import QuantumRuntime
from prefect_qiskit.vendors import QiskitAerCredentials
from qiskit.circuit import QuantumCircuit
from qiskit.transpiler import generate_preset_pass_manager
@task
def transpile_task(circuit, target):
pm = generate_preset_pass_manager(
optimization_level=2,
target=target,
)
return pm.run(circuit)
@flow
def sample_bell():
# 1. Create QuantumRuntime for Aer backend
credentials = QiskitAerCredentials(
num_qubits=2,
noise=True,
)
runtime = QuantumRuntime(
resource_name="aer_simulator",
credentials=credentials,
)
# 2. Create ISA quantum circuit
bell = QuantumCircuit(2)
bell.h(0)
bell.cx(0, 1)
bell.measure_all()
isa_circ = transpile_task(
circuit=bell,
target=runtime.get_target(),
)
# 3. Execute workflow sampler
result = runtime.sampler(
[isa_circ],
options={"default_shots": 100},
)
print(result[0].data.meas.get_counts())
# Run the flow
if __name__ == "__main__":
sample_bell()
```
Before running your workflow, start the Prefect server:
```bash
prefect server start --background
```
You can then run the workflow as a standard Python script. Once the workflow begins,
you can monitor its execution status in the Prefect console.
For common workflow usage, refer to the [Prefect documentation](https://docs.prefect.io/v3/develop/write-flows).
> [!TIP]
> The runtime Block also supports asynchronous execution.
> For massive parallel execution of primitives,
> using the `await` expression will efficiently utilize your computational resources.
## Registering Blocks
Register Blocks to make them available for use with the Prefect console.
```bash
prefect block register -m prefect_qiskit
prefect block register -m prefect_qiskit.vendors
```
## Contribution Guidelines
If you'd like to contribute to Prefect Qiskit, please take a look at our [contribution guidelines](https://qiskit-community.github.io/prefect-qiskit/contribution/). By participating, you are expected to uphold our code of conduct.
We use [GitHub issues](https://github.com/qiskit-community/prefect-qiskit/issues) for tracking requests and bugs.
For Prefect workflow, open issues and PRs against [PrefectHQ/prefect](https://github.com/PrefectHQ/prefect) instead of this repository.
Likewise, open issues and PRs against [Qiskit/qiskit](https://github.com/Qiskit/qiskit) for Qiskit Primitives.
## License
[Apache License 2.0](LICENSE.txt)
Raw data
{
"_id": null,
"home_page": null,
"name": "prefect-qiskit",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Naoki Kanazawa <knzwnao@jp.ibm.com>",
"keywords": "quantum computing, workflow, qiskit, prefect",
"author": null,
"author_email": "Naoki Kanazawa <knzwnao@jp.ibm.com>",
"download_url": "https://files.pythonhosted.org/packages/e4/ab/477ae54c20e5dd5183b15b76d86f4f51e9bea1728fd6ae4bf80fef76b440/prefect_qiskit-0.2.0.tar.gz",
"platform": null,
"description": "# Prefect Qiskit\n\n[](https://opensource.org/licenses/Apache-2.0)\n[](https://github.com/Qiskit-Community/prefect-qiskit/releases)\n\n\nThis library integrates [Prefect](https://www.prefect.io/) with [Qiskit Primitives](https://docs.quantum.ibm.com/api/qiskit/primitives), \nwhich are vendor-agnostic abstractions for quantum computation. \n\nGiven the high cost and limited processing time of quantum computation, \nfatal errors can disrupt the entire workflow. \nThis library enhances software fault tolerance \nby implementing primitive execution within a Prefect workflow.\n\nFor more details, visit the full documentation [here](https://qiskit-community.github.io/prefect-qiskit/).\n\n## Installation\n\nPrefect Qiskit requires Python 3.10 or later. \nWe encourage install via ``pip``\n\n```bash\npip install prefect-qiskit\n```\n\nPip will handle all dependencies automatically and you will always install the latest version.\n\n\n## Quantum Computing Workflow\n\nThe programming model and syntax are largely consistent with conventional Qiskit primitives, \nallowing easy integration of Prefect's powerful job management features \ninto existing experiment codebases. \nThe key difference is the use of the `QuantumRuntime` Block, \nwhich implements the Prefect API for quantum computing.\n\nUnlike the conventional pattern that uses primitive class instances to create jobs, \nthe runtime Block encapsulates vendor-specific job handling \nand provides robust error handling during execution.\n\nFor example, the following script samples the probability distribution of \nthe Bell state using the Qiskit Aer simulator.\n\n```python\nfrom prefect import flow, task\nfrom prefect_qiskit import QuantumRuntime\nfrom prefect_qiskit.vendors import QiskitAerCredentials\nfrom qiskit.circuit import QuantumCircuit\nfrom qiskit.transpiler import generate_preset_pass_manager\n\n\n@task\ndef transpile_task(circuit, target):\n pm = generate_preset_pass_manager(\n optimization_level=2,\n target=target,\n )\n return pm.run(circuit)\n\n\n@flow\ndef sample_bell():\n # 1. Create QuantumRuntime for Aer backend\n credentials = QiskitAerCredentials(\n num_qubits=2, \n noise=True,\n )\n runtime = QuantumRuntime(\n resource_name=\"aer_simulator\", \n credentials=credentials,\n )\n # 2. Create ISA quantum circuit\n bell = QuantumCircuit(2)\n bell.h(0)\n bell.cx(0, 1)\n bell.measure_all()\n isa_circ = transpile_task(\n circuit=bell, \n target=runtime.get_target(),\n )\n # 3. Execute workflow sampler\n result = runtime.sampler(\n [isa_circ], \n options={\"default_shots\": 100},\n )\n print(result[0].data.meas.get_counts())\n\n\n# Run the flow\nif __name__ == \"__main__\":\n sample_bell()\n```\n\nBefore running your workflow, start the Prefect server:\n\n```bash\nprefect server start --background\n```\n\nYou can then run the workflow as a standard Python script. Once the workflow begins, \nyou can monitor its execution status in the Prefect console. \nFor common workflow usage, refer to the [Prefect documentation](https://docs.prefect.io/v3/develop/write-flows).\n\n> [!TIP]\n> The runtime Block also supports asynchronous execution.\n> For massive parallel execution of primitives, \n> using the `await` expression will efficiently utilize your computational resources.\n\n\n## Registering Blocks\n\nRegister Blocks to make them available for use with the Prefect console.\n\n```bash\nprefect block register -m prefect_qiskit\nprefect block register -m prefect_qiskit.vendors\n```\n\n## Contribution Guidelines\n\nIf you'd like to contribute to Prefect Qiskit, please take a look at our [contribution guidelines](https://qiskit-community.github.io/prefect-qiskit/contribution/). By participating, you are expected to uphold our code of conduct.\n\nWe use [GitHub issues](https://github.com/qiskit-community/prefect-qiskit/issues) for tracking requests and bugs.\nFor Prefect workflow, open issues and PRs against [PrefectHQ/prefect](https://github.com/PrefectHQ/prefect) instead of this repository.\nLikewise, open issues and PRs against [Qiskit/qiskit](https://github.com/Qiskit/qiskit) for Qiskit Primitives.\n\n## License\n\n[Apache License 2.0](LICENSE.txt)\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "Prefect workflow integration for Qiskit Primitives.",
"version": "0.2.0",
"project_urls": {
"Documentation": "https://qiskit-community.github.io/prefect-qiskit/",
"Homepage": "https://github.com/qiskit-community/prefect-qiskit"
},
"split_keywords": [
"quantum computing",
" workflow",
" qiskit",
" prefect"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3eb36a6c5e07640442822e75914c3917992d67006507c65bb3d0e67b89aae356",
"md5": "3d227a53def8c781b22d62792eacb493",
"sha256": "681e56c1c3629f4571948df6c31ce064b5c7492a5335833f6982ed710226a743"
},
"downloads": -1,
"filename": "prefect_qiskit-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3d227a53def8c781b22d62792eacb493",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 715781,
"upload_time": "2025-07-17T09:35:41",
"upload_time_iso_8601": "2025-07-17T09:35:41.859438Z",
"url": "https://files.pythonhosted.org/packages/3e/b3/6a6c5e07640442822e75914c3917992d67006507c65bb3d0e67b89aae356/prefect_qiskit-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e4ab477ae54c20e5dd5183b15b76d86f4f51e9bea1728fd6ae4bf80fef76b440",
"md5": "f947cbd71aba2e4dd8a1a47ca91aafd2",
"sha256": "fae6648b98e64d883c1f0dd6f5031298a0cba34e7b0ef35c953c6afb0bcd03f5"
},
"downloads": -1,
"filename": "prefect_qiskit-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "f947cbd71aba2e4dd8a1a47ca91aafd2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 891888,
"upload_time": "2025-07-17T09:35:44",
"upload_time_iso_8601": "2025-07-17T09:35:44.124196Z",
"url": "https://files.pythonhosted.org/packages/e4/ab/477ae54c20e5dd5183b15b76d86f4f51e9bea1728fd6ae4bf80fef76b440/prefect_qiskit-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-17 09:35:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "qiskit-community",
"github_project": "prefect-qiskit",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "prefect-qiskit"
}