[KernelGen][MThreads] Add adaptive_max_pool3d_backward Moore Threads specialized operator #601
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright 2026 FlagOS Contributors | |
| # | |
| # 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. | |
| name: "ondemand test" | |
| on: | |
| issue_comment: | |
| types: [created] | |
| permissions: | |
| pull-requests: write | |
| checks: read | |
| contents: read | |
| jobs: | |
| preprocess: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| continue: ${{ steps.check.outputs.continue }} | |
| op: ${{ steps.parse-command.outputs.OP_ID}} | |
| runner: ${{ steps.parse-command.outputs.RUNNER }} | |
| pull: ${{ steps.parse-command.outputs.PR_NUMBER }} | |
| existing: ${{ steps.parse-command.outputs.EXISTING_OP }} | |
| steps: | |
| - id: checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - id: check | |
| uses: github.qkg1.topmand@3442f3fa1efe01bdb024b157083c337902d17372 # v2.0.3 | |
| with: | |
| command: "/test" | |
| allowed_contexts: pull_request | |
| allow_forks: "true" | |
| skip_reviews: "true" | |
| fork_review_bypass: "true" | |
| permissions: "write,admin" | |
| param_separator: " " | |
| - id: parse-command | |
| if: ${{ steps.check.outputs.continue == 'true' }} | |
| env: | |
| PULL_NUMBER: ${{ github.event.issue.number }} | |
| COMMENT_BODY: ${{ steps.check.outputs.comment_body }} | |
| run: | | |
| # Parse command arguments | |
| # Comment format: "/test <op>:<runner>", e.g. "/test constant_pad_nd:mthreads" | |
| params="${COMMENT_BODY#/test }" | |
| op="${params%%:*}" | |
| runner="${params##*:}" | |
| echo "OP_ID=${op}" >> $GITHUB_OUTPUT | |
| echo "RUNNER=${runner}" >> $GITHUB_OUTPUT | |
| echo "PR_NUMBER=${PULL_NUMBER}" >> $GITHUB_OUTPUT | |
| # Detect if operator exists before | |
| num=$(grep -rP "pytest\.mark\.${op}\b" tests | wc -l) | |
| if [ "$num" -eq "0" ]; then | |
| echo "EXISTING_OP=0" >> $GITHUB_OUTPUT | |
| else | |
| echo "EXISTING_OP=1" >> $GITHUB_OUTPUT | |
| fi | |
| test-operator: | |
| needs: preprocess | |
| if: needs.preprocess.outputs.continue == 'true' | |
| runs-on: ${{ needs.preprocess.outputs.runner }} | |
| steps: | |
| - id: resolve-vendor | |
| shell: bash | |
| env: | |
| RUNNER_LABEL: ${{ needs.preprocess.outputs.runner }} | |
| run: | | |
| case "${RUNNER_LABEL}" in | |
| h20) | |
| VENDOR="nvidia" | |
| BACKEND="nvidia-cuda133" | |
| ;; | |
| a100) | |
| VENDOR="nvidia" | |
| BACKEND="nvidia-cuda133" | |
| ;; | |
| h100) | |
| # Driver 535.183.06 supports up to CUDA 12.9, so use the 12.8 | |
| # profile (cuda133 requires a newer driver). Note: nvcc is not on | |
| # PATH in this node's container (cuda at /usr/local/cuda-12.9); | |
| # C++ extension builds may need PATH/CUDA_HOME set. | |
| # This node's container glibc is too old for FlagTree | |
| # (needs GLIBC 2.38), so use upstream Triton instead. | |
| VENDOR="nvidia" | |
| BACKEND="nvidia-cuda128" | |
| echo "COMPILER=triton" >> $GITHUB_ENV | |
| ;; | |
| ascend) | |
| VENDOR="ascend" | |
| # The ascend runner pool contains nodes with two different CANN | |
| # toolkits (8.5.x and 9.0.x). The job may land on either node, so | |
| # detect the CANN version on the node and pick the matching | |
| # backend: 8.5.x -> ascend-cann850, 9.0.x -> ascend-cann900 | |
| CANN_VERSION=$(ls -d /usr/local/Ascend/cann-* 2>/dev/null | sed 's|.*/cann-||' | sort -V | tail -1) | |
| case "${CANN_VERSION}" in | |
| 8.5*) | |
| BACKEND="ascend-cann850" | |
| ;; | |
| 9.0*) | |
| BACKEND="ascend-cann900" | |
| ;; | |
| *) | |
| echo "::error::Cannot detect CANN version on ascend runner (got '${CANN_VERSION}')" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| ;; | |
| cann850) | |
| VENDOR="ascend" | |
| BACKEND="ascend-cann850" | |
| ;; | |
| cann9) | |
| VENDOR="ascend" | |
| BACKEND="ascend-cann900" | |
| ;; | |
| mthreads) | |
| VENDOR="mthreads" | |
| BACKEND="mthreads-musa520" | |
| ;; | |
| metax) | |
| VENDOR="metax" | |
| # The metax runner pool contains nodes with two different MACA | |
| # drivers (3.7.x and 3.8.x). The job may land on either node, so | |
| # detect the driver on the node and pick the matching backend: | |
| # 3.7.x -> metax-maca3720, 3.8.x -> metax-maca3810 | |
| MACA_VERSION=$(mx-smi 2>/dev/null | awk -F': ' '/MACA Version/{split($2,a," "); print a[1]}') | |
| case "${MACA_VERSION}" in | |
| 3.7.*) | |
| BACKEND="metax-maca3720" | |
| ;; | |
| 3.8.*) | |
| BACKEND="metax-maca3810" | |
| ;; | |
| *) | |
| echo "::error::Cannot detect MACA version on metax runner (got '${MACA_VERSION}')" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| ;; | |
| maca372) | |
| VENDOR="metax" | |
| BACKEND="metax-maca3720" | |
| ;; | |
| maca381) | |
| VENDOR="metax" | |
| BACKEND="metax-maca3810" | |
| ;; | |
| enflame) | |
| VENDOR="enflame" | |
| BACKEND="enflame-tops1106" | |
| ;; | |
| cambricon) | |
| VENDOR="cambricon" | |
| BACKEND="cambricon-neuware472" | |
| ;; | |
| *) | |
| VENDOR="${RUNNER_LABEL}" | |
| BACKEND="${RUNNER_LABEL}" | |
| ;; | |
| esac | |
| echo "VENDOR=${VENDOR}" >> $GITHUB_ENV | |
| echo "BACKEND=${BACKEND}" >> $GITHUB_ENV | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| continue-on-error: true | |
| - uses: ./.github/actions/checkout-retry | |
| - name: setup-gh | |
| shell: bash | |
| env: | |
| GH_VERSION: "2.95.0" | |
| run: | | |
| GH_DIR="${HOME}/.local/bin" | |
| if command -v gh &>/dev/null; then | |
| echo "gh already available: $(gh --version | head -1)" | |
| elif [ -x "${GH_DIR}/gh" ]; then | |
| echo "gh found at ${GH_DIR}: $("${GH_DIR}/gh" --version | head -1)" | |
| echo "${GH_DIR}" >> $GITHUB_PATH | |
| else | |
| mkdir -p "${GH_DIR}" | |
| curl -fsSL "https://resource.flagos.net/repository/flagos-filestore/github/gh_${GH_VERSION}_linux_amd64.tar.gz" \ | |
| | tar -xz --strip-components=2 -C "${GH_DIR}" "gh_${GH_VERSION}_linux_amd64/bin/gh" | |
| echo "Installed gh ${GH_VERSION} to ${GH_DIR}" | |
| echo "${GH_DIR}" >> $GITHUB_PATH | |
| fi | |
| - id: checkout-pr | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| echo "checking out ${{ needs.preprocess.outputs.pull }}" | |
| gh pr checkout ${{ needs.preprocess.outputs.pull }} | |
| - uses: ./.github/actions/setup-flaggems | |
| with: | |
| backend: ${{ env.BACKEND }} | |
| gpu_check_script: tools/gpu_check_${{ env.VENDOR }}.sh | |
| - id: run-tests | |
| shell: bash | |
| env: | |
| EXISTING_OP: ${{ needs.preprocess.outputs.existing }} | |
| run: | | |
| source .venv/bin/activate | |
| tools/run_tests.py --ops ${{ needs.preprocess.outputs.op }} \ | |
| --gpus "${AVAILABLE_GPUS}" \ | |
| --dump-output \ | |
| --output-dir results_new | |
| if [ "$EXISTING_OP" == "0" ]; then | |
| tools/psum_text --format markdown \ | |
| --output report.md \ | |
| --single \ | |
| results_new | |
| mv results_new results | |
| else | |
| git checkout master | |
| tools/run_tests.py --ops ${{ needs.preprocess.outputs.op }} \ | |
| --gpus "${AVAILABLE_GPUS}" \ | |
| --dump-output \ | |
| --output-dir results_old | |
| # merge two data sets into one directory | |
| mkdir results | |
| mv results_old results/before | |
| mv results_new results/after | |
| tools/psum_text --format markdown \ | |
| --single \ | |
| --compare \ | |
| --output report.md \ | |
| results | |
| fi | |
| - id: upload-results | |
| # uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| uses: actions/upload-artifact@v7.0.1 | |
| continue-on-error: true | |
| with: | |
| name: ${{ needs.preprocess.outputs.op }}-${{ env.BACKEND }} | |
| path: results/ | |
| - id: attach-result-link | |
| if: steps.upload-results.outcome == 'success' | |
| run: | | |
| echo -e "\n---\n" >> report.md | |
| echo -e "📎 Download the full log [here](${{ steps.upload-results.outputs.artifact-url }})" >> report.md | |
| - id: comment | |
| uses: mshick/add-pr-comment@ec328af66588ab8f77cdeb2c264f14aba45bbf59 # 3.12.0 | |
| with: | |
| message-path: report.md | |
| message-id: ${{ needs.preprocess.outputs.op }}-${{ needs.preprocess.outputs.runner }} | |
| allow-repeats: True | |
| - id: failure-report | |
| if: failure() | |
| uses: mshick/add-pr-comment@ec328af66588ab8f77cdeb2c264f14aba45bbf59 # 3.12.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| message: | | |
| ## ❌ On-demand test failed | |
| **Operator:** `${{ needs.preprocess.outputs.op }}` | |
| **Runner:** `${{ needs.preprocess.outputs.runner }}` | |
| **Backend:** ${{ env.BACKEND }} | |
| The test failed to complete. Check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details. | |
| message-id: ${{ needs.preprocess.outputs.op }}-${{ needs.preprocess.outputs.runner }} |