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

Warn instead of raising exceptions in inf-check #1852

Merged
merged 2 commits into from
Dec 31, 2024

Conversation

zhu-han
Copy link
Contributor

@zhu-han zhu-han commented Dec 30, 2024

No description provided.

icefall/hooks.py Outdated
@@ -40,8 +40,8 @@ def register_inf_check_hooks(model: nn.Module) -> None:
def forward_hook(_module, _input, _output, _name=name):
if isinstance(_output, Tensor):
if not torch.isfinite(_output.to(torch.float32).sum()):
raise ValueError(
f"The sum of {_name}.output is not finite: {_output}"
logging.warning(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will the training continue with inf loss and inf grad?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, like the backward code, it will just warn instead of printing the tensor and raising an exception.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In that case, will it propagate the inf grad to model parameters and result in inf parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is only applied with the inf-check option tuned on, i.e., for finding where the infinites are coming from. So it wouldn't affect normal model training.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. Thanks!

@csukuangfj
Copy link
Collaborator

Could you fix the style issues?

Copy link
Collaborator

@csukuangfj csukuangfj left a comment

Choose a reason for hiding this comment

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

Thanks!

@csukuangfj csukuangfj merged commit df46a3e into k2-fsa:master Dec 31, 2024
146 of 198 checks passed
yfyeung pushed a commit to yfyeung/icefall that referenced this pull request Jan 9, 2025
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.

2 participants