Skip to content

refactor(c++): 🎨 implementation into either source or inline files - #203

Open
robertodr wants to merge 5 commits into
mainfrom
refactor-split-impls
Open

refactor(c++): 🎨 implementation into either source or inline files#203
robertodr wants to merge 5 commits into
mainfrom
refactor-split-impls

Conversation

@robertodr

@robertodr robertodr commented Aug 5, 2026

Copy link
Copy Markdown
Member

Summary

🤖 AI text below 🤖

This pull request primarily refactors and reorganizes the implementation of graph encoding and cross-rank storage logic in the monoprop library. The main changes involve moving inline function implementations from headers to a new .cpp file, improving encapsulation, and cleaning up header dependencies. Additionally, a new utility function is added for parameter validation.

Refactoring and Implementation Reorganization

  • Moved inline implementations from MPGraphEncodingStorage.h and MPGraphEncodingTypes.h into a new source file MPGraphEncoding.cpp, replacing inline functions with declarations in the headers. This improves build times and encapsulation of implementation details. [1] [2] [3] [4] [5] [6] [7]
  • Updated CMake configuration to compile the new MPGraphEncoding.cpp file as part of the build.

API and Dependency Cleanups

  • Removed unnecessary includes and unused code from headers, reducing header bloat and unnecessary dependencies. [1] [2] [3] [4]
  • Changed the inclusion of inline implementation files in MonomialPropagator.h to a single .inl file, further reducing header complexity.

New and Improved Utilities

  • Added a new function expected_num_params to Validation.cpp and exposed it in Validation.h, providing a utility to determine the expected number of parameters from a mapping vector. [1] [2]
  • Removed unused static utility functions from MonomialPropagator that are now provided elsewhere.

These changes improve code organization, maintainability, and build performance by isolating implementation details and reducing header dependencies.

Checklist

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

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:
  • I used the following tool to generate or modify code: GitHub Copilot, Claude Sonnet 4.6 and Claude Opus 4.8

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.

@robertodr robertodr changed the title refactor(c++): 🎨 split implementation into either source or inlin… refactor(c++): 🎨 implementation into either source or inline files Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

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

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.70%. Comparing base (16c3255) to head (0941331).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #203   +/-   ##
=======================================
  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.

@robertodr
robertodr force-pushed the refactor-split-impls branch from dd1ded4 to 959a78e Compare August 5, 2026 12:27
@robertodr
robertodr changed the base branch from chore-split-implementation to chore-cibuildwheel-conf August 5, 2026 12:27
@robertodr
robertodr force-pushed the refactor-split-impls branch from 8c8cd31 to 8c4a9ea Compare August 5, 2026 14:10
@robertodr
robertodr force-pushed the refactor-split-impls branch from 8c4a9ea to 8bb5b72 Compare August 5, 2026 14:42
@Panadestein
Panadestein force-pushed the refactor-split-impls branch from 8bb5b72 to d4d25ae Compare August 5, 2026 15:45
@robertodr
robertodr force-pushed the refactor-split-impls branch from d4d25ae to c5e4065 Compare August 5, 2026 16:12
@robertodr
robertodr force-pushed the refactor-split-impls branch 2 times, most recently from 64d772c to 6bde741 Compare August 5, 2026 19:18
@robertodr
robertodr force-pushed the refactor-split-impls branch 2 times, most recently from 97f4592 to e80a34b Compare August 6, 2026 09:20
@github-actions github-actions Bot added the cpp label Aug 6, 2026
@robertodr
robertodr force-pushed the refactor-split-impls branch from 56de96f to a4bad9a Compare August 6, 2026 10:04
Base automatically changed from chore-cibuildwheel-conf to main August 6, 2026 11:47
@robertodr
robertodr force-pushed the refactor-split-impls branch 2 times, most recently from bbffa88 to b57f203 Compare August 6, 2026 11:48
@robertodr
robertodr removed the request for review from fpietra August 6, 2026 11:48
@robertodr
robertodr force-pushed the refactor-split-impls branch from b57f203 to 0a38197 Compare August 7, 2026 08:17
@robertodr

Copy link
Copy Markdown
Member Author

Results of running just bench on this branch in comparison to main. No regression that I can see.

Heisenberg

Time

Operation main refactor-split-impls
model / hubbard 634.404 ms 650.501 ms
model / pauli 210.296 ms 212.944 ms
random / build_graph 9.231 ms 9.292 ms
random / energy 1.520 ms 1.263 ms
random / gradient 6.759 ms 3.709 ms
random / inplace 8.002 ms 7.873 ms
random / pare 4.028 ms 440.2 us

Memory (peak RSS)

Operation main refactor-split-impls
model / hubbard 217.61 MiB 216.55 MiB
model / pauli 159.72 MiB 159.81 MiB
random / build_graph 176.58 MiB 176.78 MiB
random / energy 175.51 MiB 175.71 MiB
random / gradient 181.27 MiB 181.48 MiB
random / inplace 197.15 MiB 197.32 MiB
random / pare 176.03 MiB 176.27 MiB

Schrödinger

Time

Operation main refactor-split-impls
random / build_graph 162.400 ms 157.635 ms
random / energy 19.136 ms 20.280 ms
random / gradient 40.633 ms 43.227 ms
random / inplace 111.969 ms 111.535 ms
random / pare 10.478 ms 17.221 ms

Memory (peak RSS)

Operation main refactor-split-impls
random / build_graph 23580.09 MiB 26896.44 MiB
random / energy 1919.83 MiB 1921.88 MiB
random / gradient 1953.00 MiB 1955.20 MiB
random / inplace 28983.84 MiB 32985.34 MiB
random / pare 1865.67 MiB 1866.43 MiB

@robertodr
robertodr force-pushed the refactor-split-impls branch from 0a38197 to 8ba6c49 Compare August 10, 2026 08:40
@robertodr
robertodr force-pushed the refactor-split-impls branch from 8ba6c49 to 0941331 Compare August 10, 2026 18:51
@robertodr
robertodr requested a review from Panadestein August 10, 2026 18:52
@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.

1 participant