-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
sync : ggml (backend v2) #3912
Merged
sync : ggml (backend v2) #3912
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
aa7a2c4
sync : ggml (backend v2) (wip)
ggerganov e819070
sync : migrate examples and llama.cpp to dynamic graphs (wip)
ggerganov 4fe646f
sync : update tests + fix max op params to 64
ggerganov 83c96d5
sync : ggml-cuda
ggerganov 8401e3e
llama : fix save/load state context size
ggerganov 815f44e
sync : try to fix build on tvOS
ggerganov 16e819d
sync : pass custom graph sizes in training examples
ggerganov e2349ec
sync : update graph copies to new ggml API
ggerganov f3fb45b
Merge branch 'master' into sync
ggerganov 7f8e2a5
sync : update sync-ggml.sh with new files
ggerganov 075ee61
Merge branch 'master' into sync
ggerganov dc22db7
scripts : fix header in sync script
ggerganov b1592ea
train : fix context size calculations
ggerganov e50ab5a
llama : increase inference graph size up to 4096 nodes
ggerganov 081a86d
Merge branch 'master' into sync
ggerganov aa1f36c
Merge branch 'master' into sync
ggerganov a4de804
train : allocate grads for backward graphs
ggerganov 548ec46
train : allocate grads for gb_tmp
ggerganov 9efc6b9
Merge branch 'master' into sync
ggerganov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1615,6 +1615,7 @@ int main(int argc, char ** argv) { | |
opt->params = ggml_opt_default_params(GGML_OPT_ADAM); | ||
opt->params.print_forward_graph = false; | ||
opt->params.print_backward_graph = false; | ||
opt->params.graph_size = LLAMA_TRAIN_MAX_NODES; | ||
opt->params.n_threads = params.common.n_threads; | ||
opt->params.past = params.common.opt_past; | ||
opt->params.delta = params.common.opt_delta; | ||
|
@@ -1768,11 +1769,11 @@ int main(int argc, char ** argv) { | |
for (unsigned order = 0; order < (unsigned) GGML_CGRAPH_EVAL_ORDER_COUNT; ++order) { | ||
ctx_compute = ggml_init(ctx_compute_params); | ||
alloc = ggml_allocr_new_measure(tensor_alignment); | ||
gf = ggml_new_graph(ctx_compute); | ||
gf = ggml_new_graph_custom(ctx_compute, LLAMA_TRAIN_MAX_NODES, true); | ||
gf->order = (enum ggml_cgraph_eval_order) order; | ||
gb = ggml_new_graph(ctx_compute); | ||
gb = ggml_new_graph_custom(ctx_compute, LLAMA_TRAIN_MAX_NODES, false); | ||
gb_tmp = params.common.use_checkpointing | ||
? ggml_new_graph(ctx_compute) | ||
? ggml_new_graph_custom(ctx_compute, LLAMA_TRAIN_MAX_NODES, false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
: NULL; | ||
loss = llama_build_lora_finetune_graphs( | ||
&model, &lora, alloc, ctx_compute, | ||
|
@@ -1801,11 +1802,11 @@ int main(int argc, char ** argv) { | |
mem_compute_data.resize(max_compute_size); | ||
ctx_compute = ggml_init(ctx_compute_params); | ||
alloc = ggml_allocr_new(mem_compute_data.data(), mem_compute_data.size(), tensor_alignment); | ||
gf = ggml_new_graph(ctx_compute); | ||
gf = ggml_new_graph_custom(ctx_compute, LLAMA_TRAIN_MAX_NODES, true); | ||
gf->order = best_order; | ||
gb = ggml_new_graph(ctx_compute); | ||
gb = ggml_new_graph_custom(ctx_compute, LLAMA_TRAIN_MAX_NODES, false); | ||
gb_tmp = params.common.use_checkpointing | ||
? ggml_new_graph(ctx_compute) | ||
? ggml_new_graph_custom(ctx_compute, LLAMA_TRAIN_MAX_NODES, false) | ||
: NULL; | ||
loss = llama_build_lora_finetune_graphs( | ||
&model, &lora, alloc, ctx_compute, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slaren Does this look OK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, I don't know if
gb
here needs grads or not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gb
needs grads, becausegb
also contains thegf
nodes, which have grads.Changing the
bool grads
argument fromfalse
totrue
resolves a triggered assert in ggml.cggml_graph_cpy
.With this change finetune runs, I will report back if the results are good as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
ggml_graph_cpy
be changed to allow skipping the grads if the src has them but not the dst?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was an additional - unrelated to this PR - regression in finetune and train-text-from-scratch due to new yarn rope implementation.
Changing
bool grads
argument to true and applying #3974 to fix the backward process of rope, the output of finetune is correct.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to note, lines 1805 and 1807 below needs that change as well, I missed them at first attempt to copy this fix.
Also, mentioned regression and #3974 fix seems to be critical, because otherwise finetune produces LORA's without any progress from one checkpoint to another.