forked from pytorch/FBGEMM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for triton-based GEMM in OSS (pytorch#2570)
Summary: - Add support for triton-based GEMM in OSS Pull Request resolved: pytorch#2570 Differential Revision: D57419173 Pulled By: q10
- Loading branch information
1 parent
1c0344f
commit 0f9672d
Showing
23 changed files
with
182 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
|
||
# shellcheck disable=SC1091,SC2128 | ||
. "$( dirname -- "$BASH_SOURCE"; )/utils_base.bash" | ||
|
||
################################################################################ | ||
# Triton Setup Functions | ||
################################################################################ | ||
|
||
install_triton () { | ||
local env_name="$1" | ||
local triton_version="$2" | ||
if [ "$env_name" == "" ]; then | ||
echo "Usage: ${FUNCNAME[0]} ENV_NAME [TRITON_VERSION]" | ||
echo "Example(s):" | ||
echo " ${FUNCNAME[0]} build_env # Install the repo-default version of Triton" | ||
echo " ${FUNCNAME[0]} build_env 2.1 # Install a designated version of Triton" | ||
return 1 | ||
else | ||
echo "################################################################################" | ||
echo "# Build + Install Triton" | ||
echo "#" | ||
echo "# [$(date --utc +%FT%T.%3NZ)] + ${FUNCNAME[0]} ${*}" | ||
echo "################################################################################" | ||
echo "" | ||
fi | ||
|
||
test_network_connection || return 1 | ||
|
||
# shellcheck disable=SC2155 | ||
local env_prefix=$(env_name_or_prefix "${env_name}") | ||
|
||
echo "[BUILD] Checking out triton ..." | ||
cd ../third_party/triton/python || return 1 | ||
if [ "$triton_version" != "" ]; then | ||
(print_exec git checkout "${triton_version}") || return 1 | ||
fi | ||
|
||
echo "[BUILD] Installing Triton ..." | ||
# shellcheck disable=SC2086 | ||
(exec_with_retries 3 conda run --no-capture-output ${env_prefix} python -m pip install -e .) || return 1 | ||
|
||
# shellcheck disable=SC2086 | ||
(test_python_import_package "${env_name}" triton) || return 1 | ||
|
||
cd - || return 1 | ||
echo "[INSTALL] Successfully installed Triton ${triton_version}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
################################################################################ | ||
# Target Sources | ||
################################################################################ | ||
|
||
set(experimental_triton_python_source_files | ||
triton_gemm/__init__.py | ||
triton_gemm/fp8_gemm.py) | ||
|
||
|
||
################################################################################ | ||
# Install Python Files | ||
################################################################################ | ||
|
||
install(FILES ${experimental_triton_python_source_files} | ||
DESTINATION fbgemm_gpu/experimental/gemm/triton_gemm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# pyre-strict | ||
|
||
from typing import Tuple | ||
|
||
import torch | ||
|
||
|
||
gpu_unavailable: Tuple[bool, str] = ( | ||
not torch.cuda.is_available() or torch.cuda.device_count() == 0, | ||
"CUDA is not available or no GPUs detected", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# pyre-strict | ||
|
||
try: | ||
# pyre-ignore[21] | ||
# @manual=//deeplearning/fbgemm/fbgemm_gpu:test_utils | ||
from fbgemm_gpu import open_source | ||
|
||
# pyre-ignore[21] | ||
# @manual=//deeplearning/fbgemm/fbgemm_gpu:test_utils | ||
from fbgemm_gpu.docs.version import __version__ # noqa: F401 | ||
except Exception: | ||
open_source: bool = False |
Oops, something went wrong.