Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Refactor Qubit and QubitSet to a separate module #717

Merged
merged 2 commits into from
Oct 3, 2023
Merged

Conversation

kshitijc
Copy link
Contributor

@kshitijc kshitijc commented Sep 29, 2023

Issue #, if available:

Description of changes:

  • The existing implementation has circular dependencies between the circuit and pulse modules. Trying to execute the statement from braket.pulse import PulseSequence causes an ImportError. The following dependencies are executed:
from braket.pulse.pulse_sequence import PulseSequence (braket/pulse/__init__.py) -> from braket.circuits.qubit_set import QubitSet (braket/pulse/pulse_sequence.py) -> from braket.circuits import circuit (braket/circuits/__init__.py) -> from braket.pulse import PulseSequence (braket/circuits/circuit.py)

Conceptually, the hierarchy of the abstractions is:

Circuit
  |   \
  |   PulseSequence
  |  /
  | /
  \/
Qubit

However, today the Circuit and Qubit abstractions live in the same module causing circular dependencies:

Circuit & Qubit
   \    /\
   \/   / 
  PulseSequence

This change abstracts out the Qubit classes to its own module to align with the desired heirarchy of abstractions.

Testing done:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@kshitijc kshitijc requested a review from a team as a code owner September 29, 2023 23:15
@codecov
Copy link

codecov bot commented Sep 29, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (1acf476) 100.00% compared to head (b765b92) 100.00%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #717   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          123       126    +3     
  Lines         8185      8189    +4     
  Branches      1827      1827           
=========================================
+ Hits          8185      8189    +4     
Files Coverage Δ
src/braket/_sdk/_version.py 100.00% <100.00%> (ø)
src/braket/circuits/ascii_circuit_diagram.py 100.00% <100.00%> (ø)
src/braket/circuits/circuit.py 100.00% <100.00%> (ø)
src/braket/circuits/compiler_directive.py 100.00% <100.00%> (ø)
src/braket/circuits/gate.py 100.00% <100.00%> (ø)
src/braket/circuits/gate_calibrations.py 100.00% <100.00%> (ø)
src/braket/circuits/gates.py 100.00% <100.00%> (ø)
src/braket/circuits/instruction.py 100.00% <100.00%> (ø)
src/braket/circuits/moments.py 100.00% <100.00%> (ø)
src/braket/circuits/noise.py 100.00% <100.00%> (ø)
... and 21 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@speller26 speller26 left a comment

Choose a reason for hiding this comment

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

Really happy to see this split out; the only thing that gives me pause is the name of the module. braket.qubits Forces everything in the module to be a qubit register, but what if we introduce qudits down the line? What if we have a module that can store any fundamental unit? Don't know what I'd all it though.

@laurencap
Copy link
Contributor

laurencap commented Oct 2, 2023

I like @peterkomar-aws's idea of the directory organization being braket/registers/qubit.py. Either way, can we add a line to the init file to allow users to import as from braket.qubits import Qubit? I find it hard as a user (with the existing documentation) to find the right paths, so lets keep it simple where possible.

@kshitijc kshitijc merged commit 98ea275 into main Oct 3, 2023
28 checks passed
@kshitijc kshitijc deleted the mv_qubits branch October 3, 2023 04:26
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.

3 participants