Skip to content

feat(core): Dependency Graph #65

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

Merged
merged 1 commit into from
Apr 27, 2025
Merged

Conversation

potatomashed
Copy link
Collaborator

@potatomashed potatomashed commented Apr 27, 2025

Here’s a draft GitHub PR description you can drop into your merge request:

This PR introduces a torch.fx.Graph style doubly‐linked dependency graph

  • Nodes wrap an opaque "statement" plus its input/output variables
  • Maintains:
    • a stmt_to_node map to find a node by its statement
    • a var_to_producer map from each variable to the node that produces it
    • a var_to_consumers map from each variable to all nodes that consume it
  • Provides safe, consistent APIs to:
    • create, insert (before/after), replace, erase nodes
    • query producers/consumers by node or by variable

Why it matters

  • Enables IR-level transformations and analyses that need to track data dependencies
  • Guarantees correctness of producer/consumer relationships as the graph is edited
  • Lays the groundwork for scheduling passes (topological sort, liveness, CSE, fusion, etc.)

Unittests

50 pytest cases covering:

  • basic chain graphs, branching graphs, empty/inputs‐only graphs
  • all API calls, success & failure modes (invalid anchors, duplicate stmts/vars, head/leaf errors)
  • identity vs. equality, iteration‐stop, idempotent clears, and more

@potatomashed potatomashed marked this pull request as ready for review April 27, 2025 06:31
@potatomashed potatomashed changed the title feat(core): DepGraph feat(core): Dependency Graph Apr 27, 2025
@potatomashed potatomashed merged commit 81d8c25 into mlc-ai:main Apr 27, 2025
4 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.

1 participant