-
Notifications
You must be signed in to change notification settings - Fork 211
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
Fix for issue #213 #289
Fix for issue #213 #289
Conversation
torchquantum/operator/op_types.py
Outdated
@@ -7,6 +7,7 @@ | |||
from ..macro import C_DTYPE, F_DTYPE | |||
from typing import Iterable, Union, List | |||
from enum import IntEnum | |||
from torchquantum.util.quantization.clifford_quantization import CliffordQuantizer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this import necessary here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, wait, I missed your initial comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you instead import this lazily, so in the conditional branch where we actually call CliffordQuantizer
? Afterward, will merge in!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for figuring this out! Just a quick question on the extra import then I can merge this in!
torchquantum/operator/op_types.py
Outdated
@@ -7,6 +7,7 @@ | |||
from ..macro import C_DTYPE, F_DTYPE | |||
from typing import Iterable, Union, List | |||
from enum import IntEnum | |||
from torchquantum.util.quantization.clifford_quantization import CliffordQuantizer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, wait, I missed your initial comment.
torchquantum/operator/op_types.py
Outdated
@@ -7,6 +7,7 @@ | |||
from ..macro import C_DTYPE, F_DTYPE | |||
from typing import Iterable, Union, List | |||
from enum import IntEnum | |||
from torchquantum.util.quantization.clifford_quantization import CliffordQuantizer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you instead import this lazily, so in the conditional branch where we actually call CliffordQuantizer
? Afterward, will merge in!
Also, don’t worry about tests, it’s likely from numpy 2.0 breaking. Once we merge, I think we should be good. |
Alright I moved the import into the conditional branch, so it should be good now. |
Merged, thanks so much! |
To fix issue #213, it looks like the
QuantumDevice
needs to be initialized with the batch size (batch size is 1 by default which is why the size was [1, 2] instead of [256, 2]).After this change, there is a
NameError
forCliffordQuantizer
:which can be fixed by importing it in the
torchquantum/operator/op_types.py
file, which calls theCliffordQuantizer
function.After these changes, I believe
examples/clifford_qnn/mnist_clifford_qnn.py
can run out-of-the-box:@Hanrui-Wang @01110011011101010110010001101111