Skip to content

Add new initializer: hyper_init#411

Open
sm2909 wants to merge 1 commit intoSciML:masterfrom
sm2909:master
Open

Add new initializer: hyper_init#411
sm2909 wants to merge 1 commit intoSciML:masterfrom
sm2909:master

Conversation

@sm2909
Copy link
Contributor

@sm2909 sm2909 commented Mar 25, 2026

Fixes #303

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the contributor guidelines, in particular the SciML Style Guide and COLPRAC.
  • Any new documentation only uses public API

Implementation Details

The hyper_init function executes the following steps:

  1. Sampling: Samples $N$ points on a Poincaré ball.
  2. Distance Calculation: Calculates hyperbolic distances between all sampled points, populating an $N \times N$ kernel.
  3. Weighting: Applies $\sigma$ on the kernel to establish geometry-aware kernel weights.
  4. Sparsification: Sparsifies the kernel by selecting the top $k$ values in each row.
  5. Scaling: Applies spectral scaling to finalize the matrix.

Refactoring & Helper Functions

To keep hyper_init clean, the logic is modularized into three helper functions (taking inspiration from the original Proof of Concept):

  • hyperbolic_distance_poincare
  • sample_poincare_points
  • topk_row_sparsify

Mathematical Assumptions

A simplifying assumption is used when sampling the radius $\rho$ from the Poincaré ball. To match the approximation used in the PoC, the radius is sampled linearly:

rho = rand(rng) * R_max

Instead of the exact inverse transform sampling method:

u = rand(rng)
rho = acosh(u * (cosh(R_max) - 1) + 1)

Questions:

  1. Method Signature: Could you please take a look at the method signature? If the kwargs need more clarity or better naming conventions, I am happy to adjust them.
  2. Verification & Testing: How can I formally verify that the initialization values produced are mathematically accurate for a hyperbolic init? The procedural implementation matches the PoC from my understanding. If there is a method to test this, I am happy to test it.

# rand_hyper

```@docs
# rand_hyper
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove #


## Keyword arguments

- `d`: Dimension of the hyperbolic manifold.
Copy link
Collaborator

Choose a reason for hiding this comment

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

better to avoid single letter kwargs

@MartinuzziFrancesco
Copy link
Collaborator

Thanks for looking into this! The implementation seems to be ok, although I will need to double check against the python code. There are a couple of minor changes to tackle in the meantime, I left some comments

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.

Hyperbolic initializer

2 participants