Skip to content

Commit

Permalink
[sync] sync external until df321a7
Browse files Browse the repository at this point in the history
* [torch-frontend] add patch of torch functional communication ops (bytedance#103)
* [Compiler/Runtime/External Libs] Add flash attention external library & pass…
* lfs init for flash_attn.so
* [compiler] do not fusion single reshape in aggressive fusion (bytedance#104)
* [ci] remove ci after push (bytedance#106)
* fix ci for flash attn

https://code.byted.org/byteir/byteir/merge_requests/1054
  • Loading branch information
Vremold authored and zhekunz2 committed Jan 30, 2024
1 parent abdeab1 commit 2abdf10
Show file tree
Hide file tree
Showing 157 changed files with 5,235 additions and 3,186 deletions.
9 changes: 2 additions & 7 deletions .codebase/pipelines/runtime/build_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ while [[ $# -gt 0 ]]; do
US_DEV=true
shift
;;
--flash)
brt_BUILD_FLASH_ATTN=ON
shift
;;
*)
echo "Invalid option: $1"
exit 1
Expand Down Expand Up @@ -75,7 +71,6 @@ cmake -GNinja \
-DCMAKE_INSTALL_PREFIX="$BUILD_DIR/install" \
-Dbrt_USE_CUDA=${BRT_USE_CUDA} \
-Dbrt_USE_NCCL=${BRT_USE_NCCL} \
-Dbrt_BUILD_FLASH_ATTN=${brt_BUILD_FLASH_ATTN} \
-Dbrt_ENABLE_ASAN=${BRT_ENABLE_ASAN} \
-Dbrt_ENABLE_PYTHON_BINDINGS=${BRT_ENABLE_PYTHON_BINDINGS}

Expand All @@ -96,7 +91,7 @@ if [[ $BRT_TEST == "ON" ]]; then
pushd $BUILD_DIR
# note: now ci machine driver is 470.182.03, it's no need for compat(470.57.02) in docker
# LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_HOME/compat ./bin/brt_test_all
# ./bin/brt_test_all --gtest_filter=-\*SM80\*
./bin/brt_test_all
./bin/brt_test_all --gtest_filter=-\*SM80\*
# ./bin/brt_test_all
popd
fi
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
runtime/test/test_files/external_libs/libflash_attn.so filter=lfs diff=lfs merge=lfs -text
external_libs/libs/libflash_attn.so filter=lfs diff=lfs merge=lfs -text
12 changes: 0 additions & 12 deletions .github/workflows/compiler-and-runtime-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
name: Compiler And Runtime Build

on:
push:
branches:
- main
paths-ignore:
- ".github/workflows/onnx-frontend-ci.yaml"
- ".github/workflows/tf-frontend-ci.yaml"
- ".github/workflows/torch-frontend-ci.yaml"
- "frontends/**"
- "**/**.md"
- "talks/**"
- "compiler/python/version.txt"
- "runtime/VERSION_NUMBER"
pull_request:
branches:
- main
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/e2e_test.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
name: e2e Numerical test CI

on:
push:
branches:
- main
paths:
- ".github/workflows/e2e_test.yaml"
- "scripts/e2e/build_and_test_e2e.sh"
- "tests/**"
pull_request:
branches:
- main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format-check.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Format Check

on: [push, pull_request, workflow_dispatch]
on: [pull_request, workflow_dispatch]

jobs:
clang-format-check:
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/onnx-frontend-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
name: ONNX-Frontend CI

on:
push:
branches:
- main
paths:
- ".github/workflows/onnx-frontend-ci.yaml"
- "frontends/onnx-frontend/**"
- "!**/**.md"
- "!talks/**"
pull_request:
branches:
- main
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/tf-frontend-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
name: TfFrontend CI

on:
push:
branches:
- main
paths:
- ".github/workflows/tf-frontend-ci.yaml"
- "frontends/tf-frontend/**"
- "!**/**.md"
pull_request:
branches:
- main
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/torch-frontend-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
name: TorchFrontend CI

on:
push:
branches:
- main
paths:
- ".github/workflows/torch-frontend-ci.yaml"
- "frontends/torch-frontend/**"
- "!**/**.md"
- "!frontends/torch-frontend/torch-frontend/python/version.txt"
pull_request:
branches:
- main
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//===- HloToByreCustom.h ---------------------------------------*--- C++-*-===//
//
// Copyright 2022 ByteDance Ltd. and/or its affiliates. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//===----------------------------------------------------------------------===//

#ifndef BYTEIR_CONVERSION_HLOTOBYRETENSOR_HLOTOBYRECUSTOM_H
#define BYTEIR_CONVERSION_HLOTOBYRETENSOR_HLOTOBYRECUSTOM_H

#include "mhlo/IR/hlo_ops.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/StringRef.h"
#include <memory>
#include <string>

namespace mlir {
// forward decl
namespace func {
class FuncOp;
} // namespace func
class Operation;

struct ByreCustomConfig {
std::function<llvm::StringRef(llvm::StringRef)> getCustomLibPath;
std::function<llvm::StringRef(llvm::StringRef)> getApiName;
std::function<ArrayAttr(mhlo::CustomCallOp)> getExtraArgs;
};

ByreCustomConfig getCudaByreCustomConfig();

// use ByreCustomConvertRuleBase to decide how to convert to byre custom op
std::unique_ptr<OperationPass<func::FuncOp>>
createConvertHloToByreCustomPass(const ByreCustomConfig &);

} // namespace mlir

#endif // BYTEIR_CONVERSION_HLOTOBYRETENSOR_HLOTOBYRECUSTOM_H
47 changes: 47 additions & 0 deletions compiler/include/byteir/Dialect/Byre/ByreOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,51 @@ def Byre_AliasOp
let hasVerifier = 1;
}

def Byre_CustomOp : Byre_Op<"custom",
[HasParent<"func::FuncOp">,
DeclareOpInterfaceMethods<ByreInterface, ["getCalleeName"]>]> {
let summary = "compute custom operation passed by library path and api name. ";
let description = [{
Example:
```mlir
%2 = byre.custom(%0, %1) { lib_path = "xxx.so", api_name = "add", extra_args = [0 : i64, 1 : i64, 2.0 : f32] } : (f32, f32) -> f32
```
During execution, "xxx.so" will be loaded, and "add" function will be called.
}];

let arguments = (ins
StrAttr:$lib_path,
StrAttr:$api_name,
Variadic<AnyType>:$operands,
ArrayAttr:$extra_args,
OptionalAttr<ArrayAttr>:$memory_effects
);

let results = (outs
Variadic<AnyType>:$results
);

let builders = [
OpBuilder<(ins "StringRef":$lib_path,
"StringRef":$api_name,
"ValueRange":$inputs,
"ValueRange":$outputs,
"ArrayAttr":$extra_args)>
];

let extraClassDeclaration = [{
FunctionType getType();

/// Get the argument operands to the called function.
operand_range getArgOperands() {
return {arg_operand_begin(), arg_operand_end()};
}

operand_iterator arg_operand_begin() { return operand_begin(); }
operand_iterator arg_operand_end() { return operand_end(); }
}];

let hasVerifier = 1;
}

#endif // BYTEIR_DIALECT_BYRE_BYRE_OPS
1 change: 1 addition & 0 deletions compiler/lib/Conversion/HloToByreTensor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_byteir_conversion_library(ByteIRHloToByreTensor
HloToByreCustom.cpp
HloToByreTensor.cpp

ADDITIONAL_HEADER_DIRS
Expand Down
Loading

0 comments on commit 2abdf10

Please sign in to comment.