Skip to content

Commit 23000a3

Browse files
apaszkeGoogle-ML-Automation
authored andcommitted
Always suppress the differing_executors Hypothesis health check
It's only relevant to notify about potential key collisions in the example database, but we explicitly disable it, so it doesn't matter. PiperOrigin-RevId: 707914664
1 parent 3915f4a commit 23000a3

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

jax/_src/test_util.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,13 +2147,30 @@ def setup_hypothesis(max_examples=30) -> None:
21472147
except (ModuleNotFoundError, ImportError):
21482148
return
21492149

2150+
# In our tests we often use subclasses with slightly different class variables
2151+
# to generate whole suites of parameterized tests, but this approach does not
2152+
# work well with Hypothesis databases, which use some function of the method
2153+
# identity to generate keys. But, if the method is defined in a superclass,
2154+
# all subclasses share the same key. This key collision can lead to confusing
2155+
# false positives in other health checks.
2156+
#
2157+
# Still, as far as I understand, for as long as we don't use the example
2158+
# database, it should be perfectly safe to suppress this health check. This
2159+
# seems simpler than rewriting our tests that trigger this behavior. See
2160+
# the end of https://github.com/HypothesisWorks/hypothesis/issues/3446 for
2161+
# more context.
2162+
suppressed_checks = []
2163+
if hasattr(hp.HealthCheck, "differing_executors"):
2164+
suppressed_checks.append(hp.HealthCheck.differing_executors)
2165+
21502166
hp.settings.register_profile(
21512167
"deterministic",
21522168
database=None,
21532169
derandomize=True,
21542170
deadline=None,
21552171
max_examples=max_examples,
21562172
print_blob=True,
2173+
suppress_health_check=suppressed_checks,
21572174
)
21582175
hp.settings.register_profile(
21592176
"interactive",

tests/pallas/indexing_test.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@
5151
NDIndexer = indexing.NDIndexer
5252
ds = indexing.ds
5353

54-
HP_DIFFERING_EXECUTORS = []
55-
if hasattr(hp.HealthCheck, "differing_executors"):
56-
HP_DIFFERING_EXECUTORS = [hp.HealthCheck.differing_executors]
57-
5854

5955
_INDEXING_TEST_CASES = [
6056
((4, 8, 128), (...,), (4, 8, 128)),
@@ -375,7 +371,6 @@ def permute_columns_in_row_kernel(left, right, new_left, new_right):
375371
np.testing.assert_array_equal(left_out_np, left_out)
376372
np.testing.assert_array_equal(right_out_np, right_out)
377373

378-
@hp.settings(suppress_health_check=HP_DIFFERING_EXECUTORS)
379374
@hp.given(hps.data())
380375
def test_vmap_nd_indexing(self, data):
381376
self.skipTest("TODO(necula): enable this test; was in jax_triton.")

0 commit comments

Comments
 (0)