Conversation
) 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 Report✅ All modified and coverable lines are covered by tests. 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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tritontoot.backendso triton loads before TensorFlow, but caught onlyImportError. A broken native install raises something else — typicallyOSErrorfor a missing shared object — which escaped both the probe and the enclosing torch block, soimport otfailed outright. A failure insidefind_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
Exceptionand covers thefind_speccall too.How has this been tested (if it applies)
New test puts a
tritonraisingOSErroron the path and assertsimport otstill 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