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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions icefall/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,15 @@ 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(f"The sum of {_name}.output is not finite")
elif isinstance(_output, tuple):
for i, o in enumerate(_output):
if isinstance(o, tuple):
o = o[0]
if not isinstance(o, Tensor):
continue
if not torch.isfinite(o.to(torch.float32).sum()):
raise ValueError(
f"The sum of {_name}.output[{i}] is not finite: {_output}"
)
logging.warning(f"The sum of {_name}.output[{i}] is not finite")

# default param _name is a way to capture the current value of the variable "name".
def backward_hook(_module, _input, _output, _name=name):
Expand Down
Loading