@@ -450,12 +450,16 @@ def test_lru_lfu_custom_score_function_ranks_by_its_dimension(
450450 probes = {"OLD" : (keys [:1 ], tids [:1 ]), "HF" : (keys [1 :2 ], tids [1 :2 ])}
451451
452452 table .lookup (
453- keys [1 :], tids [1 :], ScoreArg (name = "frequency" , value = ones [1 :], policy = ScorePolicy .LRU_LFU )
453+ keys [1 :],
454+ tids [1 :],
455+ ScoreArg (name = "frequency" , value = ones [1 :], policy = ScorePolicy .LRU_LFU ),
454456 )
455457 torch .cuda .synchronize ()
456458 for _ in range (28 ):
457459 table .lookup (
458- keys [1 :2 ], tids [1 :2 ], ScoreArg (name = "frequency" , value = ones [1 :2 ], policy = ScorePolicy .LRU_LFU )
460+ keys [1 :2 ],
461+ tids [1 :2 ],
462+ ScoreArg (name = "frequency" , value = ones [1 :2 ], policy = ScorePolicy .LRU_LFU ),
459463 )
460464 torch .cuda .synchronize ()
461465
@@ -477,12 +481,18 @@ def test_lru_lfu_custom_score_function_ranks_by_its_dimension(
477481 ev_keys , ev_tids = probes [evicted ]
478482 sv_keys , sv_tids = probes [survivor ]
479483 _ , ev_found , _ = table .lookup (
480- ev_keys , ev_tids , ScoreArg (name = "frequency" , value = None , policy = ScorePolicy .CONST )
484+ ev_keys ,
485+ ev_tids ,
486+ ScoreArg (name = "frequency" , value = None , policy = ScorePolicy .CONST ),
481487 )
482488 _ , sv_found , _ = table .lookup (
483- sv_keys , sv_tids , ScoreArg (name = "frequency" , value = None , policy = ScorePolicy .CONST )
489+ sv_keys ,
490+ sv_tids ,
491+ ScoreArg (name = "frequency" , value = None , policy = ScorePolicy .CONST ),
484492 )
485- assert not torch .any (ev_found ), f"{ score_fn .__name__ } should evict the { evicted } probe"
493+ assert not torch .any (
494+ ev_found
495+ ), f"{ score_fn .__name__ } should evict the { evicted } probe"
486496 assert torch .all (sv_found ), f"{ score_fn .__name__ } should keep the { survivor } probe"
487497
488498
@@ -506,7 +516,9 @@ def test_lru_lfu_decay_matches_python_oracle(current_device):
506516 one , one_tid , one_val = keys [i : i + 1 ], tids [i : i + 1 ], ones [i : i + 1 ]
507517 for _ in range (reps ):
508518 table .lookup (
509- one , one_tid , ScoreArg (name = "frequency" , value = one_val , policy = ScorePolicy .LRU_LFU )
519+ one ,
520+ one_tid ,
521+ ScoreArg (name = "frequency" , value = one_val , policy = ScorePolicy .LRU_LFU ),
510522 )
511523 torch .cuda .synchronize ()
512524
@@ -551,8 +563,8 @@ def test_lru_lfu_score_function_logical_order_remap(current_device):
551563 physical frequency, so on identical tables they evict the SAME keys."""
552564 device = torch .cuda .current_device ()
553565
554- def _run (fn , strat ):
555- table = _custom_table (fn , strat )
566+ def _run (fn , strat ): # codespell:ignore strat
567+ table = _custom_table (fn , strat ) # codespell:ignore strat
556568 n = 100
557569 keys = torch .arange (1 , 1 + n , dtype = torch .int64 , device = device )
558570 tids = torch .zeros (n , dtype = torch .int64 , device = device )
@@ -561,7 +573,9 @@ def _run(fn, strat):
561573 # Give each key a distinct frequency (key i looked up n-1-i extra times).
562574 for r in range (1 , n ):
563575 table .lookup (
564- keys [:r ], tids [:r ], ScoreArg (name = "frequency" , value = ones [:r ], policy = ScorePolicy .LRU_LFU )
576+ keys [:r ],
577+ tids [:r ],
578+ ScoreArg (name = "frequency" , value = ones [:r ], policy = ScorePolicy .LRU_LFU ),
565579 )
566580 torch .cuda .synchronize ()
567581 n_new = 40
@@ -758,7 +772,9 @@ def test_lru_lfu_default_evictor_timestamp_tiebreak(current_device):
758772 idx_parts = []
759773 for g in range (G ):
760774 s = g * per
761- idx_g , _ = _insert (table , keys [s : s + per ], tids [s : s + per ], ones [s : s + per ])
775+ idx_g , _ = _insert (
776+ table , keys [s : s + per ], tids [s : s + per ], ones [s : s + per ]
777+ )
762778 idx_parts .append (idx_g )
763779 torch .cuda .synchronize ()
764780 idx = torch .cat (idx_parts )
0 commit comments