Skip to content

Commit a9dfc0e

Browse files
authored
Merge branch 'main' into yanbing/fix_1452
2 parents 48f3c19 + 2fc98f7 commit a9dfc0e

16 files changed

+137
-31
lines changed

.github/workflows/more-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99

1010
jobs:
1111
test-cuda:
12+
permissions:
13+
id-token: write
14+
contents: read
1215
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
1316
with:
1417
runner: linux.g5.4xlarge.nvidia.gpu

.github/workflows/periodic.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ jobs:
108108
set -eux
109109
PYTHONPATH="${PWD}" python .ci/scripts/gather_test_models.py --event "periodic" --backend "gpu"
110110
test-gpu:
111+
permissions:
112+
id-token: write
113+
contents: read
111114
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
112115
name: test-gpu (${{ matrix.platform }}, ${{ matrix.model_name }})
113116
needs: gather-models-gpu

.github/workflows/pull.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ jobs:
215215
set -eux
216216
PYTHONPATH="${PWD}" python .ci/scripts/gather_test_models.py --event "pull_request" --backend "gpu"
217217
test-gpu-compile:
218+
permissions:
219+
id-token: write
220+
contents: read
218221
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
219222
name: test-gpu-compile (${{ matrix.platform }}, ${{ matrix.model_name }})
220223
needs: gather-models-gpu
@@ -250,6 +253,9 @@ jobs:
250253
echo "::endgroup::"
251254
252255
test-gpu-aoti-bfloat16:
256+
permissions:
257+
id-token: write
258+
contents: read
253259
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
254260
name: test-gpu-aoti-bfloat16 (${{ matrix.platform }}, ${{ matrix.model_name }})
255261
needs: gather-models-gpu
@@ -286,6 +292,9 @@ jobs:
286292
echo "::endgroup::"
287293
288294
test-gpu-aoti-float32:
295+
permissions:
296+
id-token: write
297+
contents: read
289298
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
290299
name: test-gpu-aoti-float32 (${{ matrix.platform }}, ${{ matrix.model_name }})
291300
needs: gather-models-gpu
@@ -327,6 +336,9 @@ jobs:
327336
echo "::endgroup::"
328337
329338
test-gpu-aoti-float16:
339+
permissions:
340+
id-token: write
341+
contents: read
330342
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
331343
name: test-gpu-aoti-float16 (${{ matrix.platform }}, ${{ matrix.model_name }})
332344
needs: gather-models-gpu
@@ -369,6 +381,9 @@ jobs:
369381
echo "::endgroup::"
370382
371383
test-gpu-eval-sanity-check:
384+
permissions:
385+
id-token: write
386+
contents: read
372387
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
373388
name: test-gpu-eval-sanity-check (${{ matrix.platform }}, ${{ matrix.model_name }})
374389
needs: gather-models-gpu
@@ -1011,6 +1026,9 @@ jobs:
10111026
echo "Tests complete."
10121027
10131028
test-build-runner-et-android:
1029+
permissions:
1030+
id-token: write
1031+
contents: read
10141032
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
10151033
with:
10161034
runner: linux.4xlarge

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010

1111
jobs:
1212
test-readme:
13+
permissions:
14+
id-token: write
15+
contents: read
1316
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
1417
secrets: inherit
1518
with:
@@ -39,6 +42,9 @@ jobs:
3942
4043
4144
test-quantization-any:
45+
permissions:
46+
id-token: write
47+
contents: read
4248
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
4349
with:
4450
runner: linux.g5.4xlarge.nvidia.gpu
@@ -66,6 +72,9 @@ jobs:
6672
echo "::endgroup::"
6773
6874
test-gguf-any:
75+
permissions:
76+
id-token: write
77+
contents: read
6978
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
7079
secrets: inherit
7180
with:

.github/workflows/run-readme-pr-mps.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
1111
with:
1212
runner: macos-m1-14
13-
timeout-minutes: 50
13+
timeout: 50
1414
script: |
1515
conda create -y -n test-readme-mps-macos python=3.10.11 llvm-openmp
1616
conda activate test-readme-mps-macos
@@ -36,7 +36,7 @@ jobs:
3636
test-quantization-mps-macos:
3737
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
3838
with:
39-
runner: macos-m1-14
39+
runner: macos-m1-14
4040
script: |
4141
set -x
4242
conda create -y -n test-quantization-mps-macos python=3.10.11
@@ -63,7 +63,7 @@ jobs:
6363
test-gguf-mps-macos:
6464
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
6565
with:
66-
runner: macos-m1-14 # neeps MPS, was macos-m1-stable
66+
runner: macos-m1-14 # needs MPS, was macos-m1-stable
6767
script: |
6868
set -x
6969
conda create -y -n test-quantization-mps-macos python=3.10.11
@@ -90,7 +90,7 @@ jobs:
9090
test-advanced-mps-macos:
9191
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
9292
with:
93-
runner: macos-m1-14 # neeps MPS, was macos-m1-stable
93+
runner: macos-m1-14 # needs MPS, was macos-m1-stable
9494
script: |
9595
set -x
9696
conda create -y -n test-quantization-mps-macos python=3.10.11

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

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99

1010
jobs:
1111
test-readme-any:
12+
permissions:
13+
id-token: write
14+
contents: read
1215
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
1316
with:
1417
runner: linux.g5.4xlarge.nvidia.gpu
@@ -28,6 +31,9 @@ jobs:
2831
echo "::endgroup::"
2932
3033
test-readme-cpu:
34+
permissions:
35+
id-token: write
36+
contents: read
3137
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
3238
with:
3339
runner: linux.g5.4xlarge.nvidia.gpu
@@ -47,6 +53,9 @@ jobs:
4753
echo "::endgroup::"
4854
4955
test-quantization-any:
56+
permissions:
57+
id-token: write
58+
contents: read
5059
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
5160
with:
5261
runner: linux.g5.4xlarge.nvidia.gpu
@@ -66,6 +75,9 @@ jobs:
6675
echo "::endgroup::"
6776
6877
test-quantization-cpu:
78+
permissions:
79+
id-token: write
80+
contents: read
6981
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
7082
with:
7183
runner: linux.g5.4xlarge.nvidia.gpu
@@ -80,6 +92,9 @@ jobs:
8092
TORCHCHAT_DEVICE=cpu .ci/scripts/run-docs quantization
8193
8294
test-gguf-any:
95+
permissions:
96+
id-token: write
97+
contents: read
8398
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
8499
with:
85100
runner: linux.g5.4xlarge.nvidia.gpu
@@ -99,6 +114,9 @@ jobs:
99114
echo "::endgroup::"
100115
101116
test-gguf-cpu:
117+
permissions:
118+
id-token: write
119+
contents: read
102120
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
103121
with:
104122
runner: linux.g5.4xlarge.nvidia.gpu
@@ -119,6 +137,9 @@ jobs:
119137
120138
121139
test-advanced-any:
140+
permissions:
141+
id-token: write
142+
contents: read
122143
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
123144
with:
124145
runner: linux.g5.4xlarge.nvidia.gpu
@@ -139,6 +160,9 @@ jobs:
139160
140161
141162
test-advanced-cpu:
163+
permissions:
164+
id-token: write
165+
contents: read
142166
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
143167
with:
144168
runner: linux.g5.4xlarge.nvidia.gpu
@@ -158,6 +182,9 @@ jobs:
158182
echo "::endgroup::"
159183
160184
test-evaluation-any:
185+
permissions:
186+
id-token: write
187+
contents: read
161188
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
162189
with:
163190
runner: linux.g5.4xlarge.nvidia.gpu
@@ -177,6 +204,9 @@ jobs:
177204
echo "::endgroup::"
178205
179206
test-evaluation-cpu:
207+
permissions:
208+
id-token: write
209+
contents: read
180210
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
181211
with:
182212
runner: linux.g5.4xlarge.nvidia.gpu
@@ -196,6 +226,9 @@ jobs:
196226
echo "::endgroup::"
197227
198228
test-multimodal-any:
229+
permissions:
230+
id-token: write
231+
contents: read
199232
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
200233
with:
201234
runner: linux.g5.4xlarge.nvidia.gpu
@@ -215,6 +248,9 @@ jobs:
215248
echo "::endgroup::"
216249
217250
test-multimodal-cpu:
251+
permissions:
252+
id-token: write
253+
contents: read
218254
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
219255
with:
220256
runner: linux.g5.4xlarge.nvidia.gpu
@@ -269,4 +305,4 @@ jobs:
269305
export PATH=/opt/rh/devtoolset-10/root/usr/bin/:$PATH
270306
echo "::endgroup::"
271307
272-
TORCHCHAT_DEVICE=cpu .ci/scripts/run-docs native
308+
TORCHCHAT_DEVICE=cpu .ci/scripts/run-docs native

.github/workflows/runner-cuda-dtype.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99

1010
jobs:
1111
test-runner-aot-cuda:
12+
permissions:
13+
id-token: write
14+
contents: read
1215
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
1316
with:
1417
runner: linux.g5.4xlarge.nvidia.gpu

install/.pins/et-pin.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
98e4dd524f2cb08414ee015b27616229cabc06ba
1+
9c043290ad3944268290e015c3063bc411e6ef6b

install/install_requirements.sh

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ VISION_NIGHTLY_VERSION=dev20241218
5959
# Nightly version for torchtune
6060
TUNE_NIGHTLY_VERSION=dev20241218
6161

62-
# Uninstall triton, as nightly will depend on pytorch-triton, which is one and the same
63-
(
64-
set -x
65-
$PIP_EXECUTABLE uninstall -y triton
66-
)
67-
6862
# The pip repository that hosts nightly torch packages. cpu by default.
6963
# If cuda is available, based on presence of nvidia-smi, install the pytorch nightly
7064
# with cuda for faster execution on cuda GPUs.
@@ -74,16 +68,28 @@ then
7468
elif [[ -x "$(command -v rocminfo)" ]];
7569
then
7670
TORCH_NIGHTLY_URL="https://download.pytorch.org/whl/nightly/rocm6.2"
71+
elif [[ -x "$(command -v xpu-smi)" ]];
72+
then
73+
TORCH_NIGHTLY_URL="https://download.pytorch.org/whl/nightly/xpu"
7774
else
7875
TORCH_NIGHTLY_URL="https://download.pytorch.org/whl/nightly/cpu"
7976
fi
8077

8178
# pip packages needed by exir.
82-
REQUIREMENTS_TO_INSTALL=(
83-
torch=="2.6.0.${PYTORCH_NIGHTLY_VERSION}"
84-
torchvision=="0.22.0.${VISION_NIGHTLY_VERSION}"
85-
torchtune=="0.5.0.${TUNE_NIGHTLY_VERSION}"
86-
)
79+
if [[ -x "$(command -v xpu-smi)" ]];
80+
then
81+
REQUIREMENTS_TO_INSTALL=(
82+
torch=="2.6.0.${PYTORCH_NIGHTLY_VERSION}"
83+
torchvision=="0.22.0.${VISION_NIGHTLY_VERSION}"
84+
torchtune=="0.5.0"
85+
)
86+
else
87+
REQUIREMENTS_TO_INSTALL=(
88+
torch=="2.6.0.${PYTORCH_NIGHTLY_VERSION}"
89+
torchvision=="0.22.0.${VISION_NIGHTLY_VERSION}"
90+
torchtune=="0.5.0.${TUNE_NIGHTLY_VERSION}"
91+
)
92+
fi
8793

8894
#
8995
# First install requirements in install/requirements.txt. Older torch may be
@@ -95,6 +101,12 @@ REQUIREMENTS_TO_INSTALL=(
95101
$PIP_EXECUTABLE install -r install/requirements.txt --extra-index-url "${TORCH_NIGHTLY_URL}"
96102
)
97103

104+
# Uninstall triton, as nightly will depend on pytorch-triton, which is one and the same
105+
(
106+
set -x
107+
$PIP_EXECUTABLE uninstall -y triton
108+
)
109+
98110
# Install the requirements. --extra-index-url tells pip to look for package
99111
# versions on the provided URL if they aren't available on the default URL.
100112
(
@@ -116,8 +128,6 @@ if [[ -x "$(command -v nvidia-smi)" ]]; then
116128
$PYTHON_EXECUTABLE torchchat/utils/scripts/patch_triton.py
117129
)
118130
fi
119-
120-
121131
(
122132
set -x
123133
$PIP_EXECUTABLE install evaluate=="0.4.3" lm-eval=="0.4.2" psutil=="6.0.0"

torchchat/cli/builder.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ class BuilderArgs:
7373

7474
def __post_init__(self):
7575
if self.device is None:
76-
self.device = "cuda" if torch.cuda.is_available() else "cpu"
76+
if torch.cuda.is_available():
77+
self.device = "cuda"
78+
elif torch.xpu.is_available():
79+
self.device = "xpu"
80+
else:
81+
self.device = "cpu"
7782

7883
if not (
7984
(self.checkpoint_path and self.checkpoint_path.is_file())

torchchat/cli/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ def _add_model_config_args(parser, verb: str) -> None:
176176
"--device",
177177
type=str,
178178
default=None,
179-
choices=["fast", "cpu", "cuda", "mps"],
180-
help="Hardware device to use. Options: fast, cpu, cuda, mps",
179+
choices=["fast", "cpu", "cuda", "mps", "xpu"],
180+
help="Hardware device to use. Options: fast, cpu, cuda, mps, xpu",
181181
)
182182
model_config_parser.add_argument(
183183
"--attention-backend",

0 commit comments

Comments
 (0)