Skip to content

Towards a minimal-dependency install#1871

Merged
mpharrigan merged 12 commits into
quantumlib:mainfrom
mpharrigan:2026-06/mindep
Jun 16, 2026
Merged

Towards a minimal-dependency install#1871
mpharrigan merged 12 commits into
quantumlib:mainfrom
mpharrigan:2026-06/mindep

Conversation

@mpharrigan

@mpharrigan mpharrigan commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

This PR is an initial step towards carving out a core of functionality that doesn't need niche dependencies. This adds a new CI check that runs tests in qualtran/_infra and qualtran/dtype with only a small set of dependencies.

This is accomplished with pytest importorskips and local imports in the library for "optional" functionality.

The heaviest "minimal" dependency is of course Cirq, which is technically challenging to make optimal since GateWithRegisters inherits from cirq.Gate which needs cirq.Gate at the global/module level.

@mpharrigan mpharrigan marked this pull request as ready for review June 16, 2026 17:30

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a minimal dependency verification script and updates various tests and modules to lazily import optional dependencies (such as quimb, galois, fxpmath, pennylane, and pydot) or gracefully skip tests when they are not installed. Key feedback points out that using pytest.skip inside test_gate_with_registers when quimb is missing will prematurely skip subsequent assertions, and suggests catching ModuleNotFoundError instead. Additionally, it is recommended to add pennylane to the optional packages verification list and to specify stacklevel=2 when raising warnings in qualtran/drawing/init.py to improve warning traceability.

Comment thread qualtran/_infra/gate_with_registers_test.py Outdated
Comment thread check/pytest-minimal-install
Comment thread qualtran/drawing/__init__.py
mpharrigan and others added 3 commits June 16, 2026 10:35
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@mpharrigan mpharrigan merged commit c47b6ce into quantumlib:main Jun 16, 2026
15 checks passed
mpharrigan added a commit that referenced this pull request Jun 17, 2026
Another step forwards in having programmatic access to importing bloqs.

In an earlier PR we added the "bloq manifest", which is in
`bloqs/manifest.py` and defines two static lists of strings
(essentially). The first is a list of all the bloq class names (fully
qualified). The bloq classes report their canonical import path with our
`_pkg_` class method, which defaults to one level up from the leaf
module the class is defined in. This presumes that we "re-export" our
classes one level up. This PR adds a check that the bloq class names
from the manifest actually are importable and fixes the failures by
re-exporting the import to an `__init__.py` or by overriding `_pkg_` to
make it a "local" bloq.

The test also compliments the "minimal install" test from #1871 by
asserting that everything is at least importable without heavy
dependencies except for specific subpackages (galois bloqs need the
`galois` package is the main one)
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.

1 participant