Use a better cherry-pick strategy for stable pytorch w/ distribute changes (#129987)
1. Update the branch name from internal feedback
2. Only cherry-pick in the changes to these folders
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129987
Approved by: https://github.com/seemethere
diff --git a/.github/scripts/sync_distributed_folder_prototype.sh b/.github/scripts/sync_distributed_folder_prototype.sh
index 23ba3e4..e58832f 100755
--- a/.github/scripts/sync_distributed_folder_prototype.sh
+++ b/.github/scripts/sync_distributed_folder_prototype.sh
@@ -2,7 +2,7 @@
set -eoux pipefail
-SYNC_BRANCH=fbcode/pytorch-stable-prototype
+SYNC_BRANCH=pytorch-stable-prototype
git config user.email "fake@example.com"
git config user.name "PyTorch Stable Bot"
@@ -11,7 +11,9 @@
git fetch origin "$SYNC_BRANCH"
git checkout "$SYNC_BRANCH"
-for SHA in $(git log 4333e122d4b74cdf84351ed2907045c6a767b4cd..origin/main --pretty="%h" --reverse -- torch/distributed torch/csrc/distributed test/distributed test/cpp/c10d benchmarks/distributed)
+# Using a hardcoded SHA here is a massive speedup as we can skip the entire history of the pytorch GitHub repo.
+# This specific SHA was chosen as it was before the "branch point" of the stable branch
+for SHA in $(git log ba3b05fdf37ddbc3c301294d6a560a816335e717..origin/main --pretty="%h" --reverse -- torch/distributed torch/csrc/distributed test/distributed test/cpp/c10d benchmarks/distributed)
do
# `git merge-base --is-ancestor` exits with code 0 if the given SHA is an ancestor, and non-0 otherwise
if git merge-base --is-ancestor $SHA HEAD || [[ $(git log --grep="(cherry picked from commit $SHA") ]]
@@ -20,7 +22,12 @@
continue
fi
echo "Copying $SHA"
- git cherry-pick -x "$SHA"
+ git cherry-pick -x "$SHA" -X theirs
+ git reset --soft HEAD~1
+ git add torch/distributed torch/csrc/distributed test/distributed test/cpp/c10d benchmarks/distributed
+ git checkout .
+ git commit --reuse-message=HEAD@{1}
+ git clean -f
done
if [[ "${WITH_PUSH}" == true ]]; then