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

Fix parsing error caused by dot-separated variable debugNames #1109

Closed
wants to merge 1 commit into from

Conversation

Njuapp
Copy link
Contributor

@Njuapp Njuapp commented Jun 13, 2022

Description

Sometimes when fallback is triggered, the debugName of parameter names could contain ., e.g., input.1 and input_ids.1. Such torchscript files, after conversion and saving to disk, cannot be parsed successfully. We propose to replace such . with _, which can be a solution.

Fixes #1112

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
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@github-actions github-actions bot added the component: core Issues re: The core compiler label Jun 13, 2022
Signed-off-by: Cheng Hang <calvinhance@gmail.com>
LOG_DEBUG("input name:" << input->debugName());
if (input->debugName().find(".") != std::string::npos) {
auto pos = input->debugName().find(".");
auto newName = input->debugName().replace(pos, 1, "_");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems hacky, @bowang007 thoughts? We might just be doing something wrong upstream causing these issues.

Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens is that when there is any fallback we will copy the Metadata of the inputs of the lowered graph (include debugname()) to the inputs of the new graph through this line As a result, the inputs' names' are same with the Lowered Graph inputs, which has some values as x.1, these names cannot be deserialized by torch.jit.load(). This explains why we are not getting this error when there is no fallback, since all the inputs are substituted by input_0, input_1 when there is no fallback.
Another solution to this error would be simply deleting the mapping here. I did some tests locally which could help resolve this issue. However, not sure if this deletion would induce other issues, will run the test cases to ensure it works.

@bowang007
Copy link
Collaborator

raised another PR to fix it in upstream code. #1148

@narendasan
Copy link
Collaborator

Closing in favor of #1148

@narendasan narendasan closed this Jul 15, 2022
@Njuapp Njuapp deleted the fix_dot_varname branch November 14, 2022 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: core Issues re: The core compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [Bug] Parse failure in fallback cases
4 participants