Skip to content

Commit

Permalink
Add FBGEMM submodule (#2293)
Browse files Browse the repository at this point in the history
Summary:
This PR does the following:
- Upgrade the default CUDA version to 12.4.
- Pre-install fbgemm_gpu genai kernels to the nightly docker.

Pull Request resolved: #2293

Test Plan:
Build base image: https://github.com/pytorch/benchmark/actions/runs/9476276319
Build nightly docker: https://github.com/pytorch/benchmark/actions/runs/9486161032

Reviewed By: aaronenyeshi

Differential Revision: D58471717

Pulled By: xuzhao9

fbshipit-source-id: 9d2e0b45b7cba4af1cb7578daec001605ee03985
  • Loading branch information
xuzhao9 authored and facebook-github-bot committed Jun 12, 2024
1 parent 3ecaae9 commit abb45ae
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "submodules/lit-llama"]
path = submodules/lit-llama
url = https://github.com/Lightning-AI/lit-llama.git
[submodule "submodules/FBGEMM"]
path = submodules/FBGEMM
url = https://github.com/pytorch/FBGEMM.git
5 changes: 4 additions & 1 deletion docker/build-torchbench-nightly-docker.sh
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
docker build . -f torchbench-nightly.dockerfile -t ghcr.io/pytorch/torchbench:latest
TORCHBENCH_BRANCH=${TORCHBENCH_BRANCH:-main}

docker build . -f torchbench-nightly.dockerfile -t ghcr.io/pytorch/torchbench:latest \
--build-arg TORCHBENCH_BRANCH=${TORCHBENCH_BRANCH}
4 changes: 2 additions & 2 deletions docker/gcp-a100-runner-dind.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ RUN sudo mkdir -p /workspace; sudo chown runner:runner /workspace
# We assume that the host NVIDIA driver binaries and libraries are mapped to the docker filesystem

# Use the CUDA installation scripts from pytorch/builder
# Install CUDA 12.4 only to reduce docker size
RUN cd /workspace; git clone https://github.com/pytorch/builder.git
RUN sudo bash -c 'source /workspace/builder/common/install_cuda.sh; install_118; prune_118'
RUN sudo bash -c 'source /workspace/builder/common/install_cuda.sh; install_121; prune_121'
RUN sudo bash -c 'source /workspace/builder/common/install_cuda.sh; install_124; prune_124'

# Install miniconda
RUN wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /workspace/Miniconda3-latest-Linux-x86_64.sh
Expand Down
13 changes: 10 additions & 3 deletions docker/torchbench-nightly.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ ENV SETUP_SCRIPT=/workspace/setup_instance.sh
ARG TORCHBENCH_BRANCH=${TORCHBENCH_BRANCH:-main}
ARG FORCE_DATE=${FORCE_DATE}

# Setup Conda env and CUDA
RUN git clone -b "${TORCHBENCH_BRANCH}" --single-branch \
https://github.com/pytorch/benchmark /workspace/benchmark
# Checkout Torchbench and submodules
RUN git clone --recurse-submodules -b "${TORCHBENCH_BRANCH}" --single-branch \
https://github.com/pytorch/benchmark /workspace/benchmark

# Setup conda env and CUDA
RUN cd /workspace/benchmark && \
. ${SETUP_SCRIPT} && \
python ./utils/python_utils.py --create-conda-env ${CONDA_ENV} && \
Expand Down Expand Up @@ -45,6 +46,12 @@ RUN cd /workspace/benchmark && \
. ${SETUP_SCRIPT} && \
python utils/cuda_utils.py --install-torchbench-deps

# Install FBGEMM GENAI
RUN cd /workspace/benchmark && \
. ${SETUP_SCRIPT} && \
python install.py --userbenchmark triton --fbgemm

# Install Torchbench models
RUN cd /workspace/benchmark && \
. ${SETUP_SCRIPT} && \
python install.py
6 changes: 4 additions & 2 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def pip_install_requirements(requirements_txt="requirements.txt"):
choices=list_userbenchmarks(),
help="Install requirements for optional components.",
)
args = parser.parse_args()
args, extra_args = parser.parse_known_args()

os.chdir(os.path.realpath(os.path.dirname(__file__)))

Expand All @@ -68,9 +68,11 @@ def pip_install_requirements(requirements_txt="requirements.txt"):
if args.userbenchmark:
# Install userbenchmark dependencies if exists
userbenchmark_dir = REPO_ROOT.joinpath("userbenchmark", args.userbenchmark)
cmd = [sys.executable, "install.py"]
cmd.extend(extra_args)
if userbenchmark_dir.joinpath("install.py").is_file():
subprocess.check_call(
[sys.executable, "install.py"], cwd=userbenchmark_dir.absolute()
cmd, cwd=userbenchmark_dir.absolute()
)
sys.exit(0)

Expand Down
1 change: 1 addition & 0 deletions submodules/FBGEMM
Submodule FBGEMM added at 182f3a
27 changes: 27 additions & 0 deletions userbenchmark/triton/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import argparse
import subprocess
import sys
import os
from pathlib import Path

REPO_PATH = Path(os.path.abspath(__file__)).parent.parent.parent
FBGEMM_PATH = REPO_PATH.joinpath("submodules", "FBGEMM", "fbgemm_gpu")

def install_fbgemm():
cmd = ["pip", "install", "-r", "requirements.txt"]
subprocess.check_call(cmd, cwd=str(FBGEMM_PATH.resolve()))
# Build target A100(8.0) or H100(9.0)
cmd = [sys.executable, "setup.py", "bdist_wheel", "--package_variant=genai", "-DTORCH_CUDA_ARCH_LIST=8.0;9.0"]
subprocess.check_call(cmd, cwd=str(FBGEMM_PATH.resolve()))

def test_fbgemm():
cmd = [sys.executable, "-c", '"import fbgemm_gpu.experimental.gen_ai"']
subprocess.check_call(cmd)

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--fbgemm", action="store_true", help="Install FBGEMM GPU")
args = parser.parse_args()
if args.fbgemm:
install_fbgemm()
test_fbgemm()
12 changes: 4 additions & 8 deletions utils/cuda_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@
from typing import Optional

# defines the default CUDA version to compile against
DEFAULT_CUDA_VERSION = "12.1"
DEFAULT_CUDA_VERSION = "12.4"

CUDA_VERSION_MAP = {
"11.8": {
"pytorch_url": "cu118",
"magma_version": "magma-cuda118",
},
"12.1": {
"pytorch_url": "cu121",
"magma_version": "magma-cuda121",
"12.4": {
"pytorch_url": "cu124",
"magma_version": "magma-cuda124",
},
}
PIN_CMAKE_VERSION = "3.22.*"
Expand Down

0 comments on commit abb45ae

Please sign in to comment.