From cf3838f4241d326d7d9ca401fd6c7dfdeed3e99f Mon Sep 17 00:00:00 2001 From: suryasidd Date: Wed, 11 Sep 2024 12:20:36 -0700 Subject: [PATCH 1/5] Added torch compile row in pytorch install table --- _includes/quick_start_local.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/_includes/quick_start_local.html b/_includes/quick_start_local.html index d56c586a2f02..0f4e422efabc 100644 --- a/_includes/quick_start_local.html +++ b/_includes/quick_start_local.html @@ -103,6 +103,29 @@
CPU
+
+
+
Torch Compile
+
+
+
Inductor
+
+
+
CUDA graphs
+
+
+
ONNX Runtime
+
+
+
OpenVINO
+
+
+
TensorRT
+
+
+
TVM
+
+
Run this Command:
From 2026e0a570051b6c46ffd43d41d5734048109a5b Mon Sep 17 00:00:00 2001 From: suryasidd Date: Wed, 11 Sep 2024 22:54:08 -0700 Subject: [PATCH 2/5] Fixed indentation issue --- _includes/quick_start_local.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/quick_start_local.html b/_includes/quick_start_local.html index 0f4e422efabc..441cf7a2e313 100644 --- a/_includes/quick_start_local.html +++ b/_includes/quick_start_local.html @@ -125,7 +125,7 @@
TVM
-
+
Run this Command:
From 602611a40ed0935d6da4e24688f1c96f82cd17d8 Mon Sep 17 00:00:00 2001 From: suryasidd Date: Thu, 12 Sep 2024 00:15:55 -0700 Subject: [PATCH 3/5] Changed the div ids for torch compile --- _includes/quick_start_local.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/_includes/quick_start_local.html b/_includes/quick_start_local.html index 441cf7a2e313..8b3f294a6a21 100644 --- a/_includes/quick_start_local.html +++ b/_includes/quick_start_local.html @@ -24,6 +24,9 @@
Compute Platform
+
+
Torch Compile
+
Run this Command:
@@ -107,22 +110,19 @@
Torch Compile
-
+
Inductor
-
-
CUDA graphs
-
-
-
ONNX Runtime
+
+
CUDA Graphs
-
+
OpenVINO
-
+
TensorRT
-
+
TVM
From 22de8dba754e91fdf3d204bc76aa914ebe4bff35 Mon Sep 17 00:00:00 2001 From: suryasidd Date: Wed, 2 Oct 2024 00:41:11 -0700 Subject: [PATCH 4/5] Added logic for OpenVINO and ONNXRT backends --- _includes/quick-start-module.js | 174 +++++++++++++++++++++++++++++++ _includes/quick_start_local.html | 17 +-- assets/quick-start-module.js | 103 ++++++++++++++++++ 3 files changed, 288 insertions(+), 6 deletions(-) diff --git a/_includes/quick-start-module.js b/_includes/quick-start-module.js index 37da3ab79893..b5e569c95532 100644 --- a/_includes/quick-start-module.js +++ b/_includes/quick-start-module.js @@ -21,6 +21,7 @@ var opts = { pm: 'pip', language: 'python', ptbuild: 'stable', + 'torch-compile': null }; var supportedCloudPlatforms = [ @@ -34,6 +35,7 @@ var package = $(".package > .option"); var language = $(".language > .option"); var cuda = $(".cuda > .option"); var ptbuild = $(".ptbuild > .option"); +var torchCompile = $(".torch-compile > .option") os.on("click", function() { selectedOption(os, this, "os"); @@ -50,6 +52,9 @@ cuda.on("click", function() { ptbuild.on("click", function() { selectedOption(ptbuild, this, "ptbuild") }); +torchCompile.on("click", function() { + selectedOption(torchCompile, this, "torch-compile") +}); // Pre-select user's operating system $(function() { @@ -168,7 +173,96 @@ function changeAccNoneName(osname) { } } +function getIDFromBackend(backend) { + const idTobackendMap = { + inductor: 'inductor', + cgraphs : 'cudagraphs', + onnxrt: 'onnxrt', + openvino: 'openvino', + tensorrt: 'tensorrt', + tvm: 'tvm', + }; + return idTobackendMap[backend] +} + +function getInstallCommand(optionID) { + backend = getIDFromBackend(optionID); + finalCmd = ""; + pipCmdOV = "pip3 install openvino"; + condaCmdOV = "conda install openvino"; + pipCmdOnnx = "pip3 install onnxruntime" + condaCmdOnnx = "conda install onnxruntime"; + if (backend == "openvino") { + if (opts.pm == "pip") { + finalCmd = pipCmdOV; + } + else if (opts.pm == "conda") { + finalCmd = condaCmdOV; + } + } + if(backend == "onnxrt") { + if (opts.pm == "pip") { + finalCmd = pipCmdOnnx; + } + else if (opts.pm == "conda") { + finalCmd = condaCmdOnnx; + } + } + return finalCmd; +} + +function getTorchCompileUsage(optionId) { + backend = getIDFromBackend(optionId); + importCmdOV = "
" + "import openvino.torch" + "
"; + finalCmd = ""; + tcUsage = "# Torch Compile usage: "; + backendCmd = `torch.compile(model, backend="${backend}")`; + finalUsageCmd = tcUsage; + importCmdOnnx = "
" + "import onnxruntime" + "
"; + if (backend == "openvino") { + if (opts.pm == "libtorch") { + return "# Torch compile openvino not supported with Libtorch"; + } + if (opts.pm == "source") { + finalCmd += "# Follow instructions at this URL to build openvino from source: https://github.com/openvinotoolkit/openvino/blob/master/docs/dev/build.md" + "
" ; + tcUsage += importCmdOV; + } + else if (opts.pm == "conda") { + tcUsage += importCmdOV; + } + if (opts.os == "windows" && !tcUsage.includes(importCmdOV)) { + tcUsage += importCmdOV; + } + } + if (backend == "onnxrt") { + tcUsage += importCmdOnnx; + if (opts.pm == "libtorch") { + return "# Torch compile onnxruntime not supported with Libtorch"; + } + if (opts.pm == "source") { + finalCmd += "# Follow instructions at this URL to build onnxruntime from source: https://onnxruntime.ai/docs/build" + "
" ; + } + } + return finalCmd + tcUsage + backendCmd; +} +// Add Torch Compile usage instructions as a command note +function addTorchCompileCommandNote(selectedOptionId) { + console.log(selectedOptionId); + + if (!selectedOptionId) { + return; + } + + $("#command").append( + `
 ${getInstallCommand(selectedOptionId)} 
` + ); + result = getTorchCompileUsage(selectedOptionId); + $("#command").append( + `
 ${result} 
` + ); +} function selectedOption(option, selection, category) { + console.log("Surya Option:", option) $(option).removeClass("selected"); $(selection).addClass("selected"); opts[category] = selection.id; @@ -208,7 +302,87 @@ function selectedOption(option, selection, category) { changeVersion(opts.ptbuild); //make sure unsupported platforms are disabled disableUnsupportedPlatforms(opts.os); + } else if (category === "torch-compile") { + if (selection.id === previousSelection) { + $(selection).removeClass("selected"); + opts[category] = null; + } + } + commandMessage(buildMatcher()); + if (category === "os") { + disableUnsupportedPlatforms(opts.os); + display(opts.os, 'installation', 'os'); + } + changeAccNoneName(opts.os); + addTorchCompileCommandNote(opts['torch-compile']) +} + +function display(selection, id, category) { + var container = document.getElementById(id); + // Check if there's a container to display the selection + if (container === null) { + return; + } + var elements = container.getElementsByClassName(category); + for (var i = 0; i < elements.length; i++) { + if (elements[i].classList.contains(selection)) { + $(elements[i]).addClass("selected"); + } else { + $(elements[i]).removeClass("selected"); + } + } +} + +function buildMatcher() { + return ( + opts.ptbuild.toLowerCase() + + "," + + opts.pm.toLowerCase() + + "," + + opts.os.toLowerCase() + + "," + + opts.cuda.toLowerCase() + + "," + + opts.language.toLowerCase() + ); +} + +// Cloud Partners sub-menu toggle listeners +$("[data-toggle='cloud-dropdown']").on("click", function(e) { + if ($(this).hasClass("open")) { + $(this).removeClass("open"); + // If you deselect a current drop-down item, don't display it's info any longer + display(null, 'cloud', 'platform'); + } else { + $("[data-toggle='cloud-dropdown'].open").removeClass("open"); + $(this).addClass("open"); + var cls = $(this).find(".cloud-option-body")[0].className; + for (var i = 0; i < supportedCloudPlatforms.length; i++) { + if (cls.includes(supportedCloudPlatforms[i])) { + display(supportedCloudPlatforms[i], 'cloud', 'platform'); + } + } } +}); + +function commandMessage(key) { + var object = {"preview,pip,linux,accnone,python": "pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,pip,linux,cuda.x,python": "pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu118", "preview,pip,linux,cuda.y,python": "pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu121", "preview,pip,linux,cuda.z,python": "pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu124", "preview,pip,linux,rocm5.x,python": "pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm6.2", "preview,conda,linux,cuda.x,python": "conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch-nightly -c nvidia", "preview,conda,linux,cuda.y,python": "conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch-nightly -c nvidia", "preview,conda,linux,cuda.z,python": "conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch-nightly -c nvidia", "preview,conda,linux,rocm5.x,python": "NOTE: Conda packages are not currently available for ROCm, please use pip instead
", "preview,conda,linux,accnone,python": "conda install pytorch torchvision torchaudio cpuonly -c pytorch-nightly", "preview,libtorch,linux,accnone,cplusplus": "Download here (Pre-cxx11 ABI):
https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip
Download here (cxx11 ABI):
https://download.pytorch.org/libtorch/nightly/cpu/libtorch-cxx11-abi-shared-with-deps-latest.zip", "preview,libtorch,linux,cuda.x,cplusplus": "Download here (Pre-cxx11 ABI):
https://download.pytorch.org/libtorch/nightly/cu118/libtorch-shared-with-deps-latest.zip
Download here (cxx11 ABI):
https://download.pytorch.org/libtorch/nightly/cu118/libtorch-cxx11-abi-shared-with-deps-latest.zip", "preview,libtorch,linux,cuda.y,cplusplus": "Download here (Pre-cxx11 ABI):
https://download.pytorch.org/libtorch/nightly/cu121/libtorch-shared-with-deps-latest.zip
Download here (cxx11 ABI):
https://download.pytorch.org/libtorch/nightly/cu121/libtorch-cxx11-abi-shared-with-deps-latest.zip", "preview,libtorch,linux,cuda.z,cplusplus": "Download here (Pre-cxx11 ABI):
https://download.pytorch.org/libtorch/nightly/cu124/libtorch-shared-with-deps-latest.zip
Download here (cxx11 ABI):
https://download.pytorch.org/libtorch/nightly/cu124/libtorch-cxx11-abi-shared-with-deps-latest.zip", "preview,libtorch,linux,rocm5.x,cplusplus": "Download here (Pre-cxx11 ABI):
https://download.pytorch.org/libtorch/nightly/rocm6.2/libtorch-shared-with-deps-latest.zip
Download here (cxx11 ABI):
https://download.pytorch.org/libtorch/nightly/rocm6.2/libtorch-cxx11-abi-shared-with-deps-latest.zip", "preview,pip,macos,cuda.x,python": "# CUDA is not available on MacOS, please use default package
pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,pip,macos,cuda.y,python": "# CUDA is not available on MacOS, please use default package
pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,pip,macos,cuda.z,python": "# CUDA is not available on MacOS, please use default package
pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,pip,macos,rocm5.x,python": "# ROCm is not available on MacOS, please use default package
pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,pip,macos,accnone,python": "pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,conda,macos,cuda.x,python": "# CUDA is not available on MacOS, please use default package
conda install pytorch-nightly::pytorch torchvision torchaudio -c pytorch-nightly", "preview,conda,macos,cuda.y,python": "# CUDA is not available on MacOS, please use default package
conda install pytorch-nightly::pytorch torchvision torchaudio -c pytorch-nightly", "preview,conda,macos,cuda.z,python": "# CUDA is not available on MacOS, please use default package
conda install pytorch-nightly::pytorch torchvision torchaudio -c pytorch-nightly", "preview,conda,macos,rocm5.x,python": "# ROCm is not available on MacOS, please use default package
conda install pytorch-nightly::pytorch torchvision torchaudio -c pytorch-nightly", "preview,conda,macos,accnone,python": "conda install pytorch-nightly::pytorch torchvision torchaudio -c pytorch-nightly", "preview,libtorch,macos,accnone,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):
https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip", "preview,libtorch,macos,cuda.x,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):
https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip", "preview,libtorch,macos,cuda.y,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):
https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip", "preview,libtorch,macos,cuda.z,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):
https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip", "preview,libtorch,macos,rocm5.x,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):
https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip", "preview,pip,windows,accnone,python": "pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,pip,windows,cuda.x,python": "pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu118", "preview,pip,windows,cuda.y,python": "pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu121", "preview,pip,windows,cuda.z,python": "pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu124", "preview,pip,windows,rocm5.x,python": "NOTE: ROCm is not available on Windows", "preview,conda,windows,cuda.x,python": "conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch-nightly -c nvidia", "preview,conda,windows,cuda.y,python": "conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch-nightly -c nvidia", "preview,conda,windows,cuda.z,python": "conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch-nightly -c nvidia", "preview,conda,windows,rocm5.x,python": "NOTE: ROCm is not available on Windows", "preview,conda,windows,accnone,python": "conda install pytorch torchvision torchaudio cpuonly -c pytorch-nightly", "preview,libtorch,windows,accnone,cplusplus": "Download here (Release version):
https://download.pytorch.org/libtorch/nightly/cpu/libtorch-win-shared-with-deps-latest.zip
Download here (Debug version):
https://download.pytorch.org/libtorch/nightly/cpu/libtorch-win-shared-with-deps-debug-latest.zip", "preview,libtorch,windows,cuda.x,cplusplus": "Download here (Release version):
https://download.pytorch.org/libtorch/nightly/cu118/libtorch-win-shared-with-deps-latest.zip
Download here (Debug version):
https://download.pytorch.org/libtorch/nightly/cu118/libtorch-win-shared-with-deps-debug-latest.zip", "preview,libtorch,windows,cuda.y,cplusplus": "Download here (Release version):
https://download.pytorch.org/libtorch/nightly/cu121/libtorch-win-shared-with-deps-latest.zip
Download here (Debug version):
https://download.pytorch.org/libtorch/nightly/cu121/libtorch-win-shared-with-deps-debug-latest.zip", "preview,libtorch,windows,cuda.z,cplusplus": "Download here (Release version):
https://download.pytorch.org/libtorch/nightly/cu124/libtorch-win-shared-with-deps-latest.zip
Download here (Debug version):
https://download.pytorch.org/libtorch/nightly/cu124/libtorch-win-shared-with-deps-debug-latest.zip", "preview,libtorch,windows,rocm5.x,cplusplus": "NOTE: ROCm is not available on Windows", "stable,pip,linux,accnone,python": "pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu", "stable,pip,linux,cuda.x,python": "pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118", "stable,pip,linux,cuda.y,python": "pip3 install torch torchvision torchaudio", "stable,pip,linux,cuda.z,python": "pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124", "stable,pip,linux,rocm5.x,python": "pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.1", "stable,conda,linux,cuda.x,python": "conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia", "stable,conda,linux,cuda.y,python": "conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia", "stable,conda,linux,cuda.z,python": "conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia", "stable,conda,linux,rocm5.x,python": "NOTE: Conda packages are not currently available for ROCm, please use pip instead
", "stable,conda,linux,accnone,python": "conda install pytorch torchvision torchaudio cpuonly -c pytorch", "stable,libtorch,linux,accnone,cplusplus": "Download here (Pre-cxx11 ABI):
https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-2.4.1%2Bcpu.zip
Download here (cxx11 ABI):
https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.4.1%2Bcpu.zip", "stable,libtorch,linux,cuda.x,cplusplus": "Download here (Pre-cxx11 ABI):
https://download.pytorch.org/libtorch/cu118/libtorch-shared-with-deps-2.4.1%2Bcu118.zip
Download here (cxx11 ABI):
https://download.pytorch.org/libtorch/cu118/libtorch-cxx11-abi-shared-with-deps-2.4.1%2Bcu118.zip", "stable,libtorch,linux,cuda.y,cplusplus": "Download here (Pre-cxx11 ABI):
https://download.pytorch.org/libtorch/cu121/libtorch-shared-with-deps-2.4.1%2Bcu121.zip
Download here (cxx11 ABI):
https://download.pytorch.org/libtorch/cu121/libtorch-cxx11-abi-shared-with-deps-2.4.1%2Bcu121.zip", "stable,libtorch,linux,cuda.z,cplusplus": "Download here (Pre-cxx11 ABI):
https://download.pytorch.org/libtorch/cu124/libtorch-shared-with-deps-2.4.1%2Bcu124.zip
Download here (cxx11 ABI):
https://download.pytorch.org/libtorch/cu124/libtorch-cxx11-abi-shared-with-deps-2.4.1%2Bcu124.zip", "stable,libtorch,linux,rocm5.x,cplusplus": "Download here (Pre-cxx11 ABI):
https://download.pytorch.org/libtorch/rocm6.1/libtorch-shared-with-deps-2.4.1%2Brocm6.1.zip
Download here (cxx11 ABI):
https://download.pytorch.org/libtorch/rocm6.1/libtorch-cxx11-abi-shared-with-deps-2.4.1%2Brocm6.1.zip", "stable,pip,macos,cuda.x,python": "# CUDA is not available on MacOS, please use default package
pip3 install torch torchvision torchaudio", "stable,pip,macos,cuda.y,python": "# CUDA is not available on MacOS, please use default package
pip3 install torch torchvision torchaudio", "stable,pip,macos,cuda.z,python": "# CUDA is not available on MacOS, please use default package
pip3 install torch torchvision torchaudio", "stable,pip,macos,rocm5.x,python": "# ROCm is not available on MacOS, please use default package
pip3 install torch torchvision torchaudio", "stable,pip,macos,accnone,python": "pip3 install torch torchvision torchaudio", "stable,conda,macos,cuda.x,python": "# CUDA is not available on MacOS, please use default package
conda install pytorch::pytorch torchvision torchaudio -c pytorch", "stable,conda,macos,cuda.y,python": "# CUDA is not available on MacOS, please use default package
conda install pytorch::pytorch torchvision torchaudio -c pytorch", "stable,conda,macos,cuda.z,python": "# CUDA is not available on MacOS, please use default package
conda install pytorch::pytorch torchvision torchaudio -c pytorch", "stable,conda,macos,rocm5.x,python": "# ROCm is not available on MacOS, please use default package
conda install pytorch::pytorch torchvision torchaudio -c pytorch", "stable,conda,macos,accnone,python": "conda install pytorch::pytorch torchvision torchaudio -c pytorch", "stable,libtorch,macos,accnone,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):
https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.4.1.zip", "stable,libtorch,macos,cuda.x,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):
https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.4.1.zip", "stable,libtorch,macos,cuda.y,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):
https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.4.1.zip", "stable,libtorch,macos,cuda.z,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):
https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.4.1.zip", "stable,libtorch,macos,rocm5.x,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):
https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.4.1.zip", "stable,pip,windows,accnone,python": "pip3 install torch torchvision torchaudio", "stable,pip,windows,cuda.x,python": "pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118", "stable,pip,windows,cuda.y,python": "pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121", "stable,pip,windows,cuda.z,python": "pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124", "stable,pip,windows,rocm5.x,python": "NOTE: ROCm is not available on Windows", "stable,conda,windows,cuda.x,python": "conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia", "stable,conda,windows,cuda.y,python": "conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia", "stable,conda,windows,cuda.z,python": "conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia", "stable,conda,windows,rocm5.x,python": "NOTE: ROCm is not available on Windows", "stable,conda,windows,accnone,python": "conda install pytorch torchvision torchaudio cpuonly -c pytorch", "stable,libtorch,windows,accnone,cplusplus": "Download here (Release version):
https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-2.4.1%2Bcpu.zip
Download here (Debug version):
https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-debug-2.4.1%2Bcpu.zip", "stable,libtorch,windows,cuda.x,cplusplus": "Download here (Release version):
https://download.pytorch.org/libtorch/cu118/libtorch-win-shared-with-deps-2.4.1%2Bcu118.zip
Download here (Debug version):
https://download.pytorch.org/libtorch/cu118/libtorch-win-shared-with-deps-debug-2.4.1%2Bcu118.zip", "stable,libtorch,windows,cuda.y,cplusplus": "Download here (Release version):
https://download.pytorch.org/libtorch/cu121/libtorch-win-shared-with-deps-2.4.1%2Bcu121.zip
Download here (Debug version):
https://download.pytorch.org/libtorch/cu121/libtorch-win-shared-with-deps-debug-2.4.1%2Bcu121.zip", "stable,libtorch,windows,cuda.z,cplusplus": "Download here (Release version):
https://download.pytorch.org/libtorch/cu124/libtorch-win-shared-with-deps-2.4.1%2Bcu124.zip
Download here (Debug version):
https://download.pytorch.org/libtorch/cu124/libtorch-win-shared-with-deps-debug-2.4.1%2Bcu124.zip", "stable,libtorch,windows,rocm5.x,cplusplus": "NOTE: ROCm is not available on Windows"}; + + if (!object.hasOwnProperty(key)) { + $("#command").html( + "
 # Follow instructions at this URL: https://github.com/pytorch/pytorch#from-source 
" + ); + } else if (key.indexOf("lts") == 0 && key.indexOf('rocm') < 0) { + $("#command").html("
" + object[key] + "
"); + } else { + $("#command").html("
" + object[key] + "
"); + } +} + +// Set cuda version right away +changeVersion("stable") + + commandMessage(buildMatcher()); if (category === "os") { disableUnsupportedPlatforms(opts.os); diff --git a/_includes/quick_start_local.html b/_includes/quick_start_local.html index 8b3f294a6a21..294af3713220 100644 --- a/_includes/quick_start_local.html +++ b/_includes/quick_start_local.html @@ -106,23 +106,28 @@
CPU
-
+
+
Torch Compile
-
+ +
Inductor
-
+
CUDA Graphs
-
+
OpenVINO
-
+
+
ONNX Runtime
+
+
TensorRT
-
+
TVM
diff --git a/assets/quick-start-module.js b/assets/quick-start-module.js index dfde9363d5e6..13481dfbb678 100644 --- a/assets/quick-start-module.js +++ b/assets/quick-start-module.js @@ -21,6 +21,7 @@ var opts = { pm: 'pip', language: 'python', ptbuild: 'stable', + 'torch-compile': null }; var supportedCloudPlatforms = [ @@ -34,6 +35,7 @@ var package = $(".package > .option"); var language = $(".language > .option"); var cuda = $(".cuda > .option"); var ptbuild = $(".ptbuild > .option"); +var torchCompile = $(".torch-compile > .option") os.on("click", function() { selectedOption(os, this, "os"); @@ -50,6 +52,9 @@ cuda.on("click", function() { ptbuild.on("click", function() { selectedOption(ptbuild, this, "ptbuild") }); +torchCompile.on("click", function() { + selectedOption(torchCompile, this, "torch-compile") +}); // Pre-select user's operating system $(function() { @@ -168,9 +173,101 @@ function changeAccNoneName(osname) { } } +function getIDFromBackend(backend) { + const idTobackendMap = { + inductor: 'inductor', + cgraphs : 'cudagraphs', + onnxrt: 'onnxrt', + openvino: 'openvino', + tensorrt: 'tensorrt', + tvm: 'tvm', + }; + return idTobackendMap[backend] +} + +function getInstallCommand(optionID) { + backend = getIDFromBackend(optionID); + finalCmd = ""; + pipCmdOV = "pip3 install openvino"; + condaCmdOV = "conda install openvino"; + pipCmdOnnx = "pip3 install onnxruntime" + condaCmdOnnx = "conda install onnxruntime"; + if (backend == "openvino") { + if (opts.pm == "pip") { + finalCmd = pipCmdOV; + } + else if (opts.pm == "conda") { + finalCmd = condaCmdOV; + } + } + if(backend == "onnxrt") { + if (opts.pm == "pip") { + finalCmd = pipCmdOnnx; + } + else if (opts.pm == "conda") { + finalCmd = condaCmdOnnx; + } + } + return finalCmd; +} + +function getTorchCompileUsage(optionId) { + backend = getIDFromBackend(optionId); + importCmdOV = "
" + "import openvino.torch" + "
"; + finalCmd = ""; + tcUsage = "# Torch Compile usage: "; + backendCmd = `torch.compile(model, backend="${backend}")`; + finalUsageCmd = tcUsage; + importCmdOnnx = "
" + "import onnxruntime" + "
"; + if (backend == "openvino") { + if (opts.pm == "libtorch") { + return "# Torch compile openvino not supported with Libtorch"; + } + if (opts.pm == "source") { + finalCmd += "# Follow instructions at this URL to build openvino from source: https://github.com/openvinotoolkit/openvino/blob/master/docs/dev/build.md" + "
" ; + tcUsage += importCmdOV; + } + else if (opts.pm == "conda") { + tcUsage += importCmdOV; + } + if (opts.os == "windows" && !tcUsage.includes(importCmdOV)) { + tcUsage += importCmdOV; + } + } + if (backend == "onnxrt") { + tcUsage += importCmdOnnx; + if (opts.pm == "libtorch") { + return "# Torch compile onnxruntime not supported with Libtorch"; + } + if (opts.pm == "source") { + finalCmd += "# Follow instructions at this URL to build onnxruntime from source: https://onnxruntime.ai/docs/build" + "
" ; + } + } + return finalCmd + tcUsage + backendCmd; +} +// Add Torch Compile usage instructions as a command note +function addTorchCompileCommandNote(selectedOptionId) { + console.log(selectedOptionId); + + if (!selectedOptionId) { + return; + } + + $("#command").append( + `
 ${getInstallCommand(selectedOptionId)} 
` + ); + $("#command").append( + `
 ${getTorchCompileUsage(selectedOptionId)} 
` + ); +} + + function selectedOption(option, selection, category) { + console.log("Surya Option:", option) + console.log("Surya prevSel:", opts[category]) $(option).removeClass("selected"); $(selection).addClass("selected"); + const previousSelection = opts[category]; opts[category] = selection.id; if (category === "pm") { var elements = document.getElementsByClassName("language")[0].children; @@ -208,6 +305,11 @@ function selectedOption(option, selection, category) { changeVersion(opts.ptbuild); //make sure unsupported platforms are disabled disableUnsupportedPlatforms(opts.os); + } else if (category === "torch-compile") { + if (selection.id === previousSelection) { + $(selection).removeClass("selected"); + opts[category] = null; + } } commandMessage(buildMatcher()); if (category === "os") { @@ -215,6 +317,7 @@ function selectedOption(option, selection, category) { display(opts.os, 'installation', 'os'); } changeAccNoneName(opts.os); + addTorchCompileCommandNote(opts['torch-compile']) } function display(selection, id, category) { From 3b2249a22788e4b4bf258013d7932b7a1997fdad Mon Sep 17 00:00:00 2001 From: suryasidd Date: Fri, 4 Oct 2024 10:27:24 -0700 Subject: [PATCH 5/5] Cleaned up the functions --- _includes/quick-start-module.js | 97 ++++++++++++++++++-------------- _includes/quick_start_local.html | 2 +- assets/quick-start-module.js | 92 +++++++++++++++++------------- 3 files changed, 110 insertions(+), 81 deletions(-) diff --git a/_includes/quick-start-module.js b/_includes/quick-start-module.js index b5e569c95532..0ffaaaf969a4 100644 --- a/_includes/quick-start-module.js +++ b/_includes/quick-start-module.js @@ -182,72 +182,88 @@ function getIDFromBackend(backend) { tensorrt: 'tensorrt', tvm: 'tvm', }; - return idTobackendMap[backend] + return idTobackendMap[backend]; +} + +function getPmCmd(backend) { + const pmCmd = { + onnxrt: 'onnxruntime', + tvm: 'apache-tvm', + openvino: 'openvino', + tensorrt: 'torch-tensorrt', + }; + return pmCmd[backend]; +} + +function getImportCmd(backend) { + const importCmd = { + onnxrt: 'import onnxruntime', + tvm: 'import tvm', + openvino: 'import openvino.torch', + tensorrt: 'import torch_tensorrt' + } + return importCmd[backend]; } function getInstallCommand(optionID) { backend = getIDFromBackend(optionID); + pmCmd = getPmCmd(optionID); finalCmd = ""; - pipCmdOV = "pip3 install openvino"; - condaCmdOV = "conda install openvino"; - pipCmdOnnx = "pip3 install onnxruntime" - condaCmdOnnx = "conda install onnxruntime"; - if (backend == "openvino") { - if (opts.pm == "pip") { - finalCmd = pipCmdOV; - } - else if (opts.pm == "conda") { - finalCmd = condaCmdOV; - } - } - if(backend == "onnxrt") { - if (opts.pm == "pip") { - finalCmd = pipCmdOnnx; - } - else if (opts.pm == "conda") { - finalCmd = condaCmdOnnx; - } - } + if (opts.pm == "pip") { + finalCmd = `pip3 install ${pmCmd}`; + } + else if (opts.pm == "conda") { + finalCmd = `conda install ${pmCmd}`; + } return finalCmd; } function getTorchCompileUsage(optionId) { backend = getIDFromBackend(optionId); - importCmdOV = "
" + "import openvino.torch" + "
"; + importCmd = "
" + getImportCmd(optionId) + "
"; finalCmd = ""; tcUsage = "# Torch Compile usage: "; backendCmd = `torch.compile(model, backend="${backend}")`; - finalUsageCmd = tcUsage; - importCmdOnnx = "
" + "import onnxruntime" + "
"; + libtorchCmd = `# Torch compile ${backend} not supported with Libtorch`; + + if (opts.pm == "libtorch") { + return libtorchCmd; + } if (backend == "openvino") { - if (opts.pm == "libtorch") { - return "# Torch compile openvino not supported with Libtorch"; - } if (opts.pm == "source") { finalCmd += "# Follow instructions at this URL to build openvino from source: https://github.com/openvinotoolkit/openvino/blob/master/docs/dev/build.md" + "
" ; - tcUsage += importCmdOV; + tcUsage += importCmd; } else if (opts.pm == "conda") { - tcUsage += importCmdOV; + tcUsage += importCmd; } - if (opts.os == "windows" && !tcUsage.includes(importCmdOV)) { - tcUsage += importCmdOV; + if (opts.os == "windows" && !tcUsage.includes(importCmd)) { + tcUsage += importCmd; } } + else{ + tcUsage += importCmd; + } if (backend == "onnxrt") { - tcUsage += importCmdOnnx; - if (opts.pm == "libtorch") { - return "# Torch compile onnxruntime not supported with Libtorch"; - } if (opts.pm == "source") { finalCmd += "# Follow instructions at this URL to build onnxruntime from source: https://onnxruntime.ai/docs/build" + "
" ; } } - return finalCmd + tcUsage + backendCmd; + if (backend == "tvm") { + if (opts.pm == "source") { + finalCmd += "# Follow instructions at this URL to build tvm from source: https://tvm.apache.org/docs/install/from_source.html" + "
" ; + } + } + if (backend == "tensorrt") { + if (opts.pm == "source") { + finalCmd += "# Follow instructions at this URL to build tensorrt from source: https://pytorch.org/TensorRT/getting_started/installation.html#compiling-from-source" + "
" ; + } + } + finalCmd += tcUsage + backendCmd; + return finalCmd } -// Add Torch Compile usage instructions as a command note + function addTorchCompileCommandNote(selectedOptionId) { - console.log(selectedOptionId); if (!selectedOptionId) { return; @@ -256,13 +272,12 @@ function addTorchCompileCommandNote(selectedOptionId) { $("#command").append( `
 ${getInstallCommand(selectedOptionId)} 
` ); - result = getTorchCompileUsage(selectedOptionId); $("#command").append( - `
 ${result} 
` + `
 ${getTorchCompileUsage(selectedOptionId)} 
` ); } + function selectedOption(option, selection, category) { - console.log("Surya Option:", option) $(option).removeClass("selected"); $(selection).addClass("selected"); opts[category] = selection.id; diff --git a/_includes/quick_start_local.html b/_includes/quick_start_local.html index 294af3713220..cd59dccca14c 100644 --- a/_includes/quick_start_local.html +++ b/_includes/quick_start_local.html @@ -124,7 +124,7 @@
ONNX Runtime
-
+
TensorRT
diff --git a/assets/quick-start-module.js b/assets/quick-start-module.js index 13481dfbb678..fd2d1be1cc8d 100644 --- a/assets/quick-start-module.js +++ b/assets/quick-start-module.js @@ -182,72 +182,88 @@ function getIDFromBackend(backend) { tensorrt: 'tensorrt', tvm: 'tvm', }; - return idTobackendMap[backend] + return idTobackendMap[backend]; +} + +function getPmCmd(backend) { + const pmCmd = { + onnxrt: 'onnxruntime', + tvm: 'apache-tvm', + openvino: 'openvino', + tensorrt: 'torch-tensorrt', + }; + return pmCmd[backend]; +} + +function getImportCmd(backend) { + const importCmd = { + onnxrt: 'import onnxruntime', + tvm: 'import tvm', + openvino: 'import openvino.torch', + tensorrt: 'import torch_tensorrt' + } + return importCmd[backend]; } function getInstallCommand(optionID) { backend = getIDFromBackend(optionID); + pmCmd = getPmCmd(optionID); finalCmd = ""; - pipCmdOV = "pip3 install openvino"; - condaCmdOV = "conda install openvino"; - pipCmdOnnx = "pip3 install onnxruntime" - condaCmdOnnx = "conda install onnxruntime"; - if (backend == "openvino") { - if (opts.pm == "pip") { - finalCmd = pipCmdOV; - } - else if (opts.pm == "conda") { - finalCmd = condaCmdOV; - } - } - if(backend == "onnxrt") { - if (opts.pm == "pip") { - finalCmd = pipCmdOnnx; - } - else if (opts.pm == "conda") { - finalCmd = condaCmdOnnx; - } - } + if (opts.pm == "pip") { + finalCmd = `pip3 install ${pmCmd}`; + } + else if (opts.pm == "conda") { + finalCmd = `conda install ${pmCmd}`; + } return finalCmd; } function getTorchCompileUsage(optionId) { backend = getIDFromBackend(optionId); - importCmdOV = "
" + "import openvino.torch" + "
"; + importCmd = "
" + getImportCmd(optionId) + "
"; finalCmd = ""; tcUsage = "# Torch Compile usage: "; backendCmd = `torch.compile(model, backend="${backend}")`; - finalUsageCmd = tcUsage; - importCmdOnnx = "
" + "import onnxruntime" + "
"; + libtorchCmd = `# Torch compile ${backend} not supported with Libtorch`; + + if (opts.pm == "libtorch") { + return libtorchCmd; + } if (backend == "openvino") { - if (opts.pm == "libtorch") { - return "# Torch compile openvino not supported with Libtorch"; - } if (opts.pm == "source") { finalCmd += "# Follow instructions at this URL to build openvino from source: https://github.com/openvinotoolkit/openvino/blob/master/docs/dev/build.md" + "
" ; - tcUsage += importCmdOV; + tcUsage += importCmd; } else if (opts.pm == "conda") { - tcUsage += importCmdOV; + tcUsage += importCmd; } - if (opts.os == "windows" && !tcUsage.includes(importCmdOV)) { - tcUsage += importCmdOV; + if (opts.os == "windows" && !tcUsage.includes(importCmd)) { + tcUsage += importCmd; } } + else{ + tcUsage += importCmd; + } if (backend == "onnxrt") { - tcUsage += importCmdOnnx; - if (opts.pm == "libtorch") { - return "# Torch compile onnxruntime not supported with Libtorch"; - } if (opts.pm == "source") { finalCmd += "# Follow instructions at this URL to build onnxruntime from source: https://onnxruntime.ai/docs/build" + "
" ; } } - return finalCmd + tcUsage + backendCmd; + if (backend == "tvm") { + if (opts.pm == "source") { + finalCmd += "# Follow instructions at this URL to build tvm from source: https://tvm.apache.org/docs/install/from_source.html" + "
" ; + } + } + if (backend == "tensorrt") { + if (opts.pm == "source") { + finalCmd += "# Follow instructions at this URL to build tensorrt from source: https://pytorch.org/TensorRT/getting_started/installation.html#compiling-from-source" + "
" ; + } + } + finalCmd += tcUsage + backendCmd; + return finalCmd } // Add Torch Compile usage instructions as a command note function addTorchCompileCommandNote(selectedOptionId) { - console.log(selectedOptionId); if (!selectedOptionId) { return; @@ -263,8 +279,6 @@ function addTorchCompileCommandNote(selectedOptionId) { function selectedOption(option, selection, category) { - console.log("Surya Option:", option) - console.log("Surya prevSel:", opts[category]) $(option).removeClass("selected"); $(selection).addClass("selected"); const previousSelection = opts[category];