From bdae19dcd662a112700a769e5a0852daa7f56960 Mon Sep 17 00:00:00 2001 From: Lenard Dome <23503601+lenarddome@users.noreply.github.com> Date: Tue, 6 Oct 2026 10:32:44 +0200 Subject: [PATCH 1/9] bench(hierarchical): profile where the time of a fit goes Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 6 + benchmarks/hierarchical_profile.py | 249 ++++++++++++++++++ .../results/hierarchical-profile-before.csv | 18 ++ .../results/hierarchical-profile-cbm.csv | 8 + 4 files changed, 281 insertions(+) create mode 100644 benchmarks/hierarchical_profile.py create mode 100644 benchmarks/results/hierarchical-profile-before.csv create mode 100644 benchmarks/results/hierarchical-profile-cbm.csv diff --git a/CHANGELOG.md b/CHANGELOG.md index eb16efd8..a897058e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Added `benchmarks/hierarchical_profile.py`, which shows where the time of a `VariationalBayes` fit goes and counts the objective evaluations per participant and iteration. On the speed comparison with cbm (RLRW, 100 participants, 120 trials), cpm made 71 evaluations in the optimiser and 22 for the Hessian, against cbm's 72 in all, at 17.3 against 5.0 ms per participant and iteration: the gap is the cost of each evaluation, not their number + ## [0.26.0.dev1] - 2026-10-05 ### Added diff --git a/benchmarks/hierarchical_profile.py b/benchmarks/hierarchical_profile.py new file mode 100644 index 00000000..e3939d4f --- /dev/null +++ b/benchmarks/hierarchical_profile.py @@ -0,0 +1,249 @@ +""" +Where does the time of a hierarchical fit go? + + python benchmarks/hierarchical_profile.py [--data DATASET.csv] [--iterations 5] [--label NAME] + +Fits one dataset of the four-armed bandit (100 participants, 120 trials) with +`RLRW` and `VariationalBayes` for a fixed number of iterations, one chain and +two optimiser starts per participant, under `cProfile`. Prints the share of +time in the optimiser, the Hessian, `evaluate_fit`, the population update and +the parts of `objective`, and the number of objective evaluations per +participant and iteration, separately for the optimiser, the Hessian and +`evaluate_fit`. Writes the table to benchmarks/results/