Skip to content

Commit e8e3362

Browse files
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 <[email protected]>
1 parent f79b23a commit e8e3362

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

src/code-predictor-forward.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ static bool code_predictor_run(const CodePredictorWeights * cw,
240240
ggml_set_output(logits);
241241
ggml_build_forward_expand(gf, logits);
242242

243+
ggml_backend_sched_reset(sched);
243244
if (!ggml_backend_sched_alloc_graph(sched, gf)) {
244245
fprintf(stderr, "[CodePredictor] FATAL: graph allocation failed\n");
245246
ggml_backend_sched_reset(sched);

src/prompt-builder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ static bool project_text_ids_backend(PipelineTTS * pt, const int32_t * ids, int
161161
struct ggml_cgraph * graph = ggml_new_graph_custom(gctx, max_nodes, false);
162162
ggml_build_forward_expand(graph, out);
163163

164+
ggml_backend_sched_reset(pt->sched);
164165
if (!ggml_backend_sched_alloc_graph(pt->sched, graph)) {
165166
ggml_backend_sched_reset(pt->sched);
166167
ggml_free(gctx);
@@ -244,6 +245,7 @@ static void project_ref_codes_backend(PipelineTTS * pt, const int32_t * ref_code
244245
struct ggml_cgraph * graph = ggml_new_graph_custom(gctx, max_nodes, false);
245246
ggml_build_forward_expand(graph, sum);
246247

248+
ggml_backend_sched_reset(pt->sched);
247249
if (!ggml_backend_sched_alloc_graph(pt->sched, graph)) {
248250
ggml_backend_sched_reset(pt->sched);
249251
ggml_free(gctx);

0 commit comments

Comments
 (0)