Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Llama Recipes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
meta-llama
Llama Recipes
Commits
fc5485d9
Commit
fc5485d9
authored
1 year ago
by
kldarek
Browse files
Options
Downloads
Patches
Plain Diff
fixing wandb for fsdp
parent
83a7c1ec
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/llama_recipes/finetuning.py
+7
-6
7 additions, 6 deletions
src/llama_recipes/finetuning.py
src/llama_recipes/utils/train_utils.py
+4
-5
4 additions, 5 deletions
src/llama_recipes/utils/train_utils.py
with
11 additions
and
11 deletions
src/llama_recipes/finetuning.py
+
7
−
6
View file @
fc5485d9
...
@@ -50,7 +50,7 @@ def setup_wandb(train_config, fsdp_config, **kwargs):
...
@@ -50,7 +50,7 @@ def setup_wandb(train_config, fsdp_config, **kwargs):
import
wandb
import
wandb
except
ImportError
:
except
ImportError
:
raise
ImportError
(
raise
ImportError
(
"
You are trying to use wandb which is not currently installed
"
"
You are trying to use wandb which is not currently installed
.
"
"
Please install it using pip install wandb
"
"
Please install it using pip install wandb
"
)
)
from
llama_recipes.configs
import
wandb_config
as
WANDB_CONFIG
from
llama_recipes.configs
import
wandb_config
as
WANDB_CONFIG
...
@@ -59,7 +59,7 @@ def setup_wandb(train_config, fsdp_config, **kwargs):
...
@@ -59,7 +59,7 @@ def setup_wandb(train_config, fsdp_config, **kwargs):
update_config
(
wandb_config
,
**
kwargs
)
update_config
(
wandb_config
,
**
kwargs
)
run
=
wandb
.
init
(
project
=
wandb_config
.
wandb_project
,
entity
=
wandb_entity
)
run
=
wandb
.
init
(
project
=
wandb_config
.
wandb_project
,
entity
=
wandb_entity
)
run
.
config
.
update
(
train_config
)
run
.
config
.
update
(
train_config
)
run
.
config
.
update
(
fsdp_config
)
run
.
config
.
update
(
fsdp_config
,
allow_val_change
=
True
)
return
run
return
run
...
@@ -84,6 +84,8 @@ def main(**kwargs):
...
@@ -84,6 +84,8 @@ def main(**kwargs):
clear_gpu_cache
(
local_rank
)
clear_gpu_cache
(
local_rank
)
setup_environ_flags
(
rank
)
setup_environ_flags
(
rank
)
wandb_run
=
None
if
train_config
.
enable_wandb
:
if
train_config
.
enable_wandb
:
if
not
train_config
.
enable_fsdp
or
rank
==
0
:
if
not
train_config
.
enable_fsdp
or
rank
==
0
:
wandb_run
=
setup_wandb
(
train_config
,
fsdp_config
,
**
kwargs
)
wandb_run
=
setup_wandb
(
train_config
,
fsdp_config
,
**
kwargs
)
...
@@ -152,9 +154,8 @@ def main(**kwargs):
...
@@ -152,9 +154,8 @@ def main(**kwargs):
peft_config
=
generate_peft_config
(
train_config
,
kwargs
)
peft_config
=
generate_peft_config
(
train_config
,
kwargs
)
model
=
get_peft_model
(
model
,
peft_config
)
model
=
get_peft_model
(
model
,
peft_config
)
model
.
print_trainable_parameters
()
model
.
print_trainable_parameters
()
if
train_config
.
enable_wandb
:
if
wandb_run
:
if
not
train_config
.
enable_fsdp
or
rank
==
0
:
wandb_run
.
config
.
update
(
peft_config
)
wandb_run
.
config
.
update
(
peft_config
)
#setting up FSDP if enable_fsdp is enabled
#setting up FSDP if enable_fsdp is enabled
if
train_config
.
enable_fsdp
:
if
train_config
.
enable_fsdp
:
...
@@ -260,7 +261,7 @@ def main(**kwargs):
...
@@ -260,7 +261,7 @@ def main(**kwargs):
fsdp_config
if
train_config
.
enable_fsdp
else
None
,
fsdp_config
if
train_config
.
enable_fsdp
else
None
,
local_rank
if
train_config
.
enable_fsdp
else
None
,
local_rank
if
train_config
.
enable_fsdp
else
None
,
rank
if
train_config
.
enable_fsdp
else
None
,
rank
if
train_config
.
enable_fsdp
else
None
,
wandb_run
if
train_config
.
enable_wandb
else
None
,
wandb_run
,
)
)
if
not
train_config
.
enable_fsdp
or
rank
==
0
:
if
not
train_config
.
enable_fsdp
or
rank
==
0
:
[
print
(
f
'
Key:
{
k
}
, Value:
{
v
}
'
)
for
k
,
v
in
results
.
items
()]
[
print
(
f
'
Key:
{
k
}
, Value:
{
v
}
'
)
for
k
,
v
in
results
.
items
()]
...
...
This diff is collapsed.
Click to expand it.
src/llama_recipes/utils/train_utils.py
+
4
−
5
View file @
fc5485d9
...
@@ -275,11 +275,10 @@ def evaluation(model,train_config, eval_dataloader, local_rank, tokenizer, wandb
...
@@ -275,11 +275,10 @@ def evaluation(model,train_config, eval_dataloader, local_rank, tokenizer, wandb
print
(
f
"
{
eval_ppl
=
}
{
eval_epoch_loss
=
}
"
)
print
(
f
"
{
eval_ppl
=
}
{
eval_epoch_loss
=
}
"
)
if
wandb_run
:
if
wandb_run
:
if
not
train_config
.
enable_fsdp
or
rank
==
0
:
wandb_run
.
log
({
wandb_run
.
log
({
'
eval/perplexity
'
:
eval_ppl
,
'
eval/perplexity
'
:
eval_ppl
,
'
eval/loss
'
:
eval_epoch_loss
,
'
eval/loss
'
:
eval_epoch_loss
,
},
commit
=
False
)
},
commit
=
False
)
return
eval_ppl
,
eval_epoch_loss
return
eval_ppl
,
eval_epoch_loss
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment