Skip to content

Conversation

jomitchellnv
Copy link
Contributor

Description

This PR creates the following folder

TransformerEngine/examples/pytorch/transformer:
├── context_parallel_runner_bshd.py
├── context_parallel_runner_thd.py
├── model.py
├── __pycache__
├── README.md
├── run_context_parallel.sh
├── test_context_parallel_bshd.py
├── test_context_parallel_thd.py
└── utils.py

That provides integration tests for the THD and BSHD input formats. The test compares context parallel runs to their non context parallel counterparts.

Logits, loss, and gradients are compared for both of these scenarios with pass/fail criteria established in the testing files.

The models architecture consists of an embedding layer and 1 TE.TransformerLayer for simplicity.

Moreover, we also provide utilities for moving data to CP shards when we are using BSHD and SBHD input formats.

TODO: Not sure how you want to add this test suite into the broader testing stuff.

Fixes # (issue)

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • Creates a simple transformer and runs integration tests on it for CP and non CP comparisons.
  • Improvement to context parallel utility handling, that handles dynamic sequence dimensions during CP sharding, error checking, as well as support for the BSHD and SBHD input formats

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@jomitchellnv jomitchellnv force-pushed the context-parallel-transformer-tests branch 4 times, most recently from 5f9353b to 82e6105 Compare September 16, 2025 20:57
Signed-off-by: Jonathan Mitchell <[email protected]>
@jomitchellnv jomitchellnv force-pushed the context-parallel-transformer-tests branch from d7ec4d3 to 9c61cd7 Compare September 16, 2025 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants