-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[py mp] MathematicalProgram.AddLinearConstraint prefers sparse overload? #20516
Comments
This might a regression due to #20361. \CC @AlexandreAmice That PR had unit tests that directly construct a LinearConstraint that (seem to) prove that the dense vs sparse overloading happens correctly. However, the unit tests for MathematicalProgram only (seem to) prove that sparse overloads are correctly selected -- there were no checks added that |
@EricCousineau-TRI maybe you could share exactly which type you were passing at the call site (and the types of any other args that might affect the overload selection)? |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
From #20519 (comment), seems like one issue (for testing) is that Still not clear why overloads prefer sparse version, though. |
Sounds like we have a repro in hand now. I'll offer the next step might be to bisect Drake to figure out which commit caused this. |
I actually now have a pure It could either be the upgrade to pybind11, or it could always have been a problem. Will check on the pybind11 side. |
(The issue occurs when an overload seems to involve both dense vs. sparse and an additional argument that is |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Yeah, I'd posit that this has always been a problem, we just didn't have sufficient test coverage (explicitly checking overload behavior + using actual |
Attempted to migrate Drake+Bazel repro to pybind11+CMake, but am currently failing to reproduce the same results locally; odd. |
What happened?
I have a torque controller written as a QP in Python.
The code creates dense NumPy matrices for use with
prog.AddLinearConstraint()
.When profiling, I find that it tends to use the sparse flavor.
I found this by using
py-spy
, and seeing calls intoscipy.sparse
taking up a nontrivial amount of time.Not sure why this happens; best guess is that the pybind11 binding overload for sparse matrices has better "affinity" (i.e., can accept arguments with no conversion), though not sure why this would be the case.
For now, I can workaround it by patching Drake to not bind those overloads.
\cc @hongkai-dai @jwnimmer-tri
Version
5303029
What operating system are you using?
No response
What installation option are you using?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: