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

Fixed batchnorm bug #3170

Merged
merged 5 commits into from
Oct 14, 2024
Merged

Fixed batchnorm bug #3170

merged 5 commits into from
Oct 14, 2024

Conversation

cehongwang
Copy link
Collaborator

Description

Batch norm value trace fails when the intial weights are identical. This pull request fixed batch norm fast refit case using name trace.

Fixes # (issue)

Type of change

Please delete options that are not relevant and/or add your own.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@github-actions github-actions bot added component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Sep 20, 2024
@github-actions github-actions bot requested a review from apbose September 20, 2024 20:44
@cehongwang cehongwang marked this pull request as draft September 20, 2024 20:46
@github-actions github-actions bot added the component: tests Issues re: Tests label Sep 20, 2024
Copy link
Collaborator

@narendasan narendasan left a comment

Choose a reason for hiding this comment

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

@zewenli98 what are your thoughts here, seems like a simple enough change. @cehongwang after this is in would there be any other failure modes for fast refit?

Copy link
Collaborator

@zewenli98 zewenli98 left a comment

Choose a reason for hiding this comment

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

Is this PR still a draft or ready for review (rebase to main is needed)?

else get_trt_tensor(ctx, weight, f"{name}_weight")
)
bias = (
get_trt_tensor(ctx, 1.0, f"{name}_bias")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be 0?

else get_trt_tensor(ctx, bias, f"{name}_bias")
)
running_mean = (
get_trt_tensor(ctx, 1.0, f"{name}_running_mean")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be 0?

@zewenli98
Copy link
Collaborator

@zewenli98 what are your thoughts here, seems like a simple enough change. @cehongwang after this is in would there be any other failure modes for fast refit?

Since batchnorm was refactored previously, renaming maybe work for fast refit.

@cehongwang
Copy link
Collaborator Author

cehongwang commented Oct 1, 2024 via email

@cehongwang
Copy link
Collaborator Author

@zewenli98 what are your thoughts here, seems like a simple enough change. @cehongwang after this is in would there be any other failure modes for fast refit?

I will do similar changes to other applicable converters to make the naming trace more robust. There should not be other failures after that because we have the value trace to guarantee the correctness.

@zewenli98
Copy link
Collaborator

@cehongwang @narendasan Can you guys take a look at the issue #3200 which may be related to this PR

github-actions[bot]

This comment was marked as resolved.

@zewenli98 zewenli98 marked this pull request as ready for review October 11, 2024 22:13
Copy link
Collaborator

@zewenli98 zewenli98 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@narendasan narendasan left a comment

Choose a reason for hiding this comment

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

Rebase and lgtm

@@ -69,7 +69,8 @@
debug=debug,
min_block_size=min_block_size,
torch_executed_ops=torch_executed_ops,
make_refittable=True,
make_refitable=True,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be 2 ts now, might want to rebase this branch

Copy link
Collaborator

Choose a reason for hiding this comment

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

rebased

@@ -477,12 +477,18 @@ def _save_weight_mapping(self) -> None:
# Retrieve each weight name(s) in state_dict
if layer_type == "CONSTANT":
if "embedding" in suffix:
sd_weight_name = f"{sd_weight_name}.{torch_attr[0]}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

@zewenli98 keep track of this, seems like there could be a lot of possible names we need to have might want to look at a generic solution later

@zewenli98 zewenli98 requested a review from narendasan October 11, 2024 23:18
Copy link
Collaborator

@narendasan narendasan left a comment

Choose a reason for hiding this comment

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

LGTM!

@zewenli98 zewenli98 merged commit 6303068 into main Oct 14, 2024
69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants