Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
TransformerEngine
Commits
379c1ee3
Unverified
Commit
379c1ee3
authored
Feb 08, 2024
by
Quentin Anthony
Committed by
GitHub
Feb 08, 2024
Browse files
Update example to use new TE_DType path (#660)
Signed-off-by:
Quentin Anthony
<
qganthony@yahoo.com
>
parent
91d52ac7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
docs/examples/quickstart_utils.py
docs/examples/quickstart_utils.py
+2
-1
No files found.
docs/examples/quickstart_utils.py
View file @
379c1ee3
...
@@ -205,8 +205,9 @@ def share_parameters_with_transformerlayer_te_model(te_model, basic_model):
...
@@ -205,8 +205,9 @@ def share_parameters_with_transformerlayer_te_model(te_model, basic_model):
def
cast_to_representable
(
inp
,
scale
=
1.
,
fp8_format
=
'e4m3'
):
def
cast_to_representable
(
inp
,
scale
=
1.
,
fp8_format
=
'e4m3'
):
import
transformer_engine.pytorch.cpp_extensions
as
texcpp
import
transformer_engine.pytorch.cpp_extensions
as
texcpp
import
transformer_engine_extensions
as
tex
import
transformer_engine_extensions
as
tex
from
transformer_engine.pytorch.constants
import
TE_DType
fp8_type
=
tex
.
DType
.
kFloat8E4M3
if
fp8_format
==
'e4m3'
else
tex
.
DType
.
kFloat8E5M2
fp8_type
=
tex
.
DType
.
kFloat8E4M3
if
fp8_format
==
'e4m3'
else
tex
.
DType
.
kFloat8E5M2
input_type
=
texcpp
.
TE_DType
[
inp
.
dtype
]
input_type
=
TE_DType
[
inp
.
dtype
]
meta
=
tex
.
FP8TensorMeta
()
meta
=
tex
.
FP8TensorMeta
()
meta
.
scale
=
torch
.
ones
(
1
,
dtype
=
torch
.
float32
,
device
=
"cuda"
)
*
scale
meta
.
scale
=
torch
.
ones
(
1
,
dtype
=
torch
.
float32
,
device
=
"cuda"
)
*
scale
meta
.
scale_inv
=
torch
.
ones
(
1
,
dtype
=
torch
.
float32
,
device
=
"cuda"
)
/
scale
meta
.
scale_inv
=
torch
.
ones
(
1
,
dtype
=
torch
.
float32
,
device
=
"cuda"
)
/
scale
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment