Runtime error in mixed precision training in attention mask of transformers

Open
#1,105 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python, pytorch

Research direction

Start with the reported masked_fill call and reproduce the RuntimeError under mixed-precision training. Trace how the attention mask value is represented in the half-precision tensor, then verify that the chosen behavior avoids overflow while preserving masking semantics.

Written by the indexing model from the issue text.

Description

Hi,
I encountered with this error
RuntimeError: value cannot be converted to type at::Half without overflow: -1e+10
when implementing attention mask with code:
attn_scores_head = attn_scores_head.masked_fill(head_mask == 0, -1e10)
It seems that change the -1e10 to a smaller value works, but that is just a approximate approach. Wonder if there is some better solutions? Or, what is the biggest value that can replace -1e10?

Dominant language
Python
Stars
9k
Forks
1.5k
Avg merge
2d 4h
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

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.

More from NVIDIA/apex

All issues in NVIDIA/apex

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.