[Auto Sync] Update logits_processor.py, test_logprobs.py (20260124) (#17664)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: yehu-ux <yehu@x.ai>
This commit is contained in:
co-authored by
github-actions[bot]
yehu-ux
parent
e1833c4f5a
commit
bc6f0b5ce7
@@ -766,14 +766,19 @@ class LogitsProcessor(nn.Module):
|
|||||||
|
|
||||||
# Compute the logprobs of the chunk
|
# Compute the logprobs of the chunk
|
||||||
chunk_input_logprobs = chunk_logits[chunk_indices]
|
chunk_input_logprobs = chunk_logits[chunk_indices]
|
||||||
|
# Only index per-token arrays when the corresponding feature is active.
|
||||||
|
# Otherwise these tensors can be per-sequence (or scalars), which can
|
||||||
|
# cause out-of-bounds indexing on GPU.
|
||||||
chunk_temperature = (
|
chunk_temperature = (
|
||||||
logits_metadata.temperature[global_indices]
|
logits_metadata.temperature[global_indices]
|
||||||
if logits_metadata.temperature is not None
|
if logits_metadata.temp_scaled_logprobs
|
||||||
|
and logits_metadata.temperature is not None
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
chunk_top_p = (
|
chunk_top_p = (
|
||||||
logits_metadata.top_p[global_indices]
|
logits_metadata.top_p[global_indices]
|
||||||
if logits_metadata.top_p is not None
|
if logits_metadata.top_p_normalized_logprobs
|
||||||
|
and logits_metadata.top_p is not None
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
chunk_input_logprobs = compute_temp_top_p_normalized_logprobs(
|
chunk_input_logprobs = compute_temp_top_p_normalized_logprobs(
|
||||||
|
|||||||
@@ -334,7 +334,8 @@ class TestLogprobsDense(unittest.TestCase):
|
|||||||
print(f"Testing with config: {config}")
|
print(f"Testing with config: {config}")
|
||||||
|
|
||||||
# Sample records for this config
|
# Sample records for this config
|
||||||
test_records = random.sample(records, k=min(NUM_SAMPLES, len(records)))
|
num_samples = config.get("num_samples", NUM_SAMPLES)
|
||||||
|
test_records = random.sample(records, k=min(num_samples, len(records)))
|
||||||
random.shuffle(test_records)
|
random.shuffle(test_records)
|
||||||
|
|
||||||
# Calculate how many samples should return logprobs
|
# Calculate how many samples should return logprobs
|
||||||
|
|||||||
Reference in New Issue
Block a user