Skip to content

Gate decomposition via Householder reflections#758

Open
Vicara12 wants to merge 126 commits intoquantumlib:mainfrom
Vicara12:gate_compilation
Open

Gate decomposition via Householder reflections#758
Vicara12 wants to merge 126 commits intoquantumlib:mainfrom
Vicara12:gate_compilation

Conversation

@Vicara12
Copy link
Copy Markdown
Contributor

@Vicara12 Vicara12 commented Mar 8, 2024

This code implements the first two points in this comment from issue #596 . It adds a bloq that decomposes an arbitrary unitary gate into householder reflections. It allows for partial specification of the gate, in which case the T-gate cost of the bloq is linearly proportional to the number of gates specified.

This code is a necessary part for the goal of implementing a MPS preparation algorithm, even though it is useful on its own for other applications.

Copy link
Copy Markdown
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

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

Great contribution! @tanujkhattar can you take a look as well.

My major ask is: can we rename these bloqs and the module to something other than "decompose". We already use that term to mean something else. I see the reference uses the word "synthesis" whose verb would be synthesize

Comment thread qualtran/bloqs/chemistry/prepare_mps/decompose_gate_hr.py Outdated
Comment thread qualtran/bloqs/chemistry/prepare_mps/decompose_gate_hr.py Outdated
Comment thread qualtran/bloqs/chemistry/prepare_mps/decompose_gate_hr.py Outdated
Comment thread qualtran/bloqs/chemistry/prepare_mps/decompose_gate_hr.py Outdated
Comment thread qualtran/bloqs/chemistry/prepare_mps/decompose_gate_hr.py Outdated
Comment thread qualtran/bloqs/chemistry/prepare_mps/decompose_gate_hr.py
Comment on lines +105 to +109
"""Extra soquets inside soqs are:
* phase_grad: a phase gradient state of size phase_bitsize if internal_phase_gradient
is set to False
* refl_ancilla: a clean qubit in |0> if internal_refl_ancilla is set to False
"""
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this can probably just be line comments # instead of a docstring. If you want this to be a docstring, it should follow the docstring format.

By "extra soquets" you mean "optional soquets"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not really optional, but required in some situations. For example, if an user sets the internal_phase_grad flag to False then that register has to be provided, but it is not optional in that case.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

optional in a cosmic sense where you can set the flag to true

Comment thread qualtran/bloqs/chemistry/prepare_mps/decompose_gate_hr_test.py Outdated
@tanujkhattar tanujkhattar self-assigned this Jun 24, 2024
Copy link
Copy Markdown
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

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

@Vicara12 Thanks a lot for opening this PR and apologies for the late review!

I've left a round of comments - Would you still have time to address the comments and get this PR merged? Please let us know one way or the other since this would be a very useful primitive to get in.

Main suggestions are around making changes so we can support symbolic analysis.

Comment thread qualtran/bloqs/chemistry/prepare_mps/synthesize_gate_hr.py
Comment thread qualtran/bloqs/chemistry/prepare_mps/synthesize_gate_hr.py Outdated
Comment thread qualtran/bloqs/chemistry/prepare_mps/synthesize_gate_hr.py Outdated
Comment thread qualtran/bloqs/chemistry/prepare_mps/synthesize_gate_hr.py Outdated
Comment thread qualtran/bloqs/chemistry/prepare_mps/synthesize_gate_hr.py
def signature(self) -> Signature:
return Signature.build(target_reg=self.state_bitsize + 1, phase_grad=self.phase_bitsize)

def build_composite_bloq(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please implement a build_call_graph for symbolic analysis.

Comment thread qualtran/bloqs/reflection_using_prepare.py Outdated
Comment thread qualtran/bloqs/reflection_using_prepare.py Outdated
Comment thread qualtran/bloqs/reflection_using_prepare.py Outdated
Comment thread qualtran/bloqs/reflection_using_prepare.py Outdated
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.

4 participants