Skip to content

ENH: Implement UC-04, cross-env comparisons - #81

Merged
ev-br merged 9 commits into
benchx-dev:mainfrom
ev-br:uc-04
Nov 5, 2026
Merged

ev-br merged 9 commits into
benchx-dev:mainfrom
ev-br:uc-04

Conversation

@ev-br

@ev-br ev-br commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Implement UC-04 style fixed branch, cross-environment comparisons.

The PR is on top of gh-71.
Since the "stack" of PRs gets deep and unwieldy, here's the same PR sent against gh-71 branch on my fork: ev-br#6.

Also to simplify reviewing, the first commit adds the plan file, and the last commit removes.

The CLI spellings end up a bit different from the UC-04 itself, am happy to tweak further or discuss.
There's a demo in prototype/examples/numpy-venvs:

$ cd benchx/prototype/examples/numpy-venvs
$ ./run.sh 
== 1. the user prepares both environments; benchx builds nothing
  .venv-a: numpy 1.26.4
  .venv-b: numpy 2.0.2
== 2. the caller's loop: alternate the sides, round by round, one slot per call
precision: 3 processes x 3 values (config: /home/ev-br/proj/quansight/benchx/prototype/examples/numpy-venvs/benchx.conf.json)
  round 0, slot 0: side a
precision: 3 processes x 3 values (config: /home/ev-br/proj/quansight/benchx/prototype/examples/numpy-venvs/benchx.conf.json)
  round 0, slot 1: side b
precision: 3 processes x 3 values (config: /home/ev-br/proj/quansight/benchx/prototype/examples/numpy-venvs/benchx.conf.json)
  round 1, slot 2: side a
precision: 3 processes x 3 values (config: /home/ev-br/proj/quansight/benchx/prototype/examples/numpy-venvs/benchx.conf.json)
  round 1, slot 3: side b
precision: 3 processes x 3 values (config: /home/ev-br/proj/quansight/benchx/prototype/examples/numpy-venvs/benchx.conf.json)
  round 2, slot 4: side a
precision: 3 processes x 3 values (config: /home/ev-br/proj/quansight/benchx/prototype/examples/numpy-venvs/benchx.conf.json)
  round 2, slot 5: side b
== 3. compare: the sides differ in the numpy the collector read
run numpy-1793123241  profile environments  baseline numpy-1.26.4  contender numpy-2.0.2  [local-only]
  numpy-1.26.4: how built: {"summary":{"numpy":"1.26.4"}}
  numpy-2.0.2: how built: {"summary":{"numpy":"2.0.2"}}
  differs: coordinates.environment.system.deps.numpy, coordinates.environment.system.deps.sha256

IMPROVED (1)
  bench_sort                       wall-time  effect  -81.20%  noise   0.27%  rounds=3

NO CHANGE DETECTED (2)
  bench_matmul                     wall-time  effect  +10.34%  noise   5.34%  rounds=3
  bench_sum                        wall-time  effect   -0.50%  noise   0.23%  rounds=3
== 4. the check: declare numpy 2.0.2 for a run in the venv that has 1.26.4
precision: 3 processes x 3 values (config: /home/ev-br/proj/quansight/benchx/prototype/examples/numpy-venvs/benchx.conf.json)
  the results carry collector-mismatch; the run went ahead, with the numpy it found

ev-br pushed a commit to ev-br/benchx that referenced this pull request Oct 29, 2026
This is a follow-up PR:
- benchx-dev#83 adds the design docs
- this PR is branched off benchx-dev#81, and
  needs a rebase once that one lands
@ev-br ev-br changed the title Implement UC-04, cross-env comparisons ENH: Implement UC-04, cross-env comparisons Oct 29, 2026
ev-br pushed a commit to ev-br/benchx that referenced this pull request Nov 1, 2026
This is a follow-up PR:
- benchx-dev#83 adds the design docs
- this PR is branched off benchx-dev#81, and
  needs a rebase once that one lands
ev-br pushed a commit to ev-br/benchx that referenced this pull request Nov 1, 2026
This is a follow-up PR:
- benchx-dev#83 adds the design docs
- this PR is branched off benchx-dev#81, and
  needs a rebase once that one lands
@ev-br ev-br mentioned this pull request Nov 3, 2026
ev-br's Claude Code Agent and others added 9 commits November 3, 2026 09:58
Compare two environments with separate `bx bench` calls joined by a run
key. Place a run in a session with --label, --round and --slot, and
describe each environment with the user's own collector, checked with
verify/expect. Typed declared facts (--component, build) are deferred.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Calls that share a --run-key become the sides of one session, so two
environments can be measured by separate calls and compared with
`bx compare --run`. The caller's loop keeps the slot counter.

Refused before an order is built: any of the three without --run-key
(the default key is a timestamp per call), --label or --round without
--slot (the ingest key only gets its slot suffix when a slot is set, so
two sides would collide), a malformed or repeated label, a negative
number. With a slot, the order is written to orders/order-<slot>.json,
as in bx compare, so the calls do not overwrite each other's order.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The comparison now lists the facts that differ between the sides
(unmatched_differences, which it already computed) and the warnings the
sides' results carry (the schema's per-unit `caveats`), without changing
a verdict. The refusals say what to change: the sides differ only in their
label (describe the environment with a collector or a setup file), the
sides do not alternate (same order every round), the attempt counts differ
(same number of rounds), a call has no label or slot.

tests/test_uc04.py runs UC-04 in process: separate `bx bench` calls with
--run-key, --label, --round and --slot, the sides told apart by a context
collector or by a setup file, then `bx compare --run`.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
benchx leaves its own output (the store, the results directory, --out) out
of the tree identity with exclude pathspecs. `git add -A` refuses an
exclude pathspec that names a path the project's .gitignore already
ignores, so the tree id came out unknown whenever the results directory
was git-ignored, which is common. Such paths are now left out of the
excludes: git leaves them out anyway.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Two venvs hold different numpy versions, which no single process can, so
run.sh drives separate `bx bench` calls that alternate round by round
under one --run-key, with --label, --round and --slot, then compares them
with `bx compare --run`. A context collector (describe_env.py) tells the
sides apart: it prints the numpy its Python imports, which lands under
environment.system.deps. The provider declares each side's numpy in
how_built, and the collector's `verify: how_built` with `on_fail: warn`
flags a side whose environment is not the declared one.

The README carries the map from UC-04's spellings to the prototype's.
The CI workflow runs the example on one matrix cell (it makes its own
Python 3.12 venvs). prototype-design.md and the prototype README document
the session flags and the collector route. The plan is updated to match
the script as built.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
run.sh assumes uv, fixes the numpy versions (1.26.4 and 2.0.2), the Python
(3.12) and the rounds (3) in upper-case variables at the top, and sources
each venv's activate directly: activating another venv replaces the one
before, so there is no deactivate and no subshell. Checked with uv venvs
under set -euo pipefail. provider.sh reads the versions from the
environment run.sh exports, so versions.env is gone.

Running the default pair for the first time showed that benchx cannot
import pyarrow 25 under numpy 1.26.4 ("pyarrow requires NumPy 2.0 or
newer"), and benchx imports pyarrow. The venvs install pyarrow<25 (up to
24 imports under numpy 1.26.4). The CI step loses its ROUNDS override.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ev-br pushed a commit to ev-br/benchx that referenced this pull request Nov 3, 2026
This is a follow-up PR:
- benchx-dev#83 adds the design docs
- this PR is branched off benchx-dev#81, and
  needs a rebase once that one lands

@MaanasArora MaanasArora left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks right on a high-level read, no objections to merging and iterating!

@ev-br
ev-br merged commit 36280f7 into benchx-dev:main Nov 5, 2026
6 checks passed
@ev-br

ev-br commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @MaanasArora ! I'll merge, rebase the next PR in the "stack" (#89), and expand the discussion of the context collectors / identity design in gh-97. This will need some redesign, as you noted in #71 (comment)

ev-br pushed a commit to ev-br/benchx that referenced this pull request Nov 5, 2026
This is a follow-up PR:
- benchx-dev#83 adds the design docs
- this PR is branched off benchx-dev#81, and
  needs a rebase once that one lands
ev-br pushed a commit to ev-br/benchx that referenced this pull request Nov 5, 2026
This is a follow-up PR:
- benchx-dev#83 adds the design docs
- this PR is branched off benchx-dev#81, and
  needs a rebase once that one lands
ev-br pushed a commit to ev-br/benchx that referenced this pull request Nov 5, 2026
This is a follow-up PR:
- benchx-dev#83 adds the design docs
- this PR is branched off benchx-dev#81, and
  needs a rebase once that one lands
ev-br pushed a commit to ev-br/benchx that referenced this pull request Nov 5, 2026
This is a follow-up PR:
- benchx-dev#83 adds the design docs
- this PR is branched off benchx-dev#81, and
  needs a rebase once that one lands
ev-br added a commit that referenced this pull request Nov 6, 2026
* ENH: allow dirty trees in local comparisons

This is a follow-up PR:
- #83 adds the design docs
- this PR is branched off #81, and
  needs a rebase once that one lands

* TST: ignore dirty-tree warnings in the setup_scope tests

The two asv tests that came in with setup_scope assert the exact quality
warnings of a result. With dirty trees allowed in local comparisons, a
result also carries the dirty-* warnings the test earns by running in a
tree with uncommitted files, so compare through warnings_of(), as the
collector and pyperf tests do.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants