Skip to content

Implement a differentiable variant of the PGOP order parameter#123

Draft
janbridley wants to merge 8 commits into
mainfrom
feat/logsumexp
Draft

Implement a differentiable variant of the PGOP order parameter#123
janbridley wants to merge 8 commits into
mainfrom
feat/logsumexp

Conversation

@janbridley

@janbridley janbridley commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Description

If PGOP were discontinuous, it would be more suitable for use as a CV in metadynamics and other enhanced sampling techniques. However, the current formulation is non-smooth for several reasons. The first (and most significant) is optimization, as identifying the optimal orientation using a grid search is not differentiable. However, in the case where we fix the orientation of the OP we can ignore this. Therefore, the important problem to solve is the differentiability of the PGOP compute itself. This PR is an initial attempt at doing so.

LogSumExp is a smooth approximation of the max function that is used for nearest-neighbor correspondences inside the PGOP compute. This obeys the following inequalities: ${\displaystyle \max {{x_{1},\dots ,x_{n}}}\leq \mathrm {LSE} (x_{1},\dots ,x_{n})\leq \max {{x_{1},\dots ,x_{n}}}+\log(n).}$. More simply, this gives us a smooth upper bound on the discontinuous max function that underlies the core OP. This shifts the scale of the OP (as the order parameter is no longer guaranteed in [0, 1]) but is numerically stable and reasonably well studied.

In standard PGOP, each point j contributes:

  overlap_j = max_m  exp(-d²_m · denom)
            = exp(-min_m(d²_m) · denom)           // hard max

The smooth variant replaces this with:

  overlap_j = (1/β) · log( Σ_m exp(β · (-d²_m · denom)) )


where increasing β more closely approximates the discontinuous curve

This kernel will be significantly slower than a single execution of the non-smooth OP, but won't be used with optimization which means it's probably still usable. I can also make this much faster if we decide its useful.

Motivation and Context

Resolves: #???

How Has This Been Tested?

Existing tests pass when setting smooth_beta to 10.0, meaning we can recover the original behavior (save for the [0, 1] bounding) with a reasonably small exponential scale. This should be reverted before merging and tested separately, but currently stands as a proof of concept.

Checklist:

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.

1 participant