Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FBGEMM submodule #2293

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @jianyuh Is this the right way to build FBGEMM GenAI OSS on A100/H100?

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
Loading