autoscheduler


Nameautoscheduler JSON
Version 1.1.0 PyPI version JSON
download
home_pageNone
SummaryA library for quantum circuit composition
upload_time2024-10-31 09:18:46
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords quantum quantum computing quantum circuit optimization circuit cost reduction qiskit braket
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
   <picture>
     <source media="(prefers-color-scheme: dark)" srcset="https://github.com/Qcraft-UEx/Qcraft/blob/main/docs/_images/qcraft_logo.png?raw=true" width="60%">
     <img src="https://github.com/Qcraft-UEx/Qcraft/blob/main/docs/_images/qcraft_logo.png?raw=true" width="60%" alt="Qcraft Logo">
   </picture>
</p>

# QCRAFT AutoSchedulQ
[![PyPI Version](https://img.shields.io/pypi/v/autoscheduler.svg)](https://pypi.org/project/autoscheduler/)
![Python Versions](https://img.shields.io/badge/python-3.9%20|%203.10%20|%203.11%20|%203.12-blue.svg)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/Qcraft-UEx/QCRAFT/blob/main/LICENSE)

QCRAFT AutoSchedulQ: a library that allows users to automatically schedule the execution of their own quantum circuits, improving efficiency and reducing execution times in quantum computing environments. With this library, your Qiskit or Braket quantum circuit will be modified to increase its length but also decreasing the number of shots needed to execute it, getting a new circuit that needs more qubits but less shots to get the same result as the original circuit.

## Installation

You can install QCRAFT AutoSchedulQ and all its dependencies using pip:

```bash
pip install autoscheduler
```

You can also install from source by cloning the repository and installing from source:

```bash
git clone https://github.com/Qcraft-UEx/QCRAFT-AutoSchedulQ.git
cd autoscheduler
pip install .
```

## Usage

Here is a basic example on how to use Autoscheduler with a Quirk URL, when using a Quirk URL, it is mandatory to include the provider ('ibm' or 'aws') as an input.
```python
from autoscheduler import Autoscheduler

circuit = "https://algassert.com/quirk#circuit={'cols':[['H'],['•','X'],['Measure','Measure']]}"
max_qubits = 4
shots = 100
provider = 'ibm'
autoscheduler = Autoscheduler()
scheduled_circuit, shots, times = autoscheduler.schedule(circuit, shots, max_qubits=max_qubits, provider=provider)
results = autoscheduler.execute(scheduled_circuit,shots,'local',times)
```

Here is a basic example on how to use Autoscheduler with a GitHub URL.
```python
from autoscheduler import Autoscheduler

circuit = "https://raw.githubusercontent.com/user/repo/branch/file.py"
max_qubits = 15
shots = 1000
autoscheduler = Autoscheduler()
scheduled_circuit, shots, times = autoscheduler.schedule(circuit, shots, max_qubits=max_qubits)
results = autoscheduler.execute(scheduled_circuit,shots,'local',times)
```

Here is a basic example on how to use Autoscheduler with a Braket circuit.
```python
from autoscheduler import Autoscheduler
from braket.circuits import Circuit

circuit = Circuit()
circuit.x(0)
circuit.cnot(0,1)

max_qubits = 8
shots = 300
autoscheduler = Autoscheduler()
scheduled_circuit, shots, times = autoscheduler.schedule(circuit, shots, max_qubits=max_qubits)
results = autoscheduler.execute(scheduled_circuit,shots,'local',times)
```

Here is a basic example on how to use Autoscheduler with a Qiskit circuit.
```python
from autoscheduler import Autoscheduler
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit

qreg_q = QuantumRegister(2, 'q')
creg_c = ClassicalRegister(2, 'c')
circuit = QuantumCircuit(qreg_q, creg_c)
circuit.h(qreg_q[0])
circuit.cx(qreg_q[0], qreg_q[1])
circuit.measure(qreg_q[0], creg_c[0])
circuit.measure(qreg_q[1], creg_c[1])

max_qubits = 16
shots = 500
autoscheduler = Autoscheduler()
scheduled_circuit, shots, times = autoscheduler.schedule(circuit, shots, max_qubits=max_qubits)
results = autoscheduler.execute(scheduled_circuit,shots,'local',times)
```

It it possible to use the method schedule_and_execute instead of schedule and then execute, this method needs to have the machine in which you want to execute the circuit as a mandatory input. If the execution is on a aws machine, it is needed to specify the s3 bucket too. Also, provider is only needed when using Quirk URLs.

```python
from autoscheduler import Autoscheduler

circuit = "https://algassert.com/quirk#circuit={'cols':[['H'],['•','X'],['Measure','Measure']]}"
max_qubits = 4
shots = 100
provider = 'aws'
autoscheduler = Autoscheduler()
results = autoscheduler.schedule_and_execute(circuit, shots, 'ionq', max_qubits=max_qubits, provider=provider, s3_bucket=('amazon-braket-s3' 'my_braket_results'))
```

```python
from autoscheduler import Autoscheduler

circuit = "https://raw.githubusercontent.com/user/repo/branch/file.py"
max_qubits = 15
shots = 1000
autoscheduler = Autoscheduler()
results = autoscheduler.schedule_and_execute(circuit, shots, 'ibm_brisbane', max_qubits=max_qubits)
```

```python
from autoscheduler import Autoscheduler
from braket.circuits import Circuit

circuit = Circuit()
circuit.x(0)
circuit.cnot(0,1)

max_qubits = 8
shots = 300
autoscheduler = Autoscheduler()
results = autoscheduler.schedule_and_execute(circuit, shots, 'ionq', max_qubits=max_qubits, s3_bucket=('amazon-braket-s3' 'my_braket_results'))
```

```python
from autoscheduler import Autoscheduler
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit

qreg_q = QuantumRegister(2, 'q')
creg_c = ClassicalRegister(2, 'c')
circuit = QuantumCircuit(qreg_q, creg_c)
circuit.h(qreg_q[0])
circuit.cx(qreg_q[0], qreg_q[1])
circuit.measure(qreg_q[0], creg_c[0])
circuit.measure(qreg_q[1], creg_c[1])

max_qubits = 16
shots = 500
autoscheduler = Autoscheduler()
results = autoscheduler.schedule_and_execute(circuit, shots, 'ibm_brisbane', max_qubits=max_qubits)

```

In schedule and schedule and execute you can use the machine to infer the value of max_qubits. It is mandatory to use at least one of those parameters to build the scheduled circuit.

```python
from autoscheduler import Autoscheduler
from braket.circuits import Circuit

circuit = Circuit()
circuit.x(0)
circuit.cnot(0,1)

max_qubits = 8
shots = 300
autoscheduler = Autoscheduler()
scheduled_circuit, shots, times = autoscheduler.schedule(circuit, shots, machine='local')
results = autoscheduler.execute(scheduled_circuit,shots,'local',times)

```

```python
from autoscheduler import Autoscheduler
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit

qreg_q = QuantumRegister(2, 'q')
creg_c = ClassicalRegister(2, 'c')
circuit = QuantumCircuit(qreg_q, creg_c)
circuit.h(qreg_q[0])
circuit.cx(qreg_q[0], qreg_q[1])
circuit.measure(qreg_q[0], creg_c[0])
circuit.measure(qreg_q[1], creg_c[1])

max_qubits = 16
shots = 500
autoscheduler = Autoscheduler()
results = autoscheduler.schedule_and_execute(circuit, shots, 'ibm_brisbane')

```
QCRAFT AutoschedulQ will utilize the default AWS and IBM Cloud credentials stored on the machine for cloud executions.

## Optimizing Quantum Tasks
This library aims for the shot optimization on quantum tasks. Reducing the cost of the circuit on the end-user.

### Shot optimization
To achieve the shot optimization, the original circuit will be composed multiple time with itself. The more segments, the less shots will be needed to replicate the original circuit.
The total number of shots may differ from the original on a very small scale because the library combines the original circuit multiple times. Depending on the maximum number of qubits, to achieve the desired number of shots and cost reduction the algorithm will create segments equal to the original circuit each with a proportional number of shots, all this on a unique circuit.

**Example:**
Consider a circuit with 2 qubits, requiring 100 shots. If the maximum number of qubits of the new scheduled circuit is 6, the shots will be reduced to 100/(6/2) = 34 in total. Upon uncheduling, the results of each segment of the circuit will be aggregated, resulting on 34*(6/2) = 102 shots in total. Even so, the cost reduction has been achieved because the number of shots has been reduced from 100 to 34.

## Changelog
The changelog is available [here](https://github.com/Qcraft-UEx/QCRAFT-AutoSchedulQ/blob/main/CHANGELOG.md)

## License
QCRAFT AutoSchedulQ is licensed under the [MIT License](https://github.com/Qcraft-UEx/QCRAFT/blob/main/LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "autoscheduler",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "quantum, quantum computing, quantum circuit optimization, circuit cost reduction, qiskit, braket",
    "author": null,
    "author_email": "Jorge Casco Seco <jorgecs@unex.es>",
    "download_url": null,
    "platform": null,
    "description": "<p align=\"center\">\n   <picture>\n     <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/Qcraft-UEx/Qcraft/blob/main/docs/_images/qcraft_logo.png?raw=true\" width=\"60%\">\n     <img src=\"https://github.com/Qcraft-UEx/Qcraft/blob/main/docs/_images/qcraft_logo.png?raw=true\" width=\"60%\" alt=\"Qcraft Logo\">\n   </picture>\n</p>\n\n# QCRAFT AutoSchedulQ\n[![PyPI Version](https://img.shields.io/pypi/v/autoscheduler.svg)](https://pypi.org/project/autoscheduler/)\n![Python Versions](https://img.shields.io/badge/python-3.9%20|%203.10%20|%203.11%20|%203.12-blue.svg)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/Qcraft-UEx/QCRAFT/blob/main/LICENSE)\n\nQCRAFT AutoSchedulQ: a library that allows users to automatically schedule the execution of their own quantum circuits, improving efficiency and reducing execution times in quantum computing environments. With this library, your Qiskit or Braket quantum circuit will be modified to increase its length but also decreasing the number of shots needed to execute it, getting a new circuit that needs more qubits but less shots to get the same result as the original circuit.\n\n## Installation\n\nYou can install QCRAFT AutoSchedulQ and all its dependencies using pip:\n\n```bash\npip install autoscheduler\n```\n\nYou can also install from source by cloning the repository and installing from source:\n\n```bash\ngit clone https://github.com/Qcraft-UEx/QCRAFT-AutoSchedulQ.git\ncd autoscheduler\npip install .\n```\n\n## Usage\n\nHere is a basic example on how to use Autoscheduler with a Quirk URL, when using a Quirk URL, it is mandatory to include the provider ('ibm' or 'aws') as an input.\n```python\nfrom autoscheduler import Autoscheduler\n\ncircuit = \"https://algassert.com/quirk#circuit={'cols':[['H'],['\u2022','X'],['Measure','Measure']]}\"\nmax_qubits = 4\nshots = 100\nprovider = 'ibm'\nautoscheduler = Autoscheduler()\nscheduled_circuit, shots, times = autoscheduler.schedule(circuit, shots, max_qubits=max_qubits, provider=provider)\nresults = autoscheduler.execute(scheduled_circuit,shots,'local',times)\n```\n\nHere is a basic example on how to use Autoscheduler with a GitHub URL.\n```python\nfrom autoscheduler import Autoscheduler\n\ncircuit = \"https://raw.githubusercontent.com/user/repo/branch/file.py\"\nmax_qubits = 15\nshots = 1000\nautoscheduler = Autoscheduler()\nscheduled_circuit, shots, times = autoscheduler.schedule(circuit, shots, max_qubits=max_qubits)\nresults = autoscheduler.execute(scheduled_circuit,shots,'local',times)\n```\n\nHere is a basic example on how to use Autoscheduler with a Braket circuit.\n```python\nfrom autoscheduler import Autoscheduler\nfrom braket.circuits import Circuit\n\ncircuit = Circuit()\ncircuit.x(0)\ncircuit.cnot(0,1)\n\nmax_qubits = 8\nshots = 300\nautoscheduler = Autoscheduler()\nscheduled_circuit, shots, times = autoscheduler.schedule(circuit, shots, max_qubits=max_qubits)\nresults = autoscheduler.execute(scheduled_circuit,shots,'local',times)\n```\n\nHere is a basic example on how to use Autoscheduler with a Qiskit circuit.\n```python\nfrom autoscheduler import Autoscheduler\nfrom qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit\n\nqreg_q = QuantumRegister(2, 'q')\ncreg_c = ClassicalRegister(2, 'c')\ncircuit = QuantumCircuit(qreg_q, creg_c)\ncircuit.h(qreg_q[0])\ncircuit.cx(qreg_q[0], qreg_q[1])\ncircuit.measure(qreg_q[0], creg_c[0])\ncircuit.measure(qreg_q[1], creg_c[1])\n\nmax_qubits = 16\nshots = 500\nautoscheduler = Autoscheduler()\nscheduled_circuit, shots, times = autoscheduler.schedule(circuit, shots, max_qubits=max_qubits)\nresults = autoscheduler.execute(scheduled_circuit,shots,'local',times)\n```\n\nIt it possible to use the method schedule_and_execute instead of schedule and then execute, this method needs to have the machine in which you want to execute the circuit as a mandatory input. If the execution is on a aws machine, it is needed to specify the s3 bucket too. Also, provider is only needed when using Quirk URLs.\n\n```python\nfrom autoscheduler import Autoscheduler\n\ncircuit = \"https://algassert.com/quirk#circuit={'cols':[['H'],['\u2022','X'],['Measure','Measure']]}\"\nmax_qubits = 4\nshots = 100\nprovider = 'aws'\nautoscheduler = Autoscheduler()\nresults = autoscheduler.schedule_and_execute(circuit, shots, 'ionq', max_qubits=max_qubits, provider=provider, s3_bucket=('amazon-braket-s3' 'my_braket_results'))\n```\n\n```python\nfrom autoscheduler import Autoscheduler\n\ncircuit = \"https://raw.githubusercontent.com/user/repo/branch/file.py\"\nmax_qubits = 15\nshots = 1000\nautoscheduler = Autoscheduler()\nresults = autoscheduler.schedule_and_execute(circuit, shots, 'ibm_brisbane', max_qubits=max_qubits)\n```\n\n```python\nfrom autoscheduler import Autoscheduler\nfrom braket.circuits import Circuit\n\ncircuit = Circuit()\ncircuit.x(0)\ncircuit.cnot(0,1)\n\nmax_qubits = 8\nshots = 300\nautoscheduler = Autoscheduler()\nresults = autoscheduler.schedule_and_execute(circuit, shots, 'ionq', max_qubits=max_qubits, s3_bucket=('amazon-braket-s3' 'my_braket_results'))\n```\n\n```python\nfrom autoscheduler import Autoscheduler\nfrom qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit\n\nqreg_q = QuantumRegister(2, 'q')\ncreg_c = ClassicalRegister(2, 'c')\ncircuit = QuantumCircuit(qreg_q, creg_c)\ncircuit.h(qreg_q[0])\ncircuit.cx(qreg_q[0], qreg_q[1])\ncircuit.measure(qreg_q[0], creg_c[0])\ncircuit.measure(qreg_q[1], creg_c[1])\n\nmax_qubits = 16\nshots = 500\nautoscheduler = Autoscheduler()\nresults = autoscheduler.schedule_and_execute(circuit, shots, 'ibm_brisbane', max_qubits=max_qubits)\n\n```\n\nIn schedule and schedule and execute you can use the machine to infer the value of max_qubits. It is mandatory to use at least one of those parameters to build the scheduled circuit.\n\n```python\nfrom autoscheduler import Autoscheduler\nfrom braket.circuits import Circuit\n\ncircuit = Circuit()\ncircuit.x(0)\ncircuit.cnot(0,1)\n\nmax_qubits = 8\nshots = 300\nautoscheduler = Autoscheduler()\nscheduled_circuit, shots, times = autoscheduler.schedule(circuit, shots, machine='local')\nresults = autoscheduler.execute(scheduled_circuit,shots,'local',times)\n\n```\n\n```python\nfrom autoscheduler import Autoscheduler\nfrom qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit\n\nqreg_q = QuantumRegister(2, 'q')\ncreg_c = ClassicalRegister(2, 'c')\ncircuit = QuantumCircuit(qreg_q, creg_c)\ncircuit.h(qreg_q[0])\ncircuit.cx(qreg_q[0], qreg_q[1])\ncircuit.measure(qreg_q[0], creg_c[0])\ncircuit.measure(qreg_q[1], creg_c[1])\n\nmax_qubits = 16\nshots = 500\nautoscheduler = Autoscheduler()\nresults = autoscheduler.schedule_and_execute(circuit, shots, 'ibm_brisbane')\n\n```\nQCRAFT AutoschedulQ will utilize the default AWS and IBM Cloud credentials stored on the machine for cloud executions.\n\n## Optimizing Quantum Tasks\nThis library aims for the shot optimization on quantum tasks. Reducing the cost of the circuit on the end-user.\n\n### Shot optimization\nTo achieve the shot optimization, the original circuit will be composed multiple time with itself. The more segments, the less shots will be needed to replicate the original circuit.\nThe total number of shots may differ from the original on a very small scale because the library combines the original circuit multiple times. Depending on the maximum number of qubits, to achieve the desired number of shots and cost reduction the algorithm will create segments equal to the original circuit each with a proportional number of shots, all this on a unique circuit.\n\n**Example:**\nConsider a circuit with 2 qubits, requiring 100 shots. If the maximum number of qubits of the new scheduled circuit is 6, the shots will be reduced to 100/(6/2) = 34 in total. Upon uncheduling, the results of each segment of the circuit will be aggregated, resulting on 34*(6/2) = 102 shots in total. Even so, the cost reduction has been achieved because the number of shots has been reduced from 100 to 34.\n\n## Changelog\nThe changelog is available [here](https://github.com/Qcraft-UEx/QCRAFT-AutoSchedulQ/blob/main/CHANGELOG.md)\n\n## License\nQCRAFT AutoSchedulQ is licensed under the [MIT License](https://github.com/Qcraft-UEx/QCRAFT/blob/main/LICENSE)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A library for quantum circuit composition",
    "version": "1.1.0",
    "project_urls": {
        "Changelog": "https://github.com/Qcraft-UEx/QCRAFT-AutoSchedulQ/blob/main/CHANGELOG.md",
        "Homepage": "https://github.com/Qcraft-UEx/QCRAFT-AutoSchedulQ"
    },
    "split_keywords": [
        "quantum",
        " quantum computing",
        " quantum circuit optimization",
        " circuit cost reduction",
        " qiskit",
        " braket"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b0df1550bc9c805e31f815acd0364e2e42fb1466e49d17a60d465c17e9c3f596",
                "md5": "e3ca33c728546b266244fa96c2bfe485",
                "sha256": "67d8ea5c8756ef328a4d70d18f1755d5065a4595af0982d6fdb61e9faa73fcd6"
            },
            "downloads": -1,
            "filename": "autoscheduler-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e3ca33c728546b266244fa96c2bfe485",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 17913,
            "upload_time": "2024-10-31T09:18:46",
            "upload_time_iso_8601": "2024-10-31T09:18:46.308494Z",
            "url": "https://files.pythonhosted.org/packages/b0/df/1550bc9c805e31f815acd0364e2e42fb1466e49d17a60d465c17e9c3f596/autoscheduler-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-31 09:18:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Qcraft-UEx",
    "github_project": "QCRAFT-AutoSchedulQ",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "autoscheduler"
}
        
Elapsed time: 9.25957s