[Misc] Replaced asserts with proper exceptions to improve UX for pooling (#44593)
Signed-off-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
This commit is contained in:
@@ -40,9 +40,8 @@ class CLSPool(SequencePoolingMethod):
|
||||
pooling_metadata: PoolingMetadata,
|
||||
) -> SequencePoolingMethodOutput:
|
||||
pooling_cursor = pooling_metadata.get_pooling_cursor()
|
||||
assert not pooling_cursor.is_partial_prefill(), (
|
||||
"partial prefill not supported with CLS pooling"
|
||||
)
|
||||
if pooling_cursor.is_partial_prefill():
|
||||
raise RuntimeError("partial prefill is not supported with CLS pooling")
|
||||
|
||||
return hidden_states[pooling_cursor.first_token_indices_gpu]
|
||||
|
||||
@@ -64,9 +63,8 @@ class MeanPool(SequencePoolingMethod):
|
||||
pooling_metadata: PoolingMetadata,
|
||||
) -> SequencePoolingMethodOutput:
|
||||
pooling_cursor = pooling_metadata.get_pooling_cursor()
|
||||
assert not pooling_cursor.is_partial_prefill(), (
|
||||
"partial prefill not supported with MEAN pooling"
|
||||
)
|
||||
if pooling_cursor.is_partial_prefill():
|
||||
raise RuntimeError("partial prefill is not supported with MEAN pooling")
|
||||
|
||||
prompt_lens_cpu = pooling_cursor.prompt_lens_cpu
|
||||
num_seqs = prompt_lens_cpu.numel()
|
||||
|
||||
Reference in New Issue
Block a user