Skip to content

Commit 5cb9773

Browse files
nipung90facebook-github-bot
authored andcommitted
Call torchrec cpu tests from fbgemm test gha (pytorch#4424)
Summary: This diff kicks off the torchrec cpu unittests along with fbgemm's cpu tests when there is a pull request on fbgemm Differential Revision: D77598015
1 parent 0dbd1bc commit 5cb9773

File tree

2 files changed

+81
-8
lines changed

2 files changed

+81
-8
lines changed

.github/scripts/test_torchrec.bash

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ env_name=test_binary
1616
torchrec_package_name=""
1717
python_version=""
1818
cuda_version="x"
19-
fbgemm_wheel_path="x"
2019
miniconda_prefix="${HOME}/miniconda"
2120

2221
usage () {
2322
# shellcheck disable=SC2086
24-
echo "Usage: bash $(basename ${BASH_SOURCE[0]}) -o PACKAGE_NAME -p PYTHON_VERSION -P PYTORCH_CHANNEL_NAME -c CUDA_VERSION -w FBGEMM_WHEEL_PATH [-m MINICONDA_PREFIX] [-v] [-h]"
23+
echo "Usage: bash $(basename ${BASH_SOURCE[0]}) -o PACKAGE_NAME -p PYTHON_VERSION -P PYTORCH_CHANNEL_NAME -c CUDA_VERSION [-m MINICONDA_PREFIX] [-v] [-h]"
2524
echo "-v : verbose"
2625
echo "-h : help"
2726
echo "PACKAGE_NAME : output package name of TorchRec (e.g., torchrec_nightly)"
@@ -30,7 +29,6 @@ usage () {
3029
echo "PYTHON_VERSION : Python version (e.g., 3.10)"
3130
echo "PYTORCH_CHANNEL_NAME: PyTorch's channel name (e.g., pytorch-nightly, pytorch-test (=pre-release), pytorch (=stable release))"
3231
echo "CUDA_VERSION : PyTorch's CUDA version (e.g., 12.4)"
33-
echo "FBGEMM_WHEEL_PATH : path to FBGEMM_GPU's wheel file"
3432
echo "MINICONDA_PREFIX : path to install Miniconda (default: \$HOME/miniconda)"
3533
echo "Example: Python 3.10 + PyTorch nightly (CUDA 12.4), install miniconda at \$HOME/miniconda, using dist/fbgemm_gpu_nightly.whl"
3634
# shellcheck disable=SC2086
@@ -46,15 +44,14 @@ do
4644
P) pytorch_channel_name="${OPTARG}";;
4745
c) cuda_version="${OPTARG}";;
4846
m) miniconda_prefix="${OPTARG}";;
49-
w) fbgemm_wheel_path="${OPTARG}";;
5047
h) usage
5148
exit 0;;
5249
*) usage
5350
exit 1;;
5451
esac
5552
done
5653

57-
if [ "$torchrec_package_name" == "" ] || [ "$python_version" == "" ] || [ "$cuda_version" == "x" ] || [ "$miniconda_prefix" == "" ] || [ "$pytorch_channel_name" == "" ] || [ "$fbgemm_wheel_path" == "" ]; then
54+
if [ "$torchrec_package_name" == "" ] || [ "$python_version" == "" ] || [ "$cuda_version" == "x" ] || [ "$miniconda_prefix" == "" ] || [ "$pytorch_channel_name" == "" ]; then
5855
usage
5956
exit 1
6057
fi
@@ -93,11 +90,10 @@ fi
9390
# shellcheck disable=SC2086
9491
test_setup_conda_environment "$env_name" gcc "$python_version" pip "$pytorch_channel_name" $pytorch_variant
9592

96-
# Comment out FBGEMM_GPU since we will install it from "$fbgemm_wheel_path"
93+
# Comment out FBGEMM_GPU since we should pre-install it from the downloaded wheel file
9794
sed -i 's/fbgemm-gpu/#fbgemm-gpu/g' requirements.txt
9895
conda run -n "$env_name" python -m pip install -r requirements.txt
99-
# Install FBGEMM_GPU from a local wheel file.
100-
conda run -n "$env_name" python -m pip install "$fbgemm_wheel_path"
96+
# Check FBGemm can be imported.
10197
conda run -n "$env_name" python -c "import fbgemm_gpu"
10298

10399
################################################################################

.github/workflows/fbgemm_gpu_ci_cpu.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,80 @@ jobs:
200200
env:
201201
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
202202
run: . $PRELUDE; publish_to_pypi $BUILD_ENV "$PYPI_TOKEN" *.whl
203+
204+
205+
# Run torchrec CPU tests
206+
torchrec_cpu_tests:
207+
if: ${{ github.repository_owner == 'pytorch' }}
208+
runs-on: ${{ matrix.host-machine.instance }}
209+
container:
210+
image: amazonlinux:2023
211+
options: --user root
212+
defaults:
213+
run:
214+
shell: bash
215+
env:
216+
PRELUDE: .github/scripts/setup_env.bash
217+
BUILD_ENV: build_binary
218+
BUILD_TARGET: ${{ matrix.build-target }}
219+
BUILD_VARIANT: cpu
220+
strategy:
221+
fail-fast: false
222+
matrix:
223+
host-machine: [
224+
{ arch: x86, instance: "linux.4xlarge", timeout: 20 },
225+
{ arch: arm, instance: "linux.arm64.2xlarge", timeout: 30 },
226+
]
227+
build-target: [ "default" ]
228+
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
229+
compiler: [ "gcc", "clang" ]
230+
needs: build_artifact
231+
232+
steps:
233+
- name: Setup Build Container
234+
run: yum update -y; yum install -y binutils findutils git pciutils sudo wget which
235+
236+
- name: Checkout the Repository
237+
uses: actions/checkout@v4
238+
239+
- name: Download Wheel Artifact from GHA
240+
uses: actions/download-artifact@v4
241+
with:
242+
name: fbgemm_${{ matrix.build-target }}_${{ matrix.host-machine.arch }}_${{ matrix.compiler }}_py${{ matrix.python-version }}_cpu.whl
243+
244+
- name: Display System Info
245+
run: . $PRELUDE; print_system_info; print_ec2_info
246+
247+
- name: Display GPU Info
248+
run: . $PRELUDE; print_gpu_info
249+
250+
- name: Setup Miniconda
251+
run: . $PRELUDE; setup_miniconda $HOME/miniconda
252+
253+
- name: Create Conda Environment
254+
run: . $PRELUDE; create_conda_environment $BUILD_ENV ${{ matrix.python-version }}
255+
256+
- name: Install C/C++ Compilers for Updated LIBGCC
257+
run: . $PRELUDE; install_cxx_compiler $BUILD_ENV ${{ matrix.compiler }}
258+
259+
- name: Install PyTorch-CPU Nightly
260+
run: . $PRELUDE; install_pytorch_pip $BUILD_ENV ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.pytorch_channel_version) || 'nightly' }} cpu
261+
262+
- name: Collect PyTorch Environment Info
263+
if: ${{ success() || failure() }}
264+
run: if . $PRELUDE && which conda; then collect_pytorch_env_info $BUILD_ENV; fi
265+
266+
- name: Prepare FBGEMM_GPU Build
267+
run: . $PRELUDE; cd fbgemm_gpu; prepare_fbgemm_gpu_build $BUILD_ENV
268+
269+
- name: Install FBGEMM_GPU Wheel
270+
run: . $PRELUDE; install_fbgemm_gpu_wheel $BUILD_ENV *.whl
271+
272+
- name: Clone torchrec
273+
uses: actions/checkout@v4
274+
with:
275+
repository: pytorch/torchrec
276+
path: torchrec
277+
278+
- name: Run Pytorchrec CPU tests
279+
run: . $PRELUDE; cd torchrec/torchrec; ../../.github/scripts/test_torchrec.bash -p ${{ matrix.python-version }} -P pytorchtest -c ${{ matrix.compiler }}

0 commit comments

Comments
 (0)