Skip to content

Implementing Qibo Nexus backend - #1

Merged
scarrazza merged 10 commits into
mainfrom
porting-nexus
May 2, 2026
Merged

Implementing Qibo Nexus backend#1
scarrazza merged 10 commits into
mainfrom
porting-nexus

Conversation

@jf-kong

@jf-kong jf-kong commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Initial implementation of nexus-backend, a standalone Qibo backend for compiling and executing circuits on Quantinuum hardware through qnexus API, modelled on the layout of qibojit and qibolab.

The Nexus client was previously developed inside qibo-cloud-backends (never released or merged into main). This PR carves the Nexus pieces out into their own home.

What's in this PR

  • Source (src/nexus_backend/, 7 modules)
    • backend.pyNexusClientBackend (formerly nexus_client.py); name = "nexus-backend".
    • auth.py, config.py, errors.py, translation.py, results.py, helios.py — moved with sibling-import rewrites only.
    • __init__.py — exposes MetaBackend, NexusClientBackend, NexusBackendConfig, EstimateItem, ExecutionEstimate, run_compile_execute, PLATFORMS, __version__.
  • Tests (tests/, 6 files, 50 tests, all green)
    • test_meta_backend.py covers the qibo.set_backend("nexus-backend", ...) discovery path.
    • test_backend_contract.py covers direct NexusClientBackend(...).execute_circuit/.execute_circuits/.estimate_circuit/.estimate_circuits against mocked qnexus.
    • test_translator.py, test_config.py, test_results.py, test_helios.py — unit tests for the translation, config, result-mapping, and Helios HUGR layers.
    • All tests fully mock qnexus, pytket, pytket.qasm, guppylang, guppylang.std.*, qibo.result via monkeypatch.setitem(sys.modules, …). No live Nexus calls; CI runs offline.
  • Packaging (pyproject.toml)
    • Poetry-based, mirrors qibojit's shape.
    • Required deps: qibo ^0.2.16, qnexus >=0.39,<1, pytket >=2.8,<3, guppylang >=0.21,<1.
    • Optional groups: tests (pytest, pytest-cov, pytest-mock, pylint), docs (sphinx, furo, …).
  • Docs (doc/source/)
    • conf.py
    • index.rst (install + quickstart) and api.rst (autoclass on NexusClientBackend and MetaBackend).
  • CI (.github/workflows/)
    • unit_test.yml: Linux + macOS × Python 3.10/3.11/3.12, Poetry install, poe lint + poe test, Codecov upload on Linux 3.10.
    • deploy.yml: scaffolded but gated to workflow_dispatch only; PyPI publish is deferred.
  • README.md: install (currently via pip install git+…), quickstart.

Additional note

qibo.set_backend("nexus-backend", platform=...) triggers qibo.backends.construct_backend(...), which substitutes -_ in the backend string, calls importlib.import_module("nexus_backend"), and invokes module.MetaBackend.load(**kwargs). The contract this PR satisfies is therefore minimal: be importable as nexus_backend and expose a top-level MetaBackend.load returning a qibo.backends.abstract.Backend subclass. Same shape qibojit and qibolab use.

Verification done locally

  • poetry install --with tests — resolves cleanly.
  • poetry run pytest50 passed in 44s, fully offline, no Nexus credentials required.
  • qibo.set_backend("nexus-backend", platform="hseries:H2-1LE") — returns a real NexusClientBackend (module=nexus_backend.backend, name=nexus-backend, config.platform=hseries:H2-1LE).
  • from nexus_backend import NexusClientBackend; backend = NexusClientBackend(platform="...") — direct construction works as before; all execute_circuit / execute_circuits / estimate_circuit / estimate_circuits methods are reachable.
  • grep -RIn "qibo_cloud_backends|nexus-client|qibo-cloud-backends" src tests doc README.md pyproject.toml — zero hits (no stale references).

Test plan for reviewers

  • poetry install --with tests && poetry run pytest passes locally.
  • CI matrix is green (Linux + macOS × Py 3.10/3.11/3.12).
  • python -c "import qibo; qibo.set_backend('nexus-backend', platform='hseries:H2-1LE'); print(qibo.get_backend())" reports a NexusClientBackend with name == "nexus-backend".

@jf-kong
jf-kong requested a review from scarrazza April 29, 2026 14:57
Comment thread doc/source/index.rst Outdated
Comment thread .github/workflows/deploy.yml Outdated
@codecov

codecov Bot commented Apr 30, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@@ -0,0 +1,60 @@
name: Tests

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread doc/source/api.rst Outdated

@scarrazza scarrazza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jf-kong, please find some comments here. Could you please check coverage? I think we can avoid the sphinx for now and just keep the docs in the README (so we can avoid the documentation workflow too). If we decide to upload to pypi then we can rethink about it.

Comment thread pyproject.toml
[tool.poe.tasks]
test = "pytest"
lint = "pylint --errors-only src"
lint-warnings = "pylint --exit-zero src"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lint-warnings = "pylint --exit-zero src"
lint-warnings = "pylint --exit-zero src"
types = "true"

@scarrazza
scarrazza merged commit d7f9183 into main May 2, 2026
21 checks passed
@chmwzc
chmwzc deleted the porting-nexus branch August 3, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants