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

[Feature] Add sample, Use single precision by default #16

Merged
merged 13 commits into from
Dec 5, 2024
Merged

Conversation

dominikandreasseitz
Copy link
Collaborator

@dominikandreasseitz dominikandreasseitz commented Apr 19, 2024

Closes #18

@dominikandreasseitz dominikandreasseitz changed the title [Feature] Use single precision by default [Feature] Add sample, Use single precision by default Jun 21, 2024
@RolandMacDoland
Copy link
Collaborator

Hey @dominikandreasseitz, I'm working on fixing this PR. One thing that came up is that in test_hamevo_general while constructing the Hamiltonian:

(Pdb) hamevo
_HamiltonianEvolution(generator_name='I', target=((0, 1),), control=((None,),))

Just wondering what is the rationale behind the setting of target and control. What I understand is that:

    @staticmethod
    def parse_idx(
        idx: Tuple,
    ) -> Tuple:
        if isinstance(idx, (int, np.int64)):
            return ((idx,),)
        elif isinstance(idx, tuple):
            return (idx,)
        else:
            return (idx.astype(int),)

which makes target and control being tuples of tuples. Is this what is really intended ? For instance, defaults for control are (None,) which seems contradictory with the setting in parse_idx. Any guidance on this ? Thanks a lot :)

@dominikandreasseitz
Copy link
Collaborator Author

Hi @Roland-djee , the reason for the tuple of tuples design choice lies in the apply_gate function which can be either applied to a single gate or an arbitrary number of gates. To do so, the operators and supports are collected in a single tuple and then get applied in a single lambda expression. The "collection" part assumes a tuple of tuples for supports so thats the story behind that. I get its a bit counterintuitive but its part of legacy horqrux so i was hesitant to change it since the function is quite useful

@chMoussa chMoussa self-assigned this Dec 4, 2024
@chMoussa
Copy link
Collaborator

chMoussa commented Dec 4, 2024

Hey @RolandMacDoland I think I managed to fix this MR. What do you think?

@RolandMacDoland
Copy link
Collaborator

Hey @RolandMacDoland I think I managed to fix this MR. What do you think?

Oh, wow cool thanks. Please feel free to request a review :)

Copy link
Collaborator

@RolandMacDoland RolandMacDoland left a comment

Choose a reason for hiding this comment

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

Thanks @chMoussa. Looking good. Few comments for the sake of discussion.

horqrux/circuit.py Outdated Show resolved Hide resolved
horqrux/circuit.py Outdated Show resolved Hide resolved
horqrux/matrices.py Outdated Show resolved Hide resolved
tests/test_adjoint.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@RolandMacDoland RolandMacDoland left a comment

Choose a reason for hiding this comment

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

LGTM. Minor renaming quibble. I think it is conventional in torch to have vparams and fparams to disambiguate.

horqrux/circuit.py Outdated Show resolved Hide resolved
@chMoussa chMoussa merged commit 5fd2dad into main Dec 5, 2024
6 checks passed
@chMoussa chMoussa deleted the ds/single_prec branch December 5, 2024 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Use single precision by default
3 participants