Thanks to visit codestin.com
Credit goes to github.com

Skip to content

note: torch.zeros -> torch.empty#13807

Merged
sayakpaul merged 2 commits into
mainfrom
torch-empty-note
May 26, 2026
Merged

note: torch.zeros -> torch.empty#13807
sayakpaul merged 2 commits into
mainfrom
torch-empty-note

Conversation

@sayakpaul

Copy link
Copy Markdown
Member

What does this PR do?

torch.empty has disrupted our CI quite a bit in the past. This PR adds a note about it in .ai/models.md and encourages the use of torch.zeros or torch.ones.

@sayakpaul sayakpaul requested review from dg845 and yiyixuxu May 26, 2026 04:44
@github-actions github-actions Bot added the size/S PR with diff < 50 LOC label May 26, 2026
Comment thread .ai/models.md

Boolean gate. If `False` (default), calling that method raises `ValueError`. All transformers in the repo support this. To add support, just: (1) set the class attribute to `True`, (2) add `self.gradient_checkpointing = False` in `__init__`, (3) add `if torch.is_grad_enabled() and self.gradient_checkpointing:` branches in `forward` that call `self._gradient_checkpointing_func`. See gotcha #4.

## Gotchas

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh let's add it here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@yiyixuxu yiyixuxu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@sayakpaul sayakpaul merged commit fdc6310 into main May 26, 2026
7 checks passed
@sayakpaul sayakpaul deleted the torch-empty-note branch May 26, 2026 05:07
DN6 pushed a commit that referenced this pull request Jul 1, 2026
* note: torch.zeros -> torch.empty

* move to gotchas.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants