Refactored github action
diff --git a/.github/workflows/PR_CI.yml b/.github/workflows/PR_CI.yml
deleted file mode 100644
index 7dccfbecdc57..000000000000
--- a/.github/workflows/PR_CI.yml
+++ /dev/null
@@ -1,90 +0,0 @@
-name: Pull Request CI and Build
-
-on: pull_request
-
-jobs:
-  cancel_previous_workflow:
-    runs-on: ubuntu-latest
-    if: github.event.pull_request.draft == false && (github.base_ref == 'main' || github.base_ref == 'develop') && github.event.pull_request.base.repo.full_name == 'hpcaitech/ColossalAI'
-    steps:
-      - name: Cancel Previous Runs
-        uses: styfle/cancel-workflow-action@0.9.1
-        with:
-          access_token: ${{ github.token }}
-
-  assign_reviewer:
-    name: Assign Reviewer for PR
-    runs-on: ubuntu-latest
-    if: github.event.pull_request.draft == false && (github.base_ref == 'main' || github.base_ref == 'develop') && github.event.pull_request.base.repo.full_name == 'hpcaitech/ColossalAI' && toJson(github.event.pull_request.requested_reviewers) == '[]'
-    steps:
-      - uses: kentaro-m/auto-assign-action@v1.2.1
-        with:
-          configuration-path: '.github/reviewer_list.yml'
-
-  build:
-    name: Build and Test Colossal-AI
-    if: ${{ always() }} && github.event.pull_request.draft == false && (github.base_ref == 'main'  || github.base_ref == 'develop') && github.event.pull_request.base.repo.full_name == 'hpcaitech/ColossalAI'
-    needs: [cancel_previous_workflow, assign_reviewer]
-    runs-on: [self-hosted, gpu]
-    container:
-      image: nvcr.io/nvidia/pytorch:21.07-py3
-      options: --gpus all --rm --ipc=host -v /data/scratch/cifar-10:/data/scratch/cifar-10
-    timeout-minutes: 20
-    steps:
-      - name: Setup Environment
-        run: |
-          export https_proxy=http://172.17.0.1:7890 http_proxy=http://172.17.0.1:7890 all_proxy=socks5://172.17.0.1:7890
-      - name: Install dependencies
-        run: |
-          pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
-          pip install -U pip setuptools wheel --user
-          pip install pytest tensorboard deepspeed apex
-      - uses: actions/checkout@v2
-      - name: Install Colossal-AI      
-        run: |
-          pip install -r requirements/requirements.txt
-          pip install -v --no-cache-dir .
-      - name: Unit Testing
-        run: |
-          pytest tests
-        env:
-          DATA: /data/scratch/cifar-10
-
-  format_check:
-    name: Format Check
-    if: github.event.pull_request.draft == false && github.base_ref == 'main' && github.head_ref == 'develop' && github.event.pull_request.base.repo.full_name == 'hpcaitech/ColossalAI'
-    needs: [build]
-    runs-on: ubuntu-latest
-    steps:
-      - name: Checkout repo
-        uses: actions/checkout@v2
-
-      - name: autoyapf
-        id: autoyapf
-        uses: mritunjaysharma394/autoyapf@v2
-        with:
-          args: --style google --recursive --in-place .
-
-      - name: Check for modified files
-        id: git-check
-        run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
-      
-      - name: Push changes
-        if: steps.git-check.outputs.modified == 'true'
-        run: |
-          git config --global user.name 'github-actions' 
-          git config --global user.email 'github-actions@github.com' 
-          git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
-          git commit -am "Automated autoyapf fixes"
-      
-      - name: Create Pull Request
-        # if: steps.format.outputs.has-changes == 'true'
-        uses: peter-evans/create-pull-request@v3
-        with:
-          title: '[Bot] Automated PR to fix formatting errors'
-          body: |
-            Automated PR to fix formatting errors
-          committer: GitHub <noreply@github.com>
-          author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
-          assignees: ${{ github.actor }}
-          reviewers: frankleeeee
diff --git a/.github/workflows/assign_reviewer.yml b/.github/workflows/assign_reviewer.yml
new file mode 100644
index 000000000000..871768938639
--- /dev/null
+++ b/.github/workflows/assign_reviewer.yml
@@ -0,0 +1,19 @@
+name: Assign Reviewers for Team
+
+on: 
+  pull_request:
+    types: [opened]
+
+jobs:
+  assign_reviewer:
+    name: Assign Reviewer for PR
+    runs-on: ubuntu-latest
+    if: |
+      github.event.pull_request.draft == false && 
+      (github.base_ref == 'main' || github.base_ref == 'develop') 
+      && github.event.pull_request.base.repo.full_name == 'hpcaitech/ColossalAI' 
+      && toJson(github.event.pull_request.requested_reviewers) == '[]'
+    steps:
+      - uses: kentaro-m/auto-assign-action@v1.2.1
+        with:
+          configuration-path: '.github/reviewer_list.yml'
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 000000000000..08b3fc09abc2
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,38 @@
+name: Build
+
+on: 
+  pull_request:
+    types: [synchronize, labeled]
+
+jobs:
+  build:
+    name: Build and Test Colossal-AI
+    if: |
+        github.event.pull_request.draft == false && 
+        (github.base_ref == 'main' || github.base_ref == 'develop') && 
+        github.event.pull_request.base.repo.full_name == 'hpcaitech/ColossalAI' &&
+        contains( github.event.pull_request.labels.*.name, 'Run Build and Test')
+    runs-on: [self-hosted, gpu]
+    container:
+      image: nvcr.io/nvidia/pytorch:21.07-py3
+      options: --gpus all --rm --ipc=host -v /data/scratch/cifar-10:/data/scratch/cifar-10
+    timeout-minutes: 20
+    steps:
+      - name: Setup Environment
+        run: |
+          export https_proxy=http://172.17.0.1:7890 http_proxy=http://172.17.0.1:7890 all_proxy=socks5://172.17.0.1:7890
+      - name: Install dependencies
+        run: |
+          pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
+          pip install -U pip setuptools wheel --user
+          pip install pytest tensorboard deepspeed apex
+      - uses: actions/checkout@v2
+      - name: Install Colossal-AI      
+        run: |
+          pip install -r requirements/requirements.txt
+          pip install -v --no-cache-dir .
+      - name: Unit Testing
+        run: |
+          pytest tests
+        env:
+          DATA: /data/scratch/cifar-10
diff --git a/.github/workflows/close_inactive.yml b/.github/workflows/close_inactive.yml
index 988d9e3bc5ba..e7dec4430930 100644
--- a/.github/workflows/close_inactive.yml
+++ b/.github/workflows/close_inactive.yml
@@ -1,4 +1,5 @@
 name: Close inactive issues
+
 on:
   schedule:
     - cron: "0 0 * * *"
diff --git a/.github/workflows/compatibility_test.yml b/.github/workflows/compatibility_test.yml
new file mode 100644
index 000000000000..6b6a4304b5c5
--- /dev/null
+++ b/.github/workflows/compatibility_test.yml
@@ -0,0 +1,46 @@
+name: Compatibility Test
+
+on: workflow_dispatch
+
+jobs:
+  build:
+    name: Test for PyTorch compatibility
+    if: (github.base_ref == 'main'  || github.base_ref == 'develop') && github.repository == 'hpcaitech/ColossalAI'
+    runs-on: [self-hosted, aws]
+    strategy:
+      fail-fast: false
+      matrix:
+        # 20.07: PyTorch 1.6.0a0+9907a3e + Python 3.6
+        # 20.10: PyTorch 1.7.0a0+7036e91 + Python 3.8
+        # 20.12: PyTorch 1.8.0a0+1606899 + Python 3.8
+        # 21.06: PyTorch 1.9.0a0+c3d40fd + Python 3.8
+        container: ["nvcr.io/nvidia/pytorch:20.07-py3", 
+                    "nvcr.io/nvidia/pytorch:20.10-py3", 
+                    "nvcr.io/nvidia/pytorch:20.12-py3", 
+                    "nvcr.io/nvidia/pytorch:21.06-py3"]
+    container:
+      image: ${{ matrix.container }}
+      options: --gpus all --rm --ipc=host -v /data/scratch/cifar-10:/data/scratch/cifar-10
+    timeout-minutes: 120
+    steps:
+      - name: Setup Environment
+        run: |
+          export https_proxy=http://172.17.0.1:7890 http_proxy=http://172.17.0.1:7890 all_proxy=socks5://172.17.0.1:7890
+      - name: Install dependencies
+        run: |
+          pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
+          pip install -U pip setuptools wheel --user
+          pip install pytest tensorboard deepspeed apex
+      - uses: actions/checkout@v2
+      - name: Install Colossal-AI      
+        run: |
+          pip install -r requirements/requirements.txt
+          pip install -v --no-cache-dir .
+      - name: Unit Testing
+        run: |
+          pytest tests
+        env:
+          DATA: /data/scratch/cifar-10
+      
+
+
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 000000000000..c274bfa73924
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,31 @@
+name: Publish to PyPI
+
+on: workflow_dispatch
+
+jobs:
+  build-n-publish:
+    if: (github.base_ref == 'main' || github.base_ref == 'develop') && github.repository == 'hpcaitech/ColossalAI' && contains('["FrankLeeeee", "ver217", "feifeibear", "kurisusnowdeng"]', github.actor)
+    name: Build and publish Python 🐍 distributions 📦 to PyPI or Test PyPI
+    runs-on: ubuntu-latest
+    timeout-minutes: 20
+    steps:
+    - uses: actions/checkout@v2
+    - uses: actions/setup-python@v2
+      with:
+        python-version: '3.7.4'
+    # publish to PyPI if executed on the main branch
+    # publish to Test PyPI if executed on the develop branch
+    - name: Publish package to Test PyPI
+      if: github.base_ref == 'develop'
+      uses: pypa/gh-action-pypi-publish@release/v1
+      with:
+        user: __token__
+        password: ${{ secrets.TEST_PYPI_API_TOKEN }}
+        verbose: true
+    - name: Publish package to PyPI
+      if: github.base_ref == 'main'
+      uses: pypa/gh-action-pypi-publish@release/v1
+      with:
+        user: __token__
+        password: ${{ secrets.PYPI_API_TOKEN }}
+        verbose: true
diff --git a/.github/workflows/submodule.yml b/.github/workflows/submodule.yml
index d19892c39383..2447284e8eec 100644
--- a/.github/workflows/submodule.yml
+++ b/.github/workflows/submodule.yml
@@ -1,4 +1,5 @@
 name: Synchronize Submodule
+
 on: 
   workflow_dispatch:
   schedule:
@@ -12,6 +13,7 @@ jobs:
       - name: Checkout
         uses: actions/checkout@v2
         with:
+          ref: 'develop'
           submodules: true
 
       - name: echo

I have refactored the github action for better DevOps experience
1. assign reviewers when the PR is opened (this can only apply to users who have write permission to this repository and does not work for PR from a forked repository due to security reasons)
2. build and unit testing are only run when the label 'Run Build and Test' is added. The CI will be triggered on synchronization after the label is added as well.
3. release package to Test PyPI (for develop branch) and PyPI (for main branch) automatically. This CI is triggered on manual workflow dispatch.
4. compatibility checking with different torch versions. This CI is triggered on manual workflow dispatch.
5. removed formatting CI as pre-commit is the standard way for auto-formatting