-
Notifications
You must be signed in to change notification settings - Fork 248
Add function to convert from ComputationGraph to DynamicOpenDataflowGraph #1624
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
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7c76668
Add function to convert from ComputationGraph to DynamicOpenDataflowG…
elliottslaughter 1ad5b0b
Fixup unit tests.
elliottslaughter f8bfc02
Switch role to nullopt.
elliottslaughter 440f532
Apply PR feedback.
elliottslaughter 7b66e4a
Format.
elliottslaughter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
lib/task-spec/include/task-spec/dynamic_graph/dynamic_layer_guid_t.dtg.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| namespace = "FlexFlow" | ||
| name = "dynamic_layer_guid_t" | ||
| type = "variant" | ||
| features = [ | ||
| "eq", | ||
| "hash", | ||
| "fmt", | ||
| ] | ||
|
|
||
| includes = [ | ||
| "pcg/layer_guid_t.dtg.h", | ||
| "pcg/parallel_computation_graph/parallel_layer_guid_t.dtg.h", | ||
| ] | ||
|
|
||
| [[values]] | ||
| name = "layer_guid" | ||
| type = "::FlexFlow::layer_guid_t" | ||
|
|
||
| [[values]] | ||
| name = "pcg_layer_guid" | ||
| type = "::FlexFlow::parallel_layer_guid_t" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
lib/task-spec/include/task-spec/dynamic_graph/dynamic_open_dataflow_graph_from_cg.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #ifndef _FLEXFLOW_LIB_TASK_SPEC_INCLUDE_TASK_SPEC_DYNAMIC_GRAPH_DYNAMIC_OPEN_DATAFLOW_GRAPH_FROM_CG_H | ||
| #define _FLEXFLOW_LIB_TASK_SPEC_INCLUDE_TASK_SPEC_DYNAMIC_GRAPH_DYNAMIC_OPEN_DATAFLOW_GRAPH_FROM_CG_H | ||
|
|
||
| #include "pcg/computation_graph.dtg.h" | ||
| #include "task-spec/dynamic_graph/dynamic_open_dataflow_graph.dtg.h" | ||
|
|
||
| namespace FlexFlow { | ||
|
|
||
| DynamicOpenDataflowGraph | ||
| make_dynamic_open_dataflow_graph_from_cg(ComputationGraph const &); | ||
|
|
||
| } // namespace FlexFlow | ||
|
|
||
| #endif |
21 changes: 21 additions & 0 deletions
21
lib/task-spec/include/task-spec/dynamic_graph/dynamic_tensor_guid_t.dtg.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| namespace = "FlexFlow" | ||
| name = "dynamic_tensor_guid_t" | ||
| type = "variant" | ||
| features = [ | ||
| "eq", | ||
| "hash", | ||
| "fmt", | ||
| ] | ||
|
|
||
| includes = [ | ||
| "pcg/tensor_guid_t.dtg.h", | ||
| "pcg/parallel_computation_graph/parallel_tensor_guid_t.dtg.h", | ||
| ] | ||
|
|
||
| [[values]] | ||
| name = "tensor_guid" | ||
| type = "::FlexFlow::tensor_guid_t" | ||
|
|
||
| [[values]] | ||
| name = "pcg_tensor_guid" | ||
| type = "::FlexFlow::parallel_tensor_guid_t" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
lib/task-spec/src/task-spec/dynamic_graph/dynamic_open_dataflow_graph_from_cg.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #include "task-spec/dynamic_graph/dynamic_open_dataflow_graph_from_cg.h" | ||
| #include "op-attrs/pcg_operator_attrs.h" | ||
| #include "pcg/computation_graph.h" | ||
| #include "task-spec/dynamic_graph/dynamic_layer_guid_t.dtg.h" | ||
| #include "task-spec/dynamic_graph/dynamic_open_dataflow_graph.h" | ||
| #include "task-spec/dynamic_graph/dynamic_tensor_role.h" | ||
| #include <optional> | ||
| #include <unordered_map> | ||
|
|
||
| namespace FlexFlow { | ||
|
|
||
| DynamicOpenDataflowGraph | ||
| make_dynamic_open_dataflow_graph_from_cg(ComputationGraph const &cg) { | ||
| DynamicOpenDataflowGraph result = make_empty_dynamic_open_dataflow_graph(); | ||
|
|
||
| for (auto const &[layer, attrs] : get_layer_attrs_mapping(cg)) { | ||
| DynamicNodeAttrs result_attrs{ | ||
| /*task_type=*/std::nullopt, | ||
| /*device_coord=*/std::nullopt, | ||
| /*mapping=*/std::nullopt, | ||
| /*op_attrs=*/pcg_op_attrs_from_compgraph_op_attrs(attrs.op_attrs), | ||
| /*pcg_layer_guid=*/dynamic_layer_guid_t{layer}, | ||
| /*per_device_op_state=*/std::nullopt}; | ||
elliottslaughter marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| std::unordered_map<DynamicTensorSlot, DynamicValueAttrs> result_inputs; | ||
| for (auto const &[slot_name, tensor] : get_incoming_tensors(cg, layer)) { | ||
elliottslaughter marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| result_inputs.emplace(std::piecewise_construct, | ||
| std::forward_as_tuple( | ||
| /*slot_name=*/slot_name, | ||
| /*slot_tensor_role=*/std::nullopt), | ||
| std::forward_as_tuple( | ||
| /*tensor_guid=*/dynamic_tensor_guid_t{tensor}, | ||
| /*parallel_tensor_shape=*/std::nullopt, | ||
| /*shard_coord=*/std::nullopt, | ||
| /*accessor=*/std::nullopt, | ||
| /*role=*/std::nullopt)); | ||
| } | ||
| std::unordered_map<DynamicTensorSlot, DynamicValueAttrs> result_outputs; | ||
| for (auto const &[slot_name, tensor] : get_outgoing_tensors(cg, layer)) { | ||
| result_outputs.emplace(std::piecewise_construct, | ||
| std::forward_as_tuple( | ||
| /*slot_name=*/slot_name, | ||
| /*slot_tensor_role=*/std::nullopt), | ||
| std::forward_as_tuple( | ||
| /*tensor_guid=*/dynamic_tensor_guid_t{tensor}, | ||
| /*parallel_tensor_shape=*/std::nullopt, | ||
| /*shard_coord=*/std::nullopt, | ||
| /*accessor=*/std::nullopt, | ||
| /*role=*/std::nullopt)); | ||
| } | ||
|
|
||
| result.invocations.emplace(result_inputs, result_attrs, result_outputs); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| } // namespace FlexFlow | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.