DataLoader: consume-ahead on a background thread removes the data wait but not step time (results from #2312)

Open Beginner friendly
#2,354 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
python, pytorch

Research direction

Start with the results and profiling details in this issue, then read the linked work in #2312 to understand the background-consume change. The issue records no code or test file to modify; any follow-up should evaluate one of the listed approaches and report whether it improves step time. If revisiting the implementation, inspect how MultiDataset handles prepare_background_consume and review the note about collective ordering across ranks.

Written by the indexing model from the issue text.

Description

Consuming and collating the next batch on a background thread (#2312, now closed) cuts the wait in next(dataloader) to ~0.1 ms, but step time does not improve: the work moves from "data wait" into slower kernel launches. Recording the result and what could make it pay off.

Details

  • Unified external-aero recipe, DrivAerML surface, flare_surface, bf16, 200k cells, compile, domain size = GPU count (H100), median of 120 steps. Step time off → on: 0.148 → 0.149 s (1 GPU), 0.098 → 0.102 s (2), 0.094 → 0.094 s (8).
  • Profile at 8 GPUs: training kernels and NCCL time unchanged; host time in the compiled forward +30% and backward +48%. The step is launch-bound (~2100 kernels/step), and the consume work is Python that holds the GIL, so it slows the launching threads.
  • Ways it could pay off: consume in a separate process instead of a thread; fewer, fused or compiled transforms; or a step that is not launch-bound (e.g. CUDA graphs).
  • If revisited: MultiDataset needs to forward prepare_background_consume to its children (otherwise the background all-reduce shares the training communicator), and a collective on a background thread can still interleave with main-thread collectives in a different order per rank.
Dominant language
Python
Stars
3.5k
Forks
853
Avg merge
2d 2h
Merged PRs (30d)
64

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/physicsnemo

All issues in NVIDIA/physicsnemo

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.