[GH-ISSUE #40] Strata's Linux CPU topology detection counts SMT siblings separately #22

Closed
opened 2026-11-04 01:39:06 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @jugeeeemu on GitHub (Sep 28, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/40

Summary

In Strata's Linux implementation, physical_cores() currently enumerates the logical CPU IDs allowed by sched_getaffinity(), without deduplicating SMT siblings by physical core.

This differs from the Windows implementation, which explicitly selects one
logical processor per physical core.

The CLI help also describes the default pool size as:

every physical core except the one the host loop spins on

Existing example: #27

Issue #27 contains a Linux Ryzen 5 5600 (6C/12T) log showing:

11 expert-pool workers + the host thread

This looks consistent with the same behavior: all 12 logical CPUs are visible
to the pool instead of one logical CPU per physical core.

Reproduction

Environment:

  • Ubuntu 24.04.3 LTS
  • Intel Core i7-13700K (8 P-cores + 8 E-cores)
  • RTX 4070 12 GB
  • 128 GB DDR5
  • IQ3_S
  • Strata commit: b742ff9

CPU topology (lscpu -e=CPU,CORE,SOCKET):

CPU CORE SOCKET
  0    0      0
  1    0      0
  2    1      0
  3    1      0
  4    2      0
  5    2      0
  6    3      0
  7    3      0
  8    4      0
  9    4      0
 10    5      0
 11    5      0
 12    6      0
 13    6      0
 14    7      0
 15    7      0
 16    8      0
 17    9      0
 18   10      0
 19   11      0
 20   12      0
 21   13      0
 22   14      0
 23   15      0

With all logical CPUs visible:

taskset -c 0-23 ...
strata generate: 23 expert-pool workers + the host thread

With one logical CPU from each P-core plus all E-cores:

taskset -c 0,2,4,6,8,10,12,14,16-23 ...
strata generate: 15 expert-pool workers + the host thread

No --pool-workers override was used.

Performance impact

I came across this while experimenting with settings to improve performance.
For this issue, I reran the comparison under controlled conditions using the
engine's direct strata generate path rather than the chat/server UI.

I used a small deterministic synthetic prompt with the following options:

--tokens 248045,248045
--max-new 512
--suffix-draft 0
--pcie-mode dma
--pcie-frac 0.55
--stats

The only variable was the process CPU affinity; no --pool-workers override
was used.

Affinity Workers Decode tok/s
0-23 23 + host 33.90 / 30.00 / 32.12 (32.01 avg)
0,2,4,6,8,10,12,14,16-23 15 + host 37.94 / 37.70 / 35.61 (37.08 avg)

In this test, excluding the SMT siblings improved decode throughput by about
15.9%.

All six runs had identical speculative-decoding behavior:
168 rounds, 346/465 drafts accepted, 3.06 tokens/round.

Expected

On Linux, physical_cores() should select one allowed logical CPU per physical
core while respecting the process affinity mask, similar to the Windows
implementation.

English isn't my first language, so I used ChatGPT to help write this issue.
Sorry if any of the wording is unclear or awkward.

Originally created by @jugeeeemu on GitHub (Sep 28, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/40 ## Summary In Strata's Linux implementation, physical_cores() currently enumerates the logical CPU IDs allowed by sched_getaffinity(), without deduplicating SMT siblings by physical core. This differs from the Windows implementation, which explicitly selects one logical processor per physical core. The CLI help also describes the default pool size as: > every physical core except the one the host loop spins on ## Existing example: #27 Issue #27 contains a Linux Ryzen 5 5600 (6C/12T) log showing: ```text 11 expert-pool workers + the host thread ``` This looks consistent with the same behavior: all 12 logical CPUs are visible to the pool instead of one logical CPU per physical core. ## Reproduction Environment: - Ubuntu 24.04.3 LTS - Intel Core i7-13700K (8 P-cores + 8 E-cores) - RTX 4070 12 GB - 128 GB DDR5 - IQ3_S - Strata commit: `b742ff9` CPU topology (`lscpu -e=CPU,CORE,SOCKET`): ```text CPU CORE SOCKET 0 0 0 1 0 0 2 1 0 3 1 0 4 2 0 5 2 0 6 3 0 7 3 0 8 4 0 9 4 0 10 5 0 11 5 0 12 6 0 13 6 0 14 7 0 15 7 0 16 8 0 17 9 0 18 10 0 19 11 0 20 12 0 21 13 0 22 14 0 23 15 0 ``` With all logical CPUs visible: ```text taskset -c 0-23 ... strata generate: 23 expert-pool workers + the host thread ``` With one logical CPU from each P-core plus all E-cores: ```text taskset -c 0,2,4,6,8,10,12,14,16-23 ... strata generate: 15 expert-pool workers + the host thread ``` No `--pool-workers` override was used. ## Performance impact I came across this while experimenting with settings to improve performance. For this issue, I reran the comparison under controlled conditions using the engine's direct `strata generate` path rather than the chat/server UI. I used a small deterministic synthetic prompt with the following options: ```text --tokens 248045,248045 --max-new 512 --suffix-draft 0 --pcie-mode dma --pcie-frac 0.55 --stats ``` The only variable was the process CPU affinity; no `--pool-workers` override was used. | Affinity | Workers | Decode tok/s | |---|---:|---:| | `0-23` | 23 + host | 33.90 / 30.00 / 32.12 (**32.01 avg**) | | `0,2,4,6,8,10,12,14,16-23` | 15 + host | 37.94 / 37.70 / 35.61 (**37.08 avg**) | In this test, excluding the SMT siblings improved decode throughput by about **15.9%**. All six runs had identical speculative-decoding behavior: `168 rounds`, `346/465` drafts accepted, `3.06 tokens/round`. ## Expected On Linux, `physical_cores()` should select one allowed logical CPU per physical core while respecting the process affinity mask, similar to the Windows implementation. _English isn't my first language, so I used ChatGPT to help write this issue. Sorry if any of the wording is unclear or awkward._
Author
Owner

@Niko1221 commented on GitHub (Sep 28, 2026):

Thank you - a precise report with the measurement that makes it an easy fix. On Linux the pool now keeps one allowed CPU per physical core (package + core id from sysfs), like the Windows side, and still respects taskset (if the first sibling is left out, the other one is used). On your 13700K that is 15 workers + the host thread by default, the configuration you measured at +16%. Checked on a 6-core/12-thread Ryzen under WSL: 11 -> 5 workers. Released in 0.1.14.

<!-- gh-comment-id:5867759835 --> @Niko1221 commented on GitHub (Sep 28, 2026): Thank you - a precise report with the measurement that makes it an easy fix. On Linux the pool now keeps one allowed CPU per physical core (package + core id from sysfs), like the Windows side, and still respects `taskset` (if the first sibling is left out, the other one is used). On your 13700K that is 15 workers + the host thread by default, the configuration you measured at +16%. Checked on a 6-core/12-thread Ryzen under WSL: 11 -> 5 workers. Released in 0.1.14.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#22
No description provided.