pytorch / pytorch/tutorials

[BUG] - advanced_source/semi_structured_sparse.py fails against 2.7

Open
#3,303 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

2.7 bug
Dominant language
Python
Stars
9.3k
Forks
4.4k
Avg merge
1d 21h
Merged PRs (30d)
4

Description

Add Link

advanced_source/semi_structured_sparse.py

Describe the bug

The tutorials are failing with the following error:

Traceback (most recent call last):
  File "/var/lib/workspace/advanced_source/semi_structured_sparse.py", line 451, in <module>
    trainer.train()
  File "/usr/local/lib/python3.10/dist-packages/transformers/trainer.py", line 2241, in train
    return inner_training_loop(
  File "/usr/local/lib/python3.10/dist-packages/transformers/trainer.py", line 2270, in _inner_training_loop
    train_dataloader = self.get_train_dataloader()
  File "/usr/local/lib/python3.10/dist-packages/transformers/trainer.py", line 1029, in get_train_dataloader
    return self.accelerator.prepare(DataLoader(train_dataset, **dataloader_params))
  File "/usr/local/lib/python3.10/dist-packages/accelerate/accelerator.py", line 1398, in prepare
    result = tuple(
  File "/usr/local/lib/python3.10/dist-packages/accelerate/accelerator.py", line 1399, in <genexpr>
    self._prepare_one(obj, first_pass=True, device_placement=d) for obj, d in zip(args, device_placement)
  File "/usr/local/lib/python3.10/dist-packages/accelerate/accelerator.py", line 1270, in _prepare_one
    return self.prepare_data_loader(obj, device_placement=device_placement)
  File "/usr/local/lib/python3.10/dist-packages/accelerate/accelerator.py", line 2222, in prepare_data_loader
    prepared_data_loader = prepare_data_loader(
  File "/usr/local/lib/python3.10/dist-packages/accelerate/data_loader.py", line 1164, in prepare_data_loader
    torch.Generator(device=torch.get_default_device() if hasattr(torch, "get_default_device") else "cpu"),
  File "/var/lib/ci-user/.local/lib/python3.10/site-packages/torch/__init__.py", line 1139, in get_default_device
    device = _GLOBAL_DEVICE_CONTEXT.device_context.device
AttributeError: 'NoneType' object has no attribute 'device'

build log

Please submit fixes against the 2.7-RC-TEST branch and enable in .jenkins/validate_tutorials_built.py.
Possibly related to https://github.com/pytorch/pytorch/issues/131328

Describe your environment
  • PyTorch 2.7
  • CUDA 12.6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with advanced_source/semi_structured_sparse.py and the failing build log, then inspect .jenkins/validate_tutorials_built.py and the related PyTorch issue. Reproduce the tutorial failure against PyTorch 2.7 and determine the compatibility fix; done means the tutorial passes and is enabled in validation on the 2.7-RC-TEST branch.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ci-cd, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.