-
Notifications
You must be signed in to change notification settings - Fork 1
- Refactored quick.primitives.
#63
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
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 0.0.0-release #63 +/- ##
=================================================
+ Coverage 89.49% 89.95% +0.46%
=================================================
Files 63 63
Lines 4387 4362 -25
=================================================
- Hits 3926 3924 -2
+ Misses 461 438 -23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
….Statevector`. - Given `quick.metrics.calculate_entanglement_entropy_slope()` uses only statevectors, the code migrates from `qiskit.quantum_info.partial_trace()` to native `quick.primitives.Statevector.partial_trace()`. - Added testers for new functionality.
…d `quick.primitives.Operator`. - Added `__matmul__` dunder to `quick.primitives.Operator`. - Updated `quick.primitives` testers.
…evector. - Added testers for the recent additions to primitives. - Fixed a bug with `quick.synthesis.unitarypreparation.ShannonDecomposition` with the `QUBIT_KEYS` missing some keys causing IndexError.
- Modified `get_counts` for `quick.circuit.PennylaneCircuit` to account for the version difference functionality.
- Updated `.decompose()` of `quick.circuit.Circuit` for better clarity and performance. - Fixed a bug with `.control()` in `quick.circuit.Circuit` where gates that do not have C, MC- methods available now get decomposed before being converted to controlled format. - Deprecated `quick.circuit.gate_matrix.Gate`, which will be brought back properly in quick's rewrite. - Added `.control()` to `quick.primitives.Operator` for calculating the controlled unitary of a unitary. - Brought `Scalar` back to `__mul__` for `quick.primitives.Operator` and `quick.primitives.Statevector` to act as global phase. - Added testers for the additions.
- Added constructor from general matrix to `quick.primitives.Operator` via using SVD.
- Slightly updated two qubit decomposition. - Added new test cases for weyl coordinates.
Refactored
quick.primitivesfor less code bloat and clarity. This consisted of deprecatingquick.primitives.Braandquick.primitives.Ketand creating a new primitive class calledquick.primitives.Statevector.quick.primitives.Brain specific will not be supported due to incompatibility of its compilation to statevectors, and by extension infeasibility of its original purpose which was to compile Bra-Ket expressions (inner-products, outer products, etc.) to circuits.This PR aims to provide clear purpose for
quick.primitives. Primitives are conventionally used in three main manners:1) Classical simulation of circuits to extract statevectors/unitaries: This task is done via circuit frameworks and
quick.backendand thus we avoid redoing this feature in primitives to comply with python zen, specifically "There should be one-- and preferably only one --obvious way to do it.", meaning any and all executions of the circuit are to be done only via backends or default backends present in the circuit frameworks.2) Datatype representation to annotate a variable as a Statevector/Operator: This was the way
quick.primitivesoperated mainly, which leads to code smell and incoherent usage of such dataclass andNDArrayfrom numpy. We avoid this, and only use primitives where their functionality as described in (3) are needed.3) Containing primitive specific functionality for reusability: Normalization, padding, etc. are functionality that are widely utilized with such entities, and thus the main focus of
quick.primitivesnow is to provide a class that contains such functionality for ease of use. That means users do not need to usequick.primitivesif they do not use such functionality and can simply useNDArraywithquick.predicatesto ensure a numpy array satisfies their requirements.This PR is first of many to align with the improved, rot-free development pattern in mind.