Skip to content

Conversation

@junaid-hasan
Copy link

Summary

This PR resolves several UserWarning messages from PyTorch by

  • updating deprecated function calls in the custom Adam optimizer located in src/optim.py.
  • updating function calls in src/model/transformer.py and src/model/lstm.py.
  • updating .gitignore to include a dump directory for saving temporary training files.

This is a non-functional change that ensures forward compatibility with future PyTorch versions and cleans up the logs.

Changes

The following deprecated function signatures were updated:

  • add_(Number, Tensor) is now add_(Tensor, *, alpha=Number)
  • addcmul_(Number, Tensor, Tensor) is now addcmul_(Tensor, Tensor, *, value=Number)
  • addcdiv_(Number, Tensor, Tensor) is now addcdiv_(Tensor, Tensor, *, value=Number)
  • replace .byte() with .bool() in masking
  • Added dump directory to .gitignore

Example:

Before:

  • p.data.addcdiv_(-step_size, exp_avg, denom)
  • generated[-1].masked_fill_(unfinished_sents.byte(), self.eos_index)

After:

  • p.data.addcdiv_(exp_avg, denom, value=-step_size)
  • generated[-1].masked_fill_(unfinished_sents.bool(), self.eos_index)

Context

This change is motivated by an API evolution in PyTorch, as discussed in the official PyTorch repository.

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 this pull request may close these issues.

1 participant