Skip to content

TE: update test to be more stable #2156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2025

Conversation

kshitij12345
Copy link
Collaborator

@kshitij12345 kshitij12345 commented May 31, 2025

Running pytest thunder/tests/test_transformer_engine_executor.py -k test_te_linear_forward_backward_multiple_iteration[defau --count 200 (or testing with mxfp8_e4m3 recipe).

Could lead to

>       assert_close(w1, te_linear1.weight)
E       AssertionError: Tensor-likes are not close!
E       
E       Mismatched elements: 16777216 / 16777216 (100.0%)
E       Greatest absolute difference: nan at index (0, 0) (up to 1e-05 allowed)
E       Greatest relative difference: nan at index (0, 0) (up to 0.016 allowed)

This was most likely due to not correctly initializing the linear and using dummy data. Have updated the test to initialize the Linear and also updated the target tensor for training.

Now running pytest thunder/tests/test_transformer_engine_executor.py -k test_te_linear_forward_backward_multiple_iteration[defau --count 200 passes for all cases. Tested on both H100 and B200 where default recipe is DelayedScaling and MXFP8BlockScaling respectively.

@kshitij12345 kshitij12345 marked this pull request as ready for review May 31, 2025 19:49
@kshitij12345 kshitij12345 requested a review from IvanYashchuk May 31, 2025 19:50
Copy link
Collaborator

@t-vi t-vi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but let's have @IvanYashchuk take a look if he wants.

Copy link
Collaborator

@IvanYashchuk IvanYashchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the testing time change with the new target_value?

@kshitij12345
Copy link
Collaborator Author

On H100

Running - pytest thunder/tests/test_transformer_engine_executor.py -k test_te_linear_forward_backward_multiple_iteration[defau --count 200

Main Branch - ~12.3 seconds

Running 200 items in this shard

thunder/tests/test_transformer_engine_executor.py ........................................................................................................................................................................................................                                      [100%]

======================================================================================================================== 200 passed, 2000 deselected, 1200 warnings in 12.30s =========================================================================================================================

PR Branch - ~11.3 seconds

Running 200 items in this shard

thunder/tests/test_transformer_engine_executor.py ........................................................................................................................................................................................................                                      [100%]

======================================================================================================================== 200 passed, 2000 deselected, 1200 warnings in 11.32s =========================================================================================================================

Shouldn't be very different for B200.

@kshitij12345 kshitij12345 merged commit b0dc72e into Lightning-AI:main Jun 1, 2025
53 checks passed
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.

3 participants