Skip to content

Update Low Precision LayerNorm arguments #1994

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 26 commits into from
Feb 28, 2023
Merged

Conversation

nik-mosaic
Copy link
Contributor

@nik-mosaic nik-mosaic commented Feb 23, 2023

This PR changes the Low Precision LayerNorm (LPLN) arguments to match the torch.nn.LayerNorm arguments, so a user can manually replace a LayerNorm layer with an LPLN layer. Please note that using
apply_low_precision_layernorm(model)
will replace all torch.nn.LayerNorms for you, so it is not necessary to use the LPLayerNorm class directly.

On exporting models with LPLN:
LowPrecision LayerNorm works with ONNX exporting, but it does not support Torchscript. torch.get_autocast_gpu_dtype() is not supported by Torchscript.

We change the test test_gpu_huggingface_export_for_inference_onnx to use LPLN instead of Fused LayerNorm to verify export functionality.

@nik-mosaic nik-mosaic marked this pull request as ready for review February 28, 2023 00:30
nik-mosaic and others added 3 commits February 27, 2023 16:34
@mvpatel2000 mvpatel2000 self-requested a review February 28, 2023 00:52
@nik-mosaic nik-mosaic merged commit dfa1d59 into mosaicml:dev Feb 28, 2023
@nik-mosaic nik-mosaic deleted the nik/lpln branch February 28, 2023 01:32
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.

4 participants