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

Top-level loop for compiler #1576

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0d639ac
initial implmentation of meomry algorithm
wmdi Oct 13, 2024
da857a5
fmt
wmdi Oct 16, 2024
ef8c5c2
pass existing tests
wmdi Oct 16, 2024
982f1f5
initialize memory algorithm
wmdi Oct 31, 2024
01c6a6b
Merge remote-tracking branch 'flexflow/repo-refactor' into memory-alg
wmdi Oct 31, 2024
964c885
fix tests & format
wmdi Oct 31, 2024
0c0e7b0
minimum tests for memory algorithm
wmdi Nov 7, 2024
7778377
renaming
wmdi Dec 18, 2024
0315160
fmt
wmdi Dec 18, 2024
855a7d5
fix
wmdi Dec 30, 2024
2b4e127
rename single machine mapping
wmdi Jan 9, 2025
f72fb6f
Merge branch 'master' into memory-alg
lockshaw Jan 9, 2025
50bae93
format
wmdi Jan 9, 2025
3297d3f
Merge branch 'memory-alg' of github.com:wmdi/FlexFlow into memory-alg
wmdi Jan 9, 2025
d96b678
top-level loop for compiler
wmdi Jan 15, 2025
cd9b031
Merge branch 'master' into memory-alg
lockshaw Jan 15, 2025
1dcaa42
Merge branch 'master' into memory-alg
lockshaw Jan 20, 2025
c16bcf6
fixes
wmdi Jan 21, 2025
2e93e74
Merge branch 'memory-alg' of github.com:wmdi/FlexFlow into memory-alg
wmdi Jan 21, 2025
62389ad
upd
wmdi Jan 22, 2025
6d2fe50
fixes
wmdi Jan 29, 2025
45a931c
fix
wmdi Jan 30, 2025
efc7a9a
Merge remote-tracking branch 'flexflow/master' into memory-alg
wmdi Jan 30, 2025
4f97602
Merge remote-tracking branch 'flexflow/master' into memory-alg
wmdi Feb 12, 2025
14234b4
fix some errors introduced in merge
wmdi Feb 12, 2025
30e51fc
upd
wmdi Feb 20, 2025
ddbace1
Merge remote-tracking branch 'origin/master' into memory-alg
wmdi Feb 25, 2025
eb58e91
add test case for get mm problem tree
wmdi Feb 25, 2025
40c3494
Fix is_valid_machine_mapping_problem_tree, add hacky printing for pro…
lockshaw Feb 26, 2025
962934d
upd
wmdi Feb 27, 2025
550127a
update (#3)
Marsella8 Feb 28, 2025
948d247
fix get_optimal_machine_mapping
wmdi Mar 2, 2025
612bff5
implement divisible_by constarint type in substitutions
wmdi Mar 2, 2025
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
Prev Previous commit
Next Next commit
renaming
  • Loading branch information
wmdi committed Dec 18, 2024
commit 77783771b873ba2f2abd0fa45d32a03db548138b
9 changes: 3 additions & 6 deletions lib/compiler/include/compiler/cost_estimator/cost_estimator.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _FLEXFLOW_LIB_COMPILER_INCLUDE_COMPILER_COST_ESTIMATOR_COST_ESTIMATOR_H
#define _FLEXFLOW_LIB_COMPILER_INCLUDE_COMPILER_COST_ESTIMATOR_COST_ESTIMATOR_H

#include "compiler/cost_estimator/cost_metric.dtg.h"
#include "compiler/cost_estimator/op_cost_metrics.dtg.h"
#include "compiler/cost_estimator/op_cost_estimate_key.dtg.h"
#include "compiler/cost_estimator/tensor_set_movement.dtg.h"
#include "op-attrs/parallel_tensor_shape.dtg.h"
Expand All @@ -12,10 +12,8 @@
namespace FlexFlow {

struct ICostEstimator {
virtual float estimate_cost(OpCostEstimateKey const &) const = 0;
virtual OpCostMetrics estimate_cost(OpCostEstimateKey const &) const = 0;
virtual float estimate_cost(TensorSetMovement const &) const = 0;
virtual CostMetric
estimate_cost_with_memory(OpCostEstimateKey const &) const = 0;

ICostEstimator() = default;
ICostEstimator(ICostEstimator const &) = delete;
Expand All @@ -26,9 +24,8 @@ struct ICostEstimator {
CHECK_RC_COPY_VIRTUAL_COMPLIANT(ICostEstimator);

struct CostEstimator {
float estimate_cost(OpCostEstimateKey const &k) const;
OpCostMetrics estimate_cost(OpCostEstimateKey const &) const;
float estimate_cost(TensorSetMovement const &m) const;
CostMetric estimate_cost_with_memory(OpCostEstimateKey const &k) const;

template <typename T, typename... Args>
static typename std::enable_if<std::is_base_of<ICostEstimator, T>::value,
Expand Down
28 changes: 0 additions & 28 deletions lib/compiler/include/compiler/cost_estimator/cost_metric.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace = "FlexFlow"
name = "CostMetric"
name = "OpCostMetrics"
features = [
"eq",
"fmt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define _FLEXFLOW_COMPILER_MACHINE_MAPPING_GET_OPTIMAL_MACHINE_MAPPING_H

#include "compiler/machine_mapping/machine_mapping_cache.dtg.h"
#include "compiler/machine_mapping/machine_mapping_config.dtg.h"
#include "compiler/machine_mapping/machine_mapping_constraints.dtg.h"
#include "compiler/machine_mapping/machine_mapping_context.dtg.h"
#include "compiler/machine_mapping/machine_mapping_problem_tree/machine_mapping_problem_tree.dtg.h"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,42 @@
#define _FLEXFLOW_COMPILER_MACHINE_MAPPING_MEMORY_OPTIMIZATION_GET_OPTIMAL_MACHINE_MAPPING_WITH_MEMORY_H

#include "compiler/machine_mapping/machine_mapping_cache.dtg.h"
#include "compiler/machine_mapping/machine_mapping_config.dtg.h"
#include "compiler/machine_mapping/machine_mapping_constraints.dtg.h"
#include "compiler/machine_mapping/machine_mapping_context.dtg.h"
#include "compiler/machine_mapping/machine_mapping_problem_tree/machine_mapping_problem_tree.dtg.h"
#include "compiler/machine_mapping/machine_mapping_problem_tree/mm_problem_tree_parallel_split.dtg.h"
#include "compiler/machine_mapping/machine_mapping_problem_tree/mm_problem_tree_series_split.dtg.h"
#include "compiler/machine_mapping/memory_optimization/machine_mapping_cache_with_memory.dtg.h"
#include "compiler/machine_mapping/memory_optimization/machine_mapping_with_memory_cache.dtg.h"
#include "compiler/machine_mapping/parallel_split_transformation.dtg.h"
#include "pcg/machine_specification.dtg.h"

namespace FlexFlow {

MachineMappingResultWithMemory get_optimal_machine_mapping_with_memory(
MachineMappingCacheWithMemory &result_cache,
MachineMappingWithMemoryResult get_optimal_machine_mapping_with_memory(
MachineMappingWithMemoryCache &result_cache,
MachineMappingContext const &context,
MachineMappingProblemTree const &problem_tree,
MachineSpecification const &resources,
MachineMappingConstraints const &constraints);

MachineMappingResultWithMemory get_optimal_machine_mapping_with_memory(
MachineMappingCacheWithMemory &result_cache,
MachineMappingWithMemoryResult get_optimal_machine_mapping_with_memory(
MachineMappingWithMemoryCache &result_cache,
MachineMappingContext const &context,
MMProblemTreeSeriesSplit const &series_split,
MachineSpecification const &resources,
MachineMappingConstraints const &constraints,
std::optional<ParallelSplitTransformation> const
&parallel_split_transformation);

MachineMappingResultWithMemory get_optimal_machine_mapping_with_memory(
MachineMappingCacheWithMemory &result_cache,
MachineMappingWithMemoryResult get_optimal_machine_mapping_with_memory(
MachineMappingWithMemoryCache &result_cache,
MachineMappingContext const &context,
MMProblemTreeParallelSplit const &parallel_split,
MachineSpecification const &resources,
MachineMappingConstraints const &constraints);

MachineMappingResultWithMemory get_optimal_machine_mapping_with_memory(
MachineMappingCacheWithMemory &result_cache,
MachineMappingWithMemoryResult get_optimal_machine_mapping_with_memory(
MachineMappingWithMemoryCache &result_cache,
MachineMappingContext const &,
UnmappedOpCostEstimateKey const &leaf,
MachineSpecification const &resources,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#ifndef _FLEXFLOW_LIB_COMPILER_INCLUDE_COMPILER_MACHINE_MAPPING_MEMORY_OPTIMIZATION_MACHINE_MAPPING_CACHE_WITH_MEMORY_H
#define _FLEXFLOW_LIB_COMPILER_INCLUDE_COMPILER_MACHINE_MAPPING_MEMORY_OPTIMIZATION_MACHINE_MAPPING_CACHE_WITH_MEMORY_H

#include "compiler/machine_mapping/memory_optimization/machine_mapping_cache_with_memory.dtg.h"
#include "compiler/machine_mapping/memory_optimization/machine_mapping_with_memory_cache.dtg.h"

namespace FlexFlow {

MachineMappingCacheWithMemory empty_machine_mapping_cache_with_memory();
std::optional<MachineMappingResultWithMemory>
machine_mapping_cache_with_memory_load(
MachineMappingCacheWithMemory const &, MachineMappingState const &);
void machine_mapping_cache_with_memory_save(
MachineMappingCacheWithMemory &,
MachineMappingWithMemoryCache empty_machine_mapping_with_memory_cache();
std::optional<MachineMappingWithMemoryResult>
machine_mapping_with_memory_cache_load(
MachineMappingWithMemoryCache const &, MachineMappingState const &);
void machine_mapping_with_memory_cache_save(
MachineMappingWithMemoryCache &,
MachineMappingState const &,
MachineMappingResultWithMemory const &);
MachineMappingWithMemoryResult const &);

} // namespace FlexFlow

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace = "FlexFlow"
name = "MachineMappingCacheWithMemory"
name = "MachineMappingWithMemoryCache"
features = [
"eq",
"hash",
Expand All @@ -9,7 +9,7 @@ features = [
includes = [
"<unordered_map>",
"compiler/machine_mapping/machine_mapping_state.dtg.h",
"compiler/machine_mapping/memory_optimization/machine_mapping_result_with_memory.dtg.h",
"compiler/machine_mapping/memory_optimization/machine_mapping_with_memory_result.dtg.h",
]

src_includes = [
Expand All @@ -19,4 +19,4 @@ src_includes = [

[[fields]]
name = "raw_map"
type = "std::unordered_map<::FlexFlow::MachineMappingState, ::FlexFlow::MachineMappingResultWithMemory>"
type = "std::unordered_map<::FlexFlow::MachineMappingState, ::FlexFlow::MachineMappingWithMemoryResult>"
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef _FLEXFLOW_COMPILER_MACHINE_MAPPING_MEMORY_OPTIMIZATION_MACHINE_MAPPING_RESULT_WITH_MEMORY_H
#define _FLEXFLOW_COMPILER_MACHINE_MAPPING_MEMORY_OPTIMIZATION_MACHINE_MAPPING_RESULT_WITH_MEMORY_H

#include "compiler/machine_mapping/memory_optimization/machine_mapping_with_memory_result.dtg.h"
#include "compiler/machine_mapping/parallel_split_transformation.dtg.h"
#include <optional>

namespace FlexFlow {

[[nodiscard]] MachineMappingWithMemoryResult
empty_machine_mapping_with_memory_result();
[[nodiscard]] bool is_empty(MachineMappingWithMemoryResult const &);

[[nodiscard]] MachineMappingWithMemoryResult get_mapping_with_minimal_runtime(
std::unordered_set<MachineMappingWithMemoryResult> const &);

[[nodiscard]] MachineMappingWithMemoryResult
remove_non_pareto_optimal_machine_mapping_result(
MachineMappingWithMemoryResult const &);

[[nodiscard]] MachineMappingWithMemoryResult
series_combine(float comm_cost,
MachineMappingWithMemoryResult const &pre_result,
MachineMappingWithMemoryResult const &post_result,
std::optional<ParallelSplitTransformation> const
&parallel_split_transformation);
[[nodiscard]] MachineMappingWithMemoryResult
parallel_combine(MachineMappingWithMemoryResult const &lhs_result,
MachineMappingWithMemoryResult const &rhs_result);

[[nodiscard]] MachineMappingWithMemoryResult
minimize_runtime(MachineMappingWithMemoryResult const &m1,
MachineMappingWithMemoryResult const &m2);

[[nodiscard]] MachineMappingWithMemoryResult
make_singleton_machine_mapping_with_memory_result(
OpCostMetrics cost, MachineView const &machine_view);

} // namespace FlexFlow

#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace = "FlexFlow"
name = "MachineMappingResultWithMemory"
name = "MachineMappingWithMemoryResult"
features = [
"eq",
"hash",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ features = [

includes = [
"compiler/machine_mapping/parallel_layer_guid_oblivious_machine_mapping.dtg.h",
"compiler/cost_estimator/cost_metric.dtg.h",
"compiler/cost_estimator/op_cost_metrics.dtg.h",
]

[[fields]]
name = "cost"
type = "::FlexFlow::CostMetric"
type = "::FlexFlow::OpCostMetrics"

[[fields]]
name = "machine_mapping"
Expand Down
7 changes: 1 addition & 6 deletions lib/compiler/src/compiler/cost_estimator/cost_estimator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@ namespace FlexFlow {
CostEstimator::CostEstimator(std::shared_ptr<ICostEstimator> implementation_ptr)
: implementation_ptr(implementation_ptr) {}

float CostEstimator::estimate_cost(OpCostEstimateKey const &k) const {
OpCostMetrics CostEstimator::estimate_cost(OpCostEstimateKey const &k) const {
return this->implementation_ptr->estimate_cost(k);
}

float CostEstimator::estimate_cost(TensorSetMovement const &m) const {
return this->implementation_ptr->estimate_cost(m);
}

CostMetric
CostEstimator::estimate_cost_with_memory(OpCostEstimateKey const &k) const {
return this->implementation_ptr->estimate_cost_with_memory(k);
}

} // namespace FlexFlow
55 changes: 0 additions & 55 deletions lib/compiler/src/compiler/cost_estimator/cost_metric.cc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ MachineMappingResult
auto get_mapping_result = [&](MachineView const &machine_view) {
OpCostEstimateKey mapped =
map_unmapped_op_cost_estimate_key(leaf, machine_view);
float cost = context.cost_estimator.estimate_cost(mapped);
float cost = context.cost_estimator.estimate_cost(mapped).runtime;

return make_singleton_machine_mapping_result(cost, machine_view);
};
Expand Down
Loading
Loading