Skip to content

Raise an error in scatter when broadcast and AMM are incompatible #8796

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions distributed/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2779,6 +2779,17 @@ def scatter(
"Consider using a normal for loop and Client.submit"
)

if broadcast and dask.config.get(
"distributed.scheduler.active-memory-manager.start"
):
Comment on lines +2782 to +2784
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is problematic.

  1. you want to specifically test for ReduceReplicas. Namely, at the moment of writing AMM also serves the RetireWorker policy and could serve other, harmless user-defined policies.
  2. the AMM could have been started by hand with client.amm.start(). The API call clent.amm.running() is there for this.

I would instead suggest adding a new RPC endpoint to

  • distributed.active_memory_manager.AMMClientProxy and to
  • distributed.active_memory_manager.ActiveMemoryManagerExtension.amm_handler

which returns a set of currently running policies, and test that instead.
(caveat: there can be more than one RetireWorker policies running when you have more than one worker closing gracefully at the same time).

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @crusaderky - I agree that the config check is not sufficient. Thanks for the suggestions!

raise RuntimeError(
"Scattering data with broadcast=True is incompatible "
"with the Active Memory Manager’s ReduceReplicas "
"policy. Please disable the AMM plugin by setting "
"the following config to False: "
"'distributed.scheduler.active-memory-manager.start'"
)

try:
local_worker = get_worker()
except ValueError:
Expand Down
6 changes: 6 additions & 0 deletions distributed/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2353,6 +2353,12 @@ async def test__broadcast(c, s, a, b):
assert a.data == b.data == {x.key: 1, y.key: 2}


@gen_cluster(client=True)
async def test__broadcast_raises(c, s, a, b):
with pytest.raises(RuntimeError):
await c.scatter([1, 2], broadcast=True)


@gen_cluster(client=True, nthreads=[("127.0.0.1", 1)] * 4, config=NO_AMM)
async def test__broadcast_integer(c, s, *workers):
x, y = await c.scatter([1, 2], broadcast=2)
Expand Down
Loading