-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: Data race in stringdtype_finalize_descr under free-threading #28813
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
Comments
Do you think this is most likely a recent regression or just randomly showing up now? |
it is the first time I see this race in JAX CI |
Weird, I can't think of a way for two threads to get a handle on the same newly created StringDType instance from the array creation logic. If you have any idea which test triggered this that would probably help. |
I'm trying to get a reproducer. numpy_string_array = np.array(
["abcdefghijklmnopqrstuvwxyz", "cba"], dtype=np.dtypes.StringDType() # type: ignore
)
jax_string_array = jnp.asarray(numpy_string_array, device=cpu_devices[0])
# or
# jax_string_array = jax.device_put(numpy_string_array, device=cpu_devices[0])
# or
# jax_string_array = jnp.asarray(
# numpy_string_array,
# device=cpu_devices[0],
# dtype=np.dtypes.StringDType(),
# ) and debugging a bit the numpy code when creating such a string array, dtype is set up as following: numpy/numpy/_core/src/multiarray/arraytypes.c.src Line 4305 in e05ec39
Seems like dtype is fetched from a global structure numpy/numpy/_core/src/multiarray/stringdtype/dtype.c Lines 636 to 637 in e05ec39
|
Hmmm, @ngoldbaum maybe the way things were we set the global singleton exactly once from |
Well, we have a lock hanging off the descriptor. Might as well use it... Thanks for tracking this down @vfdev-5. |
I'm confused by this - how is execution accessing If you look slightly higher up in the implementation of numpy/numpy/_core/src/multiarray/arraytypes.c.src Lines 4250 to 4267 in 80d5607
So there's probably something else going on in the case that races for Jax. One thing I can do is set the I can also use locking as discussed above. |
If |
I created #28862 |
Uh oh!
There was an error while loading. Please reload this page.
Describe the issue:
We see the following data race report by TSAN in JAX CI 3.13 free-threading:
Report
cc @hawkinsp
Reproduce the code example:
Error message:
Python and NumPy Versions:
Runtime Environment:
No response
Context for the issue:
JAX CI Link: https://github.com/jax-ml/jax/actions/runs/14633862367/job/41061013541
The text was updated successfully, but these errors were encountered: