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

CosineWindow expands over all circuit wires #5080

Merged
merged 3 commits into from Jan 19, 2024
Merged

Conversation

timmysilv
Copy link
Contributor

@timmysilv timmysilv commented Jan 17, 2024

Context:
When StatePrepBase operations are used at the start of a circuit on a subset of all circuit wires, we want to initialize the system state with all other wires set to the zero-state. CosineWindow did not implement this edge-case, and only returned a state spanning the subspace of the wires it acts on regardless of wire order given (it only used wire_order for transposition, not expansion)

Description of the Change:
Update CosineWindow.state_vector to expand over unused wires present in the provided wire_order

Master:

>>> qml.CosineWindow(wires=[0, 1]).state_vector(wire_order=[0, 1, 2]).shape
(2, 2)

Branch:

>>> qml.CosineWindow(wires=[0, 1]).state_vector(wire_order=[0, 1, 2]).shape
(2, 2, 2)

Benefits:
No more unexpected errors when CosineWindow is used as a state-prep operation on a subset of wires with DefaultQubit

Possible Drawbacks:
N/A

[sc-54223]

@timmysilv timmysilv requested review from KetpuntoG and a team January 17, 2024 22:02
Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8a43135) 99.68% compared to head (67e1b45) 99.68%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5080      +/-   ##
==========================================
- Coverage   99.68%   99.68%   -0.01%     
==========================================
  Files         394      394              
  Lines       35733    35466     -267     
==========================================
- Hits        35622    35354     -268     
- Misses        111      112       +1     

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

Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

👍 looks good.

@timmysilv timmysilv requested a review from a team January 18, 2024 19:54
Copy link
Contributor

@lillian542 lillian542 left a comment

Choose a reason for hiding this comment

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

🚀

@timmysilv timmysilv enabled auto-merge (squash) January 19, 2024 20:41
@timmysilv timmysilv merged commit e270b0e into master Jan 19, 2024
35 checks passed
@timmysilv timmysilv deleted the cosine-window-wire-order branch January 19, 2024 20:59
mudit2812 pushed a commit that referenced this pull request Jan 19, 2024
**Context:**
When StatePrepBase operations are used at the start of a circuit on a
subset of all circuit wires, we want to initialize the system state with
all other wires set to the zero-state. `CosineWindow` did not implement
this edge-case, and only returned a state spanning the subspace of the
wires it acts on regardless of wire order given (it only used
`wire_order` for transposition, not expansion)

**Description of the Change:**
Update `CosineWindow.state_vector` to expand over unused wires present
in the provided `wire_order`

Master:
```pycon
>>> qml.CosineWindow(wires=[0, 1]).state_vector(wire_order=[0, 1, 2]).shape
(2, 2)
```
Branch:
```pycon
>>> qml.CosineWindow(wires=[0, 1]).state_vector(wire_order=[0, 1, 2]).shape
(2, 2, 2)
```

**Benefits:**
No more unexpected errors when `CosineWindow` is used as a state-prep
operation on a subset of wires with DefaultQubit

**Possible Drawbacks:**
N/A

[sc-54223]
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.

None yet

3 participants