Skip to content
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

Add tools to list dispatcher specializations #2132

Closed
wants to merge 3 commits into from

Conversation

Ericgig
Copy link
Member

@Ericgig Ericgig commented Mar 23, 2023

Description
Add a function that list all dispatched functions and their specialization.
It automatically adapt to new data-layer and dispatched functions.
Only show pure specialization: solve[Dense, Dense] not solve[CSR, Dense].

I also register 2 specializations that were created, but not registered.

Example:

>>> from qutip.core.data.dev_utils import specialisation_table
>>> specialisation_table()

Output only specialisation
|Dispatched function | JaxArray |   CSR    |  Dense   |
|zeros               |   True   |   True   |   True   |
|identity            |   True   |   True   |   True   |
|diag                |   True   |   True   |   True   |
|one_element         |   True   |   True   |   True   |
...
Binary specialisation
|Dispatched function | JaxArray |   CSR    |  Dense   |
|add                 |   True   |   True   |   True   |
|sub                 |   True   |   True   |   True   |
|matmul              |   True   |   True   |   True   |
|multiply            |   True   |   True   |   True   |
|kron                |   True   |   True   |   True   |
|solve               |  False   |  False   |   True   |
...

This could also go into a notebook if it fit better there.

@coveralls
Copy link

Coverage Status

Coverage: 75.328%. Remained the same when pulling 585435c on Ericgig:dev.spec_table into 775cdcc on qutip:master.

@@ -1,6 +1,8 @@
[run]
source = qutip
omit =
# Skip dev tools
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should skip the dev tools in coverage. It's always good to know what code is being covered by tests, even if we decide not to cover them.

Aside: I also think that tests should be included in coverage. I've often picked up issues where a test or part of a test isn't being run by looking at coverage (e.g. the test is skipped if a dependency isn't installed and no test runner instance has that dependency).

Copy link
Contributor

@hodgestar hodgestar left a comment

Choose a reason for hiding this comment

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

Having some helpers for examining the dispatcher tree seems like a good idea and you already found some missed specializations using them.

I don't have a strong opinion on what these tools should look like yet, so very happy with these.

I would prefer to have a couple of simple tests for the two top-level functions just to be sure we don't accidentally break them if we tweak the data layer.

@Ericgig
Copy link
Member Author

Ericgig commented Mar 23, 2023

I just cleaned up a tool I used when making the jax data layer, but I don't want to add something that will ask for our time to maintain, thus no test or coverage.

In this meaning, it doesn't seems belong here.

I am closing this and making a new one with just the missing specializations + will check if they were also skipped in test.

@Ericgig Ericgig closed this Mar 23, 2023
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.

None yet

3 participants