Skip to content

Fix roberta conversion bugs #964

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

Merged
merged 1 commit into from
Apr 14, 2022
Merged

Conversation

Njuapp
Copy link
Contributor

@Njuapp Njuapp commented Apr 6, 2022

Description

Fix bugs encountered when converting a RoBERTa model.

Fixes #963

Specifically, it fixes three things:

  • For aten::ne.Scalar(Tensor self, Scalar other) -> (Tensor), the datatype of Scalar is by default initialized to be of type float. This should be int32 in this case.
  • For aten::cumsum(Tensor self, int dim, *, int? dtype=None) -> (Tensor), the zeroValue which stores runningSum, is by default initialized to be of type float. This should be int32 in this case.
  • For aten::to.dtype(Tensor self, int dtype, bool non_blocking=False, bool copy=False, int? memory_format=None) -> (Tensor), it could be casting tensor to long datatype, but this cannot be processed in our code. We simply add an entry in get_at_trt_type_map, where at::kLong would be mapped to nvinfer1::DataType::kINT32 since tensorRT could not support long.

Type of change

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

  • Bug fix (non-breaking change which fixes an issue)

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

@narendasan
Copy link
Collaborator

@Njuapp Can you sign your commits?

@@ -238,6 +238,7 @@ const std::unordered_map<at::ScalarType, nvinfer1::DataType>& get_at_trt_type_ma
{at::kFloat, nvinfer1::DataType::kFLOAT},
{at::kHalf, nvinfer1::DataType::kHALF},
{at::kInt, nvinfer1::DataType::kINT32},
{at::kLong, nvinfer1::DataType::kINT32},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont want to just associate all instances of long with kINT32. If there are cases of kLong we should explicity handle these cases and explain what we want to do

Copy link
Collaborator

Choose a reason for hiding this comment

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

So in this case in the evaluator, we can add a code path for Long in the to evaluator (when truncate is enabled) and print a warning

@Njuapp Njuapp force-pushed the roberta_fix branch 2 times, most recently from eb69bf2 to 4153778 Compare April 13, 2022 07:29
@Njuapp
Copy link
Contributor Author

Njuapp commented Apr 13, 2022

I have done cpp_lint with clang-format-9, but it still fails in CI/CD as above. I don't understand the reasons. Maybe you can help check cpp_lint too.

@narendasan
Copy link
Collaborator

I can fix the linting

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

@narendasan narendasan merged commit 3c59ece into pytorch:master Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [Bug] Failure to compile RoBERTa model with Torch-TRT
2 participants