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

[Subgraph] Implement SubGraphBase/SubGraphCpu to update NetworkGraph; adding graph_scope property #2865

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

EunjuYang
Copy link
Contributor

@EunjuYang EunjuYang commented Jan 10, 2025

Dear reviewers,

Abstract
This PR aims to suggest the first draft to resolve #2864.
This PR implements SubGraphBase which is a virtual class with GraphCore subgraph; the subgraph manages the layers included in the subgraph. Also, This PR updats NetworkGraph to manage multiple subgraph usng GraphCore graph. To this end, it implemented the SubGraphBase to inherit GraphNode.
Please note that, this draft only considers to implement the skeleton, so it doesn't fully consider to support multiple subgraphs. The feature will be added in later PR. However, it would be happy to listen your idea on managing multiple subgraphs.

List of commits

  • 4d66ea9: Refactor: Move Defined Behavior from NetworkGraph to SubGraphBase
    • Moved the defined behavior from NetworkGraph to SubGraphBase.
    • Updated public methods of NetworkGraph to pass their behaviors to SubGraphBase.
    • Removed unused private methods in NetworkGraph.
  • 708475e: Move forwarding/incremental_forwarding op from neuralnet to SubGraphBase
    • Update the definition of forwarding operations in neuralnet to be defined within each subgraph type.
    • Modify the implementation so that both forwarding and incremental_forwarding can now be defined individually for each subgraph type.
  • d4c9922: Move backwarding op from neuralnet to SubGraphBase
    • Update the definition of backwarding operations in neuralnet to be defined within each subgraph type.
    • applyGradients is also updated without taking any callback from
      outside.
  • 66bd5b5: Update type of graph in NetworkGraph and relevant unit tests
    • Updated SubGraphBase to inherit GraphNode
    • Changed the graph type inside NetworkGraph from SubGraphBase to GraphCore, using SubGraphBase as its GraphNode type.
    • Allowed for the addition of multiple SubGraphBase graph nodes in the future.
    • Assumed that NetworkGraph always has a default_subgraph called default_subgraph, and updated the existing code to maintain compatibility.
    • Updated the relevant unit test codes.
  • 3c4aecd: Split Input Setup and Label Setup for Subgraphs
    • Refactored the input and label setup logic for subgraphs by splitting them into separate functions: setInputs() and setLabels().
    • Introduced new functions setInputs() and setLabels() to handle input and label setups independently for each subgraph.
  • 17e0c8c: Update SubGraphBase to be virtual and Implement SubGraphCpu
    • Updated the base class SubGraphBase to become a virtual base class and implemented a derived class SubGraphCpu.
    • Set up NetworkGraph to default to creating and utilizing one instance of SubGraphCpu.
    • Declared several member functions related to memory management and computation engines as pure virtual functions (=0) in SubGraphBase.
  • 87edf02: Add graph_scope property to designate subgraph of a layer
    • This commit adds a graph_scope property to designate the subgraph,
      which a layer belongs to.
    • This commit updates NetworkGraph's addLayer function to check the
      GraphName of the layer and create a subgraph if the graph doesn't
      exist.

Self evaluation:

  1. Build test: [*]Passed [ ]Failed [ ]Skipped
  2. Run test: [*]Passed [ ]Failed [ ]Skipped

Copy link
Member

@skykongkong8 skykongkong8 left a comment

Choose a reason for hiding this comment

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

If I understood correctly, this PR aims to move almost all the basic functionalities of networkGraph to some instances of subgraph, which can have different compute engine backends variants in order to govern them! (CPU, GPU, ... )
Detailed explanations per commit helped my understanding a LOT! Really appreciate it😁
Looks Good to me!

…bGraphBase`

- Moved the defined behavior from `NetworkGraph` to `SubGraphBase`.
- Updated public methods of `NetworkGraph` to pass their behaviors to `SubGraphBase`.
- Removed unused private methods in `NetworkGraph`.

Signed-off-by: Eunju Yang <[email protected]>
…o SubGraphBase

- Update the definition of forwarding operations in neuralnet to be defined within each subgraph type.
- Modify the implementation so that both forwarding and incremental_forwarding can now be defined individually for each subgraph type.

Signed-off-by: Eunju Yang <[email protected]>
- Update the definition of backwarding operations in neuralnet to be defined within each subgraph type.
- `applyGradients` is also updated without taking any callback from
  outside.

Signed-off-by: Eunju Yang <[email protected]>
… tests

- Updated `SubGraphBase` to inherit `GraphNode`
- Changed the `graph` type inside `NetworkGraph` from `SubGraphBase` to `GraphCore`, using `SubGraphBase` as its `GraphNode` type.
- Allowed for the addition of multiple `SubGraphBase` graph nodes in the future.
- Assumed that NetworkGraph always has a `default_subgraph` called default_subgraph, and updated the existing code to maintain compatibility.
- Updated the relevant unit test codes.

Signed-off-by: Eunju Yang <[email protected]>
- Refactored the input and label setup logic for subgraphs by splitting them into separate functions: `setInputs()` and `setLabels()`.
- Introduced new functions `setInputs()` and `setLabels()` to handle input and label setups independently for each subgraph.

Signed-off-by: Eunju Yang <[email protected]>
…hCpu`

- Updated the base class `SubGraphBase` to become a virtual base class and implemented a derived class `SubGraphCpu`.
- Set up `NetworkGraph` to default to creating and utilizing one instance of `SubGraphCpu`.
- Declared several member functions related to memory management and computation engines as pure virtual functions (=0) in `SubGraphBase`.

Signed-off-by: Eunju Yang <[email protected]>
- This commit adds a `graph_scope` property to designate the subgraph,
  which a layer belongs to.
- This commit updates NetworkGraph's addLayer function to check the
  GraphName of the layer and create a subgraph if the graph doesn't
  exist.

Signed-off-by: Eunju Yang <[email protected]>
- The previous version didn't implement a constructor for subgraph
  initialization.
- This commit resolves the issue.

Signed-off-by: Eunju Yang <[email protected]>
@EunjuYang EunjuYang force-pushed the pr/subgraph/base_cpu_property branch from 5f32216 to dcebfd1 Compare January 16, 2025 06:42
@EunjuYang EunjuYang requested a review from haehun as a code owner January 16, 2025 06:42
@EunjuYang
Copy link
Contributor Author

Please note that I've rebased the PR on main (2025-01-16 15:46 KST) !
Updated commits are 4d66ea9 and 17e0c8c, which were conflicted with #2872.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Subgraph] Enabling a feature to manage a graph in subgraph level.
3 participants