Skip to content

Commit b10ed32

Browse files
EddyLXJfacebook-github-bot
authored andcommitted
Support no eviction in Feature score eviction policy (meta-pytorch#3488)
Summary: X-link: pytorch/FBGEMM#5059 X-link: facebookresearch/FBGEMM#2068 As title If one table is using feature score eviction in one tbe, then all tables in this tbe need to use the same policy. Feature score eviction can support ttl based eviction now. This diff is adding support no eviction in feature score eviction policy. Differential Revision: D84660528
1 parent 890a523 commit b10ed32

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

torchrec/distributed/batched_embedding_kernel.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ def _populate_zero_collision_tbe_params(
334334
training_id_eviction_trigger_count = [0] * len(config.embedding_tables)
335335
training_id_keep_count = [0] * len(config.embedding_tables)
336336
l2_weight_thresholds = [0.0] * len(config.embedding_tables)
337+
enable_eviction_for_feature_score_eviction_policy = [True] * len(
338+
config.embedding_tables
339+
)
337340
eviction_strategy = -1
338341
table_names = [table.name for table in config.embedding_tables]
339342
l2_cache_size = tbe_params["l2_cache_size"]
@@ -393,6 +396,9 @@ def _populate_zero_collision_tbe_params(
393396
)
394397
training_id_keep_count[i] = policy_t.training_id_keep_count
395398
ttls_in_mins[i] = policy_t.eviction_ttl_mins
399+
enable_eviction_for_feature_score_eviction_policy[i] = (
400+
policy_t.enable_eviction
401+
)
396402
if eviction_strategy == -1 or eviction_strategy == 5:
397403
eviction_strategy = 5
398404
else:
@@ -454,6 +460,7 @@ def _populate_zero_collision_tbe_params(
454460
eviction_free_mem_check_interval_batch=eviction_free_mem_check_interval_batch,
455461
threshold_calculation_bucket_stride=threshold_calculation_bucket_stride,
456462
threshold_calculation_bucket_num=threshold_calculation_bucket_num,
463+
enable_eviction_for_feature_score_eviction_policy=enable_eviction_for_feature_score_eviction_policy,
457464
)
458465
else:
459466
eviction_policy = EvictionPolicy(meta_header_lens=meta_header_lens)

torchrec/modules/embedding_configs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ class FeatureScoreBasedEvictionPolicy(VirtualTableEvictionPolicy):
240240
None # 0 means no eviction
241241
)
242242
inference_eviction_ttl_mins: Optional[int] = None # 0 means no eviction
243+
enable_eviction: bool = (
244+
True # Currently we only support using same eviction policy in one tbe for mutiple tables, if one table doesn't need eviction we can set this flag to False
245+
)
243246

244247
def __post_init__(self) -> None:
245248
if self.inference_eviction_feature_score_threshold is None:

0 commit comments

Comments
 (0)