Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

omp: reset CPU affinity before the tuning re-exec (fixes #471)#476

Merged
JustVugg merged 1 commit into
JustVugg:devJustVugg/colibri:devfrom
veerareddyvishal144:fix-omp-reexec-affinityveerareddyvishal144/colibri:fix-omp-reexec-affinityCopy head branch name to clipboard
Jul 21, 2026
Merged

omp: reset CPU affinity before the tuning re-exec (fixes #471)#476
JustVugg merged 1 commit into
JustVugg:devJustVugg/colibri:devfrom
veerareddyvishal144:fix-omp-reexec-affinityveerareddyvishal144/colibri:fix-omp-reexec-affinityCopy head branch name to clipboard

Conversation

@veerareddyvishal144

Copy link
Copy Markdown
Contributor

Implements the fix you sketched in #471: reset the master thread's affinity to all online CPUs immediately before the execv, so the second image's libgomp constructor enumerates places from the full core set and the user's OMP_PROC_BIND/OMP_PLACES work as documented. Clamped to CPU_SETSIZE, and a sched_setaffinity failure just warns and proceeds (the re-exec still happens, behaviour = status quo).

Also adds the #471 note to docs/tuning.md next to the "explicit OMP_* settings always take precedence" paragraph, with COLI_OMP_TUNED=1 documented as the escape hatch.

Verified on the affected host (2× Xeon 8370C, 48C/2 NUMA, GLM-5.2 int4 fully resident)

Repro env from #471 (OMP_NUM_THREADS=48 OMP_PROC_BIND=spread OMP_PLACES=cores, no escape hatch, re-exec taken — [OMP] hot-thread tuning: re-exec once present in stderr):

before after
Cpus_allowed_list (engine, mid-decode) 0-1 0-95
greedy decode 0.11 tok/s 4.34 tok/s (32-token run; matches this host's normal I4S=1 rate)

Build: 0 warnings; oracle 32/32 TF passes.

One nuance from the issue thread, made explicit: a deliberate outer restriction (taskset/numactl -C around the whole process) is also widened by this reset. If that matters, gating the reset on "current mask ⊂ one core while OMP_PROC_BIND is set" is a follow-up option; kept to your simpler version here.

execv preserves the CPU affinity mask. With user-exported
OMP_PROC_BIND/OMP_PLACES, libgomp's constructor binds the master thread
to place 0 before main() runs; the re-exec'd image inherited that
one-core mask, enumerated OMP_PLACES=cores inside it, and jailed the
whole team on one core (~20x slowdown, measured 0.11 vs 2.65 tok/s on
a 2-socket 48C Ice Lake). Reset affinity to all online CPUs right
before execv so the fresh libgomp binds from the full set; the user's
OMP_* env still takes precedence. Verified on the same host: with
OMP_PROC_BIND=spread OMP_PLACES=cores and no COLI_OMP_TUNED escape
hatch, the re-exec'd engine now reports Cpus_allowed_list 0-95 and
decodes at full speed. Adds the JustVugg#471 note to docs/tuning.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@JustVugg
JustVugg merged commit 766dd07 into JustVugg:dev Jul 21, 2026
JustVugg added a commit that referenced this pull request Jul 21, 2026
#476's sched_setaffinity/CPU_* reset needs _GNU_SOURCE before the first system
header. The standalone engine build defines it at the top of colibri.c (reset
stays active where #471 needs it), but test TUs #include colibri.c after
<assert.h>/<math.h>, so CPU_SETSIZE is exposed too late and the C test suite
failed to compile (CPU_SETSIZE undeclared). Guard the block: active in make
glm/colibri, compiled-out in tests (which never re-exec).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.