pytorch - 💡(How to fix) Fix Deterministic implementation of CTC Loss [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#178052Fetched 2026-04-08 01:07:20
View on GitHub
Comments
2
Participants
3
Timeline
41
Reactions
0
Timeline (top)
subscribed ×17mentioned ×16labeled ×6commented ×2
RAW_BUFFERClick to expand / collapse

🚀 The feature, motivation and pitch

For reproducibility, it will be very helpful if a deterministic implementation of CTC Loss is implemented. The advantages of this are fairly obvious.

RuntimeError: ctc_loss_backward_gpu does not have a deterministic implementation, but you set 'torch.use_deterministic_algorithms(True)'. You can turn off determinism just for this operation, or you can use the 'warn_only=True' option, if that's acceptable for your application. You can also file an issue at https://github.com/pytorch/pytorch/issues to help us prioritize adding deterministic support for this operation.

Alternatives

No response

Additional context

No response

cc @ptrblck @msaroufim @eqy @jerryzh168 @tinglvv @nWEIdia @mruberry @kurtamohler

extent analysis

Fix Plan

To fix the RuntimeError caused by the non-deterministic implementation of CTC Loss, you can use the warn_only=True option when setting deterministic algorithms. Here are the steps:

  • Set torch.use_deterministic_algorithms(True) with warn_only=True:
import torch
torch.use_deterministic_algorithms(True, warn_only=True)

Alternatively, you can turn off determinism just for the CTC Loss operation:

  • Use torch.backends.cudnn.deterministic = False before the CTC Loss operation:
import torch
torch.backends.cudnn.deterministic = False
# Your CTC Loss operation here
  • Remember to set torch.backends.cudnn.deterministic = True after the operation if needed.

Verification

To verify that the fix worked, run your code with the modified deterministic algorithm settings and check that the RuntimeError is resolved.

Extra Tips

Note that using non-deterministic algorithms may affect the reproducibility of your results. If determinism is crucial for your application, consider filing an issue at https://github.com/pytorch/pytorch/issues to request deterministic support for the CTC Loss operation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - 💡(How to fix) Fix Deterministic implementation of CTC Loss [2 comments, 3 participants]