Skip to content

Add rev11: pre-generate MC RNG, preserve azimuth chunking, and add validator/benchmark#8

Open
nicklasorte wants to merge 1 commit intomainfrom
codex/create-subchunk_agg_check_maxazi_rev11-implementation
Open

Add rev11: pre-generate MC RNG, preserve azimuth chunking, and add validator/benchmark#8
nicklasorte wants to merge 1 commit intomainfrom
codex/create-subchunk_agg_check_maxazi_rev11-implementation

Conversation

@nicklasorte
Copy link
Copy Markdown
Owner

Motivation

  • Improve runtime by removing per-iteration rng(...) reseeding and eliminating repeated random draws inside the MC loop while preserving the aggregate max-azimuth output contract.
  • Keep azimuth chunking as a memory/performance tuning knob rather than forcing full-azimuth expansion that can be memory-bound.
  • Provide tooling to validate statistical equivalence and to find a practical AZI_CHUNK for different environments.

Description

  • Added subchunk_agg_check_maxazi_rev11.m which seeds once with rng(rand_seed1) and pre-generates rand_pr_all, rand_eirp_all, and rand_clutter_all with dimensions [num_bs x num_mc_idx] and bounds [rel_min, rel_max] for use across MC iterations.
  • Restored/kept azimuth chunking as a tunable parameter with AZI_CHUNK_DEFAULT=128 and optional override via varargin, and added a short comment explaining the memory/performance tradeoff.
  • Preserved trusted aggregation semantics (dB→power via db2pow, sum across BS, power→dB via pow2db, then max over azimuth) and maintained nearest-point off-axis gain behavior.
  • Reduced hot-path overhead by gating debug NaN checks behind DEBUG_CHECKS=false and tracking per-chunk maximums to avoid repeated full-vector max scans.
  • Added validate_subchunk_agg_check_maxazi_rev10_rev11_statistical.m to run rev10 vs rev11 on identical inputs, report runtimes/speedup, compute distribution and upper-tail statistics, apply documented drift thresholds, and return a results struct with a PASS/FAIL flag.
  • Added benchmark_subchunk_agg_check_maxazi_rev11_chunk_sweep.m to sweep chunk sizes (default [64 128 256 512]) across trials, print a summary table, and recommend the fastest observed AZI_CHUNK.

Testing

  • Confirmed new files exist and were committed to the repository (subchunk_agg_check_maxazi_rev11.m, validate_subchunk_agg_check_maxazi_rev10_rev11_statistical.m, benchmark_subchunk_agg_check_maxazi_rev11_chunk_sweep.m) and the commit succeeded.
  • Performed static verification of created file contents by listing/printing the new files in the worktree.
  • Attempted to run automated runtime tests but MATLAB/Octave is not available in this environment, so the included validator and benchmark were not executed here and should be run in a proper MATLAB environment to validate runtime and statistical equivalence.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36a8e200b0

ℹ️ 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".

Comment on lines +50 to +54
rng(rand_seed1);
rel_span=(rel_max-rel_min);
rand_pr_all=rel_min+rel_span.*rand(num_bs,num_mc_idx);
rand_eirp_all=rel_min+rel_span.*rand(num_bs,num_mc_idx);
rand_clutter_all=rel_min+rel_span.*rand(num_bs,num_mc_idx);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Derive RNG stream from MC indices when pre-generating draws

This reseeds the generator with only rand_seed1 on every function call, so different sub_point_idx chunks regenerate the same random matrices whenever num_mc_idx is the same. In the chunked workflow (cell_sim_chunk_idx), that duplicates Monte Carlo realizations across chunks instead of producing unique draws per mc_iter, which can materially skew aggregate percentiles and reduce effective sample size. The pre-generation should incorporate sub_mc_idx/mc_iter identity (as prior revs did) or otherwise skip ahead in a deterministic way per chunk.

Useful? React with 👍 / 👎.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant