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
ColossalAI
Commits
084c9124
Unverified
Commit
084c9124
authored
Feb 06, 2024
by
Hongxin Liu
Committed by
GitHub
Feb 06, 2024
Browse files
[llama] fix memory issue (#5371)
* [llama] fix memory issue * [llama] add comment
parent
eb4f2d90
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
applications/Colossal-LLaMA-2/train.py
applications/Colossal-LLaMA-2/train.py
+4
-4
No files found.
applications/Colossal-LLaMA-2/train.py
View file @
084c9124
...
...
@@ -23,7 +23,7 @@ from colossal_llama2.utils.froze import freeze_non_embeds_parameters
from
colossal_llama2.utils.neftune_patch
import
activate_neftune
,
deactivate_neftune
from
torch.utils.tensorboard
import
SummaryWriter
from
tqdm
import
tqdm
from
transformers
import
LlamaConfig
,
LlamaForCausalLM
,
LlamaTokenizer
from
transformers
import
LlamaForCausalLM
,
LlamaTokenizer
import
colossalai
from
colossalai.accelerator
import
get_accelerator
...
...
@@ -232,10 +232,12 @@ def main() -> None:
else
nullcontext
()
)
with
init_ctx
:
model
=
LlamaForCausalLM
(
LlamaConfig
.
from_pretrained
(
args
.
pretrained
)
)
model
=
LlamaForCausalLM
.
from_pretrained
(
args
.
pretrained
)
# Freeze part of parameters.
if
args
.
freeze_non_embeds_params
:
freeze_non_embeds_parameters
(
model
=
model
)
# this is essential, otherwise the grad checkpoint will not work.
model
.
train
()
if
args
.
use_grad_checkpoint
:
model
.
gradient_checkpointing_enable
()
...
...
@@ -277,8 +279,6 @@ def main() -> None:
lr_scheduler
=
lr_scheduler
,
dataloader
=
dataloader
,
)
if
args
.
load_checkpoint
is
None
:
booster
.
load_model
(
model
,
args
.
pretrained
)
torch
.
set_default_dtype
(
torch
.
float
)
...
...
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