Skip to content

Commit

Permalink
Merge pull request #39 from qiboteam/qibo_and_qiskit_client_updates
Browse files Browse the repository at this point in the history
Updates for dependencies and various fixes
  • Loading branch information
BrunoLiegiBastonLiegi authored Oct 9, 2024
2 parents ee8b735 + d001462 commit 9cf4727
Show file tree
Hide file tree
Showing 8 changed files with 804 additions and 622 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: poetry install --no-interaction --no-root
if: steps.cache.outputs.cache-hit != 'true'
- name: Install project
run: poetry install --no-interaction --with test
run: poetry install --no-interaction --with tests
- name: Install task runner
run: pip install poethepoet
- name: Lint
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ Then, to simulate the circuit on the `TII` cluster through the `sim` platform:
print(result.frequencies())
```

or, in order to run on one of the chips hosted in `ibm-q`, e.g. `ibm_osaka`:
or, in order to run on one of the chips hosted in `ibm-q`, e.g. `ibm_kyiv`:

```python
qibo.set_backend("qibo-cloud-backends", client="qiskit-client", token="your_token", platform="ibm_osaka")
qibo.set_backend("qibo-cloud-backends", client="qiskit-client", token="your_token", platform="ibm_kyiv")
result = circuit()
print(result.frequencies())
```
4 changes: 2 additions & 2 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ Then, to simulate the circuit using the Qibo cloud service through the `sim` pla
result = circuit()
print(result.frequencies())
or, in order to use the `ibm_osaka` platform on the IBM `ibm-q` server:
or, in order to use the `ibm_kyiv` platform on the IBM `ibm-q` server:

.. code-block:: python
set_backend("qibo-cloud-backends", client="qiskit-client", token="your_token", platform="ibm_osaka")
set_backend("qibo-cloud-backends", client="qiskit-client", token="your_token", platform="ibm_kyiv")
result = circuit()
print(result.frequencies())
Expand Down
1,382 changes: 777 additions & 605 deletions poetry.lock

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,23 @@ packages = [{ include = "qibo_cloud_backends", from = "src" }]

[tool.poetry.dependencies]
python = ">=3.9,<3.13"
qibo = "^0.2.11"
qibo_client = "^0.0.9"
qiskit_ibm_runtime = ">=0.17"
qiskit_ibm_provider = ">=0.8.0"
qibo = "^0.2.12"
qibo_client = "^0.0.10"
qiskit_ibm_runtime = { version = "^0.17", optional = true }
qiskit_ibm_provider = { version = "^0.11", optional = true }

[tool.poetry.group.test.dependencies]
[tool.poetry.group.tests]
optional = true

[tool.poetry.group.tests.dependencies]
pytest = "^7.4.3"
pytest-cov = "^4.1.0"
pylint = "^3.0.3"
qiskit_ibm_runtime = "^0.17"
qiskit_ibm_provider = "^0.11"

[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
sphinx = "^7.2.6"
Expand All @@ -38,6 +46,8 @@ sphinx-copybutton = "^0.5.2"
nbsphinx = "^0.9.3"
furo = "^2023.9.10"

[tool.poetry.group.dev]
optional = true

[tool.poetry.group.dev.dependencies]
ipython = "^7"
Expand Down
2 changes: 1 addition & 1 deletion src/qibo_cloud_backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def load(
Args:
client (str): Name of the cloud client to load, one in ("qibo-client", "qiskit-client").
token (str): User token for the remote connection.
platform (str): Name of the platform to connect to on the provider's servers, e.g. `ibm_osaka`.
platform (str): Name of the platform to connect to on the provider's servers.
verbosity (bool): Enable verbose mode for the qibo-client. Default is False.
Returns:
qibo.backends.abstract.Backend: The loaded backend.
Expand Down
4 changes: 2 additions & 2 deletions src/qibo_cloud_backends/qiskit_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class QiskitClientBackend(NumpyBackend):
Args:
token (str): User authentication token. By default this is read from the 'IBMQ_TOKEN' environment variable.
platform (str): The IBM platform. Defaults to `"ibm_osaka"`.
platform (str): The IBM platform. Defaults to `"ibm_kyiv"`.
"""

def __init__(self, token=None, platform=None):
Expand All @@ -27,7 +27,7 @@ def __init__(self, token=None, platform=None):
"No token provided. Please explicitely pass the token `token='your_token'` or set the environment vairable `IBMQ_TOKEN='your_token'`.",
)
if platform is None:
platform = "ibm_osaka"
platform = "ibm_kyiv"
self.name = "qiskit-client"
provider = IBMProvider(token)
self.backend = provider.get_backend(platform)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

NP_BACKEND = NumpyBackend()
QISKIT_TK = os.environ.get("IBMQ_TOKEN")
QIBO_TK = os.environ.get("QIBO_CLIENT_TII_TOKEN")
QIBO_TK = os.environ.get("QIBO_CLIENT_TOKEN")


def qibo_circuit(nqubits=3):
Expand All @@ -26,7 +26,7 @@ def qibo_circuit(nqubits=3):


def qiskit_circuit(nqubits=3, measurement=True):
# ibm_osaka's native gates are: ECR, I, RZ, SX, X
# ibm_kyiv's native gates are: ECR, I, RZ, SX, X
c = Circuit(nqubits)
c.add(gates.X(0))
# c.add(gates.ECR(0,1)) # ECR not supported by (our) QASM apparently
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_list_available_backends():
@pytest.mark.parametrize("token", [None, QISKIT_TK])
def test_qiskit_client_backend(token):
c = qiskit_circuit()
client = QiskitClientBackend(token=token, platform="ibm_osaka")
client = QiskitClientBackend(token=token, platform="ibm_kyiv")
local_res = NP_BACKEND.execute_circuit(c)
remote_res = client.execute_circuit(c)
NP_BACKEND.assert_allclose(
Expand All @@ -110,7 +110,7 @@ def test_qiskit_client_backend(token):
def test_qiskit_client_backend_initial_state(measurement):
nqubits = 3
c = qiskit_circuit(nqubits, measurement=measurement)
client = QiskitClientBackend(token=QISKIT_TK, platform="ibm_osaka")
client = QiskitClientBackend(token=QISKIT_TK, platform="ibm_kyiv")
if measurement:
state = np.zeros(2**nqubits, dtype=complex)
with pytest.raises(NotImplementedError):
Expand Down

0 comments on commit 9cf4727

Please sign in to comment.