Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3786e0e
Add initial lib/substitution-generator and bin/substitutions-to-dot
lockshaw Apr 4, 2024
2890740
Format
lockshaw Apr 4, 2024
a342be7
Update proj version and add .proj.toml file to repo directly
lockshaw Apr 4, 2024
b54699b
Revert changes to flake.nix
lockshaw Apr 4, 2024
0eb172a
Prototype implementation of dtgen
lockshaw Apr 7, 2024
2586f78
Refactor op-attrs to use dtgen
lockshaw Apr 8, 2024
2011b31
Format
lockshaw Apr 8, 2024
0478c02
More dtgen'ing
lockshaw Apr 11, 2024
4873df6
Re-pass tests
lockshaw Apr 11, 2024
341742c
Simplify types in substitutions, more dtgen
lockshaw Apr 24, 2024
55c7cf1
Add new reduction dim shape inference for conv2d
lockshaw Apr 25, 2024
410c9a2
Move conv2d input parsing into public headers
lockshaw Apr 25, 2024
d6c5f7d
Remove incorrect not_implemented
lockshaw Apr 25, 2024
80d305e
Add pcg tests
lockshaw May 2, 2024
16ca8de
Add initial test for pcg
lockshaw May 14, 2024
f653585
Partial implementation of shape inference for linear
lockshaw May 14, 2024
a0c6c52
Fix rapidcheck (#8)
yingyee0111 May 26, 2024
394660e
Attempt to hide dtgen-generated files from github diff
lockshaw May 26, 2024
5d60878
Fix header file name for dtgen in gitattributes
lockshaw May 26, 2024
238da2d
Update proj and format code
lockshaw May 26, 2024
88709f0
Add initial shape inference for BMM
lockshaw May 27, 2024
d549d22
Add half of shape inference for Attention
lockshaw May 27, 2024
8405ebf
Finish initial shape inference for Attention
lockshaw May 28, 2024
946acca
Enable op-attrs and pcg tests in CI
lockshaw May 28, 2024
1a6d1f8
Add parallel shape inference for add and relu
lockshaw May 30, 2024
3e7ceac
Add parallel shape inference for embedding
lockshaw May 31, 2024
dd008d0
Add shape inference for repartition, combine, replicate, and reduction
lockshaw May 31, 2024
cb2c862
Include tests for reduction
lockshaw May 31, 2024
bf7a965
Address wmdi comments
lockshaw Jun 2, 2024
3a05ef2
Fixup linear shape inference, add tests for linear
lockshaw Jun 3, 2024
b2ce683
Merge remote-tracking branch 'origin/repo-refactor' into pcg-serializ…
lockshaw Jun 3, 2024
13cb842
Fix tests
lockshaw Jun 3, 2024
967cb22
Format
lockshaw Jun 3, 2024
7e288ec
Fix build errors
lockshaw Jun 3, 2024
115dd49
change lcov in ci to rm dtgen coverage
Jun 3, 2024
4462af2
Remove dtgen from coverage
lockshaw Jun 3, 2024
75032ba
Merge branch 'repo-refactor' into pcg-serialization
lockshaw Jun 3, 2024
1124218
Temporarily disable substitutions build in CI
lockshaw Jun 3, 2024
5109ca9
Format
lockshaw Jun 3, 2024
0618cfe
Fix substitution-generator build and tests
lockshaw Jun 3, 2024
0732e8b
Format
lockshaw Jun 3, 2024
cdfdd11
fix ci coverage attempt
Jun 3, 2024
97dc743
Merge branch 'pcg-serialization' of github.com:lockshaw/FlexFlow into…
Jun 3, 2024
137e59c
second attempt
Jun 4, 2024
70e1f09
small fix
Jun 4, 2024
6230d99
small fix
Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

[{CMakeLists.txt,*.cmake}]
indent_style = space
indent_size = 2

[*.{cc,h,cu,cpp}]
indent_style = space
indent_size = 2

[*.py]
indent_style = space
indent_size = 4

[*.toml]
indent_style = space
indent_size = 2
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.dtg.cc linguist-generated=true
*.dtg.h linguist-generated=true
37 changes: 24 additions & 13 deletions .github/workflows/per-lib-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ jobs:
run: |
build_libs.sh kernels

- name: Build substitutions
run: |
build_libs.sh substitutions
# - name: Build substitutions
# run: |
# build_libs.sh substitutions

- name: Build compiler
run: |
build_libs.sh compiler
# - name: Build compiler
# run: |
# build_libs.sh compiler

- name: Build substitution-generator
run: |
Expand All @@ -88,30 +88,41 @@ jobs:
run: |
test_libs.sh utils

- name: Test substitutions
- name: Test op-attrs
run: |
test_libs.sh substitutions
test_libs.sh op-attrs

- name: Test compiler
- name: Test pcg
run: |
test_libs.sh compiler
test_libs.sh pcg

# - name: Test substitutions
# run: |
# test_libs.sh substitutions

# - name: Test compiler
# run: |
# test_libs.sh compiler

- name: Test substitution-generator
run: |
test_libs.sh substitution-generator

- name: Generate code coverage
run: |
echo "gitwork: $GITHUB_WORKSPACE"
lcov --capture --directory . --output-file main_coverage.info
lcov --remove main_coverage.info '/nix/store/' --output-file main_coverage.info
lcov --list main_coverage.info
lcov --extract main_coverage.info "$GITHUB_WORKSPACE/lib/*" --output-file main_coverage_e.info
lcov --remove main_coverage_e.info "$GITHUB_WORKSPACE/lib/*.dtg.h" "$GITHUB_WORKSPACE/lib/*.dtg.cc" --output-file main_coverage_e_f.info
lcov --list main_coverage_e_f.info

- name: Upload code coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: main_coverage.info
file: main_coverage_e_f.info
flags: unittests
plugin: pycoverage #hope this will disable gcov
name: codecov-umbrella
fail_ci_if_error: false
verbose: true
13 changes: 9 additions & 4 deletions .proj.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ build_targets = [
"utils",
"op-attrs",
"kernels",
"substitutions",
"compiler",
"pcg",
# "substitutions",
# "compiler",
"substitution-generator",
]
test_targets = [
"utils-tests",
"substitutions-tests",
"compiler-tests",
"op-attrs-tests",
"pcg-tests",
# "substitutions-tests",
# "compiler-tests",
"substitution-generator-tests",
]

[cmake_flags_extra]
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
inputsFrom = [ ci ];
inherit (ci) CMAKE_FLAGS;

VIMPLUGINS = lib.strings.concatStringsSep "," [
"${proj-repo.packages.${system}.proj-nvim}"
];

buildInputs = builtins.concatLists [
(with pkgs; [
clang-tools
Expand Down
7 changes: 3 additions & 4 deletions lib/compiler/test/src/test_optimal_cost.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ TEST_SUITE(FF_TEST_SUITE) {

MultiDiEdge e{n1, pcg.add_node_port(), n0, pcg.add_node_port()};
pcg.add_edge(e);
pcg.add_output(e,
ParallelTensor(ParallelTensorDims({2, 1}),
DataType::FLOAT,
CreateGrad::YES));
ParallelDim dim = {2, 1, false};
ParallelTensorDims dims = {FFOrdered<ParallelDim>{dim}};
pcg.add_output(e, ParallelTensor(dims, DataType::FLOAT, CreateGrad::YES));

auto test_allowed_machine_views = [](Operator const &,
MachineSpecification const &) {
Expand Down
7 changes: 5 additions & 2 deletions lib/kernels/include/kernels/array_shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "utils/stack_vector.h"
#include "utils/visitable.h"
#include <cstddef>
#include <optional>
#include <vector>

namespace FlexFlow {
Expand Down Expand Up @@ -41,8 +42,10 @@ struct ArrayShape {
std::optional<std::size_t> at_maybe(std::size_t) const;

ArrayShape reversed_dim_order() const;
ArrayShape sub_shape(std::optional<legion_dim_t> start,
std::optional<legion_dim_t> end) const;

ArrayShape
sub_shape(std::optional<std::variant<ff_dim_t, legion_dim_t>> start,
std::optional<std::variant<ff_dim_t, legion_dim_t>> end) const;

public:
LegionTensorDims dims;
Expand Down
2 changes: 1 addition & 1 deletion lib/kernels/include/kernels/cast_kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "device.h"
#include "kernels/accessor.h"
#include "kernels/ff_handle.h"
#include "op-attrs/activation.h"
#include "op-attrs/activation.dtg.h"

namespace FlexFlow {
namespace Kernels {
Expand Down
2 changes: 1 addition & 1 deletion lib/kernels/include/kernels/conv_2d_kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "device.h"
#include "kernels/accessor.h"
#include "kernels/ff_handle.h"
#include "op-attrs/activation.h"
#include "op-attrs/activation.dtg.h"
#include "utils/visitable.h"

namespace FlexFlow {
Expand Down
2 changes: 1 addition & 1 deletion lib/kernels/include/kernels/element_binary_kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "ff_handle.h"
#include "kernels/array_shape.h"
#include "op-attrs/datatype.h"
#include "op-attrs/op.h"
#include "op-attrs/operator_type.h"

namespace FlexFlow {

Expand Down
22 changes: 19 additions & 3 deletions lib/kernels/include/kernels/element_unary_kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,34 @@ namespace ElementUnary {

ElementUnaryPerDeviceState init_kernel(ArrayShape const &input_shape,
ArrayShape const &output_shape,
ElementUnaryUnifiedAttrs const &attrs);
ElementUnaryAttrs const &attrs);

void forward_kernel(ffStream_t stream,
ElementUnaryPerDeviceState const &device_state,
ElementUnaryUnifiedAttrs const &attrs,
ElementUnaryAttrs const &attrs,
PerDeviceFFHandle &handle,
GenericTensorAccessorR const &input,
GenericTensorAccessorW const &output);

void forward_kernel(ffStream_t stream,
ElementUnaryPerDeviceState const &device_state,
ElementScalarUnaryAttrs const &attrs,
PerDeviceFFHandle &handle,
GenericTensorAccessorR const &input,
GenericTensorAccessorW const &output);

void backward_kernel(ffStream_t stream,
ElementUnaryPerDeviceState const &device_state,
ElementUnaryAttrs const &attrs,
PerDeviceFFHandle &handle,
GenericTensorAccessorR const &input,
GenericTensorAccessorW const &input_grad,
GenericTensorAccessorR const &output,
GenericTensorAccessorR const &output_grad);

void backward_kernel(ffStream_t stream,
ElementUnaryPerDeviceState const &device_state,
ElementUnaryUnifiedAttrs const &attrs,
ElementScalarUnaryAttrs const &attrs,
PerDeviceFFHandle &handle,
GenericTensorAccessorR const &input,
GenericTensorAccessorW const &input_grad,
Expand Down
8 changes: 4 additions & 4 deletions lib/kernels/include/kernels/legion_dim.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#ifndef _FLEXFLOW_KERNELS_INCLUDE_KERNELS_LEGION_DIM_H
#define _FLEXFLOW_KERNELS_INCLUDE_KERNELS_LEGION_DIM_H

#include "kernels/legion_dim_t.dtg.h"
#include "op-attrs/dim_ordered.h"
#include "utils/strong_typedef.h"

namespace FlexFlow {

struct legion_dim_t : strong_typedef<legion_dim_t, int> {
using strong_typedef::strong_typedef;
};
legion_dim_t add_to_legion_dim(legion_dim_t, int);

legion_dim_t legion_dim_from_ff_dim(ff_dim_t, int num_dimensions);

template <typename T>
using LegionOrdered = DimOrdered<legion_dim_t, T>;
Expand Down
54 changes: 54 additions & 0 deletions lib/kernels/include/kernels/legion_dim_t.dtg.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions lib/kernels/include/kernels/legion_dim_t.struct.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace = "FlexFlow"
name = "legion_dim_t"

features = [
"eq",
"ord",
"hash",
"json",
"fmt",
]

[[fields]]
name = "value"
type = "int"
2 changes: 1 addition & 1 deletion lib/kernels/include/kernels/pool_2d_kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "device.h"
#include "kernels/ff_handle.h"
#include "op-attrs/activation.h"
#include "op-attrs/activation.dtg.h"
#include "op-attrs/ops/pool_2d.h"
#include "utils/visitable.h"

Expand Down
2 changes: 1 addition & 1 deletion lib/kernels/include/kernels/reduce_kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "array_shape.h"
#include "device.h"
#include "ff_handle.h"
#include "op-attrs/op.h"
#include "op-attrs/operator_type.dtg.h"

namespace FlexFlow {

Expand Down
2 changes: 1 addition & 1 deletion lib/kernels/include/kernels/transpose_kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace FlexFlow {

struct TransposePerDeviceState {
int num_dim;
req<std::vector<int>> perm;
req<std::vector<legion_dim_t>> perm;
};

FF_VISITABLE_STRUCT_NONSTANDARD_CONSTRUCTION(TransposePerDeviceState,
Expand Down
11 changes: 2 additions & 9 deletions lib/kernels/src/cuda/ops/concat_kernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,8 @@ void calc_blk_size(size_t &num_blocks,
size_t &blk_size,
ArrayShape const &shape,
ff_dim_t axis) {
num_blocks = 1;
blk_size = 1;
for (int d = 0; d < shape.num_dims(); d++) {
if (d <= axis) {
blk_size *= shape[legion_dim_t(d)];
} else {
num_blocks *= shape[legion_dim_t(d)];
}
}
blk_size = shape.sub_shape(legion_dim_t{0}, axis).num_elements();
num_blocks = shape.sub_shape(axis, std::nullopt).num_elements();
}

void forward_kernel(cudaStream_t stream,
Expand Down
Loading