diff --git a/.github/scripts/install-torch-tensorrt.sh b/.github/scripts/install-torch-tensorrt.sh index c567a6f172..94de5f022a 100755 --- a/.github/scripts/install-torch-tensorrt.sh +++ b/.github/scripts/install-torch-tensorrt.sh @@ -18,7 +18,7 @@ pip install --pre -r ${PWD}/tests/py/requirements.txt # eg. timm will install the latest torchvision, however we want to use the torchvision from nightly # reinstall torch torchvisionto make sure we have the correct version pip uninstall -y torch torchvision -pip install --force-reinstall --pre ${TORCHVISION} --index-url ${INDEX_URL} --no-deps +pip install --force-reinstall --pre ${TORCHVISION} --index-url ${INDEX_URL} pip install --force-reinstall --pre ${TORCH} --index-url ${INDEX_URL} diff --git a/MODULE.bazel b/MODULE.bazel index 1ecaebba28..59196b85be 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -52,7 +52,7 @@ new_local_repository( new_local_repository( name = "cuda_win", build_file = "@//third_party/cuda:BUILD", - path = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8/", + path = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.9/", ) http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") @@ -66,7 +66,7 @@ http_archive( name = "libtorch", build_file = "@//third_party/libtorch:BUILD", strip_prefix = "libtorch", - urls = ["https://download.pytorch.org/libtorch/nightly/cu128/libtorch-shared-with-deps-latest.zip"], + urls = ["https://download.pytorch.org/libtorch/nightly/cu129/libtorch-shared-with-deps-latest.zip"], ) # in aarch64 platform you can get libtorch via either local or wheel file @@ -84,7 +84,7 @@ http_archive( name = "libtorch_win", build_file = "@//third_party/libtorch:BUILD", strip_prefix = "libtorch", - urls = ["https://download.pytorch.org/libtorch/nightly/cu128/libtorch-win-shared-with-deps-latest.zip"], + urls = ["https://download.pytorch.org/libtorch/nightly/cu129/libtorch-win-shared-with-deps-latest.zip"], ) http_archive( diff --git a/setup.py b/setup.py index 59e2babfcd..fb96d85453 100644 --- a/setup.py +++ b/setup.py @@ -215,7 +215,6 @@ def build_libtorchtrt_cxx11_abi( print("Jetpack build") if IS_SBSA: - cmd.append("--platforms=//toolchains:sbsa") print("SBSA build") if CI_BUILD: diff --git a/tests/modules/hub.py b/tests/modules/hub.py index 962a8b0309..80dd37cd4a 100644 --- a/tests/modules/hub.py +++ b/tests/modules/hub.py @@ -1,16 +1,14 @@ import importlib +import importlib.util import json import os import custom_models as cm import torch -if importlib.util.find_spec("torchvision"): - import timm - import torchvision.models as models - torch.hub._validate_not_a_forked_repo = lambda a, b, c: True + torch_version = torch.__version__ # Detect case of no GPU before deserialization of models on GPU @@ -22,7 +20,71 @@ # Downloads all model files again if manifest file is not present MANIFEST_FILE = "model_manifest.json" -to_test_models = {} +to_test_models = { + "pooling": {"model": cm.Pool(), "path": "trace"}, + "module_fallback": {"model": cm.ModuleFallbackMain(), "path": "script"}, + "loop_fallback_eval": {"model": cm.LoopFallbackEval(), "path": "script"}, + "loop_fallback_no_eval": {"model": cm.LoopFallbackNoEval(), "path": "script"}, + "conditional": {"model": cm.FallbackIf(), "path": "script"}, + "inplace_op_if": {"model": cm.FallbackInplaceOPIf(), "path": "script"}, + "standard_tensor_input": {"model": cm.StandardTensorInput(), "path": "script"}, + "tuple_input": {"model": cm.TupleInput(), "path": "script"}, + "list_input": {"model": cm.ListInput(), "path": "script"}, + "tuple_input_output": {"model": cm.TupleInputOutput(), "path": "script"}, + "list_input_output": {"model": cm.ListInputOutput(), "path": "script"}, + "list_input_tuple_output": { + "model": cm.ListInputTupleOutput(), + "path": "script", + }, + # "bert_base_uncased": {"model": cm.BertModule(), "path": "trace"}, +} + +if importlib.util.find_spec("torchvision"): + import timm + import torchvision.models as models + + torchvision_models = { + "alexnet": {"model": models.alexnet(pretrained=True), "path": "both"}, + "vgg16": {"model": models.vgg16(pretrained=True), "path": "both"}, + "squeezenet": {"model": models.squeezenet1_0(pretrained=True), "path": "both"}, + "densenet": {"model": models.densenet161(pretrained=True), "path": "both"}, + "inception_v3": {"model": models.inception_v3(pretrained=True), "path": "both"}, + "shufflenet": { + "model": models.shufflenet_v2_x1_0(pretrained=True), + "path": "both", + }, + "mobilenet_v2": {"model": models.mobilenet_v2(pretrained=True), "path": "both"}, + "resnext50_32x4d": { + "model": models.resnext50_32x4d(pretrained=True), + "path": "both", + }, + "wideresnet50_2": { + "model": models.wide_resnet50_2(pretrained=True), + "path": "both", + }, + "mnasnet": {"model": models.mnasnet1_0(pretrained=True), "path": "both"}, + "resnet18": { + "model": torch.hub.load( + "pytorch/vision:v0.9.0", "resnet18", pretrained=True + ), + "path": "both", + }, + "resnet50": { + "model": torch.hub.load( + "pytorch/vision:v0.9.0", "resnet50", pretrained=True + ), + "path": "both", + }, + "efficientnet_b0": { + "model": timm.create_model("efficientnet_b0", pretrained=True), + "path": "script", + }, + "vit": { + "model": timm.create_model("vit_base_patch16_224", pretrained=True), + "path": "script", + }, + } + to_test_models.update(torchvision_models) def get(n, m, manifest): @@ -77,67 +139,6 @@ def download_models(version_matches, manifest): def main(): - if not importlib.util.find_spec("torchvision"): - print(f"torchvision is not installed, skip models download") - return - - to_test_models = { - "alexnet": {"model": models.alexnet(pretrained=True), "path": "both"}, - "vgg16": {"model": models.vgg16(pretrained=True), "path": "both"}, - "squeezenet": {"model": models.squeezenet1_0(pretrained=True), "path": "both"}, - "densenet": {"model": models.densenet161(pretrained=True), "path": "both"}, - "inception_v3": {"model": models.inception_v3(pretrained=True), "path": "both"}, - "shufflenet": { - "model": models.shufflenet_v2_x1_0(pretrained=True), - "path": "both", - }, - "mobilenet_v2": {"model": models.mobilenet_v2(pretrained=True), "path": "both"}, - "resnext50_32x4d": { - "model": models.resnext50_32x4d(pretrained=True), - "path": "both", - }, - "wideresnet50_2": { - "model": models.wide_resnet50_2(pretrained=True), - "path": "both", - }, - "mnasnet": {"model": models.mnasnet1_0(pretrained=True), "path": "both"}, - "resnet18": { - "model": torch.hub.load( - "pytorch/vision:v0.9.0", "resnet18", pretrained=True - ), - "path": "both", - }, - "resnet50": { - "model": torch.hub.load( - "pytorch/vision:v0.9.0", "resnet50", pretrained=True - ), - "path": "both", - }, - "efficientnet_b0": { - "model": timm.create_model("efficientnet_b0", pretrained=True), - "path": "script", - }, - "vit": { - "model": timm.create_model("vit_base_patch16_224", pretrained=True), - "path": "script", - }, - "pooling": {"model": cm.Pool(), "path": "trace"}, - "module_fallback": {"model": cm.ModuleFallbackMain(), "path": "script"}, - "loop_fallback_eval": {"model": cm.LoopFallbackEval(), "path": "script"}, - "loop_fallback_no_eval": {"model": cm.LoopFallbackNoEval(), "path": "script"}, - "conditional": {"model": cm.FallbackIf(), "path": "script"}, - "inplace_op_if": {"model": cm.FallbackInplaceOPIf(), "path": "script"}, - "standard_tensor_input": {"model": cm.StandardTensorInput(), "path": "script"}, - "tuple_input": {"model": cm.TupleInput(), "path": "script"}, - "list_input": {"model": cm.ListInput(), "path": "script"}, - "tuple_input_output": {"model": cm.TupleInputOutput(), "path": "script"}, - "list_input_output": {"model": cm.ListInputOutput(), "path": "script"}, - "list_input_tuple_output": { - "model": cm.ListInputTupleOutput(), - "path": "script", - }, - # "bert_base_uncased": {"model": cm.BertModule(), "path": "trace"}, - } manifest = None version_matches = False diff --git a/tests/py/dynamo/automatic_plugin/test_flashinfer_rmsnorm.py b/tests/py/dynamo/automatic_plugin/test_flashinfer_rmsnorm.py index cf803c5ffa..389063ecd8 100644 --- a/tests/py/dynamo/automatic_plugin/test_flashinfer_rmsnorm.py +++ b/tests/py/dynamo/automatic_plugin/test_flashinfer_rmsnorm.py @@ -1,8 +1,7 @@ -import pytest - -flashinfer = pytest.importorskip("flashinfer") +import importlib import unittest +import pytest import torch import torch.nn as nn import torch_tensorrt @@ -12,6 +11,9 @@ from ..conversion.harness import DispatchTestCase +if importlib.util.find_spec("flashinfer"): + import flashinfer + @torch.library.custom_op("flashinfer::rmsnorm", mutates_args=()) # type: ignore[misc] def flashinfer_rmsnorm( @@ -31,6 +33,7 @@ def _(input: torch.Tensor, weight: torch.Tensor, b: float = 1e-6) -> torch.Tenso @unittest.skip("Not Available") +@unittest.skipIf(not importlib.util.find_spec("flashinfer"), "flashinfer not installed") class TestAutomaticPlugin(DispatchTestCase): @parameterized.expand( [