Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] add mlx test #1074

Merged
merged 30 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
da8d4b3
[CI] move mlx test to m4
CSY-ModelCloud Jan 10, 2025
114c587
[CI] fix syntax
CSY-ModelCloud Jan 10, 2025
a3551b7
[CI] update build if
CSY-ModelCloud Jan 10, 2025
50efa0a
[CI] fix mlx-files
CSY-ModelCloud Jan 10, 2025
5998778
[CI] check not ''
CSY-ModelCloud Jan 10, 2025
faaddb9
[CI] update build if
CSY-ModelCloud Jan 10, 2025
92d8ee9
[CI] if
CSY-ModelCloud Jan 10, 2025
6ba8aff
[CI] if
CSY-ModelCloud Jan 10, 2025
bc02781
[CI] print if env
CSY-ModelCloud Jan 10, 2025
2c3cea0
[CI] remove alywas
CSY-ModelCloud Jan 10, 2025
e333640
[CI] remove cancel
CSY-ModelCloud Jan 10, 2025
82a067a
[CI] Print conditions and parameters
CSY-ModelCloud Jan 10, 2025
2853581
[CI] update outputs
CSY-ModelCloud Jan 10, 2025
b3f2762
[CI] use _
CSY-ModelCloud Jan 10, 2025
b2c92ce
[CI] add needs
CSY-ModelCloud Jan 10, 2025
45d3bb8
[CI] add needs
CSY-ModelCloud Jan 10, 2025
537d5d2
[CI] rename test sh
CSY-ModelCloud Jan 10, 2025
c8f537c
[CI] fix parameter not received
CSY-ModelCloud Jan 10, 2025
b5422b1
[CI] rename
CSY-ModelCloud Jan 10, 2025
a1abdc9
[CI] update
CSY-ModelCloud Jan 10, 2025
ddb9db4
[CI] update if
CSY-ModelCloud Jan 10, 2025
35ee19f
[CI] remove ignore
CSY-ModelCloud Jan 10, 2025
6e35f05
[CI] clean local
CSY-ModelCloud Jan 10, 2025
4c1d557
[CI] clean local
CSY-ModelCloud Jan 10, 2025
ab302be
[CI] update
CSY-ModelCloud Jan 10, 2025
5219d2e
darwin BUILD_CUDA_EXT false
CSY-ModelCloud Jan 10, 2025
0a1a303
Merge remote-tracking branch 'origin/main' into CSY/mlx-test
CSY-ModelCloud Jan 10, 2025
5c019b4
[CI] add test var
CSY-ModelCloud Jan 10, 2025
eb8baab
[CI] append .py
CSY-ModelCloud Jan 10, 2025
06be80a
[CI] fix regex
CSY-ModelCloud Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 75 additions & 17 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ env:
RUNNER: 10.0.14.248
TRANSFORMERS_DIFF_TESTS: "models/test_internlm.py,models/test_internlm2_5.py,models/test_xverse.py"
TORCH_2_5_TESTS: "test_evalplus.py,test_perplexity.py,test_q4_ipex.py,test_ipex_xpu.py,test_save_loaded_quantized_model.py,test_quant_formats.py,models/test_hymba.py"
IGNORED_TEST_FILES: "test_tgi.py,test_gptneox.py,models/test_mixtral.py,test_q4_torch_apple.py"
IGNORED_TEST_FILES: "test_tgi.py,test_gptneox.py,models/test_mixtral.py"
GPTQMODEL_FORCE_BUILD: 1
repo: ${{ github.event.inputs.repo || github.repository }}
ref: ${{ github.event.inputs.ref || github.ref }}
Expand Down Expand Up @@ -111,8 +111,9 @@ jobs:
runs-on: ubuntu-latest
if: github.event.inputs.m4-only != 'true'
outputs:
torch-2-5-files: ${{ steps.files.outputs.torch-2-5-files }}
torch-files: ${{ steps.files.outputs.torch-files }}
transformers-files: ${{ steps.files.outputs.transformers-files }}
m4-files: ${{ steps.files.outputs.m4-files }}

steps:
- name: Checkout Codes
Expand Down Expand Up @@ -152,27 +153,53 @@ jobs:
all_tests = [f.removesuffix('.py') for f in os.listdir('tests/') if f.startswith('test_') and f.endswith('.py') and f.strip().removesuffix('py') not in f'{IGNORED_TEST_FILES}']
all_tests_models = ['models/'+f.removesuffix('.py') for f in os.listdir('tests/models') if f.startswith('test_') and f.endswith('.py') and f.strip().removesuffix('py') not in f'{IGNORED_TEST_FILES}']

torch_2_5_test_files = [f for f in all_tests+all_tests_models if (not input_test_files_list or f in input_test_files_list) and f not in transformers_test_files]
torch_test_files = [f for f in all_tests+all_tests_models if (not input_test_files_list or f in input_test_files_list) and f not in transformers_test_files and 'mlx' not in f]

torch_2_5_test_files = [test for test in torch_2_5_test_files if re.match(rf'{TEST_REGEX}', test)]
transformers_test_files = [test for test in transformers_test_files if re.match(rf'{TEST_REGEX}', test)]
torch_test_files = [test for test in torch_test_files if re.match(f'{TEST_REGEX}', test)]
transformers_test_files = [test for test in transformers_test_files if re.match(f'{TEST_REGEX}', test)]

print(f'{json.dumps(torch_2_5_test_files)}|{json.dumps(transformers_test_files)}')
m4_test_files = [f for f in all_tests if ('mlx' in f or 'apple' in f) and (f.strip().removesuffix('.py') in input_test_files_list if input_test_files_list else True)]

print(f'{json.dumps(torch_test_files)}|{json.dumps(transformers_test_files)}|{json.dumps(m4_test_files)}')
"

test_files=$(python3 -c "$script")
IFS='|' read -r torch_2_5_test_files transformers_test_files <<< "$test_files"
echo "torch-2-5-files=$torch_2_5_test_files" >> "$GITHUB_OUTPUT"
IFS='|' read -r torch_test_files transformers_test_files mlx_files <<< "$test_files"

echo "torch-files=$torch_test_files" >> "$GITHUB_OUTPUT"
echo "transformers-files=$transformers_test_files" >> "$GITHUB_OUTPUT"
echo "m4-files=$mlx_files" >> "$GITHUB_OUTPUT"

echo "Test files: $test_files"
echo "Torch 2.5 Test files: $torch_2_5_test_files"
echo "Torch Test files: $torch_test_files"
echo "Transformers Test files: $transformers_test_files"
echo "MLX Test files: $mlx_files"
echo "Ignored Test files: $IGNORED_TEST_FILES"

- name: Print conditions and parameters
run: |
echo "Parameters:"
echo "github.event.inputs.m4-only: ${{ github.event.inputs.m4-only }}"
echo "needs.list-test-files.outputs.torch-files: ${{ needs.list-test-files.outputs.torch-files }}"
echo "needs.list-test-files.outputs.transformers-files: ${{ needs.list-test-files.outputs.transformers-files }}"
echo "needs.list-test-files.outputs.m4-files: ${{ needs.list-test-files.outputs.m4-files }}"
echo "github.event.inputs.artifact_id: ${{ github.event.inputs.artifact_id }}"
echo "needs.build.result: ${{ needs.build.result }}"
echo "github.event.inputs.test_names: ${{ github.event.inputs.test_names }}"
echo ""

echo "Conditions:"
echo "will build run: ${{ github.event.inputs.m4-only != 'true' && needs.list-test-files.outputs.torch-files != '[]' && needs.list-test-files.outputs.transformers-files != '[]' && !(needs.list-test-files.outputs.m4-files == '[]' && needs.list-test-files.outputs.m4-files == '[]') }}"
echo "will transformers_diff run: ${{ (needs.build.result == 'success' || github.event.inputs.artifact_id != '') && github.event.inputs.m4-only != 'true' && needs.list-test-files.outputs.transformers-files != '[]' }}"
echo "will torch2_5 run: ${{ (needs.build.result == 'success' || github.event.inputs.artifact_id != '') && github.event.inputs.m4-only != 'true' && needs.list-test-files.outputs.torch-files != '[]' }}"
echo "will m4 run: ${{ (github.event.inputs.test_names == '' || contains(github.event.inputs.test_names, 'apple') || contains(github.event.inputs.test_names, 'mlx') ) && (needs.list-test-files.outputs.m4-files != '' || needs.list-test-files.outputs.m4-files != '[]') }}"

build:
runs-on: [ self-hosted, Linux ]
needs: check-vm
needs:
- check-vm
- list-test-files
if: github.event.inputs.m4-only != 'true' && needs.list-test-files.outputs.torch-files != '[]' && needs.list-test-files.outputs.transformers-files != '[]' && !(needs.list-test-files.outputs.m4-files == '[]' && needs.list-test-files.outputs.m4-files == '[]')
container:
image: ${{ needs.check-vm.outputs.ip }}:5000/modelcloud/gptqmodel:github-ci-v5
steps:
Expand Down Expand Up @@ -416,7 +443,7 @@ jobs:
- list-test-files
- check-vm
runs-on: [ self-hosted, Linux ]
if: always() && !cancelled() && (needs.build.result == 'success' || github.event.inputs.artifact_id != '') && github.event.inputs.m4-only != 'true' && needs.list-test-files.outputs.torch-2-5-files != '[]'
if: always() && !cancelled() && (needs.build.result == 'success' || github.event.inputs.artifact_id != '') && github.event.inputs.m4-only != 'true' && needs.list-test-files.outputs.torch-files != '[]'
container:
image: ${{ needs.check-vm.outputs.ip }}:5000/modelcloud/gptqmodel:github-ci-v5
options: --device /dev/dri --ipc=host
Expand All @@ -428,7 +455,7 @@ jobs:
fail-fast: false
max-parallel: ${{ fromJson(needs.check-vm.outputs.max-parallel).size || 20 }}
matrix:
test_script: ${{ fromJSON(needs.list-test-files.outputs.torch-2-5-files) }}
test_script: ${{ fromJSON(needs.list-test-files.outputs.torch-files) }}
steps:
- name: Checkout Codes
uses: actions/checkout@v4
Expand Down Expand Up @@ -521,7 +548,7 @@ jobs:
if [ "${{ matrix.test_script }}" == "test_ipex_xpu" ]; then
source /etc/profile.d/pyenv.sh && pyenv activate xpu
fi

if [[ "${{ matrix.test_script }}" == *"mlx"* ]]; then
uv pip install mlx_lm --no-build-isolation
fi
Expand Down Expand Up @@ -588,8 +615,14 @@ jobs:

m4:
runs-on: [ self-hosted, m4 ]
needs: check-vm
if: (github.event.inputs.test_names == '' || contains(github.event.inputs.test_names, 'apple') )&& !cancelled()
needs:
- check-vm
- list-test-files
if: (github.event.inputs.test_names == '' || contains(github.event.inputs.test_names, 'apple') || contains(github.event.inputs.test_names, 'mlx') ) && (needs.list-test-files.outputs.m4-files != '' && needs.list-test-files.outputs.m4-files != '[]') && !cancelled()
strategy:
fail-fast: false
matrix:
test_script: ${{ fromJSON(needs.list-test-files.outputs.m4-files) }}
steps:
- name: Checkout Codes
uses: actions/checkout@v4
Expand All @@ -599,8 +632,33 @@ jobs:

- name: Run test
run: |
ls -ahl .

export PATH="/opt/homebrew/bin:$PATH" && eval "$(pyenv init -)"
rm -rf venv || true
echo "=== activating venv"
pyenv global 3.11.11 && python -m venv venv
source venv/bin/activate

rm profile.sb || true

curl -O http://${{ needs.check-vm.outputs.ip }}/scripts/m4/profile.sb
curl -O http://${{ needs.check-vm.outputs.ip }}/scripts/m4/run.sh
sandbox-exec -f profile.sb /bin/bash ./run.sh

echo "=== installing uv setuptools build"
pip install uv setuptools build -U -i http://${{ needs.check-vm.outputs.ip }}/simple --trusted-host ${{ needs.check-vm.outputs.ip }}

echo "=== installing test tools"
uv pip install pytest parameterized vllm lm-eval device-smi mlx-lm

echo "=== installing gptqmodel"
uv pip install . --no-build-isolation

TEST=${{ matrix.test_script }}
if [[ ! "$TEST" == *.py ]]; then
TEST="$TEST.py"
fi
echo "=== running test: $TEST"
pytest tests/$TEST

pip cache purge
uv cache clean
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"https://github.com/ModelCloud/GPTQModel/releases/download/{tag_name}/{wheel_name}"
)

BUILD_CUDA_EXT = True
BUILD_CUDA_EXT = sys.platform != "darwin"

if os.environ.get("GPTQMODEL_FORCE_BUILD", None):
FORCE_BUILD = True
Expand Down
Loading