Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

#272 follow-up: --pool-affinity all (the pool's layout so far) is the default; auto and p-cores are opt-in

Niko1221cf3b351c195f
diff --git a/include/strata/kernels/cpu/pool.hpp b/include/strata/kernels/cpu/pool.hpp
index f3cd54e2a..76bda6def 100644
--- a/include/strata/kernels/cpu/pool.hpp
+++ b/include/strata/kernels/cpu/pool.hpp
@@ -63,15 +63,12 @@ struct ExpertJobMulti {
const void* nact[MAXT] = {};
};
-/// One logical processor per PHYSICAL core, so a worker is never scheduled onto an SMT sibling of another
-/// worker. On the 6-core/12-thread machine this project measures on, `hardware_concurrency()/2` workers on
-/// logical processors 0..5 would put every worker on a sibling pair and halve the useful bandwidth - which is
-/// exactly the kind of error that shows up as "the CPU path is slower than the model says" with no clue why.
-/// How worker threads are allocated across physical/logical CPU cores.
+/// How worker threads are allocated across physical/logical CPU cores (#272). `All` is the layout the pool has
+/// always used and the default; the hybrid-aware ones are opt-in (--pool-affinity auto|p-cores).
enum class PoolAffinity {
Auto, ///< Hybrid: prioritize physical P-cores, then SMT, then E-cores (defaults to P-core count)
PCores, ///< Restrict workers strictly to Performance cores and their SMT siblings
- All, ///< Legacy behavior: linear physical core order without hybrid distinction
+ All, ///< The default: one worker per physical core in the OS's order, without hybrid distinction
};
struct CpuTopology {
@@ -83,7 +80,7 @@ struct CpuTopology {
int host_core = -1; ///< Logical core reserved for host thread
};
-CpuTopology detect_cpu_topology(bool skip_first, PoolAffinity affinity = PoolAffinity::Auto);
+CpuTopology detect_cpu_topology(bool skip_first, PoolAffinity affinity = PoolAffinity::All);
/// One logical processor per PHYSICAL core, so a worker is never scheduled onto an SMT sibling of another
/// worker. On the 6-core/12-thread machine this project measures on, `hardware_concurrency()/2` workers on
@@ -91,7 +88,7 @@ CpuTopology detect_cpu_topology(bool skip_first, PoolAffinity affinity = PoolAff
/// exactly the kind of error that shows up as "the CPU path is slower than the model says" with no clue why.
///
/// `skip_first` drops the first core, which P2.S3 reserves for the host loop.
-std::vector<int> physical_cores(bool skip_first, PoolAffinity affinity = PoolAffinity::Auto);
+std::vector<int> physical_cores(bool skip_first, PoolAffinity affinity = PoolAffinity::All);
/// **THE RESERVATION IS A FICTION UNLESS THE HOST IS ACTUALLY PUT THERE.**
///
@@ -124,7 +121,7 @@ public:
/// threads on six cores. `false` is the A/B arm and exists so the change is measurable rather than
/// asserted - the counter it moves is `pool phases ... drain`, which is host-side and needs no profiler.
explicit ExpertPool(int n_workers = 0, bool pin = true, bool host_works = true,
- PoolAffinity affinity = PoolAffinity::Auto);
+ PoolAffinity affinity = PoolAffinity::All);
/// The watchdog's view of the pool (issue #31): the batch, the counters, every thread's state.
void diag(std::FILE* f) const;
~ExpertPool();
@@ -268,7 +265,7 @@ private:
};
const NativeFmt* nfmt_ = nullptr;
std::vector<SplitBufMulti> split_multi_;
- PoolAffinity affinity_ = PoolAffinity::Auto;
+ PoolAffinity affinity_ = PoolAffinity::All;
CpuTopology topo_;
};
diff --git a/src/program/generate.cpp b/src/program/generate.cpp
index 740952035..cdf6e04de 100644
--- a/src/program/generate.cpp
+++ b/src/program/generate.cpp
@@ -256,7 +256,8 @@ struct Options {
bool graph_only = false;
bool gpu_only_full = false; ///< R0.3: pre + post + head, the true per-token GPU floor
int pool_workers = 0; ///< R2.2: 0 = "all physical cores minus the host's"; >0 overrides
- strata::kernels::cpu::PoolAffinity pool_affinity = strata::kernels::cpu::PoolAffinity::Auto;
+ /// #272: the pool's core layout; `all` (the default) is the layout it always had, auto / p-cores are opt-in
+ strata::kernels::cpu::PoolAffinity pool_affinity = strata::kernels::cpu::PoolAffinity::All;
/// R2.2's first half, as an A/B arm. **ON by default**, because the measurement that justifies it is the
/// pool's own drain: 33.7 GB/s against 5/6 x 44.14 = 36.8 for five workers, on a machine whose sixth core
/// is reserved for a host thread that has nothing to do while the drain runs.
@@ -551,11 +552,12 @@ void usage() {
" pool is six threads on six cores instead of five plus an idle core;\n"
" this flag restores the five-worker form for comparison on `pool phases`.\n"
" --pool-workers N R2.2: CPU expert pool worker count. Default 0 = every physical core\n"
- " except the one the host loop spins on (or P-core count minus 1 on\n"
- " hybrid CPUs). A sweep is how the pool's deviation from `cpu_s2` is attributed.\n"
- " --pool-affinity MODE Worker CPU affinity: auto (default: prioritize P-cores), p-cores\n"
- " (strictly performance cores), or all (all physical cores without\n"
- " hybrid distinction).\n"
+ " except the one the host loop spins on (with --pool-affinity auto or\n"
+ " p-cores on a hybrid CPU: P-cores minus 1). A sweep is how the pool's\n"
+ " deviation from `cpu_s2` is attributed.\n"
+ " --pool-affinity MODE Worker CPU affinity: all (default: one worker per physical core, as\n"
+ " always), auto (hybrid CPUs: P-cores first, then their SMT siblings,\n"
+ " then E-cores) or p-cores (P-cores and their siblings only).\n"
" --coupled-draft enable coupled draft sampling for MTP drafter under sampling (STRATA_SPEC_COUPLED)\n"
" --no-coupled-draft disable coupled draft sampling (propose argmax drafts)\n"
" --mmap-experts R2.1: opt OUT of the resident expert arena, back to MapViewOfFile.\n"
@@ -2536,7 +2538,7 @@ int main(int argc, char** argv) {
srcp = &arena_src;
}
strata::kernels::cpu::ExpertPool pool(o.pool_workers, /*pin=*/true, /*host_works=*/!o.no_host_worker, o.pool_affinity);
- if (pool.is_hybrid()) {
+ if (pool.is_hybrid() && pool.affinity() != strata::kernels::cpu::PoolAffinity::All) {
const char* aff_str = pool.affinity() == strata::kernels::cpu::PoolAffinity::PCores ? "p-cores" :
pool.affinity() == strata::kernels::cpu::PoolAffinity::All ? "all" : "auto";
std::fprintf(stderr, "strata generate: hybrid CPU detected (%d P-cores / %d threads, %d E-cores), pool workers: %d, affinity: %s\n",