Skip to content

Add collect_materialized_nodes#657

Merged
inducer merged 8 commits into
inducer:mainfrom
majosm:collect-materialized-nodes
Apr 10, 2026
Merged

Add collect_materialized_nodes#657
inducer merged 8 commits into
inducer:mainfrom
majosm:collect-materialized-nodes

Conversation

@majosm

@majosm majosm commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

This PR adds a collect_materialized_nodes function that identifies all materialized nodes, including those that are implicitly materialized based on their use by another node (e.g., LoopyCall ins/outs, DistributedSend data). It also attempts to use this function to unify the identification of materialized nodes elsewhere in the code, namely MPMS materialization and distributed partitioning.

Summary of changes:

  • Adds MaterializedNodeCollector and collect_materialized_nodes to analysis.
  • Replaces/generalizes existing _MaterializedArrayCollector in distributed.
  • Fixes an issue with MPMSMaterializer not traversing LoopyCall's bindings.
  • Updates MPMSMaterializer to be aware of implicitly-materialized arrays.

@majosm majosm force-pushed the collect-materialized-nodes branch from 2ecb14e to 5da2a0a Compare April 2, 2026 17:26
@majosm majosm force-pushed the collect-materialized-nodes branch from a971e25 to 8a605b0 Compare April 2, 2026 18:01
@majosm majosm requested a review from inducer April 2, 2026 18:21
@majosm majosm mentioned this pull request Apr 2, 2026
2 tasks
@inducer inducer requested a review from Copilot April 3, 2026 14:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a unified mechanism for identifying “implicitly materialized” nodes in a Pytato DAG and wires it into both MPMS materialization and distributed partitioning, including improved handling of LoopyCall bindings/results.

Changes:

  • Add MaterializedNodeCollector / collect_materialized_nodes in pytato.analysis.
  • Update MPMS materialization to account for implicitly materialized nodes (e.g. CSRMatmul, LoopyCall ins/outs, distributed send/recv).
  • Replace the distributed partitioner’s bespoke materialized-node collector with the new analysis helper.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
pytato/transform/materialize.py MPMS materializer now consults collect_materialized_nodes and correctly traverses/handles LoopyCall bindings/results and other implicitly-materialized nodes.
pytato/distributed/partition.py Removes the local materialized-node collector and uses collect_materialized_nodes to seed partition placement logic.
pytato/analysis/__init__.py Adds the new collector + public API for determining which nodes are materialized.
.basedpyright/baseline.json Updates typing baseline to reflect the new/modified typing surface.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pytato/distributed/partition.py
Comment thread pytato/analysis/__init__.py
Comment thread pytato/analysis/__init__.py Outdated
Comment thread pytato/analysis/__init__.py Outdated
majosm added 4 commits April 3, 2026 10:51
the idea is that one should be able to call collect_materialize_nodes on a subexpression,
using include_outputs=False to indicate that the root is not a "true" output

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pytato/analysis/__init__.py
Comment thread pytato/analysis/__init__.py
Comment thread pytato/analysis/__init__.py
@inducer inducer merged commit 07a329a into inducer:main Apr 10, 2026
14 checks passed
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.

3 participants