"tests/git@developer.sourcefind.cn:OpenDAS/colossalai.git" did not exist on "f4ef2243582d9438cbc2f32d3d5b77f7d8e899d8"
Unverified Commit 13ed4b64 authored by LuGY's avatar LuGY Committed by GitHub
Browse files

[model zoo] add activation offload for gpt model (#582)

parent 46c9ba33
...@@ -165,8 +165,9 @@ class GPTBlock(CheckpointModule): ...@@ -165,8 +165,9 @@ class GPTBlock(CheckpointModule):
bias: bool = True, bias: bool = True,
apply_post_layernorm: bool = False, apply_post_layernorm: bool = False,
fuse_scale_mask_softmax: bool = False, fuse_scale_mask_softmax: bool = False,
checkpoint: bool = False): checkpoint: bool = False,
super().__init__(checkpoint) activation_offload: bool = False):
super().__init__(checkpoint, activation_offload)
self.apply_post_layernorm = apply_post_layernorm self.apply_post_layernorm = apply_post_layernorm
self.norm1 = col_nn.LayerNorm(normalized_shape=dim, eps=layernorm_epsilon, dtype=dtype) self.norm1 = col_nn.LayerNorm(normalized_shape=dim, eps=layernorm_epsilon, dtype=dtype)
self.attn = GPTSelfAttention(dim=dim, self.attn = GPTSelfAttention(dim=dim,
...@@ -252,7 +253,8 @@ class GPT(nn.Module): ...@@ -252,7 +253,8 @@ class GPT(nn.Module):
bias: bool = True, bias: bool = True,
apply_post_layernorm: bool = False, apply_post_layernorm: bool = False,
fuse_scale_mask_softmax: bool = False, fuse_scale_mask_softmax: bool = False,
checkpoint: bool = False) -> None: checkpoint: bool = False,
activation_offload: bool = False) -> None:
super().__init__() super().__init__()
self.embed = GPTEmbedding(embedding_dim=dim, self.embed = GPTEmbedding(embedding_dim=dim,
vocab_size=vocab_size, vocab_size=vocab_size,
...@@ -274,6 +276,7 @@ class GPT(nn.Module): ...@@ -274,6 +276,7 @@ class GPT(nn.Module):
apply_post_layernorm=apply_post_layernorm, apply_post_layernorm=apply_post_layernorm,
fuse_scale_mask_softmax=fuse_scale_mask_softmax, fuse_scale_mask_softmax=fuse_scale_mask_softmax,
checkpoint=checkpoint, checkpoint=checkpoint,
activation_offload=activation_offload
) for _ in range(depth) ) for _ in range(depth)
]) ])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment