Skip to content

Avoid full-batch rescans in pretraining masking - #327

Merged
Victsm merged 1 commit into
mainfrom
codex/pretraining-masking-reduction-20261113
Nov 13, 2026
Merged

Victsm merged 1 commit into
mainfrom
codex/pretraining-masking-reduction-20261113

Conversation

@Victsm

@Victsm Victsm commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

mask_event_values checked each example by repeatedly scanning the entire batch's event/token matrix. Replace that loop with grouped minimum-position reductions, retaining the same first-valid/first-selected fallback, random draws, corruption and loss targets. Skip the guarantee work when ensure_at_least_one=False.

On a retained real-data workload (32,768 anchors, 80 batches, 1.67M events), warm masking time falls 15.657s → 1.271s (12.32×) and complete loader time 18.441s → 4.034s (4.57×). Peak RSS remains about 107 GiB. These are loader-only measurements, not end-to-end training speedups.

Testing

  • Current-main masking/target-layout suite: 48 passed, 1 CUDA skip locally; Ruff/format/diff checks passed.
  • Separately verified 3,456 CPU/CUDA parity cases and exact inputs, targets and loss masks for all 80 real-data batches. Covers interleaved/missing owners, noncontiguous layouts, empty/all-invalid inputs and policy flags.
  • The published implementation and test files are byte-identical to the benchmarked prototype. No API, dependency or masking-policy changes.

Change map

#327 (comment)

@copy-pr-bot

copy-pr-bot Bot commented Nov 13, 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.

@Victsm
Victsm temporarily deployed to gha-kumo-workflow-tests November 13, 2026 09:27 — with GitHub Actions Inactive
@Victsm

Victsm commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

Change map

Observed bottleneck: guaranteeing a loss-bearing token looped over examples and searched the full event/token matrix for each, even when no fallback was needed. The direct fix retains existing masking semantics and replaces only that guarantee implementation.

File Function / scope What changed Why
packages/experimental/kumo-pytorch/src/kumo/pytorch/data/masking.py mask_event_values fallback selection Use grouped first-position reductions, preserve unknown supervision and first-token ordering, skip guarantee work when disabled Remove repeated whole-batch scans without changing random selection or outputs
packages/experimental/kumo-pytorch/tests/test_masking.py First-token/layout regressions Add interleaved/absent-owner, invalid, noncontiguous and zero-width coverage Preserve the existing first-valid/first-selected behavior across supported layouts

Verification: 48 focused tests passed (one local CUDA skip); Ruff, formatting and diff checks passed. Separate CPU/CUDA and real-data parity checks plus warm loader measurements are summarized in the description. Stop at this two-file repair; no trainer, tokenizer, native loader, API or dependency work is included.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When ensure_at_least_one is enabled, the masking logic uses batched reductions to find relevant token positions for each owner. It selects the first valid token when an owner has no selected token. If unknown tokens are not supervised and an owner has no predicted token, it clears the unknown status of that owner’s first selected token. Parameterized tests check inputs, targets, and loss masks across supervision settings, selection probabilities, and tensor layouts.

Merge Risk: Minimal · up to d384f

The change speeds up pretraining masking while the masking behavior stays the same, and the added tests cover the guarantee and supervision settings. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 2 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Change Map Design Review Inconclusive The check assesses the Change map in the PR conversation comment that begins with <!-- kumo-pr-change-map -->. That comment is not available to this review. The checkout does not contain it. Git his… Provide the body of the PR conversation comment that starts with <!-- kumo-pr-change-map --> (issuecomment-6849176507 on NVIDIA/kumo-engine PR #327). Then rerun this check. Review the map against these points: - The observed failure or re…
Passed Passed checks: 2 passed

Check name Status Explanation
Pr Size Passed The PR size check counts changed files and fails only above 40. Running git diff --name-status refs/coderabbit/pre-merge-check/base refs/coderabbit/pre-merge-check/head lists two modified files, and…
Public Resource Access Passed The check applies only to external resource references (URLs, repository locations, package source locations) that this PR adds or modifies. The PR changes two files: `packages/experimental/kumo-pytor…
Full details: Pr Size

Explanation

The PR size check counts changed files and fails only above 40. Running git diff --name-status refs/coderabbit/pre-merge-check/base refs/coderabbit/pre-merge-check/head lists two modified files, and --name-only gives a count of 2: - packages/experimental/kumo-pytorch/src/kumo/pytorch/data/masking.py (M) - packages/experimental/kumo-pytorch/tests/test_masking.py (M) Two files is well under the threshold of 40, so the check passes. Line counts were ignored as the check requires.

Full details: Public Resource Access

Explanation

The check applies only to external resource references (URLs, repository locations, package source locations) that this PR adds or modifies. The PR changes two files: packages/experimental/kumo-pytorch/src/kumo/pytorch/data/masking.py and packages/experimental/kumo-pytorch/tests/test_masking.py. I searched every added line in the diff for URLs, git+ or git@ sources, package index references, and version-pinned repository locations. The search found no such references. The only regex hit was key_ids.device, which matched a .dev pattern and is not a resource reference. The PR description and objectives link to a PR comment, but they are not part of the changed code and are outside the diff this check inspects. With no added or modified external resource reference, the check passes.

Full details: Change Map Design Review

Explanation

The check assesses the Change map in the PR conversation comment that begins with &lt;!-- kumo-pr-change-map --&gt;. That comment is not available to this review. The checkout does not contain it. Git history and the PR diff do not contain it either. The only match for the marker is in docs/development/review.md, which describes the required comment format. It does not contain the map content. Context gathered: - The reviewed diff changes two files: packages/experimental/kumo-pytorch/src/kumo/pytorch/data/masking.py and packages/experimental/kumo-pytorch/tests/test_masking.py. - docs/development/review.md requires one conversation comment with the marker. The comment must account for every changed file and must explain rationale. It must be updated after new commits. - The PR description links to the change map at issuecomment-6849176507. That link does not resolve to content in this environment. Without the map text, this check cannot judge whether each change is necessary. It also cannot judge the abstraction layer, the stated failure, the verification scope, or the stopping condition. The PR code diff alone does not satisfy the check. A PASS would require the map text. A FAIL would require a proven design defect in the map. Neither is established. The PR description reports benchmark and parity results. These results do not replace the map review.

Resolution

Provide the body of the PR conversation comment that starts with &lt;!-- kumo-pr-change-map --&gt; (issuecomment-6849176507 on NVIDIA/kumo-engine PR #327). Then rerun this check. Review the map against these points: - The observed failure or requirement. The description cites a loader timing issue in mask_event_values. - The existing behavior that was inspected, including the per-example loop and the ensure_at_least_one path. - Whether each scatter_reduce_ change is needed. Confirm that the first-valid, first-selected, and unknown-clearing fallbacks match the old per-example logic in every case. - Whether the change belongs in masking.py and does not alter the public API. - Whether the test in test_masking.py covers the interleaved-owner, empty-owner, noncontiguous, and unsupervised-unknown cases. - Whether the map states that the 3,456-case parity run and the real-data check are outside the committed tests.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bbc7655 and d384fef.

Files selected for processing: 2

  • packages/experimental/kumo-pytorch/src/kumo/pytorch/data/masking.py
  • packages/experimental/kumo-pytorch/tests/test_masking.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@Victsm
Victsm merged commit be622d3 into main Nov 13, 2026
112 of 113 checks passed
@Victsm
Victsm deleted the codex/pretraining-masking-reduction-20261113 branch November 13, 2026 18:29

This branch was previously deployed

1 inactive deployment
gha-kumo-workflow-tests — d384fefe Deployed Nov 13, 2026 by Victsm via import #2240
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.

2 participants