Conversation
|
@inducer I started looking through the loopy codegen code to try to figure out how to generate temporaries for the reduction bounds to avoid islpy errors (as is done in the loopy example), but I'm having some trouble figuring out how best to do that. Seems like I need to create the temporaries inside |
|
Yes, working inside of |
de98230 to
2e1c083
Compare
|
@inducer I think this is ready for a look. I'm not sure how to fix the lingering doc build errors. Here's what the results are looking like. Code: Kernel: |
5159091 to
f7f8699
Compare
|
FWIW, while experimenting with containers in inducer/arraycontext#349, I tried seeing what this PR would look like if sparse matrix objects were treated as arrays. The changes are here. (Basically, matrices are treated as any other array except in codegen-related mappers, which refuse to process matrices that aren't reached through matmul arrays.) |
28b29b3 to
51e65df
Compare
faa9bfc to
40eb010
Compare
40eb010 to
a50c592
Compare
4675d86 to
2274478
Compare
87f5820 to
2fff24d
Compare
There was a problem hiding this comment.
Pull request overview
Adds first-class sparse matrix support (CSR) to Pytato by introducing new array/node types and plumbing them through transforms, visualization, equality/analysis, and code generation.
Changes:
- Introduces
SparseMatrix/CSRMatrixandSparseMatmul/CSRMatmul, plus user-facing constructors (make_csr_matrix) and operation (sparse_matmul/@). - Extends core mappers/transforms/visualizers/equality/analysis to recognize and traverse
CSRMatmul. - Updates Loopy codegen to handle more general reduction bounds (incl. non-affine detection/materialization) and adds CSR matmul tests.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_pytato.py | Adds input-validation tests for CSR matmul. |
| test/test_codegen.py | Adds end-to-end Loopy codegen test for CSR matmul (single/multiple/stacked). |
| pytato/visualization/fancy_placeholder_data_flow.py | Adds CSR matmul nodes to the “fancy” data-flow visualization. |
| pytato/visualization/dot.py | Adds CSR matmul nodes/edges to DOT visualization output. |
| pytato/transform/metadata.py | Ensures metadata collection traverses CSR matmul operands. |
| pytato/transform/materialize.py | Enables materialization logic to rebuild/visit CSR matmul children without duplication. |
| pytato/transform/lower_to_index_lambda.py | Lowers CSRMatmul to an IndexLambda using a symbolic reduction. |
| pytato/transform/einsum_distributive_law.py | Integrates CSRMatmul into distributive-law transformation flow. |
| pytato/transform/init.py | Adds CSR matmul handling to core transform mapper base classes/walkers. |
| pytato/target/python/numpy_like.py | Explicitly marks CSR matmul unsupported for numpy-like targets. |
| pytato/target/loopy/codegen.py | Substantial changes to reduction handling and storage to support new lowering paths. |
| pytato/stringifier.py | Allows generic stringification of CSR matmul nodes. |
| pytato/scalar_expr.py | Adds is_quasi_affine helper for reduction-bound analysis. |
| pytato/equality.py | Adds structural equality support for CSR matmul nodes. |
| pytato/codegen.py | Documents CSR matmul lowering in CodeGenPreprocessor. |
| pytato/array.py | Adds sparse matrix types, constructors, and sparse_matmul implementation. |
| pytato/analysis/init.py | Adds CSR matmul support to dependency/user analysis utilities. |
| pytato/init.py | Exposes new sparse APIs/types at the package top level. |
| doc/conf.py | Tweaks Sphinx nitpicks/missing-reference aliases for new typing/docs references. |
| .test-conda-env-py3.yml | Adds matplotlib-base dependency (used optionally by visualization in tests). |
| .basedpyright/baseline.json | Updates pyright baseline for new/changed typing diagnostics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…e other checks over from constructor
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Matthew Smith <mjsmith6@illinois.edu>
| # FIXME: This mapper still needs to be updated to avoid duplicating arrays (see | ||
| # https://github.com/inducer/pytato/pull/515). |
Adds
CSRMatmularray type for multiplication by sparse matrices in compressed sparse row format.cc @lukeolson