test(bench): establish reproducible Criterion host baseline (#22) - #51
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c80103fe81
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fn input_view(data: &[f32], shape: Shape) -> ArrayBuf<f32, &[f32]> { | ||
| ArrayBuf::new(data, shape).expect("construct input view") |
There was a problem hiding this comment.
Pin the host benchmarks to the host platform
When this target is compiled with --features opencl or --all-features—which the documented future accelerator groups will require—ArrayBuf uses the top-level Platform, whose select implementation in src/platform.rs dispatches inputs of at least GPU_MIN_SIZE to OpenCL. Consequently, these supposedly stable host groups (including construction at line 87) will benchmark OpenCL for the medium and large cases while still reporting host-only, Rayon, corrupting the intended host-versus-accelerator comparison. Use explicitly host-backed array types or otherwise prevent these groups from being built on the feature-dependent top-level platform.
Useful? React with 👍 / 👎.
Establishes a reproducible Criterion benchmark baseline on
mainfor the host/Rayon platform, ahead of the CubeCL HAL migration. Host-only, built against the current public API with--no-default-features. No public API or default features are changed. Draft PR per the issue execution contract (draft_pr_only: true, completion authority: human).Changed files
Cargo.toml— addcriteriondev-dependency (default-features = false,cargo_bench_support) and thehost_benchmarks[[bench]]target (harness = false).benches/host_benchmarks.rs— the six benchmark categories over the documented shape matrix (harness = false, custommainprints the environment block).tests/benchmark_support/mod.rs— shared deterministic fixture + environment-recording utility (included via#[path]by both the bench and the determinism test).tests/bench_determinism.rs— verifies the fixture is deterministic, in range, seed-distinct, and that environment probing succeeds.docs/benchmarking/README.md— inventory, local execution, environment recording, comparison rules, and how Introduce backend abstraction and minimal CubeCL backend #34–[Validation] Add reproducible CubeCL CPU and accelerator conformance runner #50 should add comparable CubeCL groups without changing these host baselines.docs/benchmarking/initial-results.md— initial result artifact + exact environment identity..github/workflows/benchmarks.yml— CI step compiling benchmarks withcargo bench --no-run --no-default-features(no timing on shared CI), plus fmt check and host-only tests.README.md— replaced the stalebenchmark-branch instructions with a pointer to the new baseline.Cargo.lockis intentionally not committed (the repo gitignores it for a library).Benchmark inventory and operation mapping
ha-ndarrayops are lazy; operation-only benchmarks build deterministic input data once outside the measured region, build a cheap borrowed view per iteration in the untimediter_batchedsetup, and measure op construction + materialization viaNDArrayRead::buffer.criterion::black_boxis used throughout.construct_convertis the only intentionally end-to-end group (includes allocation + copy).ArrayBuf::convert(&data, shape)(alloc + copy)construct_convertNDArrayUnary::expunary_expNDArrayMath::add(same-shape)binary_addNDArrayTransform::broadcast+NDArrayMath::addbinary_add_broadcastNDArrayReduceAll::sum_allreduce_sum_allMatrixDual::matmulmatmulNDArrayTransform::transpose(materialized)transposeSubstitution note: axis-reduction (
NDArrayReduce::sum) requires an owned'staticaccessor via the publicreduce_axespath (Accessor::from(A)has aB: 'staticbound), sosum_all(available on borrowed inputs) is used as the representative reduction. No product functionality was added to make a benchmark possible.Shape matrix: elementwise/reduction/transform use
[16,16](latency),[256,256](medium),[1024,1024](throughput);matmuluses[16,16],[96,96],[256,256]. IDs encodedtype/shape(e.g.matmul/f32/256x256).Exact commands executed
Environment / toolchain identity
Benchmark compilation result
cargo bench --no-run --no-default-featuressucceeds in a clean checkout (Finished \bench` profile [optimized]`).Initial Criterion result artifact
All 21 benchmarks; Criterion reports
[lower mean upper]. Full machine-readable output is intarget/criterion/<group>/<bench>/new/estimates.json(not committed); seedocs/benchmarking/initial-results.mdfor the complete table. Highlights:These numbers are specific to the machine above and are a baseline, not a threshold.
Total benchmark duration
cargo bench --no-default-features(21 benchmarks,sample_size=10,warm_up_time=1s,measurement_time=3s): 103 s wall time.Test results
cargo test --no-default-features— all host-only tests pass, including the 5 newbench_determinismtests (arithmetic 2, bench_determinism 5, compare 7, cond 1, construct 3, linalg 2, reduce 3, transform 9).Known limitations / unavailable validation
all-feature validation (explicit non-goal; left to Introduce backend abstraction and minimal CubeCL backend #34–[Validation] Add reproducible CubeCL CPU and accelerator conformance runner #50).'staticaccessor requirement);sum_allused instead.matmulnot in the baseline shape matrix.Implements #22.