[Sampling] Support sampling masks with overlap scheduling (#36631)
Co-authored-by: ByronHsu <ByronHsu@users.noreply.github.com> Co-authored-by: root <root@slurm-h200-208-179.slurm-compute.tenant-slurm.svc.cluster.local> Co-authored-by: Byron Hsu <byron+per@periodiclabs.ai>
This commit is contained in:
co-authored by
ByronHsu
root
Byron Hsu
parent
55b45cb45a
commit
fd7743e0e1
@@ -100,6 +100,54 @@ class TestSamplingBatchInfoLen(CustomTestCase):
|
||||
self.assertEqual(len(info), 5)
|
||||
|
||||
|
||||
class TestSamplingMaskBatchIndices(CustomTestCase):
|
||||
def test_filter_removes_last_opted_in_row_then_merge_restores_capture(self):
|
||||
info = _make_info(
|
||||
batch_size=2,
|
||||
return_sampling_masks=[False, True],
|
||||
sampling_mask_batch_indices=torch.tensor([1]),
|
||||
)
|
||||
info.filter_batch([0], torch.tensor([0]))
|
||||
self.assertIsNone(info.sampling_mask_batch_indices)
|
||||
other = _make_info(
|
||||
batch_size=1,
|
||||
return_sampling_masks=[True],
|
||||
sampling_mask_batch_indices=torch.tensor([0]),
|
||||
)
|
||||
info.merge_batch(other)
|
||||
self.assertEqual(info.return_sampling_masks, [False, True])
|
||||
self.assertEqual(info.sampling_mask_batch_indices.tolist(), [1])
|
||||
|
||||
def test_filter_rebuilds_row_indices(self):
|
||||
info = _make_info(
|
||||
batch_size=4,
|
||||
return_sampling_masks=[False, True, False, True],
|
||||
sampling_mask_batch_indices=torch.tensor([1, 3]),
|
||||
)
|
||||
|
||||
info.filter_batch([1, 2, 3], torch.tensor([1, 2, 3]))
|
||||
|
||||
self.assertEqual(info.return_sampling_masks, [True, False, True])
|
||||
self.assertEqual(info.sampling_mask_batch_indices.tolist(), [0, 2])
|
||||
|
||||
def test_merge_offsets_rhs_row_indices(self):
|
||||
lhs = _make_info(
|
||||
batch_size=2,
|
||||
return_sampling_masks=[False, True],
|
||||
sampling_mask_batch_indices=torch.tensor([1]),
|
||||
)
|
||||
rhs = _make_info(
|
||||
batch_size=3,
|
||||
return_sampling_masks=[True, False, True],
|
||||
sampling_mask_batch_indices=torch.tensor([0, 2]),
|
||||
)
|
||||
|
||||
lhs.merge_batch(rhs)
|
||||
|
||||
self.assertEqual(lhs.return_sampling_masks, [False, True, True, False, True])
|
||||
self.assertEqual(lhs.sampling_mask_batch_indices.tolist(), [1, 2, 4])
|
||||
|
||||
|
||||
class TestMergeCustomLogitProcessor(CustomTestCase):
|
||||
def test_both_none_returns_none(self):
|
||||
"""Test that merging two None processor dicts returns None."""
|
||||
|
||||
Reference in New Issue
Block a user