File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
tensorrt_llm/_torch/auto_deploy/custom_ops Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -576,17 +576,22 @@ def _store_extra_arg(
576576 else :
577577 self ._extra_args [name ] = None
578578
579+ @nvtx_range ("ad_get_unique_value" )
579580 def _get_unique_value (self , occupied : Set [int ], max_val : int ) -> int :
580581 """Get un unoccupied value from the range indicated by max_val.
581582
582583 In addition, this function performs a sanity check to ensure that no value in the occupied
583584 set is out of bounds.
584585 """
585- full_range = set (range (max_val ))
586- free_values = full_range - occupied
587- out_of_range = occupied - full_range
586+ # Validate without materializing the full range set
587+ out_of_range = [v for v in occupied if v < 0 or v >= max_val ]
588588 assert not out_of_range , f"Out of range values: { out_of_range } "
589- return free_values .pop () if free_values else 0
589+
590+ # Return the smallest free value; fall back to 0 if none
591+ for candidate in range (max_val ):
592+ if candidate not in occupied :
593+ return candidate
594+ return 0
590595
591596 @nvtx_range ("ad_nest_sequences" )
592597 def nest_sequences (
You can’t perform that action at this time.
0 commit comments