Skip to content

fix(partition): 🔇 collapse identical COMMPLACE repeats - #286

Merged
Panadestein merged 3 commits into
mainfrom
fix/commplace-collapse-repeats
Aug 26, 2026
Merged

fix(partition): 🔇 collapse identical COMMPLACE repeats#286
Panadestein merged 3 commits into
mainfrom
fix/commplace-collapse-repeats

Conversation

@diagonal-hamiltonian

@diagonal-hamiltonian diagonal-hamiltonian commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Summary

Follow-up to #269, which made the COMMPLACE line unconditional at review request. That change is
correct and I am not walking it back — but making it unconditional exposed its volume, and the
volume is a defect:

One serial 585-test Python run emits 437 COMMPLACE lines, and all 437 are the same string.

A process has one placement. Reporting it 437 times is noise, not data, and it is on main now.

fix/commplace-collapse-repeats f87b662, 2 commits on 34db77d, 4 files +42/−8.

Why #269 did not catch this

Because it measured with pytest capturing. #269's body states that "the whole Python suite emits
nothing" — that reading came from a run without -s, and pytest's fd capture swallows C++ stderr.
Same arm, same command, -s the only difference:

COMMPLACE lines
pytest … -q 0
pytest … -q -s 1

The zero was capture, not silence. Any future measurement of this line needs -s, and the probe
script now says so in a comment rather than leaving the next person to rediscover it.

The fix

place_line_is_new(line) returns true the first time a line is seen and whenever it differs from the
previous call; PartitionGroup writes only when it does.

Three choices in it worth stating, because the obvious implementations are each wrong in a way:

  • It compares the whole line, not a once-flag. A std::call_once would report the first
    placement only. A process that builds an alone propagator before an MPI one has two placements
    and both are worth saying; a changed line still gets through.
  • It is a non-template free function in CpuTopology.cpp, not a static local in
    PartitionGroup<NumModes>.
    A static inside the template gets one guard per NumModes
    instantiation, so the collapse would leak one line per distinct mode count.
  • It returns a bool rather than writing. The write stays at the call site, and the collapse is
    testable without capturing stderr — which is exactly the instrument that hid the problem.

The second commit takes the argument by std::string_view (SonarQube cpp:S6009 on the first): the
function only compares and assigns, so it never needed to bind a std::string.

No knob, no behaviour change to what a distinct placement reports, and nothing branches on it.

Measurement

Arm md5 f34e996d. The counts are the point of the PR, so they are the measurement:

before (34db77d) after (d7ff600)
Python suite, 585 tests, -s 437 lines, 1 distinct 1
C++ unit binary 19 lines, 1 distinct 1

Gates on f34e996d: ctest -L unit 239/239, -L serial 238/238, job COMPLETED 0:0. The unit
count is one above main's 238 because of the new case. Python suite 585 passed, 8 deselected.
The string_view commit is a signature change only; its case still asserts 6 of 6 and the counts
above re-measured identically.

CI: all 16 checks green, clang-tidy 0 unsuppressed warnings, SonarQube 0 open issues.

The new case asserts 6 of 6 (--report_level=detailed) and covers the two failure modes separately:
a repeat is suppressed, and a changed line is not — the second is what a call_once implementation
would fail.

Ground-truth multi-rank behaviour is unchanged and re-verified with no env var set; the collapse is
per process, so co-located ranks still each report:

--cpu-bind=cores  COMMPLACE rank=0 node_rank=0 node_size=2 masks=private cpus=64  node_cpus=128 cpu_list=0-127
                  COMMPLACE rank=1 node_rank=1 node_size=2 masks=private cpus=64  node_cpus=128 cpu_list=0-127
--cpu-bind=none   COMMPLACE rank=0 node_rank=0 node_size=2 masks=shared  cpus=128 node_cpus=128 cpu_list=0-127
                  COMMPLACE rank=1 node_rank=1 node_size=2 masks=shared  cpus=128 node_cpus=128 cpu_list=0-127

These runs are not reproducible from the diff: they need the Deucalion harness, which is not in this
repo.

Checklist

  • Tests added or updated to cover the changes
  • Documentation updated (docstrings, docs/, CONTRIBUTING.md) if needed
  • CHANGELOG / release notes updated if applicable

Docs unchanged on purpose: parallelism.mdx already says the line is written per rank at propagator
construction with no knob, and that stays true.

AI/LLM disclosure

  • I did not use LLM tooling, or used it only privately for ideation
  • I used the following tool to help write this PR description: Claude Code
  • I used the following tool to generate or modify code: Claude Code

Important

By opening this PR I confirm that I have read CONTRIBUTING.md and I agree to the terms of the Contributor License Agreement.

Warning

If you're contributing on behalf of your employer, contact cla@algorithmiq.fi to arrange a Corporate CLA.

Making the line unconditional exposed its volume: the Python suite emitted 437
COMMPLACE lines in one 585-test serial run, and all 437 were the same string.
One process has one placement, so the repeats are noise, not data.

`place_line_is_new` compares the whole LINE rather than setting a once-flag: a
process that builds an `alone` propagator before an MPI one has two placements
and both are worth saying. Non-template so the guard is process-wide rather than
one per NumModes instantiation, and returned rather than written so the collapse
is testable without capturing stderr.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Docs preview: https://pr-286.monoprop-docs.pages.dev

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.70%. Comparing base (9888faa) to head (363ae4a).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #286   +/-   ##
=======================================
  Coverage   97.70%   97.70%           
=======================================
  Files          14       14           
  Lines         742      742           
  Branches       98       98           
=======================================
  Hits          725      725           
  Misses         12       12           
  Partials        5        5           
Flag Coverage Δ
cpp 97.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

SonarQube cpp:S6009 on the new signature. The function only compares and
assigns, so it never needed to own or bind a std::string.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@robertodr robertodr added this to the v0.9.0 milestone Aug 26, 2026
@Panadestein
Panadestein enabled auto-merge (squash) August 26, 2026 14:08
@Panadestein
Panadestein merged commit db46318 into main Aug 26, 2026
23 checks passed
@Panadestein
Panadestein deleted the fix/commplace-collapse-repeats branch August 26, 2026 14:11
@sonarqubecloud

Copy link
Copy Markdown

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.

3 participants