-
Notifications
You must be signed in to change notification settings - Fork 81
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
Allow various ParameterExpression
s for qiskit to tc conversion
#207
Allow various ParameterExpression
s for qiskit to tc conversion
#207
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #207 +/- ##
==========================================
+ Coverage 75.52% 75.68% +0.15%
==========================================
Files 67 67
Lines 10804 10801 -3
==========================================
+ Hits 8160 8175 +15
+ Misses 2644 2626 -18 ☔ View full report in Codecov by Sentry. |
ansatz4.ry(ansatz4_param[0] * ansatz4_param[1] + ansatz4_param[2], 0) | ||
ansatz4.rz( | ||
np.exp(np.sin(ansatz4_param[0])) | ||
+ np.abs(ansatz4_param[1]) / np.arctan(ansatz4_param[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.
ParameterVector
doesn't support np.abs
for qiskit with early versions, though not determine the exact breaking version (at least 0.23 fails).
For now, I think it is ok to have abs
in the test, just comment for a record.
tensorcircuit/translation.py
Outdated
sympy.Symbol(str(symbol).replace("[", "_").replace("]", "")) | ||
for symbol in sympy_symbols | ||
] | ||
lam_f = sympy.lambdify(sympy_symbols, expr, modules=backend.name) |
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.
for modules
arg, there is no pytorch module support for lambdify
? I think we can stick to numpy
modules? As I have tested, modules="numpy"
can support binding_params
in the tensor format of each backend
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 the contribution, it is indeed a very nice solution for parameter experession translation. To me, the only thing required to change is to use modules="numpy"
when calling lambdify
.
As long as the CI works well :) I commented the package due to some CI incompatibility which might have been resolved now. |
ParameterExpression
's for qiskit to tc conversionParameterExpression
s for qiskit to tc conversion
If I just use algebraic operations like |
It seems like using
|
Cool, thanks for your careful investigation! The PR now LGTM |
@all-contributors please add @king-p3nguin for test, doc |
I've put up a pull request to add @king-p3nguin! 🎉 |
sympy.lambdify
can fix this.qiskit.circuit.bit.Bit.index
is deprecated.test_qiskit2tc_parameterized
does not seem to be working due to the deprecation ofQubitConverter
. RemovedQubitConverter
from the test.I noticed that
qiskit-nature
is commented onrequirements-extra.txt
. Is it okay that I uncommented it?