Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.

refactor the Operator class #593

Merged
merged 81 commits into from
Aug 2, 2019

Conversation

chunfuchen
Copy link
Contributor

@chunfuchen chunfuchen commented Jul 12, 2019

Summary

Refactor the Operator class and make it more extensible for different grouping approaches.

related to #311 #345 #553 #348

Details and comments

  1. BaseOperator defines the required methods.
  • _paulis, _basis and _z2_symmetries are common info of an operator, and those info are tracked when converting to another type of operator.
  1. The WeightedPauliOperator equals to the previous paulis mode of the Operator; however, it adds a new property (basis) for recording the grouping information. By default, each pauli is one group. Therefore, the same codes can be used for tensor-product basis grouping. E.g., two grouping methods Aqua had.
  2. based on 2. the TPBGroupedWeightedPauliOperator is the previous grouped_paulis mode of the Operator, for the current grouping approach, the only difference will only be the basis field.
    • Note: the paulis property is always a flat list as in WeightedPauliOperator instead of using the first item to record the basis; and the basis field records the indices of paulis belong to that group.
  3. New class Z2Symmetries, which stores the Z2 symmetries info, including symmetries, sq_list, sq_paulis. Then this class can be used to taper an operator.

TODO

  • MatrixOperator (could be derived from Terra's Operator but will use dense representation)
  • Update unit test
  • Update docstring
  • Wrapping the old operator to new operator if possible and add deprecated message
  • Update new operator for all codes.

Discussion

Thus, if a user would like to have a new grouping approach which is similar to TPB, they can simply add new classmethod to grouping the WeightedPauliOperator and then re-use all of the codes directly.
Nonetheless, if the new grouping approach affects the way to compute expectation against a wavefunction or the way to evolve the operator, users would need to create their own new class which is derived from either BaseOperator or WeightedPauliOperator.

@dongreenberg
Copy link
Contributor

I will integrate the MatrixOperator from my previous Operator PR.

@manoelmarques manoelmarques requested a review from woodsp-ibm July 27, 2019 00:54
@chunfuchen chunfuchen changed the title refactor the Operator class [WIP] refactor the Operator class Jul 30, 2019
@t-imamichi
Copy link
Contributor

Matrix to TPB conversion takes an exponential time here. So, I recommend to show a warning message to notify it to users. They may use this path without knowing the situation.

pistoia
pistoia previously approved these changes Aug 2, 2019
@manoelmarques manoelmarques requested a review from pistoia August 2, 2019 11:46
@chunfuchen chunfuchen changed the title [WIP] refactor the Operator class refactor the Operator class Aug 2, 2019
@manoelmarques manoelmarques merged commit 1e2979c into qiskit-community:master Aug 2, 2019
mtreinish pushed a commit to mtreinish/qiskit-core that referenced this pull request Nov 20, 2020
…nhance/op_rewrite

refactor the Operator class
manoelmarques added a commit to manoelmarques/qiskit-terra that referenced this pull request Dec 7, 2020
…nhance/op_rewrite

refactor the Operator class
manoelmarques added a commit to qiskit-community/qiskit-machine-learning that referenced this pull request Feb 27, 2021
…nhance/op_rewrite

refactor the Operator class
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants