Skip to content

Commit

Permalink
Fix T_co import bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gucci-j committed Jan 3, 2025
1 parent 5a28b22 commit edfa472
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/lighteval/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@

import torch
from torch.utils.data import Dataset
from torch.utils.data.distributed import DistributedSampler, T_co
from packaging import version

torch_version = torch.__version__

if version.parse(torch_version) >= version.parse("2.5.0"):
from torch.utils.data.distributed import DistributedSampler, _T_co
else:
from torch.utils.data.distributed import DistributedSampler
from torch.utils.data.distributed import T_co as _T_co

from lighteval.tasks.requests import (
GreedyUntilRequest,
Expand Down Expand Up @@ -318,7 +326,7 @@ class GenDistributedSampler(DistributedSampler):
as our samples are sorted by length.
"""

def __iter__(self) -> Iterator[T_co]:
def __iter__(self) -> Iterator[_T_co]:
if self.shuffle:
# deterministically shuffle based on epoch and seed
g = torch.Generator()
Expand Down

0 comments on commit edfa472

Please sign in to comment.