Skip to content

Commit aca5255

Browse files
committed
Update on "Add int1 to int7 dtypes"
Summary: Similar to #117208, we want to add int1 to int7 for edge use cases for weight quantization (https://www.internalfb.com/diff/D62464487) Test Plan: python test/test_quantization.py -k test_uint4_int4_dtype Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
2 parents 689b116 + 97d2a19 commit aca5255

File tree

622 files changed

+7541
-20825
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

622 files changed

+7541
-20825
lines changed

.ci/docker/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ case "$image" in
291291
PROTOBUF=yes
292292
DB=yes
293293
VISION=yes
294-
ROCM_VERSION=6.0
294+
ROCM_VERSION=6.1
295295
NINJA_VERSION=1.9.0
296296
CONDA_CMAKE=yes
297297
TRITON=yes
@@ -302,7 +302,7 @@ case "$image" in
302302
PROTOBUF=yes
303303
DB=yes
304304
VISION=yes
305-
ROCM_VERSION=6.1
305+
ROCM_VERSION=6.2
306306
NINJA_VERSION=1.9.0
307307
CONDA_CMAKE=yes
308308
TRITON=yes

.ci/docker/common/install_cusparselt.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -ex
55
# cuSPARSELt license: https://docs.nvidia.com/cuda/cusparselt/license.html
66
mkdir tmp_cusparselt && cd tmp_cusparselt
77

8-
if [[ ${CUDA_VERSION:0:4} =~ ^12\.[2-4]$ ]]; then
8+
if [[ ${CUDA_VERSION:0:4} =~ ^12\.[2-6]$ ]]; then
99
arch_path='sbsa'
1010
export TARGETARCH=${TARGETARCH:-$(uname -m)}
1111
if [ ${TARGETARCH} = 'amd64' ] || [ "${TARGETARCH}" = 'x86_64' ]; then

.ci/docker/common/install_miopen.sh

+43-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ if [[ -z $ROCM_VERSION ]]; then
1010
exit 1;
1111
fi
1212

13+
IS_UBUNTU=0
14+
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
15+
case "$ID" in
16+
ubuntu)
17+
IS_UBUNTU=1
18+
;;
19+
centos)
20+
IS_UBUNTU=0
21+
;;
22+
*)
23+
echo "Unable to determine OS..."
24+
exit 1
25+
;;
26+
esac
27+
1328
# To make version comparison easier, create an integer representation.
1429
save_IFS="$IFS"
1530
IFS=. ROCM_VERSION_ARRAY=(${ROCM_VERSION})
@@ -57,9 +72,11 @@ MIOPEN_CMAKE_COMMON_FLAGS="
5772
-DMIOPEN_BUILD_DRIVER=OFF
5873
"
5974
# Pull MIOpen repo and set DMIOPEN_EMBED_DB based on ROCm version
60-
if [[ $ROCM_INT -ge 60200 ]] && [[ $ROCM_INT -lt 60300 ]]; then
61-
echo "ROCm 6.2 MIOpen does not need any patches, do not build from source"
75+
if [[ $ROCM_INT -ge 60300 ]]; then
76+
echo "ROCm 6.3+ MIOpen does not need any patches, do not build from source"
6277
exit 0
78+
elif [[ $ROCM_INT -ge 60200 ]] && [[ $ROCM_INT -lt 60300 ]]; then
79+
MIOPEN_BRANCH="release/rocm-rel-6.2-staging"
6380
elif [[ $ROCM_INT -ge 60100 ]] && [[ $ROCM_INT -lt 60200 ]]; then
6481
echo "ROCm 6.1 MIOpen does not need any patches, do not build from source"
6582
exit 0
@@ -93,12 +110,21 @@ else
93110
exit 1
94111
fi
95112

96-
yum remove -y miopen-hip
113+
114+
if [[ ${IS_UBUNTU} == 1 ]]; then
115+
apt-get remove -y miopen-hip
116+
else
117+
yum remove -y miopen-hip
118+
fi
97119

98120
git clone https://github.com/ROCm/MIOpen -b ${MIOPEN_BRANCH}
99121
pushd MIOpen
100122
# remove .git to save disk space since CI runner was running out
101123
rm -rf .git
124+
# Don't build CK to save docker build time
125+
if [[ $ROCM_INT -ge 60200 ]]; then
126+
sed -i '/composable_kernel/d' requirements.txt
127+
fi
102128
# Don't build MLIR to save docker build time
103129
# since we are disabling MLIR backend for MIOpen anyway
104130
if [[ $ROCM_INT -ge 50400 ]] && [[ $ROCM_INT -lt 50500 ]]; then
@@ -111,10 +137,15 @@ cmake -P install_deps.cmake --minimum
111137

112138
# clean up since CI runner was running out of disk space
113139
rm -rf /tmp/*
114-
yum clean all
115-
rm -rf /var/cache/yum
116-
rm -rf /var/lib/yum/yumdb
117-
rm -rf /var/lib/yum/history
140+
if [[ ${IS_UBUNTU} == 1 ]]; then
141+
apt-get autoclean && apt-get clean
142+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
143+
else
144+
yum clean all
145+
rm -rf /var/cache/yum
146+
rm -rf /var/lib/yum/yumdb
147+
rm -rf /var/lib/yum/history
148+
fi
118149

119150
## Build MIOpen
120151
mkdir -p build
@@ -131,7 +162,11 @@ make -j $(nproc) package
131162
# clean up since CI runner was running out of disk space
132163
rm -rf /usr/local/cget
133164

134-
yum install -y miopen-*.rpm
165+
if [[ ${IS_UBUNTU} == 1 ]]; then
166+
sudo dpkg -i miopen-hip*.deb
167+
else
168+
yum install -y miopen-*.rpm
169+
fi
135170

136171
popd
137172
rm -rf MIOpen

.ci/docker/ubuntu-rocm/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ RUN rm install_rocm.sh
6868
COPY ./common/install_rocm_magma.sh install_rocm_magma.sh
6969
RUN bash ./install_rocm_magma.sh
7070
RUN rm install_rocm_magma.sh
71+
ADD ./common/install_miopen.sh install_miopen.sh
72+
RUN bash ./install_miopen.sh ${ROCM_VERSION} && rm install_miopen.sh
7173
ENV ROCM_PATH /opt/rocm
7274
ENV PATH /opt/rocm/bin:$PATH
7375
ENV PATH /opt/rocm/hcc/bin:$PATH
@@ -121,5 +123,8 @@ RUN bash ./install_cache.sh && rm install_cache.sh
121123
ARG BUILD_ENVIRONMENT
122124
ENV BUILD_ENVIRONMENT ${BUILD_ENVIRONMENT}
123125

126+
# Install LLVM dev version (Defined in the pytorch/builder github repository)
127+
COPY --from=pytorch/llvm:9.0.1 /opt/llvm /opt/llvm
128+
124129
USER jenkins
125130
CMD ["bash"]

.ci/pytorch/build.sh

+10-14
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,8 @@ if [[ ${BUILD_ENVIRONMENT} == *"parallelnative"* ]]; then
4949
fi
5050

5151
# Enable LLVM dependency for TensorExpr testing
52-
if [[ "$BUILD_ENVIRONMENT" == *rocm* ]]; then
53-
export USE_LLVM=/opt/rocm/llvm
54-
export LLVM_DIR=/opt/rocm/llvm/lib/cmake/llvm
55-
else
56-
export USE_LLVM=/opt/llvm
57-
export LLVM_DIR=/opt/llvm/lib/cmake/llvm
58-
fi
52+
export USE_LLVM=/opt/llvm
53+
export LLVM_DIR=/opt/llvm/lib/cmake/llvm
5954

6055
if [[ "$BUILD_ENVIRONMENT" == *executorch* ]]; then
6156
# To build test_edge_op_registration
@@ -237,7 +232,7 @@ fi
237232

238233
# Do not change workspace permissions for ROCm CI jobs
239234
# as it can leave workspace with bad permissions for cancelled jobs
240-
if [[ "$BUILD_ENVIRONMENT" != *rocm* ]]; then
235+
if [[ "$BUILD_ENVIRONMENT" != *rocm* && "$BUILD_ENVIRONMENT" != *s390x* ]]; then
241236
# Workaround for dind-rootless userid mapping (https://github.com/pytorch/ci-infra/issues/96)
242237
WORKSPACE_ORIGINAL_OWNER_ID=$(stat -c '%u' "/var/lib/jenkins/workspace")
243238
cleanup_workspace() {
@@ -283,6 +278,7 @@ else
283278
# set only when building other architectures
284279
# or building non-XLA tests.
285280
if [[ "$BUILD_ENVIRONMENT" != *rocm* &&
281+
"$BUILD_ENVIRONMENT" != *s390x* &&
286282
"$BUILD_ENVIRONMENT" != *xla* ]]; then
287283
if [[ "$BUILD_ENVIRONMENT" != *py3.8* ]]; then
288284
# Install numpy-2.0.2 for builds which are backward compatible with 1.X
@@ -345,11 +341,11 @@ else
345341
CUSTOM_OP_BUILD="${CUSTOM_TEST_ARTIFACT_BUILD_DIR}/custom-op-build"
346342
CUSTOM_OP_TEST="$PWD/test/custom_operator"
347343
python --version
348-
SITE_PACKAGES="$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
344+
SITE_PACKAGES="$(python -c 'import site; print(";".join([x for x in site.getsitepackages()] + [x + "/torch" for x in site.getsitepackages()]))')"
349345

350346
mkdir -p "$CUSTOM_OP_BUILD"
351347
pushd "$CUSTOM_OP_BUILD"
352-
cmake "$CUSTOM_OP_TEST" -DCMAKE_PREFIX_PATH="$SITE_PACKAGES/torch;$SITE_PACKAGES" -DPython_EXECUTABLE="$(which python)" \
348+
cmake "$CUSTOM_OP_TEST" -DCMAKE_PREFIX_PATH="$SITE_PACKAGES" -DPython_EXECUTABLE="$(which python)" \
353349
-DCMAKE_MODULE_PATH="$CUSTOM_TEST_MODULE_PATH" -DUSE_ROCM="$CUSTOM_TEST_USE_ROCM"
354350
make VERBOSE=1
355351
popd
@@ -359,10 +355,10 @@ else
359355
JIT_HOOK_BUILD="${CUSTOM_TEST_ARTIFACT_BUILD_DIR}/jit-hook-build"
360356
JIT_HOOK_TEST="$PWD/test/jit_hooks"
361357
python --version
362-
SITE_PACKAGES="$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
358+
SITE_PACKAGES="$(python -c 'import site; print(";".join([x for x in site.getsitepackages()] + [x + "/torch" for x in site.getsitepackages()]))')"
363359
mkdir -p "$JIT_HOOK_BUILD"
364360
pushd "$JIT_HOOK_BUILD"
365-
cmake "$JIT_HOOK_TEST" -DCMAKE_PREFIX_PATH="$SITE_PACKAGES/torch;$SITE_PACKAGES" -DPython_EXECUTABLE="$(which python)" \
361+
cmake "$JIT_HOOK_TEST" -DCMAKE_PREFIX_PATH="$SITE_PACKAGES" -DPython_EXECUTABLE="$(which python)" \
366362
-DCMAKE_MODULE_PATH="$CUSTOM_TEST_MODULE_PATH" -DUSE_ROCM="$CUSTOM_TEST_USE_ROCM"
367363
make VERBOSE=1
368364
popd
@@ -374,7 +370,7 @@ else
374370
python --version
375371
mkdir -p "$CUSTOM_BACKEND_BUILD"
376372
pushd "$CUSTOM_BACKEND_BUILD"
377-
cmake "$CUSTOM_BACKEND_TEST" -DCMAKE_PREFIX_PATH="$SITE_PACKAGES/torch;$SITE_PACKAGES" -DPython_EXECUTABLE="$(which python)" \
373+
cmake "$CUSTOM_BACKEND_TEST" -DCMAKE_PREFIX_PATH="$SITE_PACKAGES" -DPython_EXECUTABLE="$(which python)" \
378374
-DCMAKE_MODULE_PATH="$CUSTOM_TEST_MODULE_PATH" -DUSE_ROCM="$CUSTOM_TEST_USE_ROCM"
379375
make VERBOSE=1
380376
popd
@@ -407,6 +403,6 @@ fi
407403

408404
# snadampal: skipping it till sccache support added for aarch64
409405
# https://github.com/pytorch/pytorch/issues/121559
410-
if [[ "$BUILD_ENVIRONMENT" != *aarch64* ]]; then
406+
if [[ "$BUILD_ENVIRONMENT" != *aarch64* && "$BUILD_ENVIRONMENT" != *s390x* ]]; then
411407
print_sccache_stats
412408
fi

.ci/pytorch/create_test_cert.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import datetime, timedelta
1+
from datetime import datetime, timedelta, timezone
22
from tempfile import mkdtemp
33

44
from cryptography import x509
@@ -42,10 +42,10 @@ def create_cert(path, C, ST, L, O, key):
4242
.issuer_name(issuer)
4343
.public_key(key.public_key())
4444
.serial_number(x509.random_serial_number())
45-
.not_valid_before(datetime.utcnow())
45+
.not_valid_before(datetime.now(timezone.utc))
4646
.not_valid_after(
4747
# Our certificate will be valid for 10 days
48-
datetime.utcnow()
48+
datetime.now(timezone.utc)
4949
+ timedelta(days=10)
5050
)
5151
.add_extension(
@@ -88,10 +88,10 @@ def sign_certificate_request(path, csr_cert, ca_cert, private_ca_key):
8888
.issuer_name(ca_cert.subject)
8989
.public_key(csr_cert.public_key())
9090
.serial_number(x509.random_serial_number())
91-
.not_valid_before(datetime.utcnow())
91+
.not_valid_before(datetime.now(timezone.utc))
9292
.not_valid_after(
9393
# Our certificate will be valid for 10 days
94-
datetime.utcnow()
94+
datetime.now(timezone.utc)
9595
+ timedelta(days=10)
9696
# Sign our certificate with our private key
9797
)

.ci/pytorch/test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ test_linux_aarch64() {
14021402
inductor/test_max_autotune inductor/test_memory_planning inductor/test_metrics inductor/test_multi_kernel inductor/test_pad_mm \
14031403
inductor/test_pattern_matcher inductor/test_perf inductor/test_profiler inductor/test_select_algorithm inductor/test_smoke \
14041404
inductor/test_split_cat_fx_passes inductor/test_standalone_compile inductor/test_torchinductor \
1405-
inductor/test_torchinductor_codegen_dynamic_shapes inductor/test_torchinductor_dynamic_shapes \
1405+
inductor/test_torchinductor_codegen_dynamic_shapes inductor/test_torchinductor_dynamic_shapes inductor/test_memory \
14061406
--shard "$SHARD_NUMBER" "$NUM_TEST_SHARDS" --verbose
14071407
}
14081408

.github/merge_rules.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@
544544
- anijain2305
545545
- bdhirsh
546546
- zou3519
547+
- isuruf
547548
mandatory_checks_name:
548549
- EasyCLA
549550
- Lint

0 commit comments

Comments
 (0)