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:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user