Skip to content

[JAX] Unifying GeLU and GeGLU in LayerNorm MLP - #765

Merged
denera merged 9 commits into
NVIDIA:mainfrom
phu0ngng:main
Apr 24, 2024
Merged

[JAX] Unifying GeLU and GeGLU in LayerNorm MLP#765
denera merged 9 commits into
NVIDIA:mainfrom
phu0ngng:main

Conversation

@phu0ngng

Copy link
Copy Markdown
Collaborator

This PR unifies the GeLU and GEGLU implementations in LayerNormMLP via a generalized fused_layernorm_fp8_mlp. Previously, there were two separate APIs for the two mentioned activations. The new routine takes activation_type: Tuple and use_bias: bool as two additional arguments, compared to old routines.

This is a preparation step for adding more activations (i.e. swiglu) later.

@deneradenera added enhancement New feature or request jax labels Apr 9, 2024
@deneradenera linked an issue Apr 9, 2024 that may be closed by this pull request
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
test_layer.py, and test_praxis_layer.py
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
@zlsh80826

Copy link
Copy Markdown
Collaborator

/te-ci jax

Comment threadtransformer_engine/jax/mlp.py Outdated
Comment threadtransformer_engine/jax/mlp.py Outdated
Comment threadtransformer_engine/jax/mlp.py Outdated
Comment threadtests/jax/test_custom_call_compute.py Outdated
Comment threadtransformer_engine/jax/mlp.py Outdated
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
@phu0ngngphu0ngng mentioned this pull request Apr 12, 2024

@deneradenera left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@denera

Copy link
Copy Markdown
Collaborator

@phu0ngng do you have CI permissions yet? If not, please check in with @ptrendx to get permissions and then trigger the CI run for this. We can merge once the tests come back clean.

@denera

Copy link
Copy Markdown
Collaborator

@phu0ngng Also please fix the linting errors here before the CI. Thanks!

************* Module transformer_engine.jax.flax.module
transformer_engine/jax/flax/module.py:690:26: W1401: Anomalous backslash in string: '\m'. String constant might be missing an r prefix. (anomalous-backslash-in-string)
transformer_engine/jax/flax/module.py:690:42: W1401: Anomalous backslash in string: '\s'. String constant might be missing an r prefix. (anomalous-backslash-in-string)
transformer_engine/jax/flax/module.py:690:48: W1401: Anomalous backslash in string: '\m'. String constant might be missing an r prefix. (anomalous-backslash-in-string)
transformer_engine/jax/flax/module.py:690:66: W1401: Anomalous backslash in string: '\e'. String constant might be missing an r prefix. (anomalous-backslash-in-string)
transformer_engine/jax/flax/module.py:691:17: W1401: Anomalous backslash in string: '\g'. String constant might be missing an r prefix. (anomalous-backslash-in-string)
transformer_engine/jax/flax/module.py:696:51: W1401: Anomalous backslash in string: '\g'. String constant might be missing an r prefix. (anomalous-backslash-in-string)
transformer_engine/jax/flax/module.py:702:64: W1401: Anomalous backslash in string: '\g'. String constant might be missing an r prefix. (anomalous-backslash-in-string)

@zlsh80826zlsh80826 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@mingxu1067mingxu1067 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Kindly remove the unnessary comment in tests/jax/test_custom_call_compute.py#332

Comment threadtransformer_engine/jax/flax/module.py Outdated
Comment threadtests/jax/test_custom_call_compute.py Outdated
Comment threadtests/jax/test_custom_call_compute.py Outdated
Comment threadtransformer_engine/jax/mlp.py Outdated

@mingxu1067mingxu1067 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Kindly remove the unnessary comment in tests/jax/test_custom_call_compute.py#332

@phu0ngng

Copy link
Copy Markdown
CollaboratorAuthor

/te-ci jax

Comment threadtests/jax/test_custom_call_compute.py Outdated
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
phu0ngngand others added 2 commits April 22, 2024 16:50
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Co-authored-by: Alp Dener <adener@nvidia.com>
Signed-off-by: Phuong Nguyen <36155692+phu0ngng@users.noreply.github.com>
@phu0ngng

Copy link
Copy Markdown
CollaboratorAuthor

/te-ci jax

@phu0ngng

Copy link
Copy Markdown
CollaboratorAuthor

Hi @denera, @mingxu1067,
I resolved all of your change requests.
Please have a look and let me know if you have any other suggestions.

@mingxu1067mingxu1067 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@denera
denera merged commit dac0001 into NVIDIA:mainApr 24, 2024
@zlsh80826

Copy link
Copy Markdown
Collaborator

Congratulations on your first pull request! @phu0ngng
This really help the future maintainance for various activation types!

pggPL pushed a commit to pggPL/TransformerEngine that referenced this pull request May 23, 2024
* combined layernorm_geglu with layernorm_gelu into fused_layernorm
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
* fixes to pass all unit tests in test_custom_call_compute.py,
test_layer.py, and test_praxis_layer.py
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
* cleaning and formatting
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
* renaming based on reviewers suggestions
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
* implemented partial fused layernorm
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
* geglu + bias passed tests
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
* added partial fused calculation for dbias_1
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
* clean up
Co-authored-by: Alp Dener <adener@nvidia.com>
Signed-off-by: Phuong Nguyen <36155692+phu0ngng@users.noreply.github.com>
---------
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Signed-off-by: Phuong Nguyen <36155692+phu0ngng@users.noreply.github.com>
Co-authored-by: Alp Dener <adener@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or requestjax

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@phu0ngng@zlsh80826@denera@ptrendx@mingxu1067