Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross compile for windows #3220

Open
wants to merge 56 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
458a4d1
skip run_shape_analysis
lanluo-nvidia Oct 6, 2024
2f408f9
test
lanluo-nvidia Oct 6, 2024
1c5e86c
test
lanluo-nvidia Oct 6, 2024
ba487dc
test
lanluo-nvidia Oct 6, 2024
99d2274
Merge branch 'main' into lluo/save_remove_inputs
lanluo-nvidia Oct 6, 2024
2b43480
test
lanluo-nvidia Oct 6, 2024
92105ce
cross compile for windows initial check in
lanluo-nvidia Oct 7, 2024
dd24bdf
test
lanluo-nvidia Oct 7, 2024
e6c9fa4
add testcase
lanluo-nvidia Oct 7, 2024
9909eca
add test case
lanluo-nvidia Oct 8, 2024
312a79e
add test case
lanluo-nvidia Oct 8, 2024
b4e02e1
Merge branch 'main' into lluo/save_remove_inputs
lanluo-nvidia Oct 11, 2024
3d94f8b
test
lanluo-nvidia Oct 13, 2024
f43669a
Merge branch 'lluo/save_remove_inputs' into lluo/cross_compilation_fo…
lanluo-nvidia Oct 13, 2024
f4d0d27
test
lanluo-nvidia Oct 14, 2024
2a43ca1
add more logs
lanluo-nvidia Oct 14, 2024
76ddd66
test
lanluo-nvidia Oct 15, 2024
28ba6cc
Merge branch 'main' into lluo/save_remove_inputs
lanluo-nvidia Oct 15, 2024
b89cbe0
resolve comments
lanluo-nvidia Oct 15, 2024
079c4be
test
lanluo-nvidia Oct 15, 2024
90f1a60
clean up
lanluo-nvidia Oct 16, 2024
c38dc5b
test
lanluo-nvidia Oct 16, 2024
2843d37
Merge branch 'main' into lluo/save_remove_inputs
lanluo-nvidia Oct 16, 2024
b06a41b
Merge branch 'lluo/save_remove_inputs' into lluo/cross_compilation_fo…
lanluo-nvidia Oct 16, 2024
3eb48d7
test
lanluo-nvidia Oct 16, 2024
fedc5c2
Merge branch 'lluo/save_remove_inputs' into lluo/cross_compilation_fo…
lanluo-nvidia Oct 16, 2024
50eb0d8
replace dummy inference
lanluo-nvidia Oct 20, 2024
95ed602
test
lanluo-nvidia Oct 20, 2024
120f30d
test
lanluo-nvidia Oct 21, 2024
424cbf7
add run_test_with_dynamic_shape change
lanluo-nvidia Oct 21, 2024
2fc9cef
Merge branch 'main' into lluo/save_remove_inputs
lanluo-nvidia Oct 21, 2024
ef54cfc
split the PR, add dummy inference for converter test
lanluo-nvidia Oct 21, 2024
14f5d61
test
lanluo-nvidia Oct 22, 2024
7563959
test
lanluo-nvidia Oct 22, 2024
77355f0
test
lanluo-nvidia Oct 22, 2024
13361fd
add linear lowering meta val
lanluo-nvidia Oct 22, 2024
f0a9fef
add linear_lowering change
lanluo-nvidia Oct 23, 2024
cff64a4
test
lanluo-nvidia Oct 23, 2024
933abac
test
lanluo-nvidia Oct 23, 2024
8417684
resolve comments
lanluo-nvidia Oct 25, 2024
8676f88
test
lanluo-nvidia Oct 25, 2024
785d0b1
change solution: use no_op_placeholder during save and replace it wit…
lanluo-nvidia Oct 26, 2024
b85cb74
Merge branch 'lluo/save_remove_inputs' into lluo/cross_compilation_fo…
lanluo-nvidia Oct 26, 2024
5d594b1
test
lanluo-nvidia Oct 26, 2024
076f47a
resolve comments
lanluo-nvidia Oct 29, 2024
8250179
Merge branch 'main' into lluo/save_remove_inputs
lanluo-nvidia Oct 29, 2024
96e93e4
resolve comments
lanluo-nvidia Oct 29, 2024
7d055bf
Merge branch 'lluo/save_remove_inputs' into lluo/cross_compilation_fo…
lanluo-nvidia Oct 30, 2024
6e214d6
Merge branch 'main' into lluo/cross_compilation_for_windows
lanluo-nvidia Oct 30, 2024
cf0e0ae
resolve comments
lanluo-nvidia Oct 30, 2024
fb7fd1d
resolve comments
lanluo-nvidia Oct 31, 2024
8fc89dc
resolve comments
lanluo-nvidia Oct 31, 2024
63b3376
Merge branch 'main' into lluo/cross_compilation_for_windows
lanluo-nvidia Nov 1, 2024
1a1ba41
merge latest main
lanluo-nvidia Nov 1, 2024
96bc256
fix linting
lanluo-nvidia Nov 1, 2024
eebe1bc
test
lanluo-nvidia Nov 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add more logs
  • Loading branch information
lanluo-nvidia committed Oct 14, 2024
commit 2a43ca16a325df570f28bc3e6d2084f3085e2e6e
2 changes: 1 addition & 1 deletion core/plugins/register_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TorchTRTPluginRegistry {
// Plugins outside this subset in TensorRT are not being logged in this. So temporarily we disable this to prevent
// multiple logging of same plugins. To provide a clear list of all plugins, we iterate through getPluginRegistry()
// where it prints the list of all the plugins registered in TensorRT with their namespaces.
plugin_logger.set_reportable_log_level(util::logging::LogLevel::kERROR);
plugin_logger.set_reportable_log_level(util::logging::LogLevel::kDEBUG);
initLibNvInferPlugins(&plugin_logger, "");
plugin_logger.set_reportable_log_level(util::logging::get_logger().get_reportable_log_level());

Expand Down
2 changes: 1 addition & 1 deletion core/runtime/register_jit_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ TORCH_LIBRARY(tensorrt, m) {
m.def("get_cudagraphs_mode", []() -> bool { return CUDAGRAPHS_MODE; });
m.def("set_cudagraphs_mode", [](bool cudagraphs_mode) -> void { CUDAGRAPHS_MODE = cudagraphs_mode; });
m.def("set_logging_level", [](int64_t level) -> void {
util::logging::get_logger().set_reportable_log_level(util::logging::LogLevel(level));
util::logging::get_logger().set_reportable_log_level(util::logging::LogLevel::kDEBUG);
});
m.def(
"get_logging_level", []() -> int64_t { return int64_t(util::logging::get_logger().get_reportable_log_level()); });
Expand Down
1 change: 0 additions & 1 deletion py/torch_tensorrt/_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ def cross_compile_save_for_windows(
file_path,
arg_inputs=torchtrt_arg_inputs,
enabled_precisions=enabled_precisions_set,
enable_cross_compile_for_windows=True,
**kwargs,
)
logger.info("successfully compiled and saved the module for windows")
lanluo-nvidia marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
11 changes: 6 additions & 5 deletions py/torch_tensorrt/dynamo/_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,18 @@ def cross_compile_save_for_windows(

# TODO: confirm with Naren whether to raise the error or just warning and ignore what user's settings for the following flags
# disable the following settings which should not be enabled for cross compile for windows
keys = (
key_sets = {
lanluo-nvidia marked this conversation as resolved.
Show resolved Hide resolved
"use_python_runtime",
"make_refittable",
"lazy_engine_init",
"cache_built_engines",
"reuse_cached_engines",
"custom_engine_cache",
)
}
# disable these settings
for key in keys:
if key in kwargs.keys() and kwargs.get(key):
kwarg_key_sets = set(kwargs.keys())
for key in key_sets.intersection(kwarg_key_sets):
if kwargs.get(key):
logger.warning(
f"arg: {key} should not be enabled for cross compile for windows feature, it is ignored."
lanluo-nvidia marked this conversation as resolved.
Show resolved Hide resolved
)
Expand Down Expand Up @@ -360,6 +361,7 @@ def compile(
"lazy_engine_init": lazy_engine_init,
"cache_built_engines": cache_built_engines,
"reuse_cached_engines": reuse_cached_engines,
"enable_cross_compile_for_windows": enable_cross_compile_for_windows,
}

settings = CompilationSettings(**compilation_options)
Expand Down Expand Up @@ -547,7 +549,6 @@ def contains_metadata(gm: torch.fx.GraphModule) -> bool:
)

trt_modules[name] = trt_module
print(f"lan added {name=}, {trt_module.output_shapes=}")

# Parse the graph I/O and store it in dryrun tracker
parse_graph_io(gm, dryrun_tracker)
Expand Down
30 changes: 0 additions & 30 deletions py/torch_tensorrt/dynamo/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import logging
import platform
from dataclasses import fields, replace
from enum import Enum
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
Expand Down Expand Up @@ -662,32 +661,3 @@ def get_flat_args_with_check(
flat_args_with_path, received_spec = pytree.tree_flatten_with_path((args, kwargs))
flat_args = tuple(x[1] for x in flat_args_with_path)
return flat_args, received_spec


def validate_cross_compile_for_windows_settings(file_path: str, **kwargs: Any) -> Any:
if platform.system() != "Linux" or platform.architecture()[0] != "64bit":
raise RuntimeError(
f"Cross compile for windows is only supported on AMD 64bit Linux architecture, current platform: {platform.system()=}, {platform.architecture()[0]=}"
)

if not file_path:
raise ValueError("File path cannot be empty. Please provide a valid file path")

# TODO: confirm with Naren whether to raise the error or just warning and ignore what user's settings for the following flags
keys = (
"use_python_runtime",
"make_refittable",
"lazy_engine_init",
"cache_built_engines",
"reuse_cached_engines",
"custom_engine_cache",
)
# if "use_python_runtime" in kwargs.keys() and kwargs.get("use_python_runtime"):
# raise RuntimeError(
# "cross_compile_save_for_windows() requires use_python_runtime arg to be set as False"
# )
# disable these settings
for key in keys:
if key in kwargs.keys():
kwargs[key] = False
return kwargs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def forward(self, a, b):
def test_load_from_windows(self):
trt_ep_path = "tests/py/dynamo/runtime/test_data/trt.ep"
try:
loaded_trt_module = torch.export.load(file_path=trt_ep_path)
loaded_trt_module = torch.export.load(trt_ep_path)
trt_gm = loaded_trt_module.module()
a = torch.randn(2, 3).cuda()
b = torch.randn(2, 3).cuda()
Expand Down
Loading