NVIDIA / NVIDIA/apex

bmm for style loss

Open
#402 1 comment 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

In many applications we need bmm for gram matrix calculation, like in neural style. However it seems gram matrix with 01 mode will always give NaN.

See the issue here
https://github.com/pytorch/pytorch/issues/3651

I encountered the same problem with apex. It seems that input should not be casted to fp16 in this case.
This happens because input matrcies can contain large values. A good solution would be scaleing them down before bmm and multiply back after bmm solves the problem.

This approach should be implemented internally since users don't know if need to manual scale in most cases

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 at the bmm entry point and reproduce the gram-matrix case described in this issue, including fp16 inputs with large values. Compare the behavior with the linked PyTorch issue and confirm whether internal scaling prevents NaN results; the issue does not name a source file or test, so those must be located first.

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
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.