Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataLoaderShard wrongly yields None instead of StopIteration when its dataloader returns StopIteration immediately #3367

Open
2 of 4 tasks
Aleko2286 opened this issue Jan 25, 2025 · 0 comments · May be fixed by #3368
Open
2 of 4 tasks

Comments

@Aleko2286
Copy link

Aleko2286 commented Jan 25, 2025

System Info

- `Accelerate` version: 1.3.0
- Platform: Linux-5.14.0-508.el9.x86_64-x86_64-with-glibc2.39
- `accelerate` bash location: /usr/local/bin/accelerate
- Python version: 3.12.3
- Numpy version: 2.2.2
- PyTorch version (GPU?): 2.5.1+cu124 (True)
- PyTorch XPU available: False
- PyTorch NPU available: False
- PyTorch MLU available: False
- PyTorch MUSA available: False
- System RAM: 62.24 GB
- GPU type: NVIDIA GeForce RTX 2060 SUPER
- `Accelerate` default config:
        - compute_environment: LOCAL_MACHINE
        - distributed_type: NO
        - mixed_precision: no
        - use_cpu: False
        - debug: False
        - num_processes: 1
        - machine_rank: 0
        - num_machines: 1
        - gpu_ids: all
        - rdzv_backend: static
        - same_network: True
        - main_training_function: main
        - enable_cpu_affinity: False
        - downcast_bf16: no
        - tpu_use_cluster: False
        - tpu_use_sudo: False
        - tpu_env: []

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • One of the scripts in the examples/ folder of Accelerate or an officially supported no_trainer script in the examples folder of the transformers repo (such as run_no_trainer_glue.py)
  • My own task or dataset (give details below)

Reproduction

The following code snippet will print "None" and then raise an UnboundLocalError:

from accelerate import Accelerator
import torch

accelerator = Accelerator()
dataset = range(10)
dataloader = torch.utils.data.DataLoader(dataset, batch_size=8, shuffle=True)
dataloader = accelerator.prepare(dataloader)

for x in accelerator.skip_first_batches(dataloader, len(dataloader)):
    print(x)

Expected behavior

The iterator should immediately return StopIteration, such that nothing is printed and the script exits normally.

@Aleko2286 Aleko2286 linked a pull request Jan 25, 2025 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant