Skip to content

Conversation

phu0ngng
Copy link
Collaborator

Description

In this PR, we add an additional check to detect whether the input is partitioned in the sequence dimension and only trigger the amax reduction across TPSP in that case.
With this change, the using_global_amax_of_x is no longer needed.

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

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

Signed-off-by: Phuong Nguyen <[email protected]>
Signed-off-by: Phuong Nguyen <[email protected]>
Copy link
Collaborator

@jberchtold-nvidia jberchtold-nvidia left a comment

Choose a reason for hiding this comment

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

Left one question, pending that LGTM. Thanks!

sequence_dim = 0 if batch_sequence_transpose else 1
# Run AR across TPSP only when tensor-sequence is detected in the input spec
if amax_scope is AmaxScope.TPSP and x_spec[sequence_dim] == gmesh.tpsp_resource:
amax = lax_paral_op(amax, jax.lax.pmax, gmesh.tpsp_resource, mesh)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Previously, we would also AR in the gmesh.tp_resource dim. To keep the previous behavior, do we still need to reduce on TP if amax_scope is TPSP but the sequence dim is TP not TPSP? Or is it okay to only reduce when tpsp is active?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We only do AG the sequence dimension before the GEMM in TPSP, thus amax reduction is needed.

If users use TP for TPSP, there are existing warnings in the GEMM op to warn users to switch to TPSP.

@phu0ngng
Copy link
Collaborator Author

/te-ci JAX L1

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