Skip to content

Commit 8b8051f

Browse files
jimone1pytorchmergebot
authored andcommitted
[Minimizer] Fix the path naming (pytorch#153130)
Summary: Added some logging and captured the indexing. See below image. {F1977773416} This is why the saved module path is called `/tmp/jimwan/minimizer_a_acc.pt` Now the updated module paths are `/tmp/jimwan/minimizer_addmm_default_103_acc.pt`. Test Plan: ``` MTIAC_USE_DIST_REF_KERNELS=all buck2 run @//mode/opt mtia/accuracy/minimizer:mtia_minimizer_runner -- --mode sequential --compare_fn allclose --pt_save_dir /tmp/debug3 --atol 1e-4 --rtol 1e-4 --all_outputs --start_idx native_layer_norm_default_80 --end_idx getitem_272 2>&1 | tee ~/test.log ``` {F1977773610} Reviewed By: qcyuan Differential Revision: D74369107 Pull Request resolved: pytorch#153130 Approved by: https://github.com/Skylion007
1 parent 086e2c2 commit 8b8051f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

torch/fx/passes/net_min_base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,17 +396,21 @@ def _run_and_compare(
396396
if self.module_exporter:
397397
if isinstance(result_key, tuple): # type: ignore[possibly-undefined]
398398
result_key = result_key[-1]
399+
# If the result is still a tuple (happens in non-sequential mode),
400+
# we only use the first element as name.
401+
if isinstance(result_key, tuple): # type: ignore[possibly-undefined]
402+
result_key = str(result_key[0])
399403
# pyre-ignore[29]: not a function
400404
self.module_exporter(
401405
a_input,
402406
submodule,
403-
str(result_key[0]) + "_cpu", # type: ignore[index]
407+
result_key + "_cpu",
404408
)
405409
# pyre-ignore[29]: not a function
406410
self.module_exporter(
407411
b_input,
408412
submodule,
409-
str(result_key[0]) + "_acc", # type: ignore[index]
413+
result_key + "_acc",
410414
)
411415
raise FxNetMinimizerResultMismatchError(f"Result mismatch for {result_key}") # type: ignore[possibly-undefined]
412416

0 commit comments

Comments
 (0)