Skip to content

Commit b217d4b

Browse files
mikekgfbmalfet
authored andcommitted
run README and quantization steps from docs on MPS (#723)
* README and quantization steps from docs on MPS * device handling for aot load * add objcopy * fixes * fixes
1 parent 823a543 commit b217d4b

File tree

4 files changed

+53
-50
lines changed

4 files changed

+53
-50
lines changed

.github/workflows/run-readme-periodic.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Run the README instructions periodically to ensure they work
22

33
on:
44
schedule:
5-
- cron: '0 0 * * *' # Runs daily at midnight UTC
5+
- cron: '0 0 * * *' # Runs daily at midnight UTC
66
push:
77
tags:
88
- ciflow/periodic/*
@@ -22,10 +22,10 @@ jobs:
2222
uname -a
2323
echo "::endgroup::"
2424
25-
# echo "::group::Install newer objcopy that supports --set-section-alignment"
26-
# yum install -y devtoolset-10-binutils
27-
# export PATH=/opt/rh/devtoolset-10/root/usr/bin/:$PATH
28-
# echo "::endgroup::"
25+
echo "::group::Install newer objcopy that supports --set-section-alignment"
26+
yum install -y devtoolset-10-binutils
27+
export PATH=/opt/rh/devtoolset-10/root/usr/bin/:$PATH
28+
echo "::endgroup::"
2929
3030
# echo "::group::get_llama"
3131
# (

parking_lot/run-readme-pr-mps.yml renamed to .github/workflows/run-readme-pr-mps.yml

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -49,45 +49,46 @@ jobs:
4949
echo "*******************************************"
5050
echo "::endgroup::"
5151

52-
test-quantization-mps-macos:
53-
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
54-
with:
55-
runner: macos-m1-stable # neeps MPS, was macos-m1-stable
56-
script: |
57-
set -x
58-
conda create -y -n test-quantization-mps-macos python=3.10.11
59-
conda activate test-quantization-mps-macos
60-
# NS: Remove previous installation of torch first
61-
# as this script does not isntall anything into conda env but rather as system dep
62-
pip3 uninstall -y torch || true
63-
set -eou pipefail
64-
65-
echo "::group::Print machine info"
66-
uname -a
67-
sysctl machdep.cpu.brand_string
68-
sysctl machdep.cpu.core_count
69-
echo "::endgroup::"
70-
71-
# echo "::group::Install newer objcopy that supports --set-section-alignment"
72-
# yum install -y devtoolset-10-binutils
73-
# export PATH=/opt/rh/devtoolset-10/root/usr/bin/:$PATH
74-
# echo "::endgroup::"
75-
76-
echo "::group::Create script to run quantization"
77-
python3 scripts/updown.py --file docs/quantization.md --replace llama3:stories15M --suppress huggingface-cli,HF_TOKEN > ./run-quantization.sh
78-
# for good measure, if something happened to updown processor,
79-
# and it did not error out, fail with an exit 1
80-
echo "exit 1" >> ./run-quantization.sh
81-
echo "::endgroup::"
82-
83-
echo "::group::Run quantization"
84-
echo "*******************************************"
85-
cat ./run-quantization.sh
86-
echo "*******************************************"
87-
bash -x ./run-quantization.sh
88-
echo "::endgroup::"
89-
90-
echo "::group::Completion"
91-
echo "tests complete"
92-
echo "*******************************************"
93-
echo "::endgroup::"
52+
# test-quantization-mps-macos:
53+
# uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
54+
# with:
55+
# runner: macos-m1-stable # neeps MPS, was macos-m1-stable
56+
# script: |
57+
# set -x
58+
# conda create -y -n test-quantization-mps-macos python=3.10.11
59+
# conda activate test-quantization-mps-macos
60+
# # NS: Remove previous installation of torch first
61+
# # as this script does not isntall anything into conda env but rather as system dep
62+
# pip3 uninstall -y torch || true
63+
# set -eou pipefail
64+
#
65+
# echo "::group::Print machine info"
66+
# uname -a
67+
# sysctl machdep.cpu.brand_string
68+
# sysctl machdep.cpu.core_count
69+
# echo "::endgroup::"
70+
#
71+
# # echo "::group::Install newer objcopy that supports --set-section-alignment"
72+
# # yum install -y devtoolset-10-binutils
73+
# # export PATH=/opt/rh/devtoolset-10/root/usr/bin/:$PATH
74+
# # echo "::endgroup::"
75+
#
76+
# echo "::group::Create script to run quantization"
77+
# python3 scripts/updown.py --file docs/quantization.md --replace llama3:stories15M --suppress huggingface-cli,HF_TOKEN > ./run-quantization.sh
78+
# # for good measure, if something happened to updown processor,
79+
# # and it did not error out, fail with an exit 1
80+
# echo "exit 1" >> ./run-quantization.sh
81+
# echo "::endgroup::"
82+
#
83+
# echo "::group::Run quantization"
84+
# echo "*******************************************"
85+
# cat ./run-quantization.sh
86+
# echo "*******************************************"
87+
# bash -x ./run-quantization.sh
88+
# echo "::endgroup::"
89+
#
90+
# echo "::group::Completion"
91+
# echo "tests complete"
92+
# echo "*******************************************"
93+
# echo "::endgroup::"
94+
#

build/builder.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,11 @@ def _initialize_model(
382382

383383
try:
384384
if "mps" in builder_args.device:
385-
print("Warning: MPS currently does not support DSO models. Trying to load for CPU.")
385+
print(
386+
"Cannot load specified DSO to MPS. Attempting to load model to CPU instead"
387+
)
386388
builder_args.device = "cpu"
387-
389+
388390
# Replace model forward with the AOT-compiled forward
389391
# This is a hacky way to quickly demo AOTI's capability.
390392
# model is still a Python object, and any mutation to its

export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def main(args):
5151
if output_dso_path and "mps" in builder_args.device:
5252
print("Warning! Device MPS not supported for export. Exporting for device CPU.")
5353
builder_args.device = "cpu"
54-
54+
5555
# TODO: clean this up
5656
# This mess is because ET does not support _weight_int4pack_mm right now
5757
if not builder_args.gguf_path:

0 commit comments

Comments
 (0)