镜像自地址
https://github.com/MINT-SJTU/Evo-RL.git
已同步 2026-11-20 18:17:06 +00:00
snapshot: sync mint main from current workspace 2026-03-03 16:32:56 +0800
这个提交包含在:
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from lerobot.scripts.lerobot_value_infer import ContiguousDistributedEvalSampler
|
||||
|
||||
|
||||
def test_contiguous_distributed_eval_sampler_has_contiguous_shards_with_tail_padding():
|
||||
dataset_size = 10
|
||||
world_size = 3
|
||||
|
||||
shards: list[list[int]] = []
|
||||
for rank in range(world_size):
|
||||
sampler = ContiguousDistributedEvalSampler(dataset_size=dataset_size, num_replicas=world_size, rank=rank)
|
||||
shard = list(iter(sampler))
|
||||
shards.append(shard)
|
||||
assert len(shard) == len(sampler) == 4
|
||||
|
||||
assert shards[0] == [0, 1, 2, 3]
|
||||
assert shards[1] == [4, 5, 6, 7]
|
||||
assert shards[2] == [8, 9, 9, 9]
|
||||
|
||||
covered = set()
|
||||
for shard in shards:
|
||||
covered.update(shard)
|
||||
assert covered == set(range(dataset_size))
|
||||
|
||||
|
||||
def test_contiguous_distributed_eval_sampler_handles_more_ranks_than_samples():
|
||||
dataset_size = 2
|
||||
world_size = 4
|
||||
|
||||
shards: list[list[int]] = []
|
||||
for rank in range(world_size):
|
||||
sampler = ContiguousDistributedEvalSampler(dataset_size=dataset_size, num_replicas=world_size, rank=rank)
|
||||
shard = list(iter(sampler))
|
||||
shards.append(shard)
|
||||
assert len(shard) == len(sampler) == 1
|
||||
|
||||
assert shards[0] == [0]
|
||||
assert shards[1] == [1]
|
||||
assert shards[2] == [1]
|
||||
assert shards[3] == [1]
|
||||
|
||||
covered = set()
|
||||
for shard in shards:
|
||||
covered.update(shard)
|
||||
assert covered == set(range(dataset_size))
|
||||
在新工单中引用
屏蔽一个用户