From e56d483a151a835e8ef8953ab956a63626940cfe Mon Sep 17 00:00:00 2001 From: woolcoxm <13604288+woolcoxm@users.noreply.github.com> Date: Wed, 15 Jul 2026 16:31:18 -0400 Subject: [PATCH] run_text: TOKENS=1 env to dump generated token ids for path A/B comparison Opt-in (default off): prints the generated token ids to stderr after generation, for exact comparison across decode paths (e.g. the S=1 resident pipeline vs the CPU path). Used to verify the pipe_layer_sparse gate relaxation is token-exact vs the CPU decode path (see #273). --- c/glm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/c/glm.c b/c/glm.c index c75fcf2..5880f19 100644 --- a/c/glm.c +++ b/c/glm.c @@ -3916,6 +3916,14 @@ static void run_text(Model *m, const char *snap, const char *prompt, int ngen){ for(int i=0;i<4;i++) printf(" %-42s %5.1f%% (%lld/%lld)\n", nm[i], la_tot[i]?100.0*la_hit[i]/la_tot[i]:0.0, (long long)la_hit[i], (long long)la_tot[i]); } + /* TOKENS=1: dump the generated token ids (newline-separated) to stderr, + * for exact A/B comparison across decode paths (e.g. resident vs CPU). + * The ids are all[np .. np+produced-1]. */ + if(getenv("TOKENS") && atoi(getenv("TOKENS"))){ + fprintf(stderr,"[TOKENS] %d generated:",produced); + for(int i=np;i