Skip to content

Conversation

@yannick-couzinie
Copy link

Not sure whether I am misunderstanding the function.

self.measure_multiple_times returns a [len(obs_list), num_wires] tensor, you have to take the product over the wires first to get the measurement of the Pauli string and then sum over the obs_list (multiplied by coefficients in the case of MeasureMultiQubitPaulisum.

Hanrui-Wang and others added 3 commits July 11, 2024 17:06
self.measure_multiple_times returns a [len(obs_list), num_wires] tensor, you have to take the product over the wires first to get the measurement of the Pauli string and then sum over the obs_list (multiplied by coefficients in the case of MeasureMultiQubitPaulisum.
@yannick-couzinie
Copy link
Author

I don't think NumPy 2 has the "complex_" datatype any more . This last commit, strictly speaking, has nothing to do with MeasureMultiPauliSum, but should get the workflows to run. I have run the workflow

       python3 examples/qubit_rotation/qubit_rotation.py --epochs 1
        python3 examples/vqe/vqe.py --epochs 1 --steps_per_epoch 1
        python3 examples/train_unitary_prep/train_unitary_prep.py --epochs 1
        python3 examples/train_state_prep/train_state_prep.py --epochs 1
        python3 examples/superdense_coding/superdense_coding_torchquantum.py
        python3 examples/regression/run_regression.py --epochs 1
        python3 examples/param_shift_onchip_training/param_shift.py
        python3 examples/mnist/mnist_2qubit_4class.py --epochs 1
        python3 examples/hadamard_grad/circ.py
        python3 examples/encoder_examples/encoder_8x2ry.py
        python3 examples/converter_tq_qiskit/convert.py
        python3 examples/amplitude_encoding_mnist/mnist_new.py --epochs 1
        python3 examples/amplitude_encoding_mnist/mnist_example.py --epochs 1
        python3 examples/PauliSumOp/pauli_sum_op.py
        python3 examples/regression/new_run_regression.py --epochs 1
        python3 examples/quanvolution/quanvolution_trainable_quantum_layer.py --epochs 1
        python3 examples/grover/grover_example_sudoku.py
        python3 examples/param_shift_onchip_training/param_shift.py
        python3 examples/quanvolution/quanvolution.py --epochs 1
        python3 examples/quantum_lstm/qlstm.py --epochs 1
        python3 examples/qaoa/max_cut_backprop.py --steps 1
        python3 examples/optimal_control/optimal_control.py --epochs 1
        python3 examples/optimal_control/optimal_control_gaussian.py --epochs 1
        python3 examples/optimal_control/optimal_control_multi_qubit.py --epochs 1
        python3 examples/save_load_example/save_load.py
        python3 examples/mnist/mnist.py --epochs 1

locally and it finishes fine with NumPy 1.26.1.

@01110011011101010110010001101111
Copy link
Collaborator

Yeah, thanks for the fix, haven’t yet looked at breaking changes from numpy 2.0. I’ll likely open a PR for that later.
Re: a review for this PR, I haven’t deal too much with our measure functions so will need to redirect the review to other maintainers.

@yannick-couzinie
Copy link
Author

Thanks! I can reverse that commit on requirements.txt if need be at least the workflows run now, the linting problem is that expval is defined when running measurements.py as main, while expval is also the name of a function. The fix is just to rename the expval in the main block at the bottom, can include it here if you want it, but it is a really straightforward fix.

@01110011011101010110010001101111 01110011011101010110010001101111 changed the base branch from main to dev November 18, 2024 20:56
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks good to me, thanks for the PR! I’ll merge into dev!

@01110011011101010110010001101111 01110011011101010110010001101111 merged commit 79ce996 into mit-han-lab:dev Nov 18, 2024
5 of 7 checks passed
@yannick-couzinie yannick-couzinie deleted the patch-1 branch November 19, 2024 02:37
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.

3 participants