Reject repetition_penalty=0 in SamplingParams.verify() (#24874)
Co-authored-by: RulinJuice <265952454+RulinJuice@users.noreply.github.com>
This commit is contained in:
@@ -178,22 +178,36 @@ class TestSamplingParamsVerify(CustomTestCase):
|
||||
|
||||
# --- repetition_penalty ---
|
||||
def test_repetition_penalty_negative_raises(self):
|
||||
"""Test that verify() rejects negative repetition_penalty (valid range is [0, 2])."""
|
||||
"""Test that verify() rejects negative repetition_penalty (valid range is (0, 2])."""
|
||||
sp = self._make(repetition_penalty=-0.1)
|
||||
with self.assertRaises(ValueError):
|
||||
sp.verify(self.VOCAB_SIZE)
|
||||
|
||||
def test_repetition_penalty_zero_raises(self):
|
||||
"""Test that verify() rejects repetition_penalty=0.
|
||||
|
||||
A value of 0 makes the sampling kernel divide logits by 0, producing
|
||||
inf/NaN in the probability tensor and crashing every TP rank with a
|
||||
device-side assert.
|
||||
"""
|
||||
sp = self._make(repetition_penalty=0.0)
|
||||
with self.assertRaises(ValueError):
|
||||
sp.verify(self.VOCAB_SIZE)
|
||||
|
||||
def test_repetition_penalty_above_two_raises(self):
|
||||
"""Test that verify() rejects repetition_penalty > 2.0."""
|
||||
sp = self._make(repetition_penalty=2.1)
|
||||
with self.assertRaises(ValueError):
|
||||
sp.verify(self.VOCAB_SIZE)
|
||||
|
||||
def test_repetition_penalty_boundaries_valid(self):
|
||||
"""Test that boundary values 0.0 and 2.0 are both accepted."""
|
||||
self._make(repetition_penalty=0.0).verify(self.VOCAB_SIZE)
|
||||
def test_repetition_penalty_boundary_two_valid(self):
|
||||
"""Test that the upper boundary value 2.0 is accepted."""
|
||||
self._make(repetition_penalty=2.0).verify(self.VOCAB_SIZE)
|
||||
|
||||
def test_repetition_penalty_small_positive_valid(self):
|
||||
"""Test that a small positive repetition_penalty (e.g. 1e-3) is accepted."""
|
||||
self._make(repetition_penalty=1e-3).verify(self.VOCAB_SIZE)
|
||||
|
||||
# --- min_new_tokens / max_new_tokens ---
|
||||
def test_negative_min_new_tokens_raises(self):
|
||||
"""Test that verify() rejects negative min_new_tokens."""
|
||||
|
||||
Reference in New Issue
Block a user