Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed to proper Xavier initialization, existing implementation was … #1927

Closed

Conversation

eknag
Copy link

@eknag eknag commented Sep 23, 2023

…resulting in a large negative bias, which was killing all gradients through the following relu. https://paperswithcode.com/method/xavier-initialization

…resulting in a large negative bias, which was killing all gradients through the following relu. https://paperswithcode.com/method/xavier-initialization
@facebook-github-bot
Copy link
Contributor

Hi @eknag!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@eknag
Copy link
Author

eknag commented Sep 23, 2023

Behavior before

 python run.py dlrm -d cuda -t train
Running train method from dlrm on cuda in eager mode with input batch size 2048 and precision fp32.
gen: tensor([[0.],
        [0.],
        [0.],
        ...,
        [0.],
        [0.],
        [0.]], device='cuda:0', grad_fn=<ReluBackward0>)
loss: 0.3434426486492157
derivative with respect to first linear layer: tensor([[0., 0., 0.,  ..., 0., 0., 0.],

@eknag
Copy link
Author

eknag commented Sep 23, 2023

Behavior after fix:

➜  benchmark git:(dev/eknag/fix_dlrm_bias_initialization) ✗ python run.py dlrm -d cuda -t train              
Running train method from dlrm on cuda in eager mode with input batch size 2048 and precision fp32.
gen: tensor([[0.0000],
        [0.0000],
        [0.0213],
        ...,
        [0.0000],
        [0.0231],
        [0.0000]], device='cuda:0', grad_fn=<ReluBackward0>)
loss: 0.3336436152458191
derivative with respect to first linear layer: tensor([[ 7.9563e-04,  7.3723e-04,  7.9948e-04,  ...,  7.8230e-04,

@xuzhao9
Copy link
Contributor

xuzhao9 commented Sep 24, 2023

@eknag Thanks for looking into this. The code is from upstream model: https://github.com/facebookresearch/dlrm/blob/main/dlrm_s_pytorch.py#L212

Could you please submit a PR for the facebookresearch/dlrm repository and see what is the feedback there? Thanks!

@eknag eknag temporarily deployed to docker-s3-upload September 24, 2023 00:49 — with GitHub Actions Inactive
@eknag eknag temporarily deployed to docker-s3-upload September 24, 2023 00:49 — with GitHub Actions Inactive
@eknag
Copy link
Author

eknag commented Sep 25, 2023

See facebookresearch/dlrm#358

Copy link
Contributor

@xuzhao9 xuzhao9 left a comment

Choose a reason for hiding this comment

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

@aaronenyeshi Can you also help take a look?

@eknag Could you please also add the URL of the upstream PR (facebookresearch/dlrm#358) to the code? We would like to track all such upstream improvements in the code.

@eknag
Copy link
Author

eknag commented Sep 27, 2023

@xuzhao9 Added. Let me know if I should do anything else - I'm new to making contributions.

Copy link
Contributor

@xuzhao9 xuzhao9 left a comment

Choose a reason for hiding this comment

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

LGTM

@eknag eknag temporarily deployed to docker-s3-upload September 28, 2023 18:40 — with GitHub Actions Inactive
@eknag eknag temporarily deployed to docker-s3-upload September 28, 2023 18:41 — with GitHub Actions Inactive
@facebook-github-bot
Copy link
Contributor

@xuzhao9 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@xuzhao9 merged this pull request in 827f90b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants