Skip to content

Commit e912cba

Browse files
PaliCfacebook-github-bot
authored andcommitted
Remove torch._running_with_deploy() from fbcode and add RuntimeError handling for load_library (#3207)
Summary: 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 03f9e01 commit e912cba

File tree

9 files changed

+11
-9
lines changed

9 files changed

+11
-9
lines changed

torchrec/distributed/comm_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
try:
2626
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops")
2727
torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:sparse_ops_cpu")
28-
except OSError:
28+
except (OSError, RuntimeError):
2929
pass
3030

3131

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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
from typing import Any, Dict, List, Optional, Set, Tuple, Union
1313

1414
import torch
15-
15+
from torch.distributed._composable.fsdp.fully_shard import FSDPModule as FSDP2
16+
||||||| base: 7fac7a14884d - noreply+581177899995665: [version bump]: horiz...
17+
if not torch._running_with_deploy():
1618
from torch.distributed._composable.fsdp.fully_shard import FSDPModule as FSDP2
1719

1820
from torch.distributed.fsdp import FullyShardedDataParallel as FSDP

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)