Skip to content

Stop mckp from silently swallowing the requested device - #473

Open
BenjaminDEMAILLE wants to merge 1 commit into
broadinstitute:mainfrom
BenjaminDEMAILLE:fix/mckp-device-transparency
Open

Stop mckp from silently swallowing the requested device#473
BenjaminDEMAILLE wants to merge 1 commit into
broadinstitute:mainfrom
BenjaminDEMAILLE:fix/mckp-device-transparency

Conversation

@BenjaminDEMAILLE

Copy link
Copy Markdown

Noticed while measuring the effect of device selection on estimation for #467.

MultipleChoiceKnapsack.estimate_noise has no device parameter. run.py passes device=args.device to every estimator, so for mckp it lands in **kwargs and is dropped. mckp is the default estimator, which means --cuda (and --mps) appear to apply to it and do not.

What this PR does not do

It does not move the computation. The hard-coded CPU is deliberate: it predates the 2026 refactor, and mckp is the memory-hungry estimator whose MAP step runs over a whole chunk at once, which is what #396 (OutOfMemory error when computing target noise counts per gene) is about. Flipping that to GPU is a memory trade-off you should make deliberately, and I cannot validate it against the datasets that hit #396.

What it does

Makes the choice visible instead of invisible:

  • device is accepted and documented on the signature, rather than silently absorbed.
  • A debug line states that the MAP step runs on the CPU rather than the requested device, and why.
  • The two hard-coded device="cpu" call sites carry a comment explaining the intent, so the next reader does not take them for an oversight, as I initially did.

Worth your decision

Should mckp honour --cuda for that MAP step? There is a real speed-up available, at a memory cost that #396 suggests is not free. Happy to implement whichever way you want, including a flag to opt in.

Verification

Full suite 176 passed, 69 skipped. ruff check, ruff format --check, mypy cellbender tests clean. New test asserts that a caller passing device="cuda" gets told, rather than silence.

`MultipleChoiceKnapsack.estimate_noise` had no `device` parameter, so the
`device=args.device` that run.py passes to every estimator was absorbed
into `**kwargs` and dropped. mckp is the default estimator, so `--cuda`
looked effective there and did nothing.

The CPU choice itself is kept. It predates the 2026 refactor, and mckp is
the memory-hungry estimator whose MAP step runs over a whole chunk at once,
which is what broadinstitute#396 is about. Moving it onto the GPU is a memory trade-off
for maintainers to make deliberately, not something to flip in passing.

What changes is only that the choice is now visible: the parameter is
accepted and documented, and a debug line says the MAP step runs on the CPU
rather than on the requested device, and why. Nothing about the computation
moves.

Worth deciding separately: whether mckp should honour --cuda for this step,
given the memory cost.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant