From ae1c7ea16fa99f6fbf5703cfe5a5618e43b945b5 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Wed, 25 Jun 2025 15:13:05 -0700 Subject: [PATCH 1/5] fix bug --- tests/modules/hub.py | 119 +++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 62 deletions(-) diff --git a/tests/modules/hub.py b/tests/modules/hub.py index 962a8b0309..2d82ac442e 100644 --- a/tests/modules/hub.py +++ b/tests/modules/hub.py @@ -19,10 +19,66 @@ "No GPU found. Please check if installed torch version is compatible with CUDA version" ) +if not importlib.util.find_spec("torchvision"): + print(f"torchvision is not installed, skip models download") + exit(0) + # Downloads all model files again if manifest file is not present MANIFEST_FILE = "model_manifest.json" -to_test_models = {} +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"}, +} def get(n, m, manifest): @@ -77,67 +133,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 From d0caab91e355631f583e46013c49503ebe24341e Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Wed, 25 Jun 2025 16:21:26 -0700 Subject: [PATCH 2/5] fix flashinfer issue --- .../dynamo/automatic_plugin/test_flashinfer_rmsnorm.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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( [ From ca84874b1fb263c58c92f45d3c6f379ee19f4b5c Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Thu, 26 Jun 2025 08:38:08 -0700 Subject: [PATCH 3/5] resolve comments --- MODULE.bazel | 6 +-- tests/modules/hub.py | 92 +++++++++++++++++++++++--------------------- 2 files changed, 52 insertions(+), 46 deletions(-) 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/tests/modules/hub.py b/tests/modules/hub.py index 2d82ac442e..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 @@ -19,49 +17,10 @@ "No GPU found. Please check if installed torch version is compatible with CUDA version" ) -if not importlib.util.find_spec("torchvision"): - print(f"torchvision is not installed, skip models download") - exit(0) - # Downloads all model files again if manifest file is not present MANIFEST_FILE = "model_manifest.json" 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"}, @@ -80,6 +39,53 @@ # "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): print("Downloading {}".format(n)) From 6d5fcd11d4cb213a8f4942cbe5417fe4070efef0 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Thu, 26 Jun 2025 13:27:50 -0700 Subject: [PATCH 4/5] test --- .github/scripts/install-torch-tensorrt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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} From c902569a462150d7d697880acbbc6c540102460c Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Thu, 26 Jun 2025 13:40:32 -0700 Subject: [PATCH 5/5] test --- setup.py | 1 - 1 file changed, 1 deletion(-) 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: