GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mbote-droid/bioeng-termbench: Terminal benchmark of biomedical engineering tasks for AI agents, with physics-aware graders: Pennes bioheat (Crank-Nicolson), pharmacokinetic models, ECG R-peaks, closed-loop glucose with Kalman filtering. Graders red-teamed for reward hacking; CUDA/CuPy; 289 tests; preprint.

BranchesTags
Open more actions menu

Latest commit

 

History

23 Commits
23 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
agent_eval
agent_eval
 
 
docker
docker
 
 
docs
docs
 
 
gpu
gpu
 
 
results
results
 
 
scripts
scripts
 
 
src/bioengbench
src/bioengbench
 
 
tasks
tasks
 
 
tests
tests
 
 
validation
validation
 
 
workflow
workflow
 
 
.gitignore
.gitignore
 
 
.zenodo.json
.zenodo.json
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CITATION.cff
CITATION.cff
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
pyproject.toml
pyproject.toml
 
 
uv.lock
uv.lock
 
 

Repository files navigation

BioEng-TermBench

CI DOI Preprint License: MIT Python 3.12 uv Ruff mypy strict Dependabot

Linux Shell Make Docker Snakemake GNU Octave Julia Jupyter CUDA Harbor

Terminal-based biomedical engineering tasks with physics-aware graders, built to train and evaluate AI agents. Each task turns a real engineering workflow into a reproducible challenge in the Harbor task format, and each grader checks engineering correctness (units, conservation, order of accuracy, safety at the true parameters, robustness under uncertainty), not just "the script ran".

Why it exists. An agent trained on a reward learns whatever the grader accepts. A grader that only checks that output files exist will reward unit slips, unconverged solvers and controllers that are fine on average but dangerous for some patients. Here the grader is treated as the sensor in the training loop and is itself validated like an instrument: correct solutions written with different methods and languages must pass, realistic wrong solutions must fail with the right diagnostic code, every check must be necessary, and the sandbox must hold against attacks.

Paper. Mbote S. Validating the graders: physics-aware rewards for AI agents on biomedical engineering tasks. Preprint, Zenodo, 2026. doi:10.5281/zenodo.23309911

Tasks

task workflow the decision the maths drives references
t01-ecg-denoise-rpeaks denoise an ambulatory ECG, detect beats, HRV filter design: suppression vs morphology fidelity Python x2, Octave
t02-pk-fit-dose fit a two-compartment PK model to 14 noisy samples a dosing regimen that is safe for the true patient Python, Octave, Julia (graded in CI)
t03-glucose-closed-loop write an insulin pump controller, tested in the loop insulin every 5 min through meals, exercise and sensor faults Python, Octave
t04-bioheat-ablation verified bioheat solver + thermal ablation plan heating time and power, robust to +-20 % perfusion finite volumes, finite elements, Octave
t05-pk-debug find and fix five defects in a PK package what is wrong, judged against a specification fixed package

Details: docs/DESIGN.md. Equations and numerical methods: docs/EQUATIONS.md.

Quick start

uv sync --frozen        # locked environment (Python 3.12)
make check              # lint, strict typing, full test suite
uv run bioeng list
uv run bioeng grade t03-glucose-closed-loop \
    --submission tasks/t03-glucose-closed-loop/solution/controller.py \
    --seeds tasks/t03-glucose-closed-loop/tests/dev_seeds.txt

As root the grader refuses to run a submission without --sandbox-user (see docs/THREAT_MODEL.md). Every terminal workflow, from daily checks to the validation campaign and image builds: docs/WORKFLOWS.md.

Grader validation

make validate runs the campaign as a Snakemake workflow and regenerates docs/VALIDATION_REPORT.md, where every number is linked to a result file with provenance and a SHA-256 manifest:

  • references: independent correct solutions on many hidden cases; every failure is a false reject (Wilson / rule-of-three bounds);
  • negative controls: realistic mistakes, mostly one-edit mutants of a reference; each must fail with its expected code, and its chance of earning reward over 8 hidden cases must be below 5 %;
  • grader mutation testing: switch a check off, or move a threshold, and the test suite must notice;
  • red team: seven attacks on the sandbox (escape, symlinks, fork bomb, detached daemon, disk, memory, forging t03's simulation record).

Findings the process produced, not anticipated (full list with evidence in validation/FINDINGS.md):

  • t02's Wald test rejected correct fits (weak identifiability); replaced by a likelihood-ratio region.
  • A plain PID passed 90 % of t03 patients until exercise was modelled.
  • t04: damage-driven perfusion made second order unmeasurable; joint space-time refinement let error terms cancel; and the centre temperature is a poor convergence functional (the independent FEM reference failed on it in 2 of 8 cases), so the order is measured on the stored energy.
  • A t01 reference had an edge-detection bug (1 recording in 100); the grader was right.
  • The t01 median-baseline method sits on the 0.05 mV fidelity limit: it passes about half the recordings and fails the rest on FIDELITY only.
  • Two planted "mistakes" were acceptable solutions (equivalent mutants) and are kept as references.
  • Without the sandbox user a t03 controller forges its own simulation record and earns a pass.
  • Mutation testing showed most acceptance thresholds were unpinned; boundary tests now pin each one with the contract's numbers.

GPU benchmark

gpu/ holds a 3D version of the t04 solver (one code path for NumPy and CuPy, plus a fused CUDA kernel) and a benchmark that checks correctness before it times anything: the 3D solution converges to the 1D reference at measured order 2.0, and the fused kernel was compiled as C++ and matched the NumPy implementation bit for bit. Run it on a free Colab T4 with gpu/BioEng_GPU_Benchmark.ipynb.

Measured on a Tesla T4 (Colab; full table in gpu/results/results.md):

float64 float32
GPU agrees with NumPy (max difference) 7e-15 K n/a
observed order, 3D vs 1D reference (on the GPU) 2.02, 2.01, 2.00 n/a
fused kernel vs NumPy, 7.2 M nodes 112x 231x
fused kernel vs CuPy array code, 17 M nodes 3.1x 9.1x
full 4-minute treatment, 17 M nodes, 2233 steps n/a 12 s fused, 90 s CuPy

The NumPy baseline is plain array code on one Colab CPU core, so the NumPy speed-ups overstate what an optimised multi-core CPU code would lose. In float32 the fused kernel moves about 240 GB/s, three quarters of the T4's peak memory bandwidth. In float64 it reaches only about 70 GB/s: the T4's slow double-precision arithmetic, not memory, limits it.

Evaluating real agents

agent_eval/harness.py runs a tool-use agent loop against the Anthropic API or any of four OpenAI-compatible providers with free tiers (Groq, Gemini, OpenRouter, Cerebras), with your key read from the environment and never written to disk. It grades the result with the real, sandboxed grader and keeps the full transcript. Prompt caching and a per-attempt token budget keep the cost down. Harbor is the faithful path when Docker is available (harbor run -p tasks/<id> -a <agent> -m <model>).

make agent-baselines                                  # scripted oracle and no-op agents, no API key
make agent-eval PROVIDER=gemini MODEL=gemini-flash-latest TASKS="t05-pk-debug" ATTEMPTS=3   # free tier
make agent-eval MODEL=<anthropic-model-id> TASKS="t05-pk-debug" ATTEMPTS=3

The scripted baselines check the pipeline before any money is spent: the oracle earns reward 1 on every task, the no-op agent 0 (results/agent_eval/SUMMARY.md). Protocol, metrics and failure taxonomy: docs/AGENT_EVAL.md.

Layout

src/bioengbench/
  core/      lifecycle (Template Method), registry, sandboxed runner
             (local or Docker), interactive sessions, seeds, scoring
  checks/    strict readers, signal metrics, event matching, units, statistics
  models/    ECG (McSharry), two-compartment PK, Bergman glucose-insulin,
             Pennes bioheat with Arrhenius damage
  tasks/     one plugin per task: case generator + check suite
  tooling/   the `bioeng` CLI
tasks/<id>/  Harbor task: instruction.md, task.toml, environment/,
             solution/, tests/ (verifier), references/ (validation only)
validation/  probes, campaign, grader mutation, red team, report
workflow/    Snakefile for the campaign
gpu/         3D solver, CPU/GPU benchmark, Colab notebook
agent_eval/  agent harness, scripted baselines
docker/      agent and grader base images, hash-pinned requirements
docs/        technical report, requirements, architecture (ADRs), design, ICD,
             equations, diagrams, threat model, FMEA, data, workflows,
             validation report, agent evaluation
results/     validation campaign and agent evaluation result files

Documentation

document contents
TECHNICAL_REPORT problem, approach, validation results, limitations: start here
REQUIREMENTS requirement IDs with traceability to tests
ARCHITECTURE components, lifecycle, 12 architecture decision records
DESIGN each task's decision, checks and the mistakes they catch
ICD every interface: verifier, CLI, file schemas, the t03 protocol
EQUATIONS models, numerical methods, verification
DIAGRAMS Mermaid: components, sequences, campaign
THREAT_MODEL assets, STRIDE threats, mitigations, residual risk
FMEA insulin-pump FMEA behind t03; FMEA of the graders
DATA synthetic data generation and distributions
WORKFLOWS every terminal workflow
VALIDATION_REPORT generated evidence
AGENT_EVAL agent evaluation protocol, metrics, failure taxonomy, cost control

Reproducibility

  • uv.lock pins every Python dependency; Docker images install from hash-pinned requirement files; scripts/pin_base_images.sh pins base images by digest.
  • Seeds expand through numpy.random.SeedSequence; maths libraries run single-threaded; verdict JSON is key-sorted with rounded floats.
  • CI grades the same submission twice and fails unless the verdicts are byte-identical. Validation results carry provenance and a hash manifest.

Known limitations

  • Synthetic physiology only (see docs/DATA.md).
  • Docker images, Harbor runs and GitHub Actions are written but not executed in the build environment used so far (no Docker Hub access). Everything else (tests, grading, privilege drop, limits, red team, determinism) has been run, with a local interpreter that mirrors the agent image.
  • The t02 Julia port runs only in CI (job julia, graded on the dev seeds), not in the local validation campaign.
  • GPU numbers are from one Colab T4 session; other GPUs and CPUs will differ.
  • Public dev_seeds.txt splits are not held out; use private_seeds.txt.
  • Not a medical device. Not for clinical use.

Citation

If you use BioEng-TermBench, please cite it: GitHub's "Cite this repository" button reads CITATION.cff.

License

MIT

About

Terminal benchmark of biomedical engineering tasks for AI agents, with physics-aware graders: Pennes bioheat (Crank-Nicolson), pharmacokinetic models, ECG R-peaks, closed-loop glucose with Kalman filtering. Graders red-teamed for reward hacking; CUDA/CuPy; 289 tests; preprint.

doi.org/10.5281/zenodo.23309911

Topics

ai-agentsbenchmarkbioheat-transferbiomedical-engineeringcudacupyecggpukalman-filterllm-evaluationnumerical-methodspdepharmacokineticspythonred-teamingreproducibilityreward-hackingscientific-computingsnakemaketerminal-bench

Resources

Readme
MIT license

Security policy

Security policy
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.