Skip to content

Commit cfa89c5

Browse files
PaliCfacebook-github-bot
authored andcommitted
Remove torch._running_with_deploy() from fbcode and add RuntimeError handling for load_library (#3207)
Summary: Pull Request resolved: #3207 As per https://fb.workplace.com/groups/pytorch.dev/permalink/1828123831099422 we can now safely remove “torch.is_deploy_running”. This commit does this! Additionally we are handling RuntimeErrors while using load_library in torchrec Differential Revision: D78525065
1 parent dd20e10 commit cfa89c5

File tree

10 files changed

+189
-186
lines changed

10 files changed

+189
-186
lines changed

torchrec/distributed/comm_ops.py

Lines changed: 179 additions & 172 deletions
Large diffs are not rendered by default.

torchrec/distributed/dist_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
torch.ops.load_library(
3939
"//deeplearning/fbgemm/fbgemm_gpu:merge_pooled_embeddings_cpu"
4040
)
41-
except OSError:
41+
except (OSError, RuntimeError):
4242
pass
4343

4444
# OSS

torchrec/distributed/embedding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
try:
106106
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
107107
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
108-
except OSError:
108+
except (OSError, RuntimeError):
109109
pass
110110

111111

torchrec/distributed/embeddingbag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
114114
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
115115
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu/codegen:index_select_ops")
116-
except OSError:
116+
except (OSError, RuntimeError):
117117
pass
118118

119119

torchrec/distributed/model_parallel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
try:
5959
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
6060
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
61-
except OSError:
61+
except (OSError, RuntimeError):
6262
pass
6363

6464

torchrec/distributed/quant_embedding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
try:
101101
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
102102
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
103-
except OSError:
103+
except (OSError, RuntimeError):
104104
pass
105105

106106

torchrec/distributed/train_pipeline/tracing.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@
1313

1414
import torch
1515

16-
if not torch._running_with_deploy():
17-
from torch.distributed._composable.fsdp.fully_shard import FSDPModule as FSDP2
18-
else:
1916

20-
class FSDP2:
21-
pass
17+
class FSDP2:
18+
pass
2219

2320

2421
from torch.distributed.fsdp import FullyShardedDataParallel as FSDP

torchrec/distributed/train_pipeline/train_pipelines.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@
8080
except ImportError:
8181
logger.warning("torchrec_use_sync_collectives is not available")
8282

83-
if not torch._running_with_deploy():
84-
torch.ops.import_module("fbgemm_gpu.sparse_ops")
83+
torch.ops.import_module("fbgemm_gpu.sparse_ops")
8584

8685

8786
# Note: doesn't make much sense but better than throwing.

torchrec/quant/embedding_modules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
try:
8080
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
8181
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
82-
except OSError:
82+
except (OSError, RuntimeError):
8383
pass
8484

8585
# OSS

torchrec/sparse/jagged_tensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
torch.ops.load_library(
4545
"//deeplearning/fbgemm/fbgemm_gpu:permute_multi_embedding_ops_gpu"
4646
)
47-
except OSError:
47+
except (OSError, RuntimeError):
4848
pass
4949

5050

0 commit comments

Comments
 (0)