Skip to content

feat(autoresearch): --wave2d-perf <W>x<H> host flag (refs #3122 A1 / #3113 Task 1) - #3134

Merged
zackees merged 1 commit into
masterfrom
feat/3122-a1-wave2d-perf-host-flag
Jun 16, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/3122-a1-wave2d-perf-host-flag

Conversation

@zackees

@zackees zackees commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

A1 of meta #3122. Wires the device-side wave2dPerf (#3116) + perfProbe* (#3118) RPCs into a single host-driven measurement pass via bash autoresearch <board> --wave2d-perf <W>x<H>.

Sequence per run

  1. perfProbeMemcpy — SRAM throughput in MB/s.
  2. perfProbeNop — cycle calibration in us/iter.
  3. perfProbeRepeat — wave2dPerf reproducibility. std_dev_pct >= 5 stamps results UNTRUSTED.
  4. wave2dPerf × 4 — {FivePoint, NinePointIsotropic} × {compute, loads_only}.
    The loads_only/compute gap isolates memory cost from compute cost — critical for ESP32-S3 PSRAM analysis (cf. fix(wave): switch WaveSimulation2D_Real grids from vector_psram to SRAM (closes #3114) #3117).

Output

Live progress per RPC + final JSON dump with structured { grid, probes, bench, untrusted, untrusted_reasons }.

Naming

Per #3124, future perf-related flags use the --perf-XX prefix convention. This flag uses the original --wave2d-perf name per explicit user direction in this session ("don't fix this now, just file an issue"). #3124 tracks the prefix-rename pass.

Files

  • ci/autoresearch/args.py — wave2d_perf: str | None field + --wave2d-perf WxH argparse.
  • ci/autoresearch/context.py — wave2d_perf_grid: tuple[int, int] | None on RunContext.
  • ci/autoresearch/phases.py — grid-spec parsing, dispatch mode check, _run_wave2d_perf_tests(ctx) (~180 lines).
  • ci/tests/test_autoresearch_phases.py — extend _make_args and _make_run_context fixtures.

Validation

  • bash lint — clean.
  • uv run pytest ci/tests/test_autoresearch_phases.py — 48/48 pass.
  • uv run python -c "from ci.autoresearch.args import Args; print(Args.parse_args(['--wave2d-perf', '64x64', '--skip-lint', 'esp32s3']).wave2d_perf)" → 64x64 (parses correctly).

Refs #3122 A1, #3113 Task 1.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added --wave2d-perf command-line option to enable Wave2D performance benchmarking with configurable grid dimensions. Includes memory and computation profiling with stability tracking.
  • Chores

    • Updated test configuration defaults to support the new performance benchmark mode.

…1 / #3113 Task 1)

A1 of meta #3122. Wires the device-side wave2dPerf (#3116) + perfProbe*
(#3118) RPCs (refactored behind fl::wave_perf::* in #3120) into a
single host-driven measurement pass.

  bash autoresearch esp32s3 --wave2d-perf 64x64

Sequence per platform run:
  1. perfProbeMemcpy — SRAM throughput, MB/s.
  2. perfProbeNop    — cycle calibration, us/iter.
  3. perfProbeRepeat — wave2dPerf reproducibility, std_dev_pct.
                       >= 5% stamps results UNTRUSTED.
  4. wave2dPerf x 4 — { FivePoint, NinePointIsotropic } x
                       { compute, loads_only }.
                      The loads_only/compute gap isolates memory
                      cost from compute cost (critical for ESP32-S3
                      per #3114 / #3117 PSRAM analysis).

Output: per-RPC live progress + final JSON dump with structured
results { grid, probes, bench, untrusted, untrusted_reasons }.

Naming note: per #3124, future perf-related flags use the
--perf-XX prefix convention. This flag uses the original
--wave2d-perf name per explicit user direction in this session
("don't fix this now, just file an issue") — #3124 tracks the
prefix-rename pass for a future PR.

Args dataclass + RunContext extended with the new field; existing
test fixture updated to construct both with the new defaults. All
48 ci/tests/test_autoresearch_phases.py tests pass.

Refs #3122 A1, #3113 Task 1.
@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c4d07d53-dc11-4f50-ad83-d2dc0540d009

📥 Commits

Reviewing files that changed from the base of the PR and between ebfda30 and a70bd5e.

📒 Files selected for processing (4)
  • ci/autoresearch/args.py
  • ci/autoresearch/context.py
  • ci/autoresearch/phases.py
  • ci/tests/test_autoresearch_phases.py

📝 Walkthrough

Walkthrough

Adds a --wave2d-perf WxH CLI option for a Wave2D performance benchmark mode. The Args dataclass gains wave2d_perf: str | None, RunContext gains wave2d_perf_grid: tuple[int, int] | None, grid parsing with dimension validation is added to phases.py, and a new _run_wave2d_perf_tests coroutine executes RPC probe/benchmark sequences against a connected device.

Changes

Wave2D Performance Benchmark Mode

Layer / File(s) Summary
Args and RunContext data contracts
ci/autoresearch/args.py, ci/autoresearch/context.py
Args adds `wave2d_perf: str
CLI registration, validation, and RunContext wiring
ci/autoresearch/args.py, ci/autoresearch/phases.py
--wave2d-perf is registered under the driver selection group; phases.py adds sys import, validates WxH dimensions in [4, 1024] with stderr error and exit(2) on failure, and persists wave2d_perf_grid into RunContext.
Wave2D benchmark coroutine
ci/autoresearch/phases.py
Adds _run_wave2d_perf_tests: connects via RpcClient, sequentially calls perfProbeMemcpy, perfProbeNop, perfProbeRepeat (stability check via std_dev_pct), and wave2dPerf for two stencils in compute and loads-only modes; marks results untrusted on instability; prints human-readable and JSON summaries; handles RpcTimeoutError, KeyboardInterrupt, and general exceptions with finally cleanup.
Test helper defaults
ci/tests/test_autoresearch_phases.py
_make_args() and _make_ctx() gain wave2d_perf=None and wave2d_perf_grid=None defaults to keep existing tests constructing valid objects.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as CLI / parse_args
  participant phases as phases.py
  participant rpc as RpcClient
  participant device as Device

  CLI->>phases: --wave2d-perf WxH
  phases->>phases: validate W,H in [4,1024]
  phases->>phases: set RunContext.wave2d_perf_grid=(W,H)
  phases->>rpc: connect to device
  rpc->>device: perfProbeMemcpy
  device-->>rpc: result
  rpc->>device: perfProbeNop
  device-->>rpc: result
  rpc->>device: perfProbeRepeat
  device-->>rpc: std_dev_pct
  note over phases: untrusted=True if std_dev_pct > threshold
  loop each stencil × mode
    rpc->>device: wave2dPerf(stencil, mode)
    device-->>rpc: bench result
  end
  phases->>phases: print summary + JSON
  phases->>rpc: close (finally)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#3118: The new _run_wave2d_perf_tests coroutine calls perfProbeMemcpy, perfProbeNop, and perfProbeRepeat via RPC, which were introduced or renamed in that PR.
  • FastLED/FastLED#3120: The wave2dPerf RPC handler and std_dev_pct field consumed by the new benchmark coroutine were refactored in that PR to delegate to fl::wave_perf.
  • FastLED/FastLED#3116: The wave2dPerf RPC endpoint called by _run_wave2d_perf_tests was originally added in that PR's AutoResearchRemote.cpp handler.

Poem

🐇 Hop hop, a new grid to measure today,
WxH dimensions tucked neatly away.
The probes check for jitter, the stencils run fast,
JSON summaries printed — results meant to last.
If unstable? Mark untrusted and hop along,
This bunny benchmarks where computations belong! 🌊

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a --wave2d-perf CLI option with WxH grid-size parameter to the autoresearch tool, directly matching the primary changeset objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/3122-a1-wave2d-perf-host-flag

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant