-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Remove duplicated weyl_coordinates python function #13193
Conversation
This commit removes the weyl_coordinates() function from the private qiskit.synthesis.two_qubit.weyl module. This function's internal use was ported to rust as part of Qiskit#11019 but it left the python implementation intact while we ensured the rust implementation was reliable longer term. Since then we've ported the majority of the two qubit synthesis to rust now and the only usage of this python implementation was the unit tests. This commit removes the python implementation and the entire internal weyl module as nothing uses it anymore. A python interface is added to the rust function and the tests are updated to call that instead. Fixes: Qiskit#8459
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 10947950215Details
💛 - Coveralls |
/// Computes the Weyl coordinates for a given two-qubit unitary matrix. | ||
/// | ||
/// Args: | ||
/// U (np.ndarray): Input two-qubit unitary. | ||
/// | ||
/// Returns: | ||
/// np.ndarray: Array of the 3 Weyl coordinates. | ||
#[pyfunction] | ||
fn weyl_coordinates(py: Python, unitary: PyReadonlyArray2<Complex64>) -> PyObject { | ||
let array = unitary.as_array(); | ||
__weyl_coordinates(array.into_faer_complex()) | ||
.to_vec() | ||
.into_pyarray_bound(py) | ||
.into() | ||
} | ||
|
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.
Did we consider this public interface in any way? If not: is there any chance it might get called with matrices whose dtypes are not complex
? I'm asking because the Python code would have happily lifted the matrix to be complex
early in the process (during the translation to the magic basis), but this will now just error immediately if anyone's doing things like weyl_coordinates(np.eye(2))
.
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.
Except of Jake's question, this PR looks good to me.
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.
I didn't think that we considered this API public in any way. It was previously used internally for some things but was replaced by rust internals in 1.0 and 1.1. Right now it's not documented anywhere nor is the deleted internal module and this function is only used for tests now. The public interface for getting the weyl coordinates would be to use the TwoQubitWeylDecomposition
and access the coordinate attributes. That being said if you think it's important I can change the input type to handle the casting here.
Summary
This commit removes the weyl_coordinates() function from the private qiskit.synthesis.two_qubit.weyl module. This function's internal use was ported to rust as part of #11019 but it left the python implementation intact while we ensured the rust implementation was reliable longer term. Since then we've ported the majority of the two qubit synthesis to rust now and the only usage of this python implementation was the unit tests. This commit removes the python implementation and the entire internal weyl module as nothing uses it anymore. A python interface is added to the rust function and the tests are updated to call that instead.
Details and comments
Fixes: #8459