Skip to content

Commit

Permalink
enable oneflow_iree(python package) and corresponding test works in ci (
Browse files Browse the repository at this point in the history
#8431)

* update test.yml

* add pytest for oneflow_iree examples

* add oneflow frontend test
  • Loading branch information
howin98 authored Jun 22, 2022
1 parent 6f9cc3f commit ca3cbdd
Show file tree
Hide file tree
Showing 33 changed files with 118 additions and 377 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Checkout Oneflow-Inc/oneflow
if: ${{ github.event.inputs.oneflow-ref == '' }}
uses: actions/checkout@v2
- uses: Oneflow-Inc/get-oneflow@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow@support-iree-ci
name: Build manylinux
id: build-cuda
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: Oneflow-Inc/get-oneflow/update-benchmark-history@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow/update-benchmark-history@support-iree-ci
name: Update benchmark history
timeout-minutes: 10
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: Oneflow-Inc/get-oneflow/cache-complete/matrix/build@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow/cache-complete/matrix/build@support-iree-ci
name: find cache
id: find-cache
timeout-minutes: 5
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
python3 -m pip install -U pip setuptools wheel --user
python3 -m pip install oss2 --user
- uses: actions/checkout@v2
- uses: Oneflow-Inc/get-oneflow@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow@support-iree-ci
name: Build ${{ matrix.entry }}
if: ${{ matrix.entry !='cpu' }}
with:
Expand All @@ -98,7 +98,7 @@ jobs:
3.8
3.9
3.10
- uses: Oneflow-Inc/get-oneflow@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow@support-iree-ci
name: Build ${{ matrix.entry }}
if: ${{ matrix.entry =='cpu' }}
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ jobs:
repository: Oneflow-Inc/conda-env
ref: 30a7f00eb48ee9009d85a848e720823e5054c66b
path: conda-env
- uses: Oneflow-Inc/get-oneflow@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow@support-iree-ci
name: Build with gcc7
if: ${{ matrix.build-type == 'gcc7'}}
with:
Expand All @@ -254,7 +254,7 @@ jobs:
oneflow-build-env: conda
conda-env-file: conda-env/dev/gcc7/environment-v2.yml
conda-env-name: oneflow-dev-gcc7-v2
- uses: Oneflow-Inc/get-oneflow@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow@support-iree-ci
name: Build with clang10
if: ${{ matrix.build-type == 'clang10'}}
with:
Expand Down
61 changes: 43 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ env:
FLOW_VISION_COMMIT: ca8ebc663b58667cf8cd1b6ef0c861522780b7bb
LIBAI_SRC: libai
LIBAI_COMMIT: 7d31d9781e5f2d559dc0820f599e0bed798488ca
ONEFLOW_IREE_SRC: oneflow_iree
ONEFLOW_IREE_COMMIT: 4322cbad2545877b1664aa8e0f17a17f6b5f687c
TEST_WITH_TORCH_IMG_TAG: registry.cn-beijing.aliyuncs.com/oneflow/test-with-pytorch-1.10.0-cuda11.3-cudnn8-runtime:afaf913e02a4ba02db92260daee22f99121cef62
MLIR_DOCKER_ARGS: "-e ONEFLOW_MLIR_ENABLE_ROUND_TRIP=1 -e ONEFLOW_MLIR_PREFER_NHWC=0 -e ONEFLOW_MLIR_ENABLE_INFERENCE_OPTIMIZATION=1"

Expand All @@ -25,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false && github.base_ref == 'master' && contains(github.event.pull_request.requested_reviewers.*.login, 'oneflow-ci-bot')
steps:
- uses: Oneflow-Inc/get-oneflow/priority-pr@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow/priority-pr@support-iree-ci
name: Check priority PR closed
id: save-cache
timeout-minutes: 5
Expand Down Expand Up @@ -159,7 +161,7 @@ jobs:
fi
echo "is_secrets_accessible=1" >> $GITHUB_ENV
- name: Wait for GPU slot
uses: Oneflow-Inc/get-oneflow/wait-for-gpu@support-cuda-1106
uses: Oneflow-Inc/get-oneflow/wait-for-gpu@support-iree-ci
if: env.is_secrets_accessible == '1'
timeout-minutes: 90
continue-on-error: true
Expand All @@ -183,7 +185,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: Oneflow-Inc/get-oneflow/cache-complete/matrix/build@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow/cache-complete/matrix/build@support-iree-ci
name: find cache
id: find-cache
timeout-minutes: 5
Expand Down Expand Up @@ -230,7 +232,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: Oneflow-Inc/get-oneflow/cache-complete@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow/cache-complete@support-iree-ci
name: Save cache if successful
id: save-cache
timeout-minutes: 5
Expand Down Expand Up @@ -266,7 +268,7 @@ jobs:
python-versions: |
3.6
3.7
- uses: Oneflow-Inc/get-oneflow@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow@support-iree-ci
name: Build manylinux ${{ matrix.entry }}
id: build-cuda
if: ${{ matrix.entry =='cu102' && !matrix.cache-hit }}
Expand All @@ -286,7 +288,7 @@ jobs:
clean-ccache: ${{ contains(github.event.pull_request.labels.*.name, 'need-clean-ccache') }}
python-versions: |
3.7
- uses: Oneflow-Inc/get-oneflow@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow@support-iree-ci
name: Build ${{ matrix.entry }}
if: ${{ matrix.entry == 'llvm13' && !matrix.cache-hit }}
with:
Expand Down Expand Up @@ -325,7 +327,7 @@ jobs:
})
- name: Upload packed liboneflow
if: ${{ !fromJson(matrix.cache-hit) && matrix.entry != 'llvm13' && matrix.entry != 'cu102_xla' }}
uses: Oneflow-Inc/get-oneflow/digest/upload@support-cuda-1106
uses: Oneflow-Inc/get-oneflow/digest/upload@support-iree-ci
timeout-minutes: 10
with:
digest: ${{ steps.save-cache.outputs.build-digest }}
Expand All @@ -336,7 +338,7 @@ jobs:
dst-dir: cpack
- name: Upload whl
if: ${{ !fromJson(matrix.cache-hit) && matrix.entry != 'llvm13' && matrix.entry != 'cu102_xla' }}
uses: Oneflow-Inc/get-oneflow/digest/upload@support-cuda-1106
uses: Oneflow-Inc/get-oneflow/digest/upload@support-iree-ci
timeout-minutes: 10
with:
digest: ${{ steps.save-cache.outputs.build-digest }}
Expand All @@ -361,7 +363,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: Oneflow-Inc/get-oneflow/cache-complete/matrix/test@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow/cache-complete/matrix/test@support-iree-ci
name: find cache
id: find-cache
timeout-minutes: 5
Expand Down Expand Up @@ -392,7 +394,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: Oneflow-Inc/get-oneflow/cache-complete/matrix/test@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow/cache-complete/matrix/test@support-iree-ci
name: find cache
id: find-cache
timeout-minutes: 5
Expand Down Expand Up @@ -456,12 +458,20 @@ jobs:
# please use a commit here
ref: ${{ env.LIBAI_COMMIT}}
path: ${{ env.LIBAI_SRC}}
- name: Checkout Oneflow-Inc/oneflow_iree
if: ${{ !fromJson(matrix.cache-hit) && contains(matrix.runs-on, 'self-hosted') }}
uses: actions/checkout@v2
with:
repository: Oneflow-Inc/oneflow_iree
# please use a commit here
ref: ${{ env.ONEFLOW_IREE_COMMIT}}
path: ${{ env.ONEFLOW_IREE_SRC}}
- name: Remove container
timeout-minutes: 45
if: ${{ contains(matrix.runs-on, 'self-hosted') }}
run: |
docker rm -f ${{ env.TEST_CONTAINER_NAME }} || true
- uses: Oneflow-Inc/get-oneflow/cache-complete@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow/cache-complete@support-iree-ci
name: Save cache if successful
id: save-cache
timeout-minutes: 5
Expand All @@ -477,7 +487,7 @@ jobs:
exit 1
- name: Download wheel and packed liboneflow
if: ${{ !fromJson(matrix.cache-hit) && contains(matrix.runs-on, 'self-hosted') }}
uses: Oneflow-Inc/get-oneflow/digest/download@support-cuda-1106
uses: Oneflow-Inc/get-oneflow/digest/download@support-iree-ci
id: download-digest
timeout-minutes: 10
with:
Expand All @@ -487,7 +497,7 @@ jobs:
ssh-tank-path: ${{ env.SSH_TANK_PATH }}
- name: Get primary node
if: ${{ !fromJson(matrix.cache-hit) && contains(matrix.runs-on, 'self-hosted') }}
uses: Oneflow-Inc/get-oneflow/master-address@support-cuda-1106
uses: Oneflow-Inc/get-oneflow/master-address@support-iree-ci
id: get-primary-node
with:
rank: ${{ matrix.rank }}
Expand Down Expand Up @@ -560,6 +570,7 @@ jobs:
docker exec ${TEST_CONTAINER_NAME} python3 -m pip install -e ${{ env.FLOW_VISION_SRC}}
docker exec ${TEST_CONTAINER_NAME} python3 -m pip install pybind11 --user
docker exec ${TEST_CONTAINER_NAME} python3 -m pip install -e ${{ env.LIBAI_SRC}}
docker exec ${TEST_CONTAINER_NAME} python3 -m pip install -e ${{ env.ONEFLOW_IREE_SRC}}
- name: Module API test (distributed)
timeout-minutes: 90
if: ${{ !fromJson(matrix.cache-hit) && matrix.test-type == 'module' && matrix.device == 'cuda' && fromJson(matrix.is-distributed) }}
Expand Down Expand Up @@ -649,12 +660,20 @@ jobs:
# please use a commit here
ref: ${{ env.LIBAI_COMMIT}}
path: ${{ env.LIBAI_SRC}}
- name: Checkout Oneflow-Inc/oneflow_iree
if: ${{ !fromJson(matrix.cache-hit) && contains(matrix.runs-on, 'self-hosted') }}
uses: actions/checkout@v2
with:
repository: Oneflow-Inc/oneflow_iree
# please use a commit here
ref: ${{ env.ONEFLOW_IREE_COMMIT}}
path: ${{ env.ONEFLOW_IREE_SRC}}
- name: Remove container
timeout-minutes: 45
if: ${{ contains(matrix.runs-on, 'self-hosted') }}
run: |
docker rm -f ${{ env.TEST_CONTAINER_NAME }} || true
- uses: Oneflow-Inc/get-oneflow/cache-complete@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow/cache-complete@support-iree-ci
name: Save cache if successful
id: save-cache
timeout-minutes: 5
Expand All @@ -670,7 +689,7 @@ jobs:
exit 1
- name: Download wheel and packed liboneflow
if: ${{ !fromJson(matrix.cache-hit) && contains(matrix.runs-on, 'self-hosted') }}
uses: Oneflow-Inc/get-oneflow/digest/download@support-cuda-1106
uses: Oneflow-Inc/get-oneflow/digest/download@support-iree-ci
id: download-digest
timeout-minutes: 10
with:
Expand Down Expand Up @@ -782,6 +801,7 @@ jobs:
docker exec ${TEST_CONTAINER_NAME} python3 -m pip install -e ${{ env.FLOW_VISION_SRC}}
docker exec ${TEST_CONTAINER_NAME} python3 -m pip install pybind11 --user
docker exec ${TEST_CONTAINER_NAME} python3 -m pip install -e ${{ env.LIBAI_SRC}}
docker exec ${TEST_CONTAINER_NAME} python3 -m pip install -e ${{ env.ONEFLOW_IREE_SRC}}
- name: Run OneFlow doctor
if: ${{ !fromJson(matrix.cache-hit) && contains(matrix.runs-on, 'self-hosted') }}
run: |
Expand Down Expand Up @@ -866,7 +886,7 @@ jobs:
body: "<details>\n <summary>Speed stats:</summary>\n\n ``` \n${{ steps.speed.outputs.stats }}\n ``` \n\n</details>".replace(/\\n/g, '\n')
})
- name: Module API test
timeout-minutes: 45
timeout-minutes: 50
if: ${{ !fromJson(matrix.cache-hit) && matrix.test-type == 'module' && !fromJson(matrix.is-distributed) }}
run: |
docker exec -e ONEFLOW_TEST_DIR=$PWD/python/oneflow/test/modules ${{ env.TEST_CONTAINER_NAME }} bash ci/test/generic_test_multi_client.sh
Expand All @@ -884,6 +904,11 @@ jobs:
docker exec -e ONEFLOW_TEST_DEVICE_NUM=4 -w $PWD/${{ env.LIBAI_SRC }} ${{ env.TEST_CONTAINER_NAME }} python3 -m oneflow.distributed.launch --nproc_per_node 4 -m unittest -f tests/models/test_gpt.py
docker exec -e ONEFLOW_TEST_DEVICE_NUM=4 -w $PWD/${{ env.LIBAI_SRC }} ${{ env.TEST_CONTAINER_NAME }} python3 -m oneflow.distributed.launch --nproc_per_node 4 -m unittest -f tests/models/test_t5.py
docker exec -e ONEFLOW_TEST_DEVICE_NUM=4 -w $PWD/${{ env.LIBAI_SRC }} ${{ env.TEST_CONTAINER_NAME }} python3 -m oneflow.distributed.launch --nproc_per_node 4 -m unittest -f tests/models/test_vit.py
- name: oneflow_iree test
timeout-minutes: 45
if: ${{ !fromJson(matrix.cache-hit) && matrix.test-type == 'misc' }}
run: |
docker exec -w $PWD/${{ env.ONEFLOW_IREE_SRC }} ${{ env.TEST_CONTAINER_NAME }} python3 -m pytest examples
- name: Expensive tests (models, cases require exclusive access to GPU)
timeout-minutes: 45
if: ${{ !fromJson(matrix.cache-hit) && (matrix.test-type == 'speed-test' || (matrix.test-type == 'misc' && matrix.device == 'cpu')) && !fromJson(matrix.is-distributed) }}
Expand All @@ -909,7 +934,7 @@ jobs:
- name: Benchmark Test
timeout-minutes: 100
if: ${{ !fromJson(matrix.cache-hit) && matrix.test-type == 'benchmark' && matrix.device == 'cuda' }}
uses: Oneflow-Inc/get-oneflow/pytest-benchmark@support-cuda-1106
uses: Oneflow-Inc/get-oneflow/pytest-benchmark@support-iree-ci
with:
collect-path: ${{ env.FLOW_VISION_SRC }}/benchmark
container-name: ${{ env.TEST_CONTAINER_NAME }}
Expand Down Expand Up @@ -962,7 +987,7 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0
- uses: Oneflow-Inc/get-oneflow/cache-complete@support-cuda-1106
- uses: Oneflow-Inc/get-oneflow/cache-complete@support-iree-ci
name: Save cache if successful
id: save-cache
timeout-minutes: 5
Expand Down
7 changes: 5 additions & 2 deletions cmake/oneflow.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,21 @@ if("${LLVM_MONO_REPO_URL}" STREQUAL
"https://github.com/llvm/llvm-project/archive/7eaa84eac3ba935d13f4267d3d533a6c3e1283ed.zip"
OR "${LLVM_MONO_REPO_URL}" STREQUAL
"https://github.com/llvm/llvm-project/archive/35e60f5de180aea55ed478298f4b40f04dcc57d1.zip"
OR "${LLVM_MONO_REPO_URL}" STREQUAL
"https://github.com/llvm/llvm-project/archive/6a9bbd9f20dcd700e28738788bb63a160c6c088c.zip"
OR "${LLVM_MONO_REPO_MD5}" STREQUAL "f2f17229cf21049663b8ef4f2b6b8062"
OR "${LLVM_MONO_REPO_MD5}" STREQUAL "6b7c6506d5922de9632c8ff012b2f945"
OR "${LLVM_MONO_REPO_MD5}" STREQUAL "e0ea669a9f0872d35bffda5ec6c5ac6f"
OR "${LLVM_MONO_REPO_MD5}" STREQUAL "241a333828bba1efa35aff4c4fc2ce87"
OR "${LLVM_MONO_REPO_MD5}" STREQUAL "075fbfdf06cb3f02373ea44971af7b03")
unset(LLVM_MONO_REPO_URL CACHE)
unset(LLVM_MONO_REPO_MD5 CACHE)
endif()
set(LLVM_MONO_REPO_URL
"https://github.com/llvm/llvm-project/archive/6a9bbd9f20dcd700e28738788bb63a160c6c088c.zip"
"https://github.com/llvm/llvm-project/archive/32805e60c9de1f82887cd2af30d247dcabd2e1d3.zip"
CACHE STRING "")
use_mirror(VARIABLE LLVM_MONO_REPO_URL URL ${LLVM_MONO_REPO_URL})
set(LLVM_MONO_REPO_MD5 "241a333828bba1efa35aff4c4fc2ce87" CACHE STRING "")
set(LLVM_MONO_REPO_MD5 "e412dc61159b5e929b0c94e44b11feb2" CACHE STRING "")
set(ONEFLOW_BUILD_ROOT_DIR "${PROJECT_BINARY_DIR}")
add_subdirectory(${PROJECT_SOURCE_DIR}/oneflow/ir)
if(WITH_MLIR)
Expand Down
31 changes: 0 additions & 31 deletions oneflow/ir/include/OneFlow/Conversion/SCFToGPU.h

This file was deleted.

1 change: 1 addition & 0 deletions oneflow/ir/include/OneFlow/OneFlowDialect.td
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def OneFlow_Dialect : Dialect {
"func::FuncDialect"
];
let hasConstantMaterializer = 1;
let useDefaultTypePrinterParser = 1;
}

#endif // ONEFLOW_DIALECT
6 changes: 0 additions & 6 deletions oneflow/ir/include/OneFlow/OneFlowOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,6 @@ def LowerOneFlowToTosaPass : Pass<"lower-oneflow-to-tosa", "ModuleOp"> {
];
}

def MapSCFToGPUPass : Pass<"gpu-greedy-parallel-loop-mapping", "ModuleOp"> {
let summary = "Greedily maps all parallel loops to gpu hardware ids";
let constructor = "mlir::oneflow::createMapSCFToGPUPass()";
let dependentDialects = ["scf::SCFDialect"];
}

def BufferHostRegisterPass : Pass<"buffer-host-register", "func::FuncOp"> {
let summary = "";
let constructor = "mlir::oneflow::createBufferHostRegisterPass()";
Expand Down
2 changes: 1 addition & 1 deletion oneflow/ir/include/OneFlow/OneFlowPatterns.td
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
include "mlir/IR/PatternBase.td"
include "OneFlow/OneFlowOps.td"
include "mlir/Dialect/MemRef/IR/MemRefOps.td"
include "mlir/Dialect/GPU/GPUOps.td"
include "mlir/Dialect/GPU/IR/GPUOps.td"

def IsNotNestedInJit: Constraint<CPred<"($0.getDefiningOp()->getParentOfType<::mlir::oneflow::Job>())">, "">;
def IsScalarTensor: Constraint<CPred<"::mlir::oneflow::IsScalarTensor($0)">, "">;
Expand Down
3 changes: 1 addition & 2 deletions oneflow/ir/include/OneFlow/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ limitations under the License.
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/Tosa/IR/TosaOps.h"
#include "mlir/Dialect/SCF/SCF.h"
#include "mlir/Dialect/GPU/GPUDialect.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "OneFlow/Conversion/OneFlowToTosa.h"
#include "OneFlow/Conversion/SCFToGPU.h"
#include "OneFlow/Transform/BufferHostRegister.h"
#include "OneFlow/Transform/ConvertInferenceOp.h"
#include "OneFlow/Transform/OutlineAndFuse.h"
Expand Down
1 change: 1 addition & 0 deletions oneflow/ir/install-llvm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ if(NOT llvm_monorepo_POPULATED)
execute_process(
COMMAND
"${CMAKE_COMMAND}" ${llvm_monorepo_SOURCE_DIR}/llvm
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} # this is required in newer version of LLVM
-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}
-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
-DCMAKE_CUDA_COMPILER_LAUNCHER=${CMAKE_CUDA_COMPILER_LAUNCHER}
Expand Down
Loading

0 comments on commit ca3cbdd

Please sign in to comment.