Skip to content

[MRG] Do not let the triton probe break import ot (follow-up to #839) - #865

Open
deeb01 wants to merge 3 commits into
PythonOT:masterfrom
deeb01:fix-triton-probe-must-not-be-fatal
Open

deeb01 wants to merge 3 commits into
PythonOT:masterfrom
deeb01:fix-triton-probe-must-not-be-fatal

Conversation

@deeb01

@deeb01 deeb01 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Types of changes

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

Motivation and context / Related issue

Follow-up to #839 / #816. That PR added an eager import triton to ot.backend so triton loads before TensorFlow, but caught only ImportError. A broken native install raises something else — typically OSError for a missing shared object — which escaped both the probe and the enclosing torch block, so import ot failed outright. A failure inside find_spec("tensorflow") would have been caught by the torch block instead and silently disabled the torch backend.

The probe is a best-effort optimisation and must never be fatal, so it now catches Exception and covers the find_spec call too.

How has this been tested (if it applies)

New test puts a triton raising OSError on the path and asserts import ot still succeeds and the torch backend is still available. Verified that it fails on master and passes here. Full suite green, pre-commit clean.

PR checklist

  • I have read the CONTRIBUTING document.
  • The documentation is up-to-date with the changes I made (check build artifacts).
  • All tests passed, and additional code has been covered with new tests.
  • I have added the PR and Issue fix to the RELEASES.md file.

)

PR PythonOT#839 added an eager `import triton` to ot.backend so that triton loads
before TensorFlow. It caught only ImportError, but a broken native install
raises other things, typically OSError for a missing shared object. That
exception escaped both the probe and the enclosing torch block, so
`import ot` failed outright, and a failure in find_spec("tensorflow")
would have been caught by the torch block and silently disabled the torch
backend instead.

The probe is a best-effort optimisation and must never be fatal, so it now
catches Exception and covers the find_spec call as well.

Adds a regression test that puts a triton raising OSError on the path and
asserts `import ot` still succeeds.
@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.88%. Comparing base (98d09a1) to head (9628dd6).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #865      +/-   ##
==========================================
+ Coverage   96.86%   96.88%   +0.01%     
==========================================
  Files         128      128              
  Lines       26304    26316      +12     
==========================================
+ Hits        25480    25495      +15     
+ Misses        824      821       -3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant