From 9032bf112f4ab2fbd1b344026df8c95369fde910 Mon Sep 17 00:00:00 2001 From: Ivan Yashchuk Date: Wed, 30 Oct 2024 17:26:37 +0200 Subject: [PATCH 1/4] Allow linear to be consumed by nvFuser by default --- thunder/executors/nvfuserex_impl.py | 1 + 1 file changed, 1 insertion(+) diff --git a/thunder/executors/nvfuserex_impl.py b/thunder/executors/nvfuserex_impl.py index c85ad67cb2..f8fa7ab61a 100644 --- a/thunder/executors/nvfuserex_impl.py +++ b/thunder/executors/nvfuserex_impl.py @@ -2241,6 +2241,7 @@ def map_inside_replacement(x: Any) -> None: def _linear_check(a: TensorProxy, b: TensorProxy, bias: TensorProxy | None) -> bool: enable_linear: None | bool = get_compile_option("nv_enable_linear", "Enable nvFuser linear.") + enable_linear = enable_linear if enable_linear is not None else True if not enable_linear: return False # Verify linear inputs and bias (optional) are supported tensors. From 76622ffebe1f0d06ec3025c283727c5ef579324d Mon Sep 17 00:00:00 2001 From: Ivan Yashchuk Date: Wed, 30 Oct 2024 20:19:28 +0200 Subject: [PATCH 2/4] Update thunder/executors/nvfuserex_impl.py Co-authored-by: Jingyue Wu --- thunder/executors/nvfuserex_impl.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/thunder/executors/nvfuserex_impl.py b/thunder/executors/nvfuserex_impl.py index f8fa7ab61a..a80db4d896 100644 --- a/thunder/executors/nvfuserex_impl.py +++ b/thunder/executors/nvfuserex_impl.py @@ -2241,7 +2241,8 @@ def map_inside_replacement(x: Any) -> None: def _linear_check(a: TensorProxy, b: TensorProxy, bias: TensorProxy | None) -> bool: enable_linear: None | bool = get_compile_option("nv_enable_linear", "Enable nvFuser linear.") - enable_linear = enable_linear if enable_linear is not None else True + if enable_linear is None: + enable_linear = True if not enable_linear: return False # Verify linear inputs and bias (optional) are supported tensors. From 3e816f3edb6cac3933033ace7c36fd97cacdfd8d Mon Sep 17 00:00:00 2001 From: Ivan Yashchuk Date: Thu, 7 Nov 2024 13:42:44 +0200 Subject: [PATCH 3/4] Make test_cse_rematerialization_nvfuser_cuda_None pass --- thunder/tests/test_nvfuser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/thunder/tests/test_nvfuser.py b/thunder/tests/test_nvfuser.py index c42c183b7e..35faef6ed4 100644 --- a/thunder/tests/test_nvfuser.py +++ b/thunder/tests/test_nvfuser.py @@ -347,6 +347,7 @@ def test_cse_rematerialization(executor, device, _): disable_torch_autograd=True, executors=executor.executors_list(), nv_enable_bookend=False, + nv_enable_linear=False, ) compiled_func(x, y) From 59ec695f6a40d2e0a05157e6519358b4d64689a3 Mon Sep 17 00:00:00 2001 From: Ivan Yashchuk Date: Mon, 18 Nov 2024 11:28:50 +0200 Subject: [PATCH 4/4] Enable linear only for nvFuser 0.2.23+ --- thunder/executors/nvfuserex_impl.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/thunder/executors/nvfuserex_impl.py b/thunder/executors/nvfuserex_impl.py index 1f2744d4ae..dc347e8f40 100644 --- a/thunder/executors/nvfuserex_impl.py +++ b/thunder/executors/nvfuserex_impl.py @@ -2240,7 +2240,9 @@ def map_inside_replacement(x: Any) -> None: def _linear_check(a: TensorProxy, b: TensorProxy, bias: TensorProxy | None) -> bool: enable_linear: None | bool = get_compile_option("nv_enable_linear", "Enable nvFuser linear.") - if enable_linear is None: + # Enable linear by default if nvFuser version is 0.2.23 or later + # Because nvFuser 0.2.23 has a fix for https://github.com/NVIDIA/Fuser/issues/3369 + if enable_linear is None and nvfuser_version() >= LooseVersion("0.2.23"): enable_linear = True if not enable_linear: return False