Skip to content

Commit e74f4e5

Browse files
committed
Update on "Fold Conv-Bn"
Adds Conv-BN folding to inductor freezing. One thing that's a little awkward now is we'll want different decompositions to run depending on if we are in the inference compiler. For now, I require that you run with torch.no_grad() so we can detect if no gradients are required before calling aot_autograd. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 ipiszy ngimel yf225 aakhundov chenyang78 soumith desertfire Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) [ghstack-poisoned]
2 parents 97e5728 + 3ae928d commit e74f4e5

672 files changed

Lines changed: 23039 additions & 14679 deletions

File tree

Some content is hidden

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

.ci/docker/build_docker.sh

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ retry () {
66
$* || (sleep 1 && $*) || (sleep 2 && $*)
77
}
88

9-
# If UPSTREAM_BUILD_ID is set (see trigger job), then we can
10-
# use it to tag this build with the same ID used to tag all other
11-
# base image builds. Also, we can try and pull the previous
12-
# image first, to avoid rebuilding layers that haven't changed.
13-
14-
#until we find a way to reliably reuse previous build, this last_tag is not in use
15-
# last_tag="$(( CIRCLE_BUILD_NUM - 1 ))"
169
tag="${DOCKER_TAG}"
10+
registry="308535385114.dkr.ecr.us-east-1.amazonaws.com"
1711

12+
# NB: The image name could now be both the short form, like pytorch-linux-bionic-py3.11-clang9, or the
13+
# full name, like 308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-bionic-py3.11-clang9
14+
if [[ "${IMAGE_NAME}" == *"${registry}/pytorch/"* ]]; then
15+
# Extract the image name from the long name
16+
EXTRACTED_IMAGE_NAME=$(echo ${IMAGE_NAME#"${registry}/pytorch/"} | awk -F '[:,]' '{print $1}')
17+
IMAGE_NAME="${EXTRACTED_IMAGE_NAME}"
18+
fi
1819

19-
registry="308535385114.dkr.ecr.us-east-1.amazonaws.com"
2020
image="${registry}/pytorch/${IMAGE_NAME}"
2121

2222
login() {
@@ -35,11 +35,6 @@ if [[ -z "${GITHUB_ACTIONS}" ]]; then
3535
trap "docker logout ${registry}" EXIT
3636
fi
3737

38-
# Try to pull the previous image (perhaps we can reuse some layers)
39-
# if [ -n "${last_tag}" ]; then
40-
# docker pull "${image}:${last_tag}" || true
41-
# fi
42-
4338
# Build new image
4439
./build.sh ${IMAGE_NAME} -t "${image}:${tag}"
4540

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cd9e4c5db76b2bb0b47d0680d3d4c24523047e7c
1+
9dc100afb538d39da17621e0f8ad233f2078e6ff

.ci/docker/common/install_onnx.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pip_install \
2424
transformers==4.25.1
2525

2626
# TODO: change this when onnx-script is on testPypi
27-
pip_install "onnxscript@git+https://github.com/microsoft/onnxscript@a3caa39b14e8ee187573f6cb607e4fe4b9fe1f2f"
27+
pip_install "onnxscript@git+https://github.com/microsoft/onnxscript@7e131c578f290ffad1f26bacda11a83daf5476ba"
2828

2929
# Cache the transformers model to be used later by ONNX tests. We need to run the transformers
3030
# package to download the model. By default, the model is cached at ~/.cache/huggingface/hub/

.ci/pytorch/build-asan.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

.ci/pytorch/build.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
1111
# shellcheck source=./common-build.sh
1212
source "$(dirname "${BASH_SOURCE[0]}")/common-build.sh"
1313

14-
if [[ "$BUILD_ENVIRONMENT" == *-clang7-asan* ]]; then
15-
exec "$(dirname "${BASH_SOURCE[0]}")/build-asan.sh" "$@"
16-
fi
17-
1814
if [[ "$BUILD_ENVIRONMENT" == *-mobile-*build* ]]; then
1915
exec "$(dirname "${BASH_SOURCE[0]}")/build-mobile.sh" "$@"
2016
fi
@@ -168,6 +164,15 @@ if [[ "${BUILD_ENVIRONMENT}" == *clang* ]]; then
168164
export CXX=clang++
169165
fi
170166

167+
if [[ "$BUILD_ENVIRONMENT" == *-clang*-asan* ]]; then
168+
export LDSHARED="clang --shared"
169+
export USE_CUDA=0
170+
export USE_ASAN=1
171+
export USE_MKLDNN=0
172+
export UBSAN_FLAGS="-fno-sanitize-recover=all"
173+
unset USE_LLVM
174+
fi
175+
171176
if [[ "${BUILD_ENVIRONMENT}" == *no-ops* ]]; then
172177
export USE_PER_OPERATOR_HEADERS=0
173178
fi

.ci/pytorch/common_utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function checkout_install_torchdeploy() {
175175
pushd multipy
176176
git checkout "${commit}"
177177
python multipy/runtime/example/generate_examples.py
178-
pip install -e . --install-option="--cudatests"
178+
BUILD_CUDA_TESTS=1 pip install -e .
179179
popd
180180
popd
181181
}

.ci/pytorch/multigpu-test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ time python test/run_test.py --verbose -i distributed/tensor/parallel/test_tp_ex
4646
# Other tests
4747
time python test/run_test.py --verbose -i test_cuda_primary_ctx
4848
time python test/run_test.py --verbose -i test_optim -- -k optimizers_with_varying_tensors
49+
time python test/run_test.py --verbose -i test_foreach -- -k test_tensors_grouping
4950
assert_git_not_dirty

.ci/pytorch/test.sh

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fi
126126
# if you're not careful. Check this if you made some changes and the
127127
# ASAN test is not working
128128
if [[ "$BUILD_ENVIRONMENT" == *asan* ]]; then
129-
export ASAN_OPTIONS=detect_leaks=0:symbolize=1:detect_stack_use_after_return=1:strict_init_order=true:detect_odr_violation=1:detect_container_overflow=0
129+
export ASAN_OPTIONS=detect_leaks=0:symbolize=1:detect_stack_use_after_return=true:strict_init_order=true:detect_odr_violation=1:detect_container_overflow=0:check_initialization_order=true:debug=true
130130
export UBSAN_OPTIONS=print_stacktrace=1
131131
export PYTORCH_TEST_WITH_ASAN=1
132132
export PYTORCH_TEST_WITH_UBSAN=1
@@ -166,6 +166,8 @@ if [[ "$BUILD_ENVIRONMENT" == *asan* ]]; then
166166

167167
# TODO: get rid of the hardcoded path
168168
export LD_PRELOAD=/usr/lib/llvm-7/lib/clang/7.0.1/lib/linux/libclang_rt.asan-x86_64.so
169+
# Disable valgrind for asan
170+
export VALGRIND=OFF
169171
# Increase stack size, because ASAN red zones use more stack
170172
ulimit -s 81920
171173

@@ -312,7 +314,6 @@ test_perf_for_dashboard() {
312314
local suite="$1"
313315
shift
314316

315-
local dtype=amp
316317
local backend=inductor
317318
local modes=()
318319
if [[ "$DASHBOARD_TAG" == *training-true* ]]; then
@@ -325,6 +326,11 @@ test_perf_for_dashboard() {
325326
local targets=(accuracy performance)
326327

327328
for mode in "${modes[@]}"; do
329+
if [[ "$mode" == "inference" ]]; then
330+
dtype=bfloat16
331+
elif [[ "$mode" == "training" ]]; then
332+
dtype=amp
333+
fi
328334
for target in "${targets[@]}"; do
329335
local target_flag=("--${target}")
330336
if [[ "$target" == "performance" ]]; then
@@ -430,7 +436,7 @@ test_dynamo_benchmark() {
430436
if [[ "${TEST_CONFIG}" == *cpu_accuracy* ]]; then
431437
test_single_dynamo_benchmark "inference" "$suite" "$shard_id" --inference --float32 "$@"
432438
else
433-
test_single_dynamo_benchmark "inference" "$suite" "$shard_id" --inference --amp "$@"
439+
test_single_dynamo_benchmark "inference" "$suite" "$shard_id" --inference --bfloat16 "$@"
434440
test_single_dynamo_benchmark "training" "$suite" "$shard_id" --training --amp "$@"
435441
fi
436442
fi
@@ -469,7 +475,7 @@ test_aten() {
469475
# Test ATen
470476
# The following test(s) of ATen have already been skipped by caffe2 in rocm environment:
471477
# scalar_tensor_test, basic, native_test
472-
if [[ "$BUILD_ENVIRONMENT" != *asan* ]] && [[ "$BUILD_ENVIRONMENT" != *rocm* ]]; then
478+
if [[ "$BUILD_ENVIRONMENT" != *rocm* ]]; then
473479
echo "Running ATen tests with pytorch lib"
474480

475481
if [[ -n "$IN_WHEEL_TEST" ]]; then
@@ -669,51 +675,45 @@ test_rpc() {
669675
}
670676

671677
test_custom_backend() {
672-
if [[ "$BUILD_ENVIRONMENT" != *asan* ]] ; then
673-
echo "Testing custom backends"
674-
CUSTOM_BACKEND_BUILD="${CUSTOM_TEST_ARTIFACT_BUILD_DIR}/custom-backend-build"
675-
pushd test/custom_backend
676-
cp -a "$CUSTOM_BACKEND_BUILD" build
677-
# Run tests Python-side and export a lowered module.
678-
python test_custom_backend.py -v
679-
python backend.py --export-module-to=model.pt
680-
# Run tests C++-side and load the exported lowered module.
681-
build/test_custom_backend ./model.pt
682-
rm -f ./model.pt
683-
popd
684-
assert_git_not_dirty
685-
fi
678+
echo "Testing custom backends"
679+
CUSTOM_BACKEND_BUILD="${CUSTOM_TEST_ARTIFACT_BUILD_DIR}/custom-backend-build"
680+
pushd test/custom_backend
681+
cp -a "$CUSTOM_BACKEND_BUILD" build
682+
# Run tests Python-side and export a lowered module.
683+
python test_custom_backend.py -v
684+
python backend.py --export-module-to=model.pt
685+
# Run tests C++-side and load the exported lowered module.
686+
build/test_custom_backend ./model.pt
687+
rm -f ./model.pt
688+
popd
689+
assert_git_not_dirty
686690
}
687691

688692
test_custom_script_ops() {
689-
if [[ "$BUILD_ENVIRONMENT" != *asan* ]] ; then
690-
echo "Testing custom script operators"
691-
CUSTOM_OP_BUILD="${CUSTOM_TEST_ARTIFACT_BUILD_DIR}/custom-op-build"
692-
pushd test/custom_operator
693-
cp -a "$CUSTOM_OP_BUILD" build
694-
# Run tests Python-side and export a script module.
695-
python test_custom_ops.py -v
696-
python model.py --export-script-module=model.pt
697-
# Run tests C++-side and load the exported script module.
698-
build/test_custom_ops ./model.pt
699-
popd
700-
assert_git_not_dirty
701-
fi
693+
echo "Testing custom script operators"
694+
CUSTOM_OP_BUILD="${CUSTOM_TEST_ARTIFACT_BUILD_DIR}/custom-op-build"
695+
pushd test/custom_operator
696+
cp -a "$CUSTOM_OP_BUILD" build
697+
# Run tests Python-side and export a script module.
698+
python test_custom_ops.py -v
699+
python model.py --export-script-module=model.pt
700+
# Run tests C++-side and load the exported script module.
701+
build/test_custom_ops ./model.pt
702+
popd
703+
assert_git_not_dirty
702704
}
703705

704706
test_jit_hooks() {
705-
if [[ "$BUILD_ENVIRONMENT" != *asan* ]] ; then
706-
echo "Testing jit hooks in cpp"
707-
HOOK_BUILD="${CUSTOM_TEST_ARTIFACT_BUILD_DIR}/jit-hook-build"
708-
pushd test/jit_hooks
709-
cp -a "$HOOK_BUILD" build
710-
# Run tests Python-side and export the script modules with hooks
711-
python model.py --export-script-module=model
712-
# Run tests C++-side and load the exported script modules
713-
build/test_jit_hooks ./model
714-
popd
715-
assert_git_not_dirty
716-
fi
707+
echo "Testing jit hooks in cpp"
708+
HOOK_BUILD="${CUSTOM_TEST_ARTIFACT_BUILD_DIR}/jit-hook-build"
709+
pushd test/jit_hooks
710+
cp -a "$HOOK_BUILD" build
711+
# Run tests Python-side and export the script modules with hooks
712+
python model.py --export-script-module=model
713+
# Run tests C++-side and load the exported script modules
714+
build/test_jit_hooks ./model
715+
popd
716+
assert_git_not_dirty
717717
}
718718

719719
test_torch_function_benchmark() {
@@ -923,7 +923,7 @@ test_cpp_extensions() {
923923

924924
test_vec256() {
925925
# This is to test vec256 instructions DEFAULT/AVX/AVX2 (platform dependent, some platforms might not support AVX/AVX2)
926-
if [[ "$BUILD_ENVIRONMENT" != *asan* ]] && [[ "$BUILD_ENVIRONMENT" != *rocm* ]]; then
926+
if [[ "$BUILD_ENVIRONMENT" != *rocm* ]]; then
927927
echo "Testing vec256 instructions"
928928
mkdir -p test/test-reports/vec256
929929
pushd build/bin

.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ modernize-*,
4242
-modernize-use-trailing-return-type,
4343
-modernize-use-nodiscard,
4444
performance-*,
45-
-performance-noexcept-move-constructor,
4645
-performance-unnecessary-value-param,
4746
readability-container-size-empty,
4847
'

.github/actions/calculate-docker-image/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ runs:
111111
- name: Build and push docker image
112112
if: inputs.always-rebuild || steps.check.outputs.rebuild
113113
env:
114-
IMAGE_NAME: ${{inputs.docker-image-name}}
114+
IMAGE_NAME: ${{ inputs.docker-image-name }}
115115
DOCKER_SKIP_S3_UPLOAD: "1"
116116
# Skip push if we don't need it, or if specified in the inputs
117117
DOCKER_SKIP_PUSH: ${{ steps.check.outputs.skip_push || inputs.skip_push }}

0 commit comments

Comments
 (0)