pymc-devs / pymc-devs/pytensor

Implement sparsify transform

Open
#1,155 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement graph rewriting sparse variables
Dominant language
Python
Stars
644
Forks
208
Avg merge
2d 14h
Merged PRs (30d)
16

Description

Description

Allow automatically redefining a graph where a variable is replaced by a sparse one.

Minimal example:

import pytensor.tensor as pt
import pytensor.sparse as ps

A = pt.matrix("A")
v = pt.vector("v")
out = A @ v

A_sparse = ps.csc_matrix(name="A_sparse")
out_sparse = sparsify(out, replace={A: A_sparse})
# Should be equivalent to `ps.dot(A_sparse, v)`

Inspired by https://jax.readthedocs.io/en/latest/_autosummary/jax.experimental.sparse.sparsify.html

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation file or test is named. Start by reproducing the minimal example with PyTensor's sparse API and the sparsify entry point; done means replacing A with A_sparse produces a graph equivalent to ps.dot(A_sparse, v).

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.