Skip to content

fix: todevice ignores non_blocking for nested containers - #105

Open
andrewwhitecdw wants to merge 2 commits into
NVlabs:mainfrom
andrewwhitecdw:bugfix/device-todevice-ignores-non-blocking-for
Open

fix: todevice ignores non_blocking for nested containers#105
andrewwhitecdw wants to merge 2 commits into
NVlabs:mainfrom
andrewwhitecdw:bugfix/device-todevice-ignores-non-blocking-for

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

Problem

fix: todevice ignores non_blocking for nested containers

Fix

Replace:

    if isinstance(batch, dict):
        return {k: todevice(v, device) for k, v in batch.items()}

    if isinstance(batch, (tuple, list)):
        return type(batch)(todevice(x, device) for x in batch)

with:

    if isinstance(batch, dict):
        return {k: todevice(v, device, callback=callback, non_blocking=non_blocking) for k, v in batch.items()}

    if isinstance(batch, (tuple, list)):
        return type(batch)(todevice(x, device, callback=callback, non_blocking=non_blocking) for x in batch)

Files changed

  • dust3r/utils/device.py

andrewwhitecdw and others added 2 commits July 27, 2026 20:48
Auditor: The stated problem is only about `non_blocking`, but the diff also forwards `callback` into recursive calls. `callback` is already applied once at the top level, so propagating it would double-apply or misapply container-level callbacks to nested values, introducing an unsafe behavior change. The fix should only forward `non_blocking`.
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