Skip to content

[DEV] fix(multimodal_dev): derive mock samples from the sample index - #6287

Open
xuwchen wants to merge 1 commit into
NVIDIA:devfrom
xuwchen:multimodal-dev-mock-index-determinism
Open

[DEV] fix(multimodal_dev): derive mock samples from the sample index#6287
xuwchen wants to merge 1 commit into
NVIDIA:devfrom
xuwchen:multimodal-dev-mock-index-determinism

Conversation

@xuwchen

@xuwchen xuwchen commented Aug 5, 2026

Copy link
Copy Markdown
Contributor
  • I, the PR author, have personally reviewed every line of this PR.

What does this PR do?

MockQwen35VLDataset.__getitem__ ignored idx and sampled from the ambient CPU RNG. With data_parallel_random_init disabled, corresponding data ranks start from the same CPU RNG state, so sample identity depended on local draw order rather than the sampler index. When two layouts used different full data-distribution degrees, a nominal global batch contained different sample sets and different numbers of distinct samples, invalidating loss and gradient A/B comparisons.

Sample generation is now keyed by (seed, split, idx), with --seed and the split propagated by the dataset provider. A BLAKE2b-derived seed initializes a private generator for token and pixel generation, making sample identity independent of rank, worker, access order, and ambient RNG, while split-specific keys keep train, validation, and test samples disjoint. Out-of-range indices and an undersized image_seq_length now raise early instead of failing silently later.

⚠️ For major changes (either in lines of code or in its impact), please make sure to first share a design doc with the team. If you're unsure what's the best way to do so, contact @NVIDIA/mcore-oncall.

Issue tracking

For PRs from open-source community contributors:

  • New features: a linked issue is required. Please open a feature request and reference it here before submitting the PR.
  • Small updates (bug fixes, minor improvements): a linked issue is recommended and will accelerate the PR review process.

Linked issue:

Contribution process

Pre-checks

  • I have added relevant unit tests
  • I have added relevant functional tests
  • I have added proper typing to my code Typing guidelines
  • I have added relevant documentation
  • I have run the autoformatter.sh on my PR

Code review

Feel free to message or comment @NVIDIA/mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!

All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.

Step 1: Mark PR as "Ready for Review"

  1. When your PR is ready, click Ready for Review.
  2. An oncall reviewer is auto-assigned and expert reviewers are notified based on your changes.
    • Some PRs may jump straight to step 2. This is determined by .github/CODEOWNERS.

⚠️ Only mark as ready once merge-conflicts are resolved and the CI is passing.
Final Review might get declined if these requirements are not fulfilled.

Step 2: Final Review

For PRs that change megatron/core, once all expert reviewers have approved, the Final Review label is applied automatically and final reviewers are assigned.

For PRs outside megatron/core, this step is skipped.

Step 3: Approved

Once all required reviewers have approved, the Approved label is applied automatically.

Merge

Any member of mcore-engineers will be able to merge your PR.

@copy-pr-bot

copy-pr-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@xuwchen
xuwchen force-pushed the multimodal-dev-mock-index-determinism branch 5 times, most recently from 5051f25 to 4c07f79 Compare August 6, 2026 09:10
The dataset drew from ambient CPU RNG and ignored idx. Ranks share the CPU seed
unless data_parallel_random_init is set, so every rank of a data-parallel group
drew the same stream and the distinct samples in a global batch collapsed to the
per-rank microbatch count — a number that changes with the parallel layout, so
two configurations being compared saw different data.

Each sample is now derived from (seed, split, idx). The split name keeps the
train/valid/test datasets apart: sharing one stream would make them emit
identical samples, trading duplication across ranks for duplication across
splits. The provider passes args.seed through, which the ambient-RNG version
got for free.

The parts are hashed with blake2b rather than added. Addition overlaps by
construction: idx=1 under seed S is idx=0 under seed S+1, and each split would
replay the previous one shifted by one index.

Since idx now determines content, out-of-range indices raise IndexError instead
of silently hashing to a plausible sample from outside the dataset.

Signed-off-by: xuwenc <xuwenc@nvidia.com>
@xuwchen
xuwchen force-pushed the multimodal-dev-mock-index-determinism branch from 4c07f79 to 716a9e7 Compare August 6, 2026 12:54
@xuwchen
xuwchen marked this pull request as ready for review August 6, 2026 13:29
@xuwchen
xuwchen requested review from a team as code owners August 6, 2026 13:29
@xuwchen
xuwchen requested a review from BestJuly August 6, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants