benchmark_test #116
This file contains 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
name: benchmark_test | |
on: | |
workflow_dispatch: | |
inputs: | |
repo_org: | |
required: false | |
description: 'Tested repository organization name. Default is InternLM' | |
type: string | |
default: 'InternLM/lmdeploy' | |
repo_ref: | |
required: false | |
description: 'Set branch or tag or commit id. Default is "main"' | |
type: string | |
default: 'main' | |
benchmark_type: | |
required: true | |
description: 'Set benchmark type. Default is "["generation", "throughtput", "api_server"]"' | |
type: string | |
default: "['apiserver', 'generation', 'throughput']" | |
offline_mode: | |
required: true | |
description: 'Whether start a offline mode, if true, you should prepare code and whl package by yourself' | |
type: boolean | |
default: false | |
dependency_pkgs: | |
required: true | |
description: 'Dependency packages, you can also set a specific version' | |
type: string | |
default: 'packaging transformers_stream_generator transformers datasets matplotlib jmespath' | |
env: | |
HOST_PIP_CACHE_DIR: /nvme/github-actions/pip-cache | |
HOST_LOCALTIME: /usr/share/zoneinfo/Asia/Shanghai | |
OUTPUT_FOLDER: cuda11.8_dist_${{ github.run_id }} | |
REPORT_DIR: /nvme/qa_test_models/benchmark_reports/${{ github.run_id }} | |
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true | |
dependency_pkgs: ${{inputs.dependency_pkgs || 'packaging transformers_stream_generator transformers datasets matplotlib jmespath'}} | |
jobs: | |
linux-build: | |
if: ${{github.event_name == 'schedule' || (!cancelled() && !inputs.offline_mode)}} | |
strategy: | |
matrix: | |
pyver: [py310] | |
runs-on: ubuntu-latest | |
env: | |
PYTHON_VERSION: ${{ matrix.pyver }} | |
PLAT_NAME: manylinux2014_x86_64 | |
DOCKER_TAG: cuda11.8 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.event.inputs.repo_org || 'InternLM/lmdeploy' }} | |
ref: ${{github.event.inputs.repo_ref || 'main'}} | |
- name: Build | |
run: | | |
echo ${PYTHON_VERSION} | |
echo ${PLAT_NAME} | |
echo ${DOCKER_TAG} | |
echo ${OUTPUT_FOLDER} | |
echo ${GITHUB_RUN_ID} | |
# remove -it | |
sed -i 's/docker run --rm -it/docker run --rm/g' builder/manywheel/build_wheel.sh | |
bash builder/manywheel/build_wheel.sh ${PYTHON_VERSION} ${PLAT_NAME} ${DOCKER_TAG} ${OUTPUT_FOLDER} | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
path: builder/manywheel/${{ env.OUTPUT_FOLDER }} | |
retention-days: 1 | |
name: my-artifact-${{ github.run_id }}-${{ matrix.pyver }} | |
benchmark: | |
needs: linux-build | |
if: ${{github.event_name == 'schedule' || !cancelled()}} | |
runs-on: [self-hosted, linux-a100] | |
strategy: | |
fail-fast: false | |
matrix: | |
benchmark_type: ${{fromJSON(github.event.inputs.benchmark_type)}} | |
timeout-minutes: 480 | |
container: | |
image: openmmlab/lmdeploy:latest-cu11 | |
options: "--gpus=all --ipc=host --user root -e PIP_CACHE_DIR=/root/.cache/pip -e NVIDIA_DISABLE_REQUIRE=1 --pull never" | |
volumes: | |
- /nvme/github-actions/pip-cache:/root/.cache/pip | |
- /nvme/github-actions/packages:/root/packages | |
- /nvme/qa_test_models:/nvme/qa_test_models | |
- /mnt/shared:/mnt/shared | |
- /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime:ro | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v3 | |
if: ${{github.event_name == 'schedule' || !inputs.offline_mode}} | |
with: | |
repository: ${{ github.event.inputs.repo_org || 'InternLM/lmdeploy' }} | |
ref: ${{github.event.inputs.repo_ref || 'main'}} | |
- name: Copy repository - offline | |
if: ${{inputs.offline_mode}} | |
run: cp -r /nvme/qa_test_models/offline_pkg/lmdeploy/. . | |
- name: Download Artifacts | |
if: ${{github.event_name == 'schedule' || !inputs.offline_mode}} | |
uses: actions/download-artifact@v4 | |
with: | |
name: my-artifact-${{ github.run_id }}-py310 | |
- name: Install lmdeploy - dependency | |
run: | | |
# manually install flash attn | |
# the install packeage from. https://github.com/Dao-AILab/flash-attention/releases | |
python3 -m pip install /root/packages/flash_attn-2.6.3+cu118torch2.3cxx11abiFALSE-cp310-cp310-linux_x86_64.whl | |
python3 -m pip install -U 'xformers' --index-url https://download.pytorch.org/whl/cu118 --no-deps | |
python3 -m pip install ${{env.dependency_pkgs}} | |
- name: Install lmdeploy | |
if: ${{github.event_name == 'schedule' || !inputs.offline_mode}} | |
run: | | |
python3 -m pip install lmdeploy-*.whl | |
python3 -m pip install triton==2.1.0 | |
python3 -m pip install -r requirements/test.txt | |
- name: Install lmdeploy - offline | |
if: ${{inputs.offline_mode}} | |
run: | | |
python3 -m pip install /nvme/qa_test_models/offline_pkg/py310/lmdeploy-*.whl | |
python3 -m pip install triton==2.1.0 | |
python3 -m pip install -r requirements/test.txt | |
- name: Check env | |
run: | | |
python3 -m pip list | |
lmdeploy check_env | |
- name: Run generation benchmark | |
if: matrix.benchmark_type == 'generation' | |
run: | | |
pytest autotest/benchmark/test_${{matrix.benchmark_type}}_performance.py -n 8 --run_id ${{ github.run_id }} -m gpu_num_1 --lf --alluredir=${{env.REPORT_DIR}}/allure-results || true | |
pytest autotest/benchmark/test_${{matrix.benchmark_type}}_performance.py -n 4 --run_id ${{ github.run_id }} -m 'gpu_num_2 and not longtext' --lf --alluredir=${{env.REPORT_DIR}}/allure-results || true | |
pytest autotest/benchmark/test_${{matrix.benchmark_type}}_performance.py -n 4 --run_id ${{ github.run_id }} -m 'gpu_num_2 and longtext' --lf --alluredir=${{env.REPORT_DIR}}/allure-results || true | |
pytest autotest/benchmark/test_${{matrix.benchmark_type}}_performance.py -n 2 --run_id ${{ github.run_id }} -m gpu_num_4 --lf --alluredir=${{env.REPORT_DIR}}/allure-results | |
- name: Run other benchmark | |
if: matrix.benchmark_type != 'generation' | |
run: | | |
pytest autotest/benchmark/test_${{matrix.benchmark_type}}_performance.py -n 8 --run_id ${{ github.run_id }} -m gpu_num_1 --lf --alluredir=${{env.REPORT_DIR}}/allure-results || true | |
pytest autotest/benchmark/test_${{matrix.benchmark_type}}_performance.py -n 4 --run_id ${{ github.run_id }} -m gpu_num_2 --lf --alluredir=${{env.REPORT_DIR}}/allure-results || true | |
pytest autotest/benchmark/test_${{matrix.benchmark_type}}_performance.py -n 2 --run_id ${{ github.run_id }} -m gpu_num_4 --lf --alluredir=${{env.REPORT_DIR}}/allure-results | |
- name: Clear workfile | |
if: always() | |
run: | | |
chmod -R 777 $REPORT_DIR | |
export workdir=$(pwd) | |
cd .. | |
rm -rf $workdir | |
mkdir $workdir | |
chmod -R 777 $workdir | |
get_result_overview: | |
if: always() && !cancelled() | |
needs: [benchmark] | |
timeout-minutes: 5 | |
runs-on: [self-hosted, linux-a100] | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.event.inputs.repo_org || 'InternLM/lmdeploy' }} | |
ref: ${{github.event.inputs.repo_ref || 'main'}} | |
- name: Get overview | |
run: | | |
pip install pandas fire mmengine | |
python3 .github/scripts/action_tools.py generate_benchmark_report $REPORT_DIR |