MPI support for state and expectation calculations - #135
MPI support for state and expectation calculations#135Vinitha-balachandran wants to merge 6 commits into
Conversation
| if self.rank > 0: | ||
| state = np.array(0) | ||
|
|
||
| if return_array: | ||
| statevector = state.flatten() if self.rank == 0 else state | ||
| else: | ||
| statevector = state if self.rank == 0 else state |
There was a problem hiding this comment.
Non-root ranks return np.array(0) which is an ambiguous scalar value.
| if self.rank > 0: | |
| state = np.array(0) | |
| if return_array: | |
| statevector = state.flatten() if self.rank == 0 else state | |
| else: | |
| statevector = state if self.rank == 0 else state | |
| if self.rank == 0: | |
| statevector = state.flatten() if return_array else state | |
| else: | |
| statevector = None |
| coeff = coeff.real | ||
|
|
||
| target_size = int(2**nqubits / comm.size) | ||
| opt = ctg.ReusableHyperOptimizer( |
There was a problem hiding this comment.
Could you move this outside the loop and then use the opt object? If you reuse it it will discard cached results.
| op_str = opstr.lower() | ||
| ops = qu.pauli(op_str[0]) | ||
| for c in op_str[1:]: | ||
| ops = ops & qu.pauli(c) |
There was a problem hiding this comment.
Maybe you can reuse this function?
| op_str = opstr.lower() | |
| ops = qu.pauli(op_str[0]) | |
| for c in op_str[1:]: | |
| ops = ops & qu.pauli(c) | |
| ops = _string_to_quimb_operator(opstr) |
| circ.apply_gate( | ||
| quimb_gate_name, | ||
| *params, | ||
| *qubits, |
There was a problem hiding this comment.
| *qubits, | |
| *qubits, | |
| parametrize=is_parametrized, |
scarrazza
left a comment
There was a problem hiding this comment.
Thanks @Vinitha-balachandran, could you please add a tests for the two new MPI functions?
|
|
||
|
|
||
| def dense_vector_tn_mpi_qu( | ||
| qasm: str, nqubits, initial_state, mps_opts, backend="numpy" |
There was a problem hiding this comment.
I would suggest including a final arg with optimizer options so we avoid hardcoding values.
There was a problem hiding this comment.
@scarrazza Thanks Stefano for the suggestions, I have addressed them all in the new commit. Also, added two pytests for the new functions.
Added mpi support in quimb