NVIDIA / NVIDIA/apex

unexpected auto-casting / use input references

Open
#385 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi,

I'm facing two strange issues when I use Apex with fp16:

  1. When I use an encoder-decoder architecture, at the end of my encoder forward function the type of my tensor is fp16, as expected. But if I do h = encoder(x) then h is of type fp32, although the type was fp16 in the forward function just before I return h. This is a bit weird and then I have to do something like: output = decoder(h.half()). Is that expected?

  2. Sometimes I provide as input a tensor and a dictionary to the encoder: h = encoder(x, dico) and the forward function of my encoder modifies the dictionary. But everything happens like if I was doing h = encoder(x, copy.deepcopy(dico)), i.e. the dictionary is identical when I exit the forward function.

Any ideas?
Thank you

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.

Research direction

Start by reproducing the two reported cases: fp16 output changing to fp32 after the encoder call, and dictionary changes not persisting when passed alongside the tensor. Compare behavior inside and outside the encoder forward function, then determine whether the observed behavior is expected or should be corrected and documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.