-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update on "nn.Linear with BSR inputs: spare the user from explicit Tr…
…iton kernel registrations" <!-- copilot:summary --> ### <samp>🤖 Generated by Copilot at 08f7a6a</samp> This pull request adds support for triton kernels in `torch` and `torch/cuda`, and refactors and tests the existing triton kernel for BSR matrix multiplication. It also adds a test case to ensure that importing `torch` does not implicitly import `triton`. cc alexsamardzic pearu cpuhrsch amjames bhosmer albanD mruberry jbschlosser walterddr mikaylagawarecki [ghstack-poisoned]
- Loading branch information
Showing
39 changed files
with
616 additions
and
225 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
7d1a95b04654ff9c216afe08a454ad0822f05370 | ||
9820899b3845e461d9031dba66062efade65d420 |
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,34 @@ | ||
FROM mcr.microsoft.com/vscode/devcontainers/miniconda:0-3 | ||
|
||
# I am suprised this is needed | ||
RUN conda init | ||
|
||
# Copy environment.yml (if found) to a temp location so we update the environment. Also | ||
# copy "noop.txt" so the COPY instruction does not fail if no environment.yml exists. | ||
COPY .devcontainer/cuda/environment.yml .devcontainer/noop.txt /tmp/conda-tmp/ | ||
RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then umask 0002 && /opt/conda/bin/conda env update -n base -f /tmp/conda-tmp/environment.yml; fi \ | ||
&& sudo rm -rf /tmp/conda-tmp | ||
|
||
# Tools needed for llvm | ||
RUN sudo apt-get -y update | ||
RUN sudo apt install -y lsb-release wget software-properties-common gnupg | ||
|
||
# Install CLANG if version is specified | ||
ARG CLANG_VERSION | ||
RUN if [ -n "$CLANG_VERSION" ]; then \ | ||
sudo wget https://apt.llvm.org/llvm.sh; \ | ||
chmod +x llvm.sh; \ | ||
sudo ./llvm.sh "${CLANG_VERSION}"; \ | ||
echo 'export CC=clang' >> ~/.bashrc; \ | ||
echo 'export CXX=clang++' >> ~/.bashrc; \ | ||
sudo apt update; \ | ||
sudo apt install -y clang; \ | ||
sudo apt install -y libomp-dev; \ | ||
fi | ||
|
||
|
||
# Install cuda if version is specified | ||
ARG CUDA_VERSION | ||
RUN if [ -n "$CUDA_VERSION" ]; then \ | ||
conda install cuda -c "nvidia/label/cuda-${CUDA_VERSION}"; \ | ||
fi |
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,37 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/anaconda | ||
{ | ||
"name": "PyTorch - CPU", | ||
"build": { | ||
"context": "../..", | ||
"dockerfile": "../Dockerfile", | ||
"args": { | ||
"USERNAME": "vscode", | ||
"BUILDKIT_INLINE_CACHE": "0", | ||
"CLANG_VERSION": "" | ||
} | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
// This is needed for lintrunner | ||
"ghcr.io/devcontainers/features/rust:1" : {} | ||
}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "bash .devcontainer/scripts/install-dev-tools.sh", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": ["streetsidesoftware.code-spell-checker"] | ||
} | ||
} | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
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,6 @@ | ||
# This environment is specific to Debian | ||
name: PyTorch | ||
dependencies: | ||
- cmake | ||
- ninja | ||
- libopenblas |
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,37 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/anaconda | ||
{ | ||
"name": "PyTorch - CUDA", | ||
"build": { | ||
"context": "../..", | ||
"dockerfile": "../Dockerfile", | ||
"args": { | ||
"USERNAME": "vscode", | ||
"BUILDKIT_INLINE_CACHE": "0", | ||
"CUDA_VERSION": "11.8.0", | ||
"CLANG_VERSION": "" | ||
} | ||
}, | ||
"runArgs": ["--gpus", "all"], | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "bash .devcontainer/scripts/install-dev-tools.sh", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": ["streetsidesoftware.code-spell-checker"] | ||
} | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
// This is needed for lintrunner | ||
"ghcr.io/devcontainers/features/rust:1" : {} | ||
} | ||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
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,6 @@ | ||
# This environment is specific to Debian | ||
name: PyTorch | ||
dependencies: | ||
- cmake | ||
- ninja | ||
- libopenblas |
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,3 @@ | ||
This file copied into the container along with environment.yml* from the parent | ||
folder. This file is included to prevents the Dockerfile COPY instruction from | ||
failing if no environment.yml is found. |
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,11 @@ | ||
#!/usr/bin/env bash | ||
# Run this command from the PyTorch directory after cloning the source code using the “Get the PyTorch Source“ section below | ||
pip install -r requirements.txt | ||
git submodule sync | ||
git submodule update --init --recursive | ||
|
||
# This takes some time | ||
make setup_lint | ||
|
||
# Add CMAKE_PREFIX_PATH to bashrc | ||
echo 'export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}' >> ~/.bashrc |
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,38 @@ | ||
#!/usr/bin/env bash | ||
# update_alternatives_clang.sh | ||
# chmod u+x update_alternatives_clang.sh | ||
# | ||
|
||
update_alternatives() { | ||
local version=${1} | ||
local priority=${2} | ||
local z=${3} | ||
local slaves=${4} | ||
local path=${5} | ||
local cmdln | ||
|
||
cmdln="--verbose --install ${path}${master} ${master} ${path}${master}-${version} ${priority}" | ||
for slave in ${slaves}; do | ||
cmdln="${cmdln} --slave ${path}${slave} ${slave} ${path}${slave}-${version}" | ||
done | ||
sudo update-alternatives ${cmdln} | ||
} | ||
|
||
if [[ ${#} -ne 2 ]]; then | ||
echo usage: "${0}" clang_version priority | ||
exit 1 | ||
fi | ||
|
||
version=${1} | ||
priority=${2} | ||
path="/usr/bin/" | ||
|
||
master="llvm-config" | ||
slaves="llvm-addr2line llvm-ar llvm-as llvm-bcanalyzer llvm-bitcode-strip llvm-cat llvm-cfi-verify llvm-cov llvm-c-test llvm-cvtres llvm-cxxdump llvm-cxxfilt llvm-cxxmap llvm-debuginfod llvm-debuginfod-find llvm-diff llvm-dis llvm-dlltool llvm-dwarfdump llvm-dwarfutil llvm-dwp llvm-exegesis llvm-extract llvm-gsymutil llvm-ifs llvm-install-name-tool llvm-jitlink llvm-jitlink-executor llvm-lib llvm-libtool-darwin llvm-link llvm-lipo llvm-lto llvm-lto2 llvm-mc llvm-mca llvm-ml llvm-modextract llvm-mt llvm-nm llvm-objcopy llvm-objdump llvm-omp-device-info llvm-opt-report llvm-otool llvm-pdbutil llvm-PerfectShuffle llvm-profdata llvm-profgen llvm-ranlib llvm-rc llvm-readelf llvm-readobj llvm-reduce llvm-remark-size-diff llvm-rtdyld llvm-sim llvm-size llvm-split llvm-stress llvm-strings llvm-strip llvm-symbolizer llvm-tapi-diff llvm-tblgen llvm-tli-checker llvm-undname llvm-windres llvm-xray" | ||
|
||
update_alternatives "${version}" "${priority}" "${master}" "${slaves}" "${path}" | ||
|
||
master="clang" | ||
slaves="analyze-build asan_symbolize bugpoint c-index-test clang++ clang-apply-replacements clang-change-namespace clang-check clang-cl clang-cpp clangd clang-doc clang-extdef-mapping clang-format clang-format-diff clang-include-fixer clang-linker-wrapper clang-move clang-nvlink-wrapper clang-offload-bundler clang-offload-packager clang-offload-wrapper clang-pseudo clang-query clang-refactor clang-rename clang-reorder-fields clang-repl clang-scan-deps clang-tidy count diagtool dsymutil FileCheck find-all-symbols git-clang-format hmaptool hwasan_symbolize intercept-build ld64.lld ld.lld llc lld lldb lldb-argdumper lldb-instr lldb-server lldb-vscode lld-link lli lli-child-target modularize not obj2yaml opt pp-trace run-clang-tidy sancov sanstats scan-build scan-build-py scan-view split-file UnicodeNameMappingGenerator verify-uselistorder wasm-ld yaml2obj yaml-bench" | ||
|
||
update_alternatives "${version}" "${priority}" "${master}" "${slaves}" "${path}" |
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
Oops, something went wrong.