Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
510c2d9
Start on pcg builder
lockshaw Jun 4, 2024
7b55ed1
Add tests and some implementation for pcg builder
lockshaw Jun 4, 2024
c379efd
Add pcg tests, make dtgen constructors explicit to fix bug
lockshaw Jun 10, 2024
35fa653
Add remainder of PCG tests
lockshaw Jun 10, 2024
865a28e
Merge remote-tracking branch 'origin/repo-refactor' into pcg-builder
lockshaw Jun 10, 2024
f379539
Fix build issues in local-execution
lockshaw Jun 10, 2024
2dbb3b9
Format
lockshaw Jun 10, 2024
4050c99
Address Reyna comments, add topological_order function for PCG
lockshaw Jun 17, 2024
42c1968
Pre multidigraph refactor
lockshaw Jun 19, 2024
3be816f
Removing visitable from sp code
lockshaw Jun 21, 2024
6d68324
Add open dataflow graph, start to replace pcg dataflow graph
lockshaw Jun 23, 2024
64a3403
Start refactoring substitutions
lockshaw Jun 24, 2024
7d4c7be
Add utility functions to support pattern matching
lockshaw Jun 25, 2024
9ab9eb2
Pre-refactor inputs
lockshaw Jun 26, 2024
7ae7c65
Merge remote-tracking branch 'origin/repo-refactor' into dataflow-graph
lockshaw Jun 26, 2024
f9b129e
Fix proj url
lockshaw Jun 26, 2024
cf73f08
Get back to substitutions, now with unordered graph inputs
lockshaw Jul 7, 2024
5fd666d
Get substitutions building
lockshaw Jul 13, 2024
5f0c88a
substitutions-tests now builds
lockshaw Jul 13, 2024
3228f2d
Fix bug in filter, pass some initial substitution tests
lockshaw Jul 14, 2024
5f4cc01
Add tests for fmt::to_string, fix some substitutions bugs
lockshaw Jul 15, 2024
ad60be0
Pass initial unit tests for find_pattern_matches
lockshaw Jul 15, 2024
a972da2
Start on unit tests for pcg pattern
lockshaw Jul 15, 2024
bcf776e
Pass initial test for find_pattern_matches
lockshaw Jul 19, 2024
e28400e
Merge remote-tracking branch 'origin/repo-refactor' into dataflow-graph
lockshaw Jul 19, 2024
fe6d65d
Fix small build issue in tests
lockshaw Jul 19, 2024
e647af7
Format
lockshaw Jul 19, 2024
8b58760
Sync tests in CI with tests in proj
lockshaw Jul 19, 2024
1fafb9d
Fix minor build errors in kernels and local-execution
lockshaw Jul 19, 2024
0804314
Format
lockshaw Jul 19, 2024
dd5465c
Remove outdated code
lockshaw Jul 20, 2024
29ec5b8
More outdated code removal
lockshaw Jul 20, 2024
ff41743
More cleanup, add test for sp decomposition
lockshaw Jul 20, 2024
e71d200
Pull apart containers.h
lockshaw Jul 21, 2024
c06710c
More sp testing and fixes
lockshaw Jul 21, 2024
2f75566
Break up graph algorithms.h
lockshaw Jul 21, 2024
c81d3a4
Pre- full SP algo commit
lockshaw Jul 23, 2024
2a11c7e
Add initial implementation and tests for cbc decomposition and invers…
lockshaw Jul 23, 2024
71a9e0f
Pass test for get_inverse_line_graph
lockshaw Jul 24, 2024
25eb1db
Add new multidigraph
lockshaw Jul 24, 2024
64f1932
Fix get_inverse_line_graph to return a MultiDiGraph instead of a DiGraph
lockshaw Jul 24, 2024
31c8d17
Add tests for parallel and series reduction finding
lockshaw Jul 24, 2024
19e7e28
Add really rough implementation of valdez sp decomposition
lockshaw Jul 24, 2024
3791e86
Fix local-execution build
lockshaw Jul 25, 2024
267b72d
Add implementations and tests for applying series/parallel reductions
lockshaw Jul 25, 2024
bb2769a
Format
lockshaw Jul 26, 2024
39cb7b3
Clean up sp decomposition interface and tests
lockshaw Jul 27, 2024
ce0234d
Format
lockshaw Jul 27, 2024
660c899
integrating compiler with dataflow-graph
Jul 31, 2024
3dc3ec6
Add comments for top-level substitutions functions, add proj doxygen …
lockshaw Jul 31, 2024
f4dfd66
Fix proj invocation in CI
lockshaw Jul 31, 2024
cb663af
Merge remote-tracking branch 'lockshaw/dataflow-graph' into get-allow…
Jul 31, 2024
72e0d2b
minor changes
Jul 31, 2024
bf0aa62
Merge remote-tracking branch 'flexflow/repo-refactor' into get-allowe…
Jul 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .proj.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build_targets = [
"kernels",
"pcg",
"substitutions",
# "compiler",
"compiler",
"substitution-generator",
"local-execution",
]
Expand All @@ -19,7 +19,7 @@ test_targets = [
"op-attrs-tests",
"pcg-tests",
"substitutions-tests",
# "compiler-tests",
"compiler-tests",
"substitution-generator-tests",
]

Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/include/compiler/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "pcg/cost_values.h"
#include "pcg/machine_view.h"
#include "pcg/parallel_computation_graph.h"
#include "pcg/parallel_computation_graph/parallel_computation_graph.h"
#include "pcg/tensor_mapping.h"

namespace FlexFlow {
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/include/compiler/cost_estimate.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "op-attrs/operator_attrs.h"
#include "op-attrs/parallel_tensor_shape.h"
#include "pcg/machine_view.h"
#include "pcg/parallel_tensor_attrs.dtg.h"
#include "pcg/parallel_computation_graph/parallel_tensor_attrs.dtg.h"

namespace FlexFlow {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
#define _FLEXFLOW_COMPILER_GRAPH_UTILS_H

#include "compiler/unity_algorithm.h"
#include "pcg/computation_graph.dtg.h"
#include "pcg/parallel_computation_graph/parallel_computation_graph.dtg.h"
#include "substitutions/sub_parallel_computation_graph.dtg.h"
#include "utils/graph/serial_parallel/serial_parallel_decomposition.dtg.h"

namespace FlexFlow {

SerialParallelDecomposition
get_serial_parallel_decomposition(ParallelComputationGraph const &pcg);

ParallelComputationGraph cg_to_pcg(ComputationGraph const &g);
SubParallelComputationGraphView
pcg_to_subpcg(ParallelComputationGraph const &g);
SubParallelComputationGraph pcg_to_subpcg(ParallelComputationGraph const &g);

// NOTE(@wmdi): I think we should have the following interfaces in the graph
// library eventually.
Expand Down
64 changes: 24 additions & 40 deletions lib/compiler/include/compiler/machine_mapping.h
Original file line number Diff line number Diff line change
@@ -1,37 +1,21 @@
#ifndef _FLEXFLOW_COMPILER_MACHINE_MAPPING_H
#define _FLEXFLOW_COMPILER_MACHINE_MAPPING_H

#include "compiler/machine_mapping.dtg.h"
#include "compiler/optimal_cost_state.dtg.h"
#include "cost_estimate.h"
#include "pcg/machine_specification.dtg.h"
#include "pcg/machine_specification.h"
#include "pcg/machine_view.h"
#include "pcg/parallel_computation_graph.h"
#include "pcg/parallel_computation_graph/parallel_computation_graph.h"
#include "substitutions/sub_parallel_computation_graph.h"
#include "utils/graph/serial_parallel/serial_parallel_decomposition.dtg.h"

namespace FlexFlow {

using SubParallelComputationGraphView =
OutputLabelledOpenMultiDiGraphView<Operator, ParallelTensor>;
MachineMapping combine(MachineMapping const &, MachineMapping const &);

struct MachineMapping {
static MachineMapping combine(MachineMapping const &, MachineMapping const &);
static bool nodes_are_disjoint(MachineMapping const &m1,
MachineMapping const &m2);

req<std::unordered_map<Node, MachineView>> machine_views;
};
FF_VISITABLE_STRUCT(MachineMapping, machine_views);

struct OptimalCostState {
SerialParallelDecomposition subgraph;
MachineSpecification resource;
std::unordered_map<Node, MachineView> given_machine_views;
req<std::unordered_map<OpenMultiDiEdge, MachineView>> frontier_machine_views;
};
FF_VISITABLE_STRUCT(OptimalCostState,
subgraph,
resource,
given_machine_views,
frontier_machine_views);
bool nodes_are_disjoint(MachineMapping const &m1, MachineMapping const &m2);

struct OptimalCostResult {
static OptimalCostResult sequential_combine(OptimalCostResult const &s1,
Expand Down Expand Up @@ -60,26 +44,26 @@ class OptimalCostCache {
std::unordered_map<OptimalCostState, OptimalCostResult> cache;
};

OptimalCostResult
optimal_cost(ParallelComputationGraph const &g,
std::function<std::unordered_set<MachineView>(
Operator const &, MachineSpecification const &)> const
&allowed_machine_views,
CostEstimator const &cost_estimator,
MachineSpecification const &resources,
OptimalCostCache &cached_subgraph_costs);
OptimalCostResult optimal_cost(
ParallelComputationGraph const &g,
std::function<std::unordered_set<MachineView>(
ParallelLayerAttrs const &, MachineSpecification const &)> const
&allowed_machine_views,
CostEstimator const &cost_estimator,
MachineSpecification const &resources,
OptimalCostCache &cached_subgraph_costs);

} // namespace FlexFlow

namespace std {

template <>
struct hash<std::unordered_map<FlexFlow::Node, FlexFlow::MachineMapping>> {
size_t operator()(
std::unordered_map<FlexFlow::Node, FlexFlow::MachineMapping> const &g)
const;
};
// namespace std {
//
// template <>
// struct hash<std::unordered_map<FlexFlow::Node, FlexFlow::MachineMapping>> {
// size_t operator()(
// std::unordered_map<FlexFlow::Node, FlexFlow::MachineMapping> const &g)
// const;
// };

}; // namespace std
// }; // namespace std

#endif
21 changes: 21 additions & 0 deletions lib/compiler/include/compiler/machine_mapping.struct.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace = "FlexFlow"
name = "MachineMapping"
features = [
"eq",
# "ord",
"hash",
# "json",
# "rapidcheck",
"fmt",
]

includes = [
"utils/graph/node/node.dtg.h",
"pcg/machine_view.dtg.h",
"utils/hash/unordered_map.h",
"utils/fmt/unordered_map.h",
]

[[fields]]
name = "machine_views"
type = "std::unordered_map<::FlexFlow::Node, ::FlexFlow::MachineView>"
36 changes: 36 additions & 0 deletions lib/compiler/include/compiler/optimal_cost_state.struct.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace = "FlexFlow"
name = "OptimalCostState"
features = [
"eq",
# "ord",
"hash",
# "json",
# "rapidcheck",
"fmt",
]

includes = [
"utils/graph/serial_parallel/serial_parallel_decomposition.dtg.h",
"pcg/machine_specification.dtg.h",
"pcg/machine_view.dtg.h",
"utils/graph/node/node.dtg.h",
"utils/graph/open_dataflow_graph/open_dataflow_edge.dtg.h",
"utils/fmt/unordered_map.h",
"utils/hash/unordered_map.h",
]

[[fields]]
name = "subgraph"
type = "::FlexFlow::SerialParallelDecomposition"

[[fields]]
name = "resource"
type = "::FlexFlow::MachineSpecification"

[[fields]]
name = "given_machine_views"
type = "std::unordered_map<::FlexFlow::Node, ::FlexFlow::MachineView>"

[[fields]]
name = "frontier_machine_views"
type = "std::unordered_map<::FlexFlow::OpenDataflowEdge, ::FlexFlow::MachineView>"
23 changes: 14 additions & 9 deletions lib/compiler/include/compiler/unity_algorithm.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
#ifndef _FLEXFLOW_COMPILER_UNITY_ALGORITHM_H
#define _FLEXFLOW_COMPILER_UNITY_ALGORITHM_H

#include "compiler/machine_mapping.h"
#include "cost_estimate.h"
#include "machine_mapping.h"
#include "pcg/computation_graph.h"
#include "pcg/machine_specification.dtg.h"
#include "substitutions/sub_parallel_computation_graph.h"

namespace FlexFlow {

struct Strategy {
ParallelComputationGraph pcg;
MachineMapping machine_mapping;
req<float> runtime;
friend bool operator!=(Strategy const &lhs, Strategy const &rhs) {
return (lhs.machine_mapping != rhs.machine_mapping) ||
(lhs.runtime != rhs.runtime);
}
};

FF_VISITABLE_STRUCT(Strategy, pcg, machine_mapping, runtime);
Expand All @@ -27,14 +32,14 @@ struct OptimizerConfig {
int max_num_ops;
};

Strategy
graph_optimize(ComputationGraph &cg,
CostEstimator const &cost_estimator,
MachineSpecification const &resources,
std::function<std::unordered_set<MachineView>(
Operator const &, MachineSpecification const &)> const
&allowed_machine_views,
OptimizerConfig const &opt_config);
Strategy graph_optimize(
ComputationGraph &cg,
CostEstimator const &cost_estimator,
MachineSpecification const &resources,
std::function<std::unordered_set<MachineView>(
ParallelLayerAttrs const &, MachineSpecification const &)> const
&allowed_machine_views,
OptimizerConfig const &opt_config);

} // namespace FlexFlow

Expand Down
Loading