Skip to content

Commit c83b60d

Browse files
add macos unit tests (#2282)
* add macos unit tests * update job name * downgrade to 3.12 * somehow, it must be in this order * add assert * revert... * copy * remove numpy version * fix env * set GPTQMODEL_FORCE_BUILD to 0 * unset all * fix comment * set permission to ready only * revert numpy
1 parent c8aefd0 commit c83b60d

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

.github/workflows/unit_tests.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ concurrency:
8282
group: ${{ github.event.inputs.ref || github.ref }}-workflow-unit-tests-${{ github.event.inputs.test_names }}
8383
cancel-in-progress: true
8484

85+
permissions:
86+
contents: read
87+
8588
jobs:
8689
check-vm:
8790
runs-on: ubuntu-24.04
@@ -699,3 +702,73 @@ jobs:
699702
run: |
700703
source venv/bin/activate && pip cache purge && uv cache clean || true
701704
rm -rf ../GPTQModel && mkdir ../GPTQModel
705+
706+
mac-test:
707+
runs-on: macos-latest
708+
env:
709+
CUDA_VISIBLE_DEVICES: ''
710+
TORCH_CUDA_ARCH_LIST: ''
711+
MAX_JOBS: 3
712+
BUILD_QQQ: 0
713+
BUILD_EORA: 0
714+
GPTQMODEL_BUILD_EXLLAMA_V1: 0
715+
GPTQMODEL_BUILD_EORA: 0
716+
GPTQMODEL_FORCE_BUILD: 0
717+
steps:
718+
- name: Checkout Codes
719+
uses: actions/checkout@v6
720+
721+
- uses: actions/setup-python@v6
722+
with:
723+
python-version: 3.12
724+
cache: 'pip'
725+
726+
# it wastes too much time to find which exactly one caused installation failed, just unset them all.....
727+
- name: Install dependencies
728+
run: |
729+
unset CUDA_DEVICE_ORDER
730+
unset CUDA_VISIBLE_DEVICES
731+
unset TORCH_CUDA_ARCH_LIST
732+
unset PYTORCH_ALLOC_CONF
733+
unset MAX_JOBS
734+
unset RUNNER
735+
unset XEON5
736+
unset UV_INDEX_URL
737+
unset CUDA_VERSION
738+
unset TORCH_VERSION
739+
unset PYTHON_VERSION
740+
unset # PYTHON_GIL
741+
unset BUILD_QQQ
742+
unset BUILD_EORA
743+
unset GPTQMODEL_BUILD_EXLLAMA_V1
744+
unset GPTQMODEL_BUILD_EORA
745+
unset LEGACY_TESTS
746+
unset IGNORED_TEST_FILES
747+
unset GPTQMODEL_FORCE_BUILD
748+
unset repo
749+
unset ref
750+
751+
python -V
752+
python -m venv venv
753+
source venv/bin/activate
754+
pip install pip uv setuptools build wheel torch -U
755+
pip install meson-python -U
756+
pip install numpy==2.2.6 -U
757+
758+
uv pip install -e . --no-build-isolation
759+
pip install pip Pillow device_smi pypcre tokenicer threadpoolctl accelerate logbar transformers optimum torch -U
760+
761+
- name: Run test
762+
run: |
763+
source venv/bin/activate
764+
python - <<'PY'
765+
import os
766+
from transformers import pipeline
767+
os.environ["CUDA_VISIBLE_DEVICES"] = ""
768+
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
769+
llm_pipeline = pipeline(model="JunHowie/Qwen3-0.6B-GPTQ-Int4")
770+
output = llm_pipeline("Which city is the capital of France?", max_new_tokens=100)
771+
print(output)
772+
773+
assert "paris" in output.lower()
774+
PY

gptqmodel/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"cuda:per": 4,
3737
"xpu:per": 1,
3838
"mps": 8,
39-
"cpu": min(12, max(1, (os.cpu_count() or 1) // 2)),
39+
"cpu": min(12, max(1, (os.cpu_count() or 1) + 1 // 2)), # count + 1, fixed pool size > 1 check when count=3
4040
"model_loader:cpu": 2,
4141
},
4242
empty_cache_every_n=512,

0 commit comments

Comments
 (0)