Skip to content

hq: phase 4 - #63

Merged
adrn merged 5 commits into
mainfrom
hq-phase4
Oct 11, 2026
Merged

adrn merged 5 commits into
mainfrom
hq-phase4

Conversation

@adrn

@adrn adrn commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Support parallelization

adrn and others added 2 commits October 10, 2026 22:42
…set order

_expected_prior_keys returned sets, and both cache paths built the sample
dicts by iterating them, so the parameter order followed string hashing and
changed between processes with PYTHONHASHSEED. Results written by separate
processes (harv-hq shards, pool workers, MPI ranks) disagreed on column order.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- execution.py: run_serial and run_pool drivers over a picklable per-source
  setup and a sink; the pool spawns single-threaded workers with at most
  2*W sources in flight. mpi_comm imports mpi4py lazily.
- Run.run_rejection takes workers and mpi; under MPI the slice is
  rank/size, only rank 0 supersedes on --overwrite, and ranks meet at
  barriers after the start and at the end. Progress logged every ~5%.
- hq run --workers / --mpi; the harv-hq[mpi] extra.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@adrn
adrn requested a balanced review from Copilot October 11, 2026 02:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Rank-local failures can leave other MPI ranks blocked indefinitely at a barrier.

1 open finding
What changed in this PR

Adds parallel rejection sampling through local process pools, explicit shards, and MPI.

Changes:

  • Adds serial/pool/MPI execution drivers and progress reporting.
  • Adds MPI packaging, CLI support, and tests.
  • Stabilizes sampler parameter ordering across processes.
File Description
uv.lock Locks optional MPI dependency.
tests/​unit/​samplers/​test_prior_cache.py Tests deterministic parameter ordering.
src/​harv/​samplers/​rejection.py Preserves declaration order for sample keys.
packages/​hq/​tests/​unit/​test_hq_rejection.py Tests pool, shard, MPI, and progress behavior.
packages/​hq/​src/​harv_hq/​run.py Selects and coordinates execution modes.
packages/​hq/​src/​harv_hq/​rejection.py Adds per-process sampler setup.
packages/​hq/​src/​harv_hq/​execution.py Implements execution drivers.
packages/​hq/​src/​harv_hq/​cli.py Enables pool and MPI options.
packages/​hq/​pyproject.toml Adds the MPI optional extra.
packages/​hq/​docs/​spec.md Documents parallel execution.
packages/​hq/​docs/​implementation-plan.md Records phase-four implementation status.
docs/​spec.md Documents deterministic parameter ordering.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/hq/src/harv_hq/run.py
adrn and others added 3 commits October 10, 2026 22:55
A rank that raised outside per-source processing (supersede, provenance,
reading, writing) left its peers blocked at a barrier. It now logs the error
and calls COMM_WORLD.Abort(1). From the Copilot review of PR #63.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
patch.dict for the workers' thread environment, one progress log call, one
try for the MPI abort, and no unreachable worker guard.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Each rank runs a local pool over its slice, so a cluster job can use one
rank per node. --mpi still excludes --shard.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@adrn
adrn merged commit 875e786 into main Oct 11, 2026
13 checks passed
@adrn
adrn deleted the hq-phase4 branch October 11, 2026 03:24
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