Skip to content

Commit 91e7fb6

Browse files
committed
Bump PyTorch pin to 2.13
1 parent af62dce commit 91e7fb6

24 files changed

Lines changed: 278 additions & 52 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
release/2.12
1+
release/2.13

‎.ci/docker/common/install_pytorch.sh‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ install_domains() {
1616
pip_install --no-build-isolation --user "git+https://github.com/pytorch/vision.git@${TORCHVISION_VERSION}"
1717
}
1818

19+
configure_pytorch_compiler() {
20+
local cxx_version
21+
cxx_version=$(/usr/bin/c++ --version | head -n1)
22+
if [[ "${cxx_version}" == *clang* ]]; then
23+
local clang_major
24+
clang_major=$(/usr/bin/c++ -dumpversion | cut -d. -f1)
25+
if [[ "${clang_major}" =~ ^[0-9]+$ && "${clang_major}" -lt 16 ]] &&
26+
command -v gcc >/dev/null &&
27+
command -v g++ >/dev/null; then
28+
export CC=gcc
29+
export CXX=g++
30+
fi
31+
fi
32+
}
33+
1934
install_pytorch_and_domains() {
2035
git clone https://github.com/pytorch/pytorch.git
2136

@@ -33,14 +48,15 @@ install_pytorch_and_domains() {
3348
if [[ -n "${PYTORCH_BUILD_MAX_JOBS:-}" ]]; then
3449
export MAX_JOBS="${PYTORCH_BUILD_MAX_JOBS}"
3550
fi
51+
configure_pytorch_compiler
3652
# Then build and install PyTorch
3753
conda_run python setup.py bdist_wheel
3854
pip_install "$(echo dist/*.whl)"
3955

4056
# Grab the pinned audio and vision commits from PyTorch
4157
TORCHAUDIO_VERSION=release/2.11
4258
export TORCHAUDIO_VERSION
43-
TORCHVISION_VERSION=release/0.27
59+
TORCHVISION_VERSION=release/0.28
4460
export TORCHVISION_VERSION
4561

4662
install_domains

‎.ci/scripts/test_model_e2e_windows.ps1‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,16 @@ try {
185185
Write-Host "::endgroup::"
186186

187187
Write-Host "::group::Build $runnerTarget"
188+
$cmakeOut = Join-Path -Path $executorchRoot -ChildPath "cmake-out"
189+
$executorchCmakeDir = Join-Path -Path $cmakeOut -ChildPath "lib\cmake\ExecuTorch"
190+
$cmakePackageArgs = @(
191+
"-DCMAKE_FIND_ROOT_PATH=$cmakeOut",
192+
"-DCMAKE_PREFIX_PATH=$cmakeOut;$executorchCmakeDir",
193+
"-Dexecutorch_DIR=$executorchCmakeDir"
194+
)
188195
Push-Location (Join-Path -Path $executorchRoot -ChildPath "examples\models\$runnerPath")
189196
try {
190-
cmake --preset $runnerPreset @cmakeCudaArgs
197+
cmake --preset $runnerPreset @cmakePackageArgs @cmakeCudaArgs
191198
cmake --build (Join-Path -Path $executorchRoot -ChildPath "cmake-out\examples\models\$runnerPath") --target $runnerTarget --config Release -j $numCores
192199
}
193200
finally {

‎.ci/scripts/utils.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ install_pytorch_and_domains() {
107107
local torch_release=$(cat version.txt)
108108
# Download key must match the upload key below (basename of dist/*.whl,
109109
# which always carries setup.py's resolved +gitHASH). Branch-ref pins
110-
# like `release/2.12` would otherwise produce `+gitrelease` here and
110+
# like `release/2.13` would otherwise produce `+gitrelease` here and
111111
# never hit the cache.
112112
local torch_short_hash=$(git rev-parse --short=7 HEAD)
113113
local torch_wheel_path="cached_artifacts/pytorch/executorch/pytorch_wheels/${system_name}/${python_version}"
@@ -178,7 +178,7 @@ install_pytorch_and_domains() {
178178
# Grab the pinned audio and vision commits from PyTorch
179179
TORCHAUDIO_VERSION=release/2.11
180180
export TORCHAUDIO_VERSION
181-
TORCHVISION_VERSION=release/0.27
181+
TORCHVISION_VERSION=release/0.28
182182
export TORCHVISION_VERSION
183183

184184
install_domains

‎.github/workflows/mlx.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ jobs:
158158
--prompt-len 4 \
159159
--max-new-tokens 5 2>&1)
160160
echo "$OUTPUT"
161-
if echo "$OUTPUT" | grep -q "Generated token ids: \[167, 94, 253, 88, 227\]"; then
161+
if echo "$OUTPUT" | grep -q "Generated token ids: \[167, 180, 167, 180, 167\]"; then
162162
echo "Success: Qwen 3.5 MoE MLX export + inference completed with expected output"
163163
else
164-
echo "Failed: unexpected output (expected [167, 94, 253, 88, 227])"
164+
echo "Failed: unexpected output (expected [167, 180, 167, 180, 167])"
165165
exit 1
166166
fi
167167
echo "::endgroup::"

‎backends/aoti/common_shims.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ AOTITorchError aoti_torch_get_dim(Tensor* tensor, int64_t* ret_dim) {
154154
return Error::Ok;
155155
}
156156

157+
AOTITorchError aoti_torch_get_numel(Tensor* tensor, int64_t* ret_numel) {
158+
*ret_numel = static_cast<int64_t>(tensor->numel());
159+
return Error::Ok;
160+
}
161+
157162
// Device and layout utility functions
158163
int32_t aoti_torch_device_type_cpu() {
159164
// Let's say cpu is 0 for ET as well

‎backends/aoti/common_shims.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ aoti_torch_get_device_index(Tensor* tensor, int32_t* ret_device_index);
5959
AOTI_SHIM_EXPORT AOTITorchError
6060
aoti_torch_get_dim(Tensor* tensor, int64_t* ret_dim);
6161

62+
AOTI_SHIM_EXPORT AOTITorchError
63+
aoti_torch_get_numel(Tensor* tensor, int64_t* ret_numel);
64+
6265
// Utility functions for device and layout information
6366
AOTI_SHIM_EXPORT int32_t aoti_torch_device_type_cpu();
6467
AOTI_SHIM_EXPORT int32_t aoti_torch_layout_strided();

‎backends/aoti/common_shims_slim.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ AOTITorchError aoti_torch_get_dim(Tensor* tensor, int64_t* ret_dim) {
6060
return Error::Ok;
6161
}
6262

63+
AOTITorchError aoti_torch_get_numel(Tensor* tensor, int64_t* ret_numel) {
64+
if (tensor == nullptr || ret_numel == nullptr) {
65+
return Error::InvalidArgument;
66+
}
67+
*ret_numel = static_cast<int64_t>(tensor->numel());
68+
return Error::Ok;
69+
}
70+
6371
int32_t aoti_torch_layout_strided() {
6472
// Slimtensor only support strided layout, the return value will always be 0,
6573
// a.k.a at::Layout::Strided;

‎backends/aoti/common_shims_slim.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ aoti_torch_get_dtype(Tensor* tensor, int32_t* ret_dtype);
4848
AOTI_SHIM_EXPORT AOTITorchError
4949
aoti_torch_get_dim(Tensor* tensor, int64_t* ret_dim);
5050

51+
AOTI_SHIM_EXPORT AOTITorchError
52+
aoti_torch_get_numel(Tensor* tensor, int64_t* ret_numel);
53+
5154
AOTI_SHIM_EXPORT int32_t aoti_torch_layout_strided();
5255

5356
// ============================================================

‎backends/aoti/tests/test_common_shims.cpp‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,21 @@ TEST_F(CommonShimsTest, ScalarTensor) {
241241
error = aoti_torch_get_sizes(tensor_0d, &sizes_ptr2);
242242
EXPECT_EQ(error, Error::Ok);
243243
EXPECT_EQ(sizes_ptr, sizes_ptr2);
244+
245+
int64_t numel = -1;
246+
error = aoti_torch_get_numel(tensor_0d, &numel);
247+
EXPECT_EQ(error, Error::Ok);
248+
EXPECT_EQ(numel, 1);
249+
}
250+
251+
TEST_F(CommonShimsTest, GetNumel) {
252+
auto tensor = create_tracked_tensor({2, 3, 4});
253+
254+
int64_t numel = -1;
255+
AOTITorchError error = aoti_torch_get_numel(tensor, &numel);
256+
257+
EXPECT_EQ(error, Error::Ok);
258+
EXPECT_EQ(numel, 24);
244259
}
245260

246261
// Test large tensor dimensions
@@ -266,6 +281,11 @@ TEST_F(CommonShimsTest, LargeTensorDimensions) {
266281
EXPECT_EQ(strides_ptr[1], 120000);
267282
EXPECT_EQ(strides_ptr[2], 400);
268283
EXPECT_EQ(strides_ptr[3], 1);
284+
285+
int64_t numel = -1;
286+
error = aoti_torch_get_numel(tensor, &numel);
287+
EXPECT_EQ(error, Error::Ok);
288+
EXPECT_EQ(numel, 2400000000);
269289
}
270290

271291
// Test that cleanup_tensor_metadata clears the cache

0 commit comments

Comments
 (0)