graph: reset scheduler before remaining shared-sched graph allocs
The talker path already resets the scheduler before allocating its graph (thanks Andi Marafioti, #4 of qwentts.cpp). The same shared scheduler is also allocated elsewhere without a reset first. The scheduler keeps split and tensor->backend assignments from the previous graph. Allocating a different graph topology on a dirty scheduler can reuse stale assignments, which is exactly the CPU divergence Andi fixed for the talker. Resetting before alloc_graph is the canonical GGML contract and is idempotent when the scheduler is already clean. Suggested-by: Andres Marafioti <andimarafioti@gmail.com>
This commit is contained in:
@@ -240,6 +240,7 @@ static bool code_predictor_run(const CodePredictorWeights * cw,
|
|||||||
ggml_set_output(logits);
|
ggml_set_output(logits);
|
||||||
ggml_build_forward_expand(gf, logits);
|
ggml_build_forward_expand(gf, logits);
|
||||||
|
|
||||||
|
ggml_backend_sched_reset(sched);
|
||||||
if (!ggml_backend_sched_alloc_graph(sched, gf)) {
|
if (!ggml_backend_sched_alloc_graph(sched, gf)) {
|
||||||
fprintf(stderr, "[CodePredictor] FATAL: graph allocation failed\n");
|
fprintf(stderr, "[CodePredictor] FATAL: graph allocation failed\n");
|
||||||
ggml_backend_sched_reset(sched);
|
ggml_backend_sched_reset(sched);
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ static bool project_text_ids_backend(PipelineTTS * pt, const int32_t * ids, int
|
|||||||
struct ggml_cgraph * graph = ggml_new_graph_custom(gctx, max_nodes, false);
|
struct ggml_cgraph * graph = ggml_new_graph_custom(gctx, max_nodes, false);
|
||||||
ggml_build_forward_expand(graph, out);
|
ggml_build_forward_expand(graph, out);
|
||||||
|
|
||||||
|
ggml_backend_sched_reset(pt->sched);
|
||||||
if (!ggml_backend_sched_alloc_graph(pt->sched, graph)) {
|
if (!ggml_backend_sched_alloc_graph(pt->sched, graph)) {
|
||||||
ggml_backend_sched_reset(pt->sched);
|
ggml_backend_sched_reset(pt->sched);
|
||||||
ggml_free(gctx);
|
ggml_free(gctx);
|
||||||
@@ -244,6 +245,7 @@ static void project_ref_codes_backend(PipelineTTS * pt, const int32_t * ref_code
|
|||||||
struct ggml_cgraph * graph = ggml_new_graph_custom(gctx, max_nodes, false);
|
struct ggml_cgraph * graph = ggml_new_graph_custom(gctx, max_nodes, false);
|
||||||
ggml_build_forward_expand(graph, sum);
|
ggml_build_forward_expand(graph, sum);
|
||||||
|
|
||||||
|
ggml_backend_sched_reset(pt->sched);
|
||||||
if (!ggml_backend_sched_alloc_graph(pt->sched, graph)) {
|
if (!ggml_backend_sched_alloc_graph(pt->sched, graph)) {
|
||||||
ggml_backend_sched_reset(pt->sched);
|
ggml_backend_sched_reset(pt->sched);
|
||||||
ggml_free(gctx);
|
ggml_free(gctx);
|
||||||
|
|||||||
Reference in New Issue
Block a user