File tree Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -718,7 +718,7 @@ def make_run_fn(
718
718
workspace_ptr = c_void_p (self .workspace .data_ptr ())
719
719
720
720
# Generate partial function.
721
- return functools .partial (
721
+ ret = functools .partial (
722
722
run_method ,
723
723
* args ,
724
724
* self .extra_args ,
@@ -727,6 +727,20 @@ def make_run_fn(
727
727
stream_ptr ,
728
728
)
729
729
730
+ # sanity check to make sure we cleanup run fn properly
731
+ try :
732
+ ret ()
733
+ except RuntimeError as e :
734
+ err_msg = str (e )
735
+
736
+ def raise_runtime_error ():
737
+ raise RuntimeError (err_msg )
738
+
739
+ self .cleanup_run_fn ()
740
+ return raise_runtime_error
741
+
742
+ return ret
743
+
730
744
def update_workspace_size (self ) -> None :
731
745
if self ._workspace_size_updated :
732
746
return
Original file line number Diff line number Diff line change @@ -2265,16 +2265,31 @@ def benchmark_choices(
2265
2265
log .warning ("Not yet implemented: %s" , e )
2266
2266
timing = float ("inf" )
2267
2267
except RuntimeError as e :
2268
+ from torch ._inductor .codegen .cuda .cuda_kernel import CUDATemplateCaller
2269
+
2270
+ if not isinstance (choice , CUDATemplateCaller ):
2271
+ log .error (
2272
+ "CUDA runtime error during autotuning: \n %s. \n Ignoring this choice." ,
2273
+ e ,
2274
+ )
2268
2275
msg = str (e )
2269
2276
if "invalid argument" in msg :
2270
2277
msg += "\n \n This may mean this GPU is too small for max_autotune mode.\n \n "
2271
2278
else :
2272
2279
if "illegal memory access" in msg :
2273
2280
msg += "\n \n Either error in template or triton bug.\n "
2274
- log .error (
2275
- "Runtime error during autotuning: \n %s. \n Ignoring this choice." ,
2276
- msg ,
2277
- )
2281
+
2282
+ if isinstance (choice , CUDATemplateCaller ):
2283
+ log .debug (
2284
+ "Runtime error during autotuning: \n %s. \n Ignoring this choice." ,
2285
+ msg ,
2286
+ exc_info = True ,
2287
+ )
2288
+ else :
2289
+ log .error (
2290
+ "Runtime error during autotuning: \n %s. \n Ignoring this choice." ,
2291
+ msg ,
2292
+ )
2278
2293
timing = float ("inf" )
2279
2294
except AssertionError as e :
2280
2295
raise AssertionError ( # noqa: B904
You can’t perform that action at this time.
0 commit comments