wren runs its model on one BLAS thread

threadpoolctl scopes the limit to wren.act, so other numpy calls in the
engine keep their threads.
This commit is contained in:
2026-10-15 09:55:02 +02:00
parent f2a823218a
commit 5e5f1836cb
4 changed files with 48 additions and 1 deletions
+22
View File
@@ -143,3 +143,25 @@ def test_nothing_is_written_unless_applied_and_sure(fake_wren, params, confidenc
}
]
}
def test_the_model_runs_on_one_blas_thread(fake_wren, monkeypatch):
"""About twice as fast for a model this small; numpy is loaded by `mlp`."""
from threadpoolctl import threadpool_info
threads: list[int] = []
act = fake_wren.act
def counted(command: str, house: Any) -> tuple[list[Any], float]:
threads.extend(
pool["num_threads"]
for pool in threadpool_info()
if pool["user_api"] == "blas"
)
return act(command, house)
monkeypatch.setattr(fake_wren, "act", counted)
_node(("kitchen_lamp", DType.BOOL)).execute({"house.command": "lights on"})
assert threads
assert set(threads) == {1}