TransformerEngine
TransformerEngine copied to clipboard
Context Parallel integration tests with a transformer layer: BSHD and THD + CP
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)
- [X] 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:
- [X] I have read and followed the contributing guidelines
- [X] The functionality is complete
- [X] I have commented my code, particularly in hard-to-understand areas
- [X] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [X] I have added tests that prove my fix is effective or that my feature works
- [X] New and existing unit tests pass locally with my changes