Skip to content

Commit 88c6058

Browse files
EddyLXJmeta-codesync[bot]
authored andcommitted
Support no eviction in Feature score eviction policy (#3488)
Summary: X-link: pytorch/FBGEMM#5059 Pull Request resolved: #3488 X-link: https://github.com/facebookresearch/FBGEMM/pull/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. Reviewed By: emlin Differential Revision: D84660528 fbshipit-source-id: 28d85126da30b2c357c7f99b6535be381a76f2ce
1 parent 0898642 commit 88c6058

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
@@ -354,6 +354,9 @@ def _populate_zero_collision_tbe_params(
354354
training_id_eviction_trigger_count = [0] * len(config.embedding_tables)
355355
training_id_keep_count = [0] * len(config.embedding_tables)
356356
l2_weight_thresholds = [0.0] * len(config.embedding_tables)
357+
enable_eviction_for_feature_score_eviction_policy = [True] * len(
358+
config.embedding_tables
359+
)
357360
eviction_strategy = -1
358361
table_names = [table.name for table in config.embedding_tables]
359362
l2_cache_size = tbe_params["l2_cache_size"]
@@ -398,6 +401,9 @@ def _populate_zero_collision_tbe_params(
398401
)
399402
training_id_keep_count[i] = policy_t.training_id_keep_count
400403
ttls_in_mins[i] = policy_t.eviction_ttl_mins
404+
enable_eviction_for_feature_score_eviction_policy[i] = (
405+
policy_t.enable_eviction
406+
)
401407
if eviction_strategy == -1 or eviction_strategy == 5:
402408
eviction_strategy = 5
403409
else:
@@ -459,6 +465,7 @@ def _populate_zero_collision_tbe_params(
459465
eviction_free_mem_check_interval_batch=eviction_free_mem_check_interval_batch,
460466
threshold_calculation_bucket_stride=threshold_calculation_bucket_stride,
461467
threshold_calculation_bucket_num=threshold_calculation_bucket_num,
468+
enable_eviction_for_feature_score_eviction_policy=enable_eviction_for_feature_score_eviction_policy,
462469
)
463470
else:
464471
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
@@ -243,6 +243,9 @@ class FeatureScoreBasedEvictionPolicy(VirtualTableEvictionPolicy):
243243
feature_score_mapping: Optional[Dict[str, float]] = None # feature score mapping
244244
feature_score_default_value: Optional[float] = None # default feature score value
245245
enable_auto_feature_score_collection: bool = False
246+
enable_eviction: bool = (
247+
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
248+
)
246249

247250
def __post_init__(self) -> None:
248251
if self.inference_eviction_feature_score_threshold is None:

0 commit comments

Comments
 (0)