Skip to content

Prevent threaded Dask workers in DistRDF backend - #22393

Merged
vepadulano merged 2 commits into
root-project:masterfrom
JAGANNATHANJP:fix-dask-thread-validation
Jul 31, 2026
Merged

Prevent threaded Dask workers in DistRDF backend#22393
vepadulano merged 2 commits into
root-project:masterfrom
JAGANNATHANJP:fix-dask-thread-validation

Conversation

@JAGANNATHANJP

Copy link
Copy Markdown
Contributor

This PR prevents unsupported threaded Dask workers in DistRDF.

Distributed RDataFrame with Dask threads may lead to crashes and does not provide advantages due to Python GIL limitations. This change validates worker configuration at backend initialization and raises a RuntimeError when threaded workers are detected.

Suggested configuration:

  • processes=True
  • threads_per_worker=1

@github-actions

github-actions Bot commented May 25, 2026

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 13h 59m 54s ⏱️
 3 878 tests  3 878 ✅ 0 💤 0 ❌
79 003 runs  79 003 ✅ 0 💤 0 ❌

Results for commit 30314f0.

♻️ This comment has been updated with latest results.

@JAGANNATHANJP
JAGANNATHANJP force-pushed the fix-dask-thread-validation branch from 5bb11cb to edb506a Compare May 25, 2026 06:37
Comment thread bindings/distrdf/python/DistRDF/Backends/Dask/Backend.py Outdated
@JAGANNATHANJP
JAGANNATHANJP force-pushed the fix-dask-thread-validation branch 3 times, most recently from 2eda199 to 0c91ac5 Compare May 27, 2026 08:54
@JAGANNATHANJP
JAGANNATHANJP requested a review from vepadulano May 28, 2026 09:47

@vepadulano vepadulano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @JAGANNATHANJP ! Before proceeding with the CI, I would like to request you to add a test for this new behaviour, perhaps in roottest/python/distrdf/backends/check_backend.py

@JAGANNATHANJP
JAGANNATHANJP requested a review from dpiparo as a code owner June 1, 2026 16:42
@JAGANNATHANJP

Copy link
Copy Markdown
Contributor Author

Added a test covering the case where scheduler_info() does not provide worker information during Dask backend initialization.

@JAGANNATHANJP
JAGANNATHANJP requested a review from vepadulano June 1, 2026 16:46
Comment thread roottest/python/distrdf/backends/check_backend.py
@JAGANNATHANJP
JAGANNATHANJP requested a review from vepadulano June 12, 2026 16:16
@JAGANNATHANJP

Copy link
Copy Markdown
Contributor Author

Resolved the merge conflict with the latest master and updated the branch.

@vepadulano

Copy link
Copy Markdown
Member

Hi @JAGANNATHANJP ,

Apparently there are still some conflicts, see e.g. https://github.com/root-project/root/actions/runs/28595013336/job/85566036258?pr=22393

Auto-merging roottest/python/distrdf/backends/check_backend.py
  CONFLICT (content): Merge conflict in roottest/python/distrdf/backends/check_backend.py
  error: could not apply def6df24ab... Add tests for Dask worker validation

@JAGANNATHANJP
JAGANNATHANJP force-pushed the fix-dask-thread-validation branch from c4078d9 to de24d80 Compare July 8, 2026 15:22
@vepadulano

Copy link
Copy Markdown
Member

Dear @JAGANNATHANJP ,

The test suite is failing on all platforms with the following error

 >       with pytest.warns(
              UserWarning, match="Number of partitions 2 is greater than number of entries 1 in the dataframe"
          ):
  E       Failed: DID NOT WARN. No warnings of type (<class 'UserWarning'>,) were emitted.
  E        Emitted warnings: [].
  
  ../../../../../src/roottest/python/distrdf/backends/check_backend.py:161: Failed
  =========================== short test summary info ============================
  FAILED ../../../../../src/roottest/python/distrdf/backends/test_all.py::TestInitialization::test_initialization_method[dask] - Failed: DID NOT WARN. No warnings of type (<class 'UserWarning'>,) were emitted.
   Emitted warnings: [].
  !!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
  ========================= 1 failed, 5 passed in 4.32s ==========================

Did you run the test suite locally before resubmitting your changes?

@JAGANNATHANJP

Copy link
Copy Markdown
Contributor Author

Hi @vepadulano,

Apologies for that! The failure was caused by an accidental indentation error during the last merge conflict resolution (df.GetValue() got shifted outside the pytest.warns block).

I have fixed the indentation in commit 9a58aa7 and verified the full test suite locally inside my build environment. All 14 tests in check_backend.py (including the new Dask worker validation test and test_initialization_method) passed 100% cleanly locally.

Could you please approve running the CI checks when you have a moment? Thank you!

@JAGANNATHANJP

Copy link
Copy Markdown
Contributor Author

Hi @vepadulano,

I investigated the recent CI failures. The failure on fedora44 (pyunittests-roottest-python-distrdf-backends-all) was caused by the Dask LocalCluster attempting to spin up a web dashboard on port 8787 during the test, which crashed on the CI runner due to port conflicts/restrictions.

I have pushed a commit to explicitly pass dashboard_address=None in check_backend.py to ensure it runs completely silently.

(Note: The other failures on Alma8/Alma9/Mac appear to be unrelated upstream C++ IO and CMake flakes).

Could you please review when the CI finishes? Thanks!

Comment thread bindings/distrdf/python/DistRDF/Backends/Dask/Backend.py
@JAGANNATHANJP
JAGANNATHANJP requested a review from vepadulano July 29, 2026 13:02

@vepadulano vepadulano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! There are still some things to cleanup.

Comment thread bindings/distrdf/python/DistRDF/Backends/Dask/Backend.py Outdated
Comment thread bindings/distrdf/python/DistRDF/Backends/Dask/Backend.py
Comment thread bindings/distrdf/python/DistRDF/Backends/Dask/Backend.py Outdated
Comment thread bindings/distrdf/python/DistRDF/Backends/Dask/Backend.py Outdated
Comment thread bindings/distrdf/python/DistRDF/Backends/Dask/Backend.py Outdated
Comment thread bindings/distrdf/python/DistRDF/Backends/Dask/Backend.py Outdated
@JAGANNATHANJP
JAGANNATHANJP requested a review from vepadulano July 30, 2026 06:36
@JAGANNATHANJP

Copy link
Copy Markdown
Contributor Author

Hi @vepadulano,

I have addressed all your review comments and also fixed the 3 CI failures from the previous run. The failures were caused by a pytest.raises(...) line in check_backend.py exceeding the ruff line length limit, which is now fixed in commit c446a5b.

Could you please review when the CI finishes? Thank you!

@vepadulano
vepadulano force-pushed the fix-dask-thread-validation branch from c446a5b to 2ea26ae Compare July 31, 2026 09:26

@vepadulano vepadulano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this nice piece of work @JAGANNATHANJP ! I went through the changes and I believe they look good. The last remaining test failure was just a warning raised by the dask cluster finding the same address used twice, which I fixed using the :0 syntax in the LocalCluster initialization to use a random address to avoid tripping Dask. I am running the CI now to make sure the tests pass on all platforms. No further action is required from your side, thanks again!

Using Dask workers with more than one thread does not provide any advantage,
seeing how the RDataFrame computation graph runs in C++ and the Python threads
are limited by the GIL anyway. Explicitly disallow using distributed RDataFrame
with Dask when the workers have been configured to use more than one thread.

Multithreading in RDataFrame can already be achieved on a single node via
`ROOT.EnableImplicitMT`. Distributed processing runs with multiple processes
instead.
@vepadulano
vepadulano force-pushed the fix-dask-thread-validation branch from 2ea26ae to 30314f0 Compare July 31, 2026 11:34
@vepadulano vepadulano linked an issue Jul 31, 2026 that may be closed by this pull request
1 task
@vepadulano
vepadulano merged commit bff78bc into root-project:master Jul 31, 2026
34 checks passed
@JAGANNATHANJP

Copy link
Copy Markdown
Contributor Author

Thank you so much @vepadulano for the review, guidance, and help with the cluster address fix! Glad to contribute to ROOT!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when using FromSpec with dask and threads

2 participants