Skip to content

collator: reject THD CP shards with non-divisible padded lengths - #1765

Open
andrewstellman wants to merge 1 commit into
NVIDIA-BioNeMo:mainfrom
andrewstellman:thd-cp-divisibility-guard
Open

andrewstellman wants to merge 1 commit into
NVIDIA-BioNeMo:mainfrom
andrewstellman:thd-cp-divisibility-guard

Conversation

@andrewstellman

@andrewstellman andrewstellman commented Sep 29, 2026 •

Copy link
Copy Markdown

Description

The THD branch of _split_batch_by_cp_rank floor-divides each padded sequence length by 2 * cp_world_size without checking that the division is exact, so the remainder tokens reach no rank. For example, with cu_seqlens_padded = [0, 8, 18] and cp_world_size = 2, positions 16 and 17 are in neither rank's shard. The BSHD branch already raises for this; this adds the same check to THD.

The shipped CP configs are unaffected: they pad to a multiple of 2 * cp_size. This only fires when pad_sequences_to_be_divisible_by is overridden to a value that isn't, and such a run now fails on the first affected batch instead of dropping tokens. Like the BSHD check, it raises on CP rank 0 and the other ranks wait for the process-group timeout. A config-time check is an alternative if you'd prefer one.

The eight copies were regenerated with ci/scripts/check_copied_files.py --fix.

Found by Quality Playbook, an AI code-review tool, with Claude; I reviewed the change.

Usage

No interface change.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactor
  • Documentation update
  • Other (please describe):

CI Pipeline Configuration

No extra labels requested.

Pre-submit Checklist

  • I have tested these changes locally: no GPU here. The new non-divisible test fails before the change and passes after, run outside the tree because collator.py imports transformer_engine.
  • I have updated the documentation accordingly (not applicable)
  • I have added/updated tests as needed
  • All existing tests pass successfully (needs a GPU; relying on CI)

The THD branch of _split_batch_by_cp_rank floor-divides each padded
sequence length by 2 * cp_world_size, so a length that is not a multiple
loses its remainder tokens from every CP rank's shard. Raise ValueError,
as the BSHD branch already does. Copies regenerated with
check_copied_files.py --fix.
@copy-pr-bot

copy-pr-bot Bot commented Sep 29, 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.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: NVIDIA-BioNeMo/bionemo-recipes/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b30ee92b-7172-4807-82c3-b9d50de960ad

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@andrewstellman
andrewstellman marked this pull request as ready for review September 29, 2026 18:39
@trvachov

Copy link
Copy Markdown
Collaborator

Thanks for this contribution! @pstjohn @jomitchellnv can you both review?

This branch has not been deployed

No deployments
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