Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/tree recombination #504

Merged
merged 15 commits into from
Sep 8, 2024
Merged

Feature/tree recombination #504

merged 15 commits into from
Sep 8, 2024

Conversation

tc85324
Copy link
Contributor

@tc85324 tc85324 commented Mar 8, 2024

PR Type

Closes #497

  • Feature
  • Tests

Description

Provides CaratheodoryRecombination and TreeRecombination solvers that are JIT compatible and avoid shape based recursion (instead using the jax for loop and while loop primitives to minimise the compilation time).

While every effort has been made to be as computationally/memory efficient as possible, I suspect there remain many ways to enhance the performance/efficiency of the implementations. However, for now, I believe the performance level is sufficient for the solvers to be useful (we should seek further performance as and when user requirements demand it).

This pull also makes a small tweak to the Coresubset materialisation and testing, as these changes aided in checking the correctness of the recombination implementations.

How Has This Been Tested?

Dedicated tests have been added, which check for most (maybe all) degenerate cases that can arise during recombination. To minimise the additional time costs incurred by testing recombination, no additional recombination specific integration tests/examples have been added.

Does this PR introduce a breaking change?

No

Checklist before requesting a review

  • I have made sure that my PR is not a duplicate.
  • My code follows the style guidelines of this project.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have performed a self-review of my code.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • Any dependent changes have been merged and published in downstream modules.

@tc85324 tc85324 added enhancement New feature or request python Pull requests that update Python code labels Mar 8, 2024
@tc85324 tc85324 force-pushed the feature/tree-recombination branch from ad63ef9 to 752cae6 Compare May 30, 2024 09:42
@tc85324 tc85324 force-pushed the feature/tree-recombination branch from 752cae6 to 442e88e Compare July 17, 2024 13:07
@tc85324 tc85324 force-pushed the feature/tree-recombination branch 2 times, most recently from c8685dc to 77072da Compare July 30, 2024 06:41
Additionally enhances coreset testing.
Adds a new `recombination.py` module to the solvers subpackage,
providing a generalised `RecombinationSolver`, in addition to the
`CaratheodoryRecombination` and `TreeRecombination` solvers.

A `RecombinationSolverTest` case has been added to `test_solvers.py`,
covering the known degenerate cases that may arise in recombination.

The documentation has been updated where required, but no dedicated
new examples/documentation pages have been created.

Refs: #497
@tc85324 tc85324 force-pushed the feature/tree-recombination branch from 77072da to fbe7f2b Compare July 31, 2024 08:05
@tc85324 tc85324 marked this pull request as ready for review July 31, 2024 09:47
@tc85324 tc85324 requested a review from db091756 July 31, 2024 11:01
@db091756
Copy link
Member

db091756 commented Aug 1, 2024

Will try review this next week! Just merged in a refactor of kernel.py so any kernel imports should be updated @tc85324

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@db091756 db091756 left a comment

Choose a reason for hiding this comment

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

Looks really good. Just some doc changes, various questions and additional comments would help me to be more confident the code is doing what the papers say

@db091756
Copy link
Member

db091756 commented Aug 19, 2024

Apologies this took a while to get to, trying to wrap up work before leaving has taken more time than expected

Performed in response to reviewer comments on #504
Adds references to the original articles for Tchakaloff's theorem and
Caratheodory's convex hull theorem (in French/German respectively), in
addition to more recent, but for our purposes equivalent, references
written in English.
Makes clearer the correspondence between the Caratheodory recombination
algorithm implemented here, and the thesis of Tchernychova. Provides
additional clarity on the steps performed in Tree recombination.
@tc85324 tc85324 requested a review from db091756 August 30, 2024 13:53
Copy link
Member

@db091756 db091756 left a comment

Choose a reason for hiding this comment

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

I am much much happier with my understanding of the code/maths with these additional comments, thanks for adding!

Remaining is some hopefully simple Pyright fixes, and I think some of these private functions could live in util.py, e.g. _resolve_rcond, _prepare_tree, _centroid.

Also, what is your opinion on the private functions being added as static methods of the CaratheodoryRecombination class. Are there any JAX implications?

coreax/solvers/recombination.py Show resolved Hide resolved
coreax/solvers/recombination.py Outdated Show resolved Hide resolved
coreax/solvers/recombination.py Show resolved Hide resolved
coreax/solvers/recombination.py Outdated Show resolved Hide resolved
@db091756 db091756 self-requested a review September 3, 2024 11:48
Copy link
Member

@db091756 db091756 left a comment

Choose a reason for hiding this comment

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

Also, some merge conflicts need fixing!

Copy link
Contributor

github-actions bot commented Sep 4, 2024

Performance review

Commit 80f8308 - Merge 7fecf80 into 2bb9990

No significant changes to performance.

In attempting to placate the pyright linter a new, erroneous change
was made to the logic in `_resolve_null_basis`. This has been fixed
and the type hints updated appropriately.
Copy link
Contributor

github-actions bot commented Sep 4, 2024

Performance review

Commit e6d82f4 - Merge 4a620be into 2bb9990

No significant changes to performance.

Apparent runtime incompatibility with jaxtyping. Appears that the
`Shaped[TypeVar, ...]` syntax used for `_ElementOfOmega is not
supported (even if the TypeVar is bound by Array).
Copy link
Contributor

github-actions bot commented Sep 4, 2024

Performance review

Commit ee9f3e8 - Merge 9fc766b into 2bb9990

No significant changes to performance.

Copy link
Member

@db091756 db091756 left a comment

Choose a reason for hiding this comment

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

Looks good! Great feature

@db091756 db091756 merged commit df8f4fc into main Sep 8, 2024
23 checks passed
@db091756 db091756 deleted the feature/tree-recombination branch September 8, 2024 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tree Recombination
2 participants