Changelog¶
All notable changes to Hyperbolix will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased¶
[1.5.1] - 2026-11-16¶
Fixes from an audit of 1.5.0. Two defaults change: HypConv2DHyperboloid's init, and the output curvature of layers that take c_in and c_out. The rule that a manifold's dtype decides now also holds for a float64 c and for NumPy input. Apart from the two defaults and the fixes listed below, float32 results with a Python-float c and jax_enable_x64 off are unchanged, except for rounding-level changes in uniform_poincare.log_prob and in the gradient of lorentz_residual with respect to a learnable c. That comparison was made on the lockfile's jax 0.9.1. With jax 0.12 the input gradients of sinh_lift_to_hyperboloid, HypLinearHyperboloidPLFC and HypRegressionPoincare also change in the last bit (relative 3e-7 at most) for a c that float32 does not represent exactly, because c now enters as a float32 array instead of a weakly typed Python scalar; values are bit-identical there too.
Changed¶
- Values change:
HypConv2DHyperboloiddefaults toreset_params="fan_in"(normal,std = sqrt(1/hcat_out_ambient_dim), zero bias). The previous defaultU(-0.02, 0.02)shrank the spread of the spatial coordinates by a factor of 0.13 to 0.14 per layer, to about 3e-4 after four layers (16 channels, 3×3 kernels,c = 1), so a default-built stack froze without any NaN;fan_inkeeps each layer between 0.98 and 1.09.reset_params="uniform"restores the old init, and"default"stays accepted as an alias of it with bit-identical kernels. The old default was the FHCNN linear layer's init, not the reference conv's (Bdeir et al. 2023 draw kernel and bias fromU(-s, s),s = sqrt(2/((C-1)·k²))). See the initialization table. - Values change:
c_outandc_attndefault toc_ininstead of 1.0, inHTCLinear,HRCDropout,HRCLayerNorm,HRCRMSNorm,HRCBatchNorm,FGGMeanOnlyBatchNorm,HyperbolicFullAttention,HyperbolicLinearAttentionandHyperbolicSoftmaxAttention. A call that passed onlyc_in=0.1used to place its output on thec = 1sheet without an error; the transformer-block example in the layer guide did exactly that. Calls that pass every curvature, or none, are unchanged. - Values change with
jax_enable_x64on: FGG layers draw their initial weights in float32 (float64 for a float64param_dtype), so a seed givesFGGLinearandFGGConv2Dthe same weights with and without x64 (FGGConv2Dwithreset_params="kaiming"or"xavier"to one float32 rounding step). Before, an x64 process drew from the float64 stream and got different weights of the same scale.FGGLorentzMLRwas not affected. Without x64 the weights are unchanged bit for bit. - Values change for
HyperbolicFullAttention(score_dtype=...): see Fixed. - Minimum Flax version is 0.12.5 (was 0.12.0). At the old floor
import hyperbolixfailed (ImportError: cannot import name 'mutable_array'), andnnx.viewreaches the library's layers only from 0.12.5. The test suite passes at jax 0.9.0 with flax 0.12.5. HyperboloidGyroRMSNorm,ProperVelocityGyroRMSNormandPoincareGyroRMSNormraiseValueErrorwhen the input's last axis does not matchnum_features(plus the time slot on the hyperboloid). Without a bias a wrong width used to pass silently; with a bias JAX raised aTypeError.- Values change at the 1e-6 level:
HypConv2DPoincareandPoincare.beta_concatcompute their beta-function scale in double precision. The scaleB(n/2, 1/2) / B(n_i/2, 1/2)was computed withjax.scipy.special.betain JAX's default dtype: in float32 it lay up to 1.3e-6 relative from the true ratio (12 rounding steps at one input channel and a 3×3 kernel, up to 17 steps at other kernel sizes), and a layer's scale differed between processes with and withoutjax_enable_x64. It is now one Python float frommath.lgamma(hyperbolix.manifolds.poincare.beta_concat_scale), the same in both. Outputs of these two change by that relative amount (under x64 a float64 scale moves too, by up to 6e-7: JAX's float64betawas that far off at 16 input channels). - Layers reject a manifold of another model. The
manifold_modulecheck looked only at method names, which the models share: 13 of the 29 layers that take a manifold (for exampleHypLinearPoincare,HypLinearPV,HypRegressionHyperboloid,HypLinearHyperboloidFHNN/FHCNN/PLFCand the gyro norms) accepted an instance of another model and computed with the wrong geometry. They now check the class and raiseTypeError; subclasses are accepted, andStereographicstays accepted by the Poincaré layers whose methods it has (HypLinearPoincare,HypRegressionPoincare). hopeandhope_rotate_spaceraiseValueErroron an odd spatial dimension (before: aTypeErrorfrom inside a reshape).sampleof both wrapped normals names the problem when it gets a stack of covariances (before: aValueErrorfrom insidejax.random.multivariate_normal);log_probtakes one covariance per mean, as before.ProductManifoldraisesValueErrorwhen a factor was built with another dtype than the product. Each factor computes in its own dtype, soProductManifold((Poincare(dtype=jnp.float64), 2), ...)with the defaultdtype=jnp.float32returned float64 from every method that returns an array underjax_enable_x64. Build the factors with the product's dtype, or pass the factors' dtype toProductManifold;ProductManifold.from_signaturealready did.
Fixed¶
- A float64
cpromoted float32 outputs to float64 underjax_enable_x64. A NumPy float64 or a float64 JAX array ascturned the output of most hyperboloid layers and functional ops (hyperboloid_core, the HRC/HTC layers, activations, norms, PLFC, FHCNN, ILNN, FGG, and through them attention, residual and positional layers), ofHypConv2DPoincare,HypRegressionPoincare, the Busemann layers andHyperPPFeatureScaling, of the isometry mapshyperboloid_to_poincare,poincare_to_hyperboloidandpoincare_to_pv, of both wrapped-normallog_probs, and ofHoroPCAandCoSNEinto float64. Values agreed to float32 rounding; the dtype did not.HoroPCA.fitraised aTypeErrorin its Fréchet-mean loop in that case. A float64 input to a float32 manifold likewise promoted the Busemann heads. All of these now cast at the function boundary. The same casts roundcto the input's dtype for bfloat16/float16 inputs, where a float32 learnablecused to promote the output to float32. HRCBatchNorm(param_dtype=jnp.float64)kept float32 running statistics. Flax'snnx.BatchNormcreates its running mean and variance in float32 whateverparam_dtypesays, so a float64 layer stored float32-rounded statistics (3e-8 relative) and normalized with them in eval mode. They are now created inparam_dtype, and stay float32 for float32 and half-precision parameters. A float64 checkpoint saved before this release restores its float32 statistics.- A float64 weight promoted
lorentz_residual's float32 output underjax_enable_x64(a NumPy scalar, a 0-d or a per-point float64 array asw_y). Strongly typed array weights are cast to the input's dtype; a Python-number weight is unchanged bit for bit. - NumPy points were not cast to the manifold's dtype. On every manifold a NumPy point gave float64 output from a float32 manifold under x64, and
Hyperboloid.egrad2rgrad,HalfSpace.projandProductManifold.egrad2rgradraisedAttributeErroron NumPy input with or without x64. - Wrapped-normal
log_probwith one point against a batch of means (zwith fewer leading axes thanmu) was broken: the Poincarélog_probreturned wrong numbers without an error when the batch size equalled the dimension and raised otherwise, and the hyperboloidlog_probraised for every batch size.zandmunow broadcast; a mean batch of size 1 against several points works too. - Float32
uniform_poincare.log_probwas-infinside the ball once the volume overflowed (n = 11,R = 10: now −93.80). The log-volume is computed in log space. HyperbolicFullAttention(score_dtype=jnp.float64)gained at most about 2× over the float32 default, and nothing in the attention weights ata = 12. It cast the stored float32 time coordinates, which carry their own rounding, into the cancelling score. It now casts only the spatial parts and rebuilds both time coordinates in float64. At scaled radiusa = 8(c = 1,τ = 1) the largest attention-weight error against a float64 layer drops from 0.14 to 3.4e-5 (float32 default: 0.21), and the largest score error from 1.06 to 4.9e-4. Values change forscore_dtypeusers only;score_dtype=Noneis bit-identical. See the attention score floor.LorentzMoEclosed over insidejax.jit,jax.vmaporjax.lax.scanraised flax's "Cannot extract graph node from different trace level". Passing the module as an argument, andnnx.jit, already worked, and their outputs are bit-identical.HypConv2DPoincarecould not be built insidejax.jitornnx.jit. Its constructor calledfloat()on a traced beta-function ratio and raisedConcretizationTypeError, like the four layers fixed in 1.5.0. The ratio is now evaluated at compile time; its value is unchanged bit for bit.HypVQEmbeddingPoincareprojected its codebook only at init, atc = 1. Withinit_scale=0.3andc = 2.5, 52 of 64 codes lay off the ball and stayed there through the EMA updates. The forward andema_updatenow project at the call-timec. With the defaultinit_scale=1e-3outputs and codebooks are bit-identical.HyperbolicRoPEdid not check itsdim:HyperbolicRoPE(dim=4)rotated points of spatial dimension 8, and an odd dimension failed with a reshape error. An odddimnow raisesValueErrorat construction and a mismatched input at call time.max_seq_lenis documented as having no effect.LorentzEmbedding's docstring said every out-of-range id gives NaN rows; ids from −V to −1 wrap around like Python indices.
Removed¶
- The unused private helper
hyperboloid._ptransp_to_0.
Tests¶
- The suite passes on an A100 at JAX's default matmul precision. With 1.5.0, 18 float32 tests of
LorentzMLAandLorentzMoEfailed there: they compare a float32 layer with a float64 transcription, or one batch shape with another, at 2e-5 or tighter, and the layers' weight GEMMs (HTCLinear, the gate product) follow the JAX default by design, which is TF32 on that card (the failing comparisons were 1e-4 to 1.6e-2 off at the default and at most 1.2e-5 under"highest"). The tests now pin full float32 products. No layer was wrong and no library code changed for this. One of them, the comparison of a batch of 2 with two batches of 1, also gets a GPU tolerance of 5e-5 (was 1e-6): the GPU's rounding there depends on the batch shape and varies between processes (2.9e-6 to 7.6e-6); on CPU the tolerance stays 1e-6.
Packaging¶
- The wheel and sdist ship
py.typed(theTyping :: Typedclassifier was already declared) and theLICENSEfile (PEP 639license = "MIT"); the metadata lists Python 3.13. chexis no longer a dependency; nothing imported it.- The README installs with
pip install hyperbolix, and its logo and links are absolute URLs, so they also work on PyPI. RAdamStateandRSGDStateare exported fromhyperbolix.optim.
Documentation¶
- Numerical-stability guide. The hyperboloid's float32 limit is stated as an error law instead of "good to 16.6": the
disterror grows aseps·sinh(a), with a median of 5e-4 ata = 12and 6e-2 at 16.6 for pairs at distance 1. The wrapped-normal gradient error at a far mean is given against the unrounded points (about 5e-3 ata = 12, 0.3 ata = 16); the old numbers left the storage rounding out. Corrected: the behaviour of a wrapped normal with a mean pasta ≈ 44, the float32 errors of the tangent-input Poincaré layers att = 8, and the aligned Busemann direction att = 20. New sentences cover effects below or outside training radii:distwith an endpoint at the exact origin (absolute error 5e-16;dist_0has none), float32 underflow of distances for coordinates below 1.1e-19, Jacobians at the Möbius floor for operands of norm below 1e-15, thec-derivative error of about3·eps/(c‖x‖²), second derivatives incat the origin,busemannnear the origin, thetanhderivative in the tail, and the Poincaré ceiling atc = 100(10.35 / 25.42). - Numerical-stability guide, TF32. On an A100 at the JAX default, small float32 products run in full precision and larger ones in TF32 (a single row in full precision at every width tried; a 5 → 12 product switches between 7 and 8 rows), so a sample evaluated alone can differ from the same sample inside a batch by the TF32 error: 3.3e-3 for
LorentzMLAat its test size, against at most 7.6e-6 underjax_default_matmul_precision="highest". - Numerical-stability guide: the attention score-floor formula is stated as the size of the error, with the measured spread (median score about half of it, worst of 144 scores about 1 to 4 times it); the wrapped-normal note on a mean cast from float64 says where the value itself turns wrong (from about
a = 87.2, by up to 0.3 %). - Numerical-stability guide, corrections from re-measuring it: the old slot-2
acoshform ofPoincare.dist_0flattened float32 radii below 7.7e-4/√c onto the constant 1.5e-3/√c (the guide said below 1.1e-3/√c onto 0; the 1.2.0 entry below is corrected too); the literal residual square's gradient error is about three times that of the residual's output (not "three times sooner" in radius); gyroadditionis no longer listed as cancellation-free (float32 result off by 3 to 22 % when operands at scaled radius 8 and 7.5 on opposite rays give a result at 0.5); the"gemm"centroid number names its setup (values on one ray,c = 0.5) and the half-angle MLR cost its hardware. - Numerical-stability guide, new limits (all outside the documented working ranges, values right in each case): within about 2 of the float32 coordinate limit the gradient of hyperboloid
distwith respect to the far point is wrong on CPU (reverse mode atc = 1: off by 0.2 at scaled radius 44 to 44.25 in dimension 2, by 0.6 to 1 at 44 in dimension 64; an A100 is right up to the limit); the half-spaceexpmap_0has a non-finite float32jacrevfor an exactly vertical step from θ ≈ 33; Hessians of Möbiusadditionandexpmapat an exactly zero operand or tangent are wrong in both dtypes, and float32 Hessians ofexpmapin a small tangent are unreliable; the Jacobian of Poincaréexpmapin the tangent carries a relative error of ordereps·λ_x(about 1e-4 at scaled radius 8 in float32); float32 Poincaré origin maps have a NaNc-derivative atc = 1e-10. - Numerical-stability guide, GPU numbers re-measured on an A100 (jax 0.9.1): float64 is not "half rate" there (a 4096 × 4096 matmul runs at 15 TFLOP/s in float64, 17 in full float32 and 90 to 100 at the TF32 default), and four
HTCLinearorFGGLinearlayers (width 256, batch 2,048) cost 5 to 25 % more in float64; a TF32 product carries about 3e-4 relative error (1e-3 is the format's machine epsilon);"highest"costs +10 % to +25 % on aHyperbolicFullAttentionforward, depending on the session (was +5.5 %, a single-process measurement); the forward-plus-backward step ofLorentzMLAwith the"variance"centroid compiles in about 55 s at S = 512 (the 104 s was measured once in another project's Python environment; the 2026-09-30 code compiles in 62 to 65 s in this one), and a forward-only jit takes about 9 min; the replay's median logit gap is given with its value at initialisation. TheFGGLinear,HTCLineardepth-16, HELM-MiCELorentzMLAandKlein.distnumbers reproduce. lorentz_midpoint's docstring says that the weights of a row should sum to about 1: below a sum ofsqrt(eps)≈ 3e-4 the floor can bind and move the midpoint toward the origin.- Docstrings: the examples of
get_manifold_infoandhas_manifold_paramsrun as written;HypLinearHyperboloidFHNN's init is attributed to the machine-translation code of Chen et al. 2021 (their graph code usesU(-1/sqrt(out), 1/sqrt(out))). - The optimizer and layer guides name
LorentzEmbedding(defaultparameterization="manifold") among the layers that need a Riemannian optimizer.getting-startedno longer saysc = 0is Euclidean for every model. The attention page gives the mask fill as-1e18. The init table gains rows forHypConv2DHyperboloidandHypRegressionHyperboloid. The API reference documentsCurvature,ScalarCurvature,AUTOandAuto. - Docstrings: the examples of
riemannian_adam,riemannian_sgd,hyperbolix.optim,ProperVelocityandhyp_avg_pool2drun as written;HypConv2DPoincare(id_init=True)is described as the reference's1/2 · eye(C_out, K²·C_in), which is not a channel identity.
1.5.0 - 2026-10-30¶
Train/eval modes now reach every batch-norm and dropout layer through model.eval(), model.train() and nnx.view. The FGG layers compute their Minkowski product in full float32 on Ampere/Hopper GPUs, and several base-point Jacobians near the origin are fixed. Two HELM options that could give NaN are removed (breaking).
Added¶
LorentzMLA(score_precision=...). The precision ofLorentzMLA's two attention-score einsums is now a constructor argument. The default staysMATMUL_PRECISION(HIGHEST), so outputs are unchanged. At the radii of the trained HELM-MiCE 120M model,DEFAULTtook 0.74× the time and gave a worst-token error of 0.035 against 0.017 nats. The centroid GEMM stays pinned, because lowering it cost 0.26 nats. It is the one geometry dot a user can lower; every other geometry dot stays pinned. See the attention score floor.FGGMeanOnlyBatchNorm(use_running_average=...)andupdate_running_mean=. The mode is now a constructor attribute, as innnx.BatchNorm, somodel.eval(),model.train()andnnx.viewreach the layer. Before, only the call argument switched it, andmodel.eval()left it in training mode. The call argument now defaults toNone, which uses the attribute; the constructor default staysFalse. The call-timeupdate_running_mean=Falsecenters with the batch mean and skips the running-mean write. It is meant for a call inside a JAX transform that does not carry the module as state, such as a module closed over innnx.fori_loop, where the write raises flax'sTraceContextError.set_viewonPoincareBatchNorm2D,HyperboloidGyroBatchNorm,ProperVelocityGyroBatchNorm,FGGMeanOnlyBatchNormandHypVQMLRPoincare, sonnx.view(model, use_running_average=True)(ordeterministic=True) reaches them.HRCBatchNormalready followed its innernnx.BatchNorm.HRCDropout,HypLinearHyperboloidFHNNandHypConv2DHyperboloidFHNNfollowmodel.eval()/model.train()/nnx.view. Their call-timedeterministicdefaulted to a fixed bool and overrode the innernnx.Dropout's own setting:model.eval()leftHRCDropoutdropping, andmodel.train()never switched on the FHNN layers' dropout. The call default is nowNone, which uses the innernnx.Dropout's setting, and a new constructordeterministicsets its starting value. The defaults are unchanged:HRCDropoutdrops (False), the FHNN layers do not (True).FGGLinear(init_kernel_scale=...)andFGGConv2D(init_kernel_scale=...). Underuse_weight_norm=Trueit sets each output column's norm at init. The defaultNonekeeps the reference init,kernel_scale = sqrt(1/(in+out)), which is a column norm ofsoftplus(sqrt(1/(in+out))), about 0.7. The docstrings said the magnitude waskernel_scaleand did not mention the softplus.hyperbolix.__version__, read from the installed package metadata.
Changed¶
- Behavior change on Ampere/Hopper GPUs:
FGGLinearandFGGConv2Dcompute their Minkowski productx @ Vin full float32 (precision=MATMUL_PRECISION, which isjax.lax.Precision.HIGHEST) instead of followingjax_default_matmul_precision, which means TF32 on those cards. Their float32 outputs there change by the TF32 error they used to carry: 2.6e-4 relative on a singleFGGLinear, near 1e-3 in the network below. CPU and float64 results are unchanged, and so is a run that already setsjax_default_matmul_precision="highest". The reason is a float64 replay of a trained network: a Procgen PPO agent (BigFish) with an encoder of 15FGGConv2Dand oneFGGLinear(c = 0.1, trained on an A100 under the JAX default), 72 checkpoints of 2,048 states each. At the JAX default the greedy action changed 120 times, and in the runs trained without a cap on the feature radius the actor logits were up to 0.14 off float64 (median 2.8e-4 to 1.0e-3). With"highest", which in that network changes only the 16 FGG products, no greedy action changed and the logits were within 1.03e-4. The effect on the return was not measured. Cost on one H100 (float32, one job, three processes per arm, new/old): forward 1.02 forFGGConv2Dand for an IMPALA-ResNet of FGG layers at batch 1,024, 1.07 for that network at batch 64; forward plus backward 1.05 to 1.16 for the single layers and 1.09 for the network at batch 1,024.HTCLinear, the FHCNN/FHNN linears,HypLinearPoincareandLorentzConv2Dstill follow the JAX default. See TF32 on Ampere and Hopper GPUs.
Removed¶
- Breaking:
LorentzResidual(weight_parameterization="identity"),LorentzResidual.project_w_y()andproject_residual_weights(model). The identity mode mirrored the raw learnablew_yof HELM's released code, which gives NaN oncew_y < 0, and needed a projection after every optimizer step. A learnablew_yis now always softplus-constrained. Passingweight_parameterizationraises aTypeError. The fixed-weight mode,scale_parameterization="exp"and the call-timeweight=stay. - Breaking:
LorentzMoEGate.update_bias(rule=...)andLorentzMoE.update_bias(rule=...). Only DeepSeek-V3's sign rule, the one the HELM paper cites, remains. The removedrule="proportional"mirrored anupdate_biasthat HELM's released training loop never calls.
Fixed¶
HypLinearHyperboloidPLFC,HypConv2DHyperboloidILNN,HypLinearHyperboloidBusemannandHypLinearPoincareBusemanncould not be built insidejax.jitornnx.jit. Their constructor check onv_maxranfloat(jnp.sinh(v_max)), and inside a jit tracejnp.sinhreturns a tracer, so the build raisedConcretizationTypeError. Libraries that build their networks inside a jitted train function hit this. The check now comparesv_maxwithasinh(sqrt(finfo(float32).max)) ≈ 45.05in plain Python and gives the same verdict eagerly and under jit. A NaNv_maxis now rejected; the old check accepted it. Within a few float32 ulps of 45.05 the verdict can differ from the old float32sinh. A workaround that builds these layers underjax.ensure_compile_time_eval()is no longer needed.- Float32
wrapped_normal_hyperboloid.log_problost accuracy for a mean far from the origin, without a NaN. It composedlogmapwith a transport to the origin, and the ambient chart storeslog_μ(z)at the mean with componentscosh atimes its length (a= scaled radius of the mean). It now reads the same vector off the gyro-difference:v = log_0((⊖μ) ⊕ z). Error of the gradient with respect to the mean against float64 (median over 16 directions),zat scaled radius 1,n = 10,c = 0.1: 1.7e-4 → 1.1e-6 ata = 12, 0.64 → 1.3e-6 at 16, 1.8e3 → 2.0e-6 at 20 (scalar σ); 1.1e-3 → 2.2e-7 ata = 10(diagonal σ). For a mean of tangent norm 1e-4 andzat scaled distance 3: 1.6e-2 → 4.0e-7. For this,log_probcomputes close pairs (sinh(θ/2) ≤ 0.5) fromz_s − μ_s: median float32 error of the gyro-difference about 4e-4 → 1e-5 at scaled base radius 6–8 for separations 1e-2 to 0.6. The publicHyperboloid.gyro_differenceand its callers (the gyro batch norm layers,HoroPCA, the proper-velocitygyro_difference) are unchanged: the close-pair branch cost those layers 1.21× to 1.33× on forward plus backward (CPU), so it is an internal option that onlylog_probsets. The log-det term keeps its second derivative atz = μ:jax.hessianoflog_probthere was−I/σ²instead of−(1/σ² + (n−1)c/3)·I(hyperboloid at any mean, Poincaré with the mean at the origin). Values change:log_probby rounding in float64 (≤ 2.9e-15 relative at scaled mean radius ≤ 3) and by the accuracy gained in float32. The raw ambientjax.gradoflog_prob, taken with a point's time and spatial slots as independent inputs, changes along the sheet's normal only; chart and Riemannian gradients are unchanged. See Known Limitations. - Hyperboloid
logmaplost its base-point Jacobian near the origin. For a base point close to the origin and a mapped point further than√c·d ≈ 0.96away, the float32 Jacobian with respect to the base point had a relative error of about 1 to 5 timeseps/(√c‖x_s‖): medians of 3e-4 to 5e-4 at√c‖x_s‖ = 3e-4and 3e-2 to 8e-2 at 3e-6 (c = 0.1,√c·d = 3), and above 1 at 1e-7. Float64 lost the same factor at its owneps. The value and the Jacobian with respect to the mapped point were at rounding level, so nothing showed in a forward check. The polar-frame assembly built this Jacobian from three terms of sized/‖x_s‖that cancel. A base point with√c‖x_s‖ ≤ 0.1now takes the displacement form(y_s − x_s) − 2S²·x_sthat close pairs already used, at every separation, and its Jacobian is within 1e-6 down to‖x_s‖ = 1e-15. Outside that neighbourhood the code path is unchanged: the base-point Jacobian is up to 9e-6 off just outside it and improves like1/‖x_s‖. Values change by a few ulp for a base point inside the neighbourhood. One exception: for a nonzero base point closer to the origin thanMIN_NORM = 1e-15, the value for a far pair was off by half and is now right, while the Jacobian with respect to a point that close to the origin stays unreliable. See Origin derivatives. The gradient of the wrapped normal'slog_probwith respect to a near-origin mean went through this Jacobian untillog_probmoved togyro_difference(thelog_probentry above). - Hyperboloid and proper-velocity
expmaplost their base-point Jacobian near the origin, andtangent_norm/tangent_innertheir base-point gradient. The geodesic length came from the radial/perpendicular split of the tangent vector, which divides by‖x_s‖; its gradient with respect to a base point near the origin carried an absolute error of abouteps/(√c‖x_s‖)of its natural scale.expmapinherited it: for a step of scaled length 10 the float32 Jacobian with respect to the base point was off by 7e-4 at√c‖x_s‖ = 1e-3, 4e-2 at 1e-5 and above 1 at 1e-7, with a correct value. A base point with√c‖x_s‖ ≤ 0.1now takes the Cartesian form of the transport to the origin, and theexpmapJacobian is within about 1e-6. The reparameterizedwrapped_normal_hyperboloid.samplecalls thisexpmapat the mean: withσ = 1its float32 Jacobian with respect to the mean was off by up to 9e-4 at scaled mean radius 1e-4 and 1e-2 at 1e-5, and is now within 1e-6. Values change by rounding for a base point inside the neighbourhood, with one exception: for a nonzero base point just belowMIN_NORM = 1e-15the three functions returned values off by up to 30 % and are now right. The raw gradient with respect to the ambient point changes along the sheet's normal only. See Origin derivatives. - A float64
cpromoted the output of float32 manifolds to float64 under x64. Manifold methods cast the points to the manifold's dtype but passedcthrough raw, so float32 points with a float64 0-dcgave float64 from, for example,Hyperboloid.logmap,tangent_norm,tangent_innerandProperVelocity.expmap. Every method ofHyperboloid,Poincare,ProperVelocity,Klein,HalfSpace,StereographicandEuclideannow castscto the manifold's dtype (ManifoldBase._cast_c), so output and computation dtype follow the manifold. Values do not change for a float32 manifold with a Python-floatc(bitwise equal on all 320 method/ccells measured); only the output dtype changes wherecwas a float64 array.
Documentation¶
- The HELM layers (
LorentzMLA,LorentzMoE,LorentzMoEGate,LorentzSwiGLU,LorentzResidual) are described as the HELM paper's form, not as reproductions of HELM's released code. Their docstrings list the differences from that code.LorentzResidualmatches HELM's LResNet in the forward pass forw_y >= 0; its input gradients differ along the hyperboloid normal only. - Corrected the float32 limit of the hyperplane MLR heads in the numerical stability guide. Near a hyperplane the logit is off by about
eps·e^(a+|ρ|)/4: 1e-3 ata + |ρ| ≈ 10.4, 1e-2 at 12.7 and 0.1 at 15.0. Off the hyperplane the relative error of the gradient is about|tanh δ|times that, withδthe scaled distance to the hyperplane. The earlier rule of thumb (0.1 % ata + ρ ≈ 15) was the median gradient error exactly on the hyperplane, where the first-order term vanishes. A float64 head removes the offset's share only if the time coordinate is also rebuilt in float64 from the spatial part.
1.4.0 - 2026-10-01¶
Two new models, Klein and HalfSpace. Far-pair Poincaré and Stereographic operations are now cancellation-free, and the Poincaré and Busemann layers score tangent input in closed form. LearnableCurvature's clamp keeps the gradient that points back inside, and non-finite input now stays non-finite instead of turning into a plausible finite output. The HELM decoder layers (LorentzMLA, LorentzMoE, LorentzEmbedding) are new. Full numbers and mechanisms are in the numerical stability guide.
Added¶
- Klein manifold (
hyperbolix.manifolds.Klein), the Beltrami–Klein ball model (Mao et al. 2024; Zhang et al. 2026). It implements the scalar-cManifoldprotocol plusgyro_difference,lorentz_factorandeinstein_midpoint.disthas one formulation (version_idxis ignored) and is cancellation-free: median float32 relative error 1.19e-05 at scaled radiusa = 4, against 4.33e-02 for Eq. 4 of Zhang et al. The chart holds half the Poincaré radius (a = 6.32float32 /13.86float64 atc = 1).Klein.expmapkeeps the factorcthat the reference_klein_expmapomits; the two agree only atc = 1. See Klein. - HalfSpace manifold (
hyperbolix.manifolds.HalfSpace), the Poincaré upper half-space model with HTorch's convention: the heightx_n > 0is the last coordinate, origine_n/√c. It implements the scalar-cManifoldprotocol, and its pairwise operations are cancellation-free. They returninf/NaN past√c·d ≈ 88.7in float32 (709.8in float64). HTorch'sptranspis not an isometry, andHalfSpacedoes not reproduce it. See Half-Space. - Isometry maps for Klein and HalfSpace (
hyperbolix.manifolds.isometry_mappings):klein_to_*/*_to_kleinfor Poincaré, Hyperboloid and PV, andhalfspace_to_*/*_to_halfspacefor Poincaré (the Cayley transform), Hyperboloid, Klein and PV. None of them projects its output. A far point mapped into Klein can land between theprojmargin and the boundary, so callKlein.projafter mapping far points in. See The Chart Ceiling and Floor. HoroPCAandCoSNEacceptProperVelocity,KleinandHalfSpaceinput. Each model is mapped by its isometry onto the hyperboloid (HoroPCA) or the Poincaré ball (CO-SNE), and results come back in the input's model. Poincaré and Hyperboloid results are bit-identical through the new routing (88/88 arrays); HoroPCA's centering changed separately (see Fixed).- HELM layers (
hyperbolix.nn_layers; He et al. 2025, arXiv:2505.24722).LorentzMLA, multi-head latent attention. Keys and values are decompressed from one low-rank latent point per token, a decoupled slice of the queries and keys is rotated by HOPE, and the score is the negative squared Lorentzian distance over a learned temperaturetau = exp(log_tau). Causal, segment (segment_ids) and padding (attention_mask) masks; only HELM'sq_lora_rank = 0path.centroid_form="gemm"is the default, as in HELM's code;"variance"is for short sequences or values far from the origin. See the attention score floor.LorentzEmbeddingandlorentz_embedding_init, the hyperboloid token embedding: aManifoldParamtable onHyperboloid(parameterization="manifold", the default, trained withriemannian_adam) or a Euclidean table of spatial coordinates ("spatial").c_outmaps the looked-up points onto another sheet.LorentzMoE,LorentzMoEGate,LorentzSwiGLU,moe_sequence_balance_loss,MoERoutingStatsandRoutingBias: the mixture of curvature experts in the form of the paper, not of the released code. Top-k routing; each routed expert is aLorentzSwiGLUon its own sheet, with aLearnableCurvaturestarting atlinspace(0.1, 2.0, E); routed and shared outputs are merged by one Lorentz centroid. Load balancing is DeepSeek-V3's auxiliary-loss-free bias (LorentzMoEGate.update_bias/LorentzMoE.update_bias, which write theRoutingBiasvariable) plus the sequence-wisemoe_sequence_balance_loss.expert_curvatures=[1.0] * E, learnable_curvature=Falsematches the released 120M checkpoint. The experts run densely (E / top_ktimes the work of a sparse dispatch), which is fine for smallE.
- Opt-in building blocks for HELM-style blocks; defaults are unchanged.
hope_rotate_space;HTCLinear(return_space=True)andHRCRMSNorm(space_only=True);positionsbroadcastable againstz.shape[:-1]inhope/HyperbolicRoPE; per-token weights inlorentz_residual/LorentzResidual, plusLorentzResidual(weight_parameterization="identity", scale_parameterization="exp")and a call-timeweight=(with"identity"a trainablew_ycan go negative, which gives NaN where the combination turns spacelike; see thelorentz_residualentry under Changed);lorentz_midpoint(form="gemm")andHyperbolicFullAttention(centroid_form="gemm"), the single-GEMM centroid (default"variance"unchanged bit for bit). project_residual_weights(model)andLorentzResidual.project_w_y(), projected gradient descent for the identity-mode (HELM)w_y: called afteroptimizer.update, they set every identity-modew_ytomax(w_y, 0), the domain of LResNet's Lemma 4.1, so a trainedw_ycannot turn the combination spacelike (NaN). Softplus-mode and fixed weights are untouched.hyperbolix.utils.math_utils.asinh, exported fromhyperbolix.utils:jnp.arcsinhwith an overflow-safe derivative. See theasinh/acoshentry under Fixed.hyperbolix.utils.AUTO/Auto, the default ofc_min/c_maxinLearnableCurvatureandLorentzMoE("resolve from the parameterization";Nonestill disables a bound). They replace the private_AUTO/_Auto.
Changed¶
- Breaking:
LearnableCurvature's clamp keeps inward gradients,straight_through_clampis removed, and the defaultsoftplus/logbounds are[init_c / 10, init_c * 10]. The forward value is stillcclipped to[c_min, c_max]. On or outside a bound, the backward now passes only a gradient that movescback inside: projected gradient descent inside the forward pass, with no extra call in the train step. The old clamp pinnedcat a bound for the rest of the run once a step crossed it. In float32 this frozeLearnableCurvature(init_c=0.1)under the defaultlogfrom step 0 (since 1.3.0). Bounds are unchanged atinit_c=1.0;identitykeeps[-10, 10]. Passingstraight_through_clampraises aTypeError, and so dojax.jvp/jax.jacfwdthrough a clamped instance (custom VJP; reverse mode andjax.hessianwork). See Choosing a parameterization. - Behavior change:
ProperVelocityGyroBatchNorm's batch mean is the Lorentz centroid of the hyperboloid lift, as inHyperboloidGyroBatchNorm, instead of the log-Euclidean mean. The log-Euclidean mean does not commute with the centering, so the output's Fréchet mean missed the bias point: by 0.73 for a batch centered at radius 2 (float64,c = 1), against 8.2e-3 now. Train-mode outputs change for off-origin batches. - Behavior change: non-finite input stays non-finite.
ProperVelocity.projis now the identity (it used to applyjnp.nan_to_num), so the PV norm layers keep non-finite rows.HypLinearPV/HypConv2DPVpass a non-finite MLR score through instead of saturating it at thesinhclip.sinh_lift_to_hyperboloid(the end ofHypLinearHyperboloidPLFC,HypConv2DHyperboloidILNNandHypLinearHyperboloidBusemann) no longer clips a non-finite score to±v_max, which gave a finite loss (12.6 to 13.8) with 4096 of 4096 NaN kernel gradients; the loss now goes NaN at the onset minibatch.HypLinearPoincareBusemannlikewise no longer clips aninflogit (e.g. alog_scalepast float32expoverflow) to±v_max; the row is NaN. In float32,uniform_poincare.samplewithn = 2returnsinfradii past√c·R ≈ 89.42. Finite rows are unchanged. See Input Overflow. - Behavior change:
frechet_meandivides the Karcher step bymean_i(a_i·coth a_i),a_i = √c·d(x_i, μ), andstep_sizeis a multiplier on that step. The fixed step overshot once the batch spread past√c·d ≈ 2: over 60 Hyperboloid/PV cells (float64) it left 24 unconverged after 100 iterations, the new step none (worst residual 4.03e-11). The iterates change whenever a point is away from the current mean. - Behavior change: the Poincaré HNN++ layers and all four Busemann layers score tangent input in closed form instead of lifting it with
expmap_0onto a stored point. This coversHypRegressionPoincarePP/HypLinearPoincarePPwithinput_space="tangent",HypConv2DPoincare, and the Poincaré and Hyperboloid Busemann layers withinput_space="tangent". Att = √c‖v‖ = 8, the float32 regression-score error drops from 2.04e-1 to 1.47e-6. At smalltthe float32 kernel gradient of the Hyperboloid Busemann layers grows like1/t, as on the Poincaré side. The Hyperboloid Busemann layers now require_busemann_tangent. See Tangent Inputs. - Behavior change: the FHCNN/FHNN scale and the Busemann layers'
alphause plainexp. A runaway scale parameter now overflows toinf(float32 pastln(FLT_MAX) ≈ 88.72) and the loss goes NaN at that step, instead of saturating atexp(87.8)throughcapped_expwith an exactly zero gradient.capped_expstays exported; the layers no longer use it. - Behavior change:
lorentz_residualnormalizes bysqrt(-c<ave, ave>_L), withoutabs()or theepsfloor. Unchanged forw_y >= 0: there-c<ave, ave>_L >= (1 + w_y)^2, and the output is bit-identical (0 of 27040 probe pairs differ). A negative weight (w_y = -1, orLorentzResidual(weight_parameterization="identity")trained below 0) that makes the combination spacelike now gives NaN instead of the finite point the HELM/LResNet reference's.abs()returns. A past-directed combination (w_y < -1) still comes back as a finite upper-sheet point. - Breaking:
HyperbolicFullAttentionstores its temperature aslog_tau(τ = exp(log_tau), always positive), starting at Hypformer'sτ = √out_features(newinit_tau). An optimizer step could drive the old rawscaleto 0 or below, and a negative value makes the softmax prefer the farthest keys. Scores are(2/c + 2⟨Q,K⟩_L)/τ.scaleandattn_biasare gone, so old checkpoints do not load;init_tau=1.0gives the old attention at init. - Behavior change:
HyperbolicLinearAttentiondivides its kernel ratio by the denominator floored at the smallest normal number, not byden + eps(Hypformer:+ 1e-6). A query whose spatial part is ≤ 0 on a head used to get ≈ 0 from that head, and now gets its attention average. At head dim 4 this hit 2 of 4 random seeds, with errors of 0.74 to 0.81. Elsewhere outputs move by abouteps/den. - Behavior change: the attention layers keep bfloat16/float16 in and out, and run their softmax in float32.
HyperbolicFullAttentionandHyperbolicSoftmaxAttentioncompute the softmax (mask fill-1e18) in at least float32, asLorentzMLAdoes.HyperbolicLinearAttentionandHyperbolicSoftmaxAttentionno longer return float32 for bfloat16/float16 input. float32 and float64 results are bit for bit unchanged. - Poincaré
distslot 2 (VERSION_METRIC_TENSOR) now runs slot 0's function. Both evaluate the sameasinhform; slots 0 and 2 are now bitwise equal in value and gradient. See Slot 2. - Cost of the Poincaré fixes. On CPU most rewritten operations and layers got faster (slot 0
distforward+backward 0.292–0.335× the old time). The slowest isptransp, 1.112–1.117× forward on CPU; on the A100 its forward is not resolved (1.120, 1.199, re-time 0.984) against identical-code runs up to 1.113. These timings predate the Busemann tangent scores, the sampler fallback and the half floors.
Removed¶
LearnableCurvature(straight_through_clamp=...); passing it raises aTypeError(see the clamp entry under Changed). The privatePoincare._dist_metric_tensoris removed as well.HyperbolicFullAttention.attn_biasandHyperbolicLinearAttention.temperature, two parameters without effect, which Hypformer also has. The bias adds one constant to a row of scores, so it cancels in the softmax. The temperature scalesφ(Q)andφ(K)alike, so it cancels in the kernel ratio except through theepsfloors; its gradient was 5 to 6 orders of magnitude below every other parameter's. The linear layer keeps the old valuet = 1, so its outputs at init are unchanged.focus_transformkeeps its signature.
Fixed¶
- Poincaré
distandlogmapwere wrong for far pairs in float32. They now useasinh(√c‖x − y‖/√(B_x·B_y))instead ofatanh(√c‖(-x) ⊕ y‖), whose argument rounds towards 1. Two points at scaled radius 7.2 on opposite sides (true distance 14.4,c = 1):dist14.332947 with an exactly zero gradient → 14.400112.ptransp(the gyration, regrouped ins = x + y) andapollonian_distno longer cancel near the boundary. Values change for every pair, by ≤ 1.3e-13 in float64. Slot 1 (VERSION_MOBIUS) is unchanged and still saturates. See Far pairs. Stereographicdist,logmapandgeodesicsaturated on far pairs atc > 0in float32. They now use the sameasinhidentity asPoincare. At the same far pair (true distance 14.4):dist12.656 → 14.39999. Values change for every pair atc > 0; atc ≤ 0,logmapandgeodesicare bit-identical anddistmoves by ≤ 3.1e-7 relative (float32). See Far pairs.- Divisor floors zeroed gradients at capped points. Poincaré divisors
1 − c‖x‖²were floored at their value at theprojcap, which the computed value of 11–76 % of capped points falls below. The floor is now half that value, which none of the measured capped points reaches atc ∈ {0.1, 0.3, 1, 2.5}(very smallccan reach it; see the guide). Klein'sg_xand the isometry maps use the same half floor. Float32tangent_normgradient error at capped points: 1.0 → 3.7e-2. Float32expmapand⊕gradients at capped points stay wrong, for other reasons. See Divisor Floors. - Float32 overflow collapsed Poincaré rows to the origin with a zero gradient.
HypLinearPoincarePPandHypConv2DPoincarecollapsed once an HNN++ score reached√c·v ≈ 44(43.9 atc = 0.1, 45.05 atc = 1);HypLinearPoincareBusemannonceO·sinh²(v_max)/c > FLT_MAX. All three now share a lift that rescales each row by a power of two, so a saturated row lands at the ball's edge (√c·‖y‖0.99999994 against 0 before). Below the old threshold, values move by a few ulp. Remaining sites: Silent overflow. - JAX's
asinh/acoshderivatives overflowed. Their JVP rules square the argument, so the float32 derivative is exactly0.0for|x| > 1.84e19although the true value is representable. Every libraryasinhcall site now uses the newmath_utils.asinhwrapper (tangent1/hypot(1, x)), and theacoshwrapper's tangent became1/(√(x−1)·√(x+1)). The hyperboloid MLR score reached this regime: at biasr = 60its bias and input gradients were exactly zero. Reported upstream as jax-ml/jax#40634. Seeasinhandacosh. - Hyperboloid-side cancellations.
wrapped_normal_hyperboloid.log_probtransports to the origin with a private transport instead ofHyperboloid.ptransp's Cartesian branch. The FHNN linear and conv layers read the output's spatial norm off the heightmdirectly.HoroPCAcenters withHyperboloid.gyro_differenceinstead of the Lorentz boost matrix: at scaled radius 8, float32transformerror 0.377 → 1.66e-4 nats. Values change whenevercenter_data=True;boost_is still fitted, buttransformnow readsmean_. uniform_poincare.sampleput samples outside small balls in float32, and itsn ≥ 3rejection loop could hang. Both directions of the radius map are now evaluated in half-angle form: at√c·R = 1e-3samples used to land up to 1.5441·R out, and now none does. Where the loop cannot accept a sample, the radius is drawn in closed form. Elsewhere the samples are bitwise unchanged. For the float32n = 2change at large radius, see the non-finite entry under Changed.- Softplus inits above 20 were not recovered exactly in float64.
_inv_softplusreturnedxinstead ofx + log1p(−exp(−x))forx > 20, soLearnableCurvature(init_c=20.5, parameterization="softplus")withparam_dtype=jnp.float64came back 351887 ulp high. The inverse is now exact (0 ulp in both dtypes).LorentzResidual's softplusinit_w_y/init_gammashare the fixed inverse. - The Busemann layers accepted the other model's manifold.
PoincareandHyperboloidboth havebusemannand_busemann_tangent, so the method-name check let each into the other model's layers. Such a pair usually failed at the first call with a shape error, but atin_dim = 2some calls ran without an error. All four Busemann layers now check the class and raise aTypeErrorat construction. The other models (Klein, HalfSpace, Stereographic, ProperVelocity, Euclidean) were already rejected. See Tangent Inputs. hopeandHyperbolicRoPErounded the positions to bfloat16 on bfloat16/float16 input, so between 512 and 1024 a position was rounded to a multiple of 4. The rotation now runs inpromote_types(dtype, float32), as HELM does; float32 and float64 input are unchanged. Worst rotation error of a bfloat16 input atS = 1000: 4.67 → 0.028.
Documentation¶
- New sections in the numerical stability guide: the MLR score at a large hyperplane offset (a half-angle rewrite was measured and not adopted, at 1.9–2.5× forward+backward cost on
HypRegressionHyperboloid), input overflow, where float32 overflow still collapses silently, the divisor floors and the tangent-input paths. The Poincaré precision table now holds measured float32 errors, and the chart ceiling is stated per curvature (12.65 / 27.73 atc = 1). The hybrid examples pass Euclidean features withinput_space="tangent". - Corrected docs and docstrings: the
gyro_difference/ptranspchart rule (the Cartesian chart applies whenever either endpoint's scaled spatial radius is at most 1e-1, not only at the origin); an accuracy warning onHyperboloid.minkowski_inner;_assert_v_max_safe, which bounds one entry only (v_max ≲ 45.05); and the tangent-projection residual in_egrad2rgrad/_tangent_proj. - The HELM citation named the wrong paper ("Chen et al. 2024, Hyperbolic Embeddings for Learning on Manifolds"); it is He et al. 2025, "HELM: Hyperbolic Large Language Models via Mixture-of-Curvature Experts" (arXiv:2505.24722). The LResNet entry in the layers API index now cites He, Yang & Ying (2025), "Lorentzian Residual Neural Networks" (KDD 2025).
riemannian_adam's docstring explains why it has no geoopt-stylestabilizeoption: every step already ends on the manifold, and re-projecting the moment only loses float32 accuracy far from the origin.- User guide and API pages checked against the code: broken examples fixed (e.g.
nnx.jittrain steps), stale advice removed,numerical-stability.mdtrimmed to user guidance.
1.3.0 - 2026-09-09¶
Changed¶
LearnableCurvature's defaultparameterizationis now"log"(was"softplus"). The softplus docstring's attribution to "the van Spengler et al. 2023 Poincare ResNet convention" didn't hold up: that paper's own reported curvature experiments (Sec. 4.2) sweep fixed valuesc ∈ {1, 0.1, 0.01}and settle onc=0.1, not a learnable softplus-reparameterized curvature — thesoftplus(raw)mechanism itself is geoopt'sStereographic/PoincareBallconvention, which the released Poincare ResNet code happens to default to (learnable=True) since its manifold is built on geoopt."softplus"remains available and its docstring now cites geoopt with the code-default note. Breaking for call sites relying on the implicit default — passparameterization="softplus"explicitly to keep the old behavior
Fixed¶
- Origin derivatives now follow the on-manifold Cartesian chart instead of value-only polar fallbacks.
Hyperboloid.gyro_differenceandptranspuse exact Cartesian formulae when either endpoint's scaled spatial radius is at most 1e-1 and keep the stable polar frame otherwise.Hyperboloid.logmapuses the regular Cartesian expression at an exact origin endpoint and the stable polar frame otherwise; ordinary autodiff follows the selected expression.busemannnow evaluates a projected-coordinate branch whose constrained first derivative agrees acrossq = <x_s,v> = 0, restoring the origin gradient-vfor a unit direction.lorentz_midpointnow uses the time/velocity variance form below, preserving the derivative of a nonzero-weight origin point in a mixed cloud. The inherited log-map origin defect predates the preceding polar-frame sweep; that sweep repaired large-radius and collinear behavior without covering every origin endpoint derivative.ProperVelocity.logmap,gyro_difference, andptranspinherit these repairs through their exact hyperboloid lifts. Public signatures, defaults, and version slots are unchanged. - Signed Möbius operations now have the literal curvature derivative at
c = 0for nonzero operands. The stable denominator evaluates separate signed factorizations forc > 0andc <= 0; both match1 + 2*sign*c*<x,y> + c^2*||x||^2*||y||^2and its slope at zero. The existingMIN_NORMradial floors leave only their bounded residual when an operand is exactly zero. The precedingabs(c)factorization selected the wrong one-sided denominator slope at zero, so a signed learnable curvature could receive the wrong update on its flat step. - Historical scope of the preceding numerics sweep. The large-radius "rest of the Hyperboloid" entry and the
_logmap_directionentry below describe the value and collinear-gradient repairs measured before this origin-derivative pass. Their measurements are preserved as historical evidence; they do not claim that every origin endpoint derivative was already correct. The firstFixedentry records the current origin behavior. - Historical value repair from the preceding numerics sweep: the rest of the Hyperboloid's two-point and tangent-space primitives cancelled the same way
dist/logmap/sqdist/tangent_normdid before this file's earlier fix:expmap(two-point form),ptransp/ptransp_0,tangent_proj,tangent_inner,egrad2rgrad, the gyroaddition(the Lorentz boost, feedingHypLinearHyperboloidPLFC's and friends' gyro-bias), andbusemannall formed an O(1) result as the difference of two O(e^{2a}) Minkowski terms,a = √c·dthe scaled geodesic radius. At that revision each read the radius off the spatial part and subtracted before squaring, via the sharedradial_perp_decompositionhelper inhyperbolix/utils/math_utils.py. Not bit-identical: forward values are unchanged up to rounding below the cancellation's onset, and gradients differ from step 0 at rounding level. Measured (4-seed medians, float32,logs/2026-09-08_hyperboloid_tangent_primitives/): gyro-addition forward geodesic error 4.181e-04 → 1.366e-05 ata=6, 1.527e-02 → 9.767e-05 ata=8, 6.557e-02 → 6.802e-04 ata=10(5 of 32 seeds non-finite as-is, 0 fixed); end-to-endriemannian_adamon aManifoldParamloses both seeds to NaN bya=9as-is, fixed stays finite througha=16; the transport isometry|ratio-1|goes from non-finite on 1-2 of 4 seeds froma=9on (max residual 6.6e+14 ata=10) to 1.192e-07 / 1.132e-06 / 7.557e-05 ata=6/8/12;egrad2rgradrelative error 3.816e-05 → 4.616e-08 ata=6, 1.000e+00 (2 of 4 seeds non-finite) → 1.005e-07 ata=14— it needs no division by a measured quantity at all now, since⟨x,x⟩_L = -1/cholds exactly on the sheet, so the 1.2.0 claim that the Riemannian gradient is unchanged afteregrad2rgradnow holds by construction rather than by cancellation luck; the aligned-branchbusemannrelative error 1.096e-02 → 1.585e-09 ata=8, 1.878e+00 → 2.274e-06 ata=12(as-is pins 1 of 4 seeds on the-34.5MIN_NORMfloor ata=10and 3 of 4 ata=12, with an identically-zero gradient ata=12; fixed pins none at either radius).expmap's landing accuracy is the one cell that is not a clean win: ata=14the fixed geodesic landing error is worse than as-is, 3.500e-02 vs 2.410e-02 median (1.45x) — seedocs/user-guide/numerical-stability.mdfor the full table. - The Poincaré/κ-stereographic Möbius denominator
1 ± 2c⟨x,y⟩ + c²‖x‖²‖y‖², behinddist,logmap,addition, andgyr, no longer forms the cancellation at the ball chart's ceiling. It evaluates separate signed factorizations built from the radial gap and sum, so subtraction happens before squaring and the literal curvature slope is retained atc = 0for nonzero operands. The measurements inprobe_poincare_mobius_ebebd09.outdescribe the earlier positive-curvature value repair and remain historical evidence; the signed zero-curvature derivative repair is covered separately above. lorentz_midpointnow uses a time/velocity variance for both its large-radius value and its origin-point derivative. Withh = sum_m w_m*x_m,t_m = x[m,0],z_m = x[m,1:]/t_m,T = h[0], andz_bar = h[1:]/T, the normalizer isD^2 = T*sum_m w_m*(1/t_m + c*t_m*||z_m-z_bar||^2) = c*(T^2-||h_s||^2). The direct variance avoids the cancelling Lorentz square and divides only by positive time coordinates, so a nonzero-weight origin point retains its derivative in a mixed cloud. Weights must be non-negative. An all-zero weight row still returns the origin as a value convention; no weight derivative is promised there. Historical measurements of the preceding radius/direction variance form remain documented as historical evidence in the numerical-stability guide.- ProperVelocity operations now share one direct hyperboloid bridge.
expmapand gyroadditionuse the bridge introduced at8e77147;gyro_differenceandptranspjoined it at757a910, andProperVelocityGyroBatchNormnow centers withgyro_difference. A tangent lifts as(<x,v>/X_0, v)atX = (sqrt(1/c+||x||^2), x), and the PV result is the spatial part of the hyperboloid result. The bridge avoids the Poincaré chart and carries the repaired Cartesian origin derivatives into PV. - HoroPCA's
horo_projectionand ProperVelocity'stangent_inner/tangent_norminherited the same cancellation, throughbusemannandradial_perp_decompositionrespectively. Measured (probe_midpoint_horopca_busemann_pv_9093ea7.out, 4-seed medians,a = √c·d):horo_projectionerror (K=2ideal directions, vs the library's own float64 path, table C.ii) 1.413e-01 → 1.086e-04 ata=8, 3.660e+00 → 8.633e-03 ata=12; Busemann-coordinate preservation|dB|8.170e-02 → 8.836e-05 ata=8. ProperVelocity|⟨v,v⟩-1|on the exactly-unit radial tangent (table C.iv) 6.250e-01 → 2.384e-07 ata=8, 1.536e+03 → 5.192e-05 ata=12. HyperboloidGyroBatchNorm's centering step,(⊖x) ⊕ ywith the batch mean close tox, cancelled in the general ambient boost. It now centers withHyperboloid.gyro_difference(x, y, c)(see### Addedbelow). That operation uses the Cartesian inverse boost when either endpoint's scaled spatial radius is at most 1e-1 and the stable polar frame otherwise. Historical high-radius value and first-derivative measurements instep2c_gyro_difference_accuracy.outandstep2c_gyro_bn_centering.outpredate the Cartesian origin repair; they do not describe the current origin derivative rule. This retires Known limit 1 ofdocs/user-guide/numerical-stability.md.ProperVelocity.dist/.logmapbetween nearby points at large radius cancelled the same way the ambient hyperboloid two-point primitives did before their own fix, since PV's tangent-space metric routes through the same Minkowski forms. Both now go through the exact liftX = (√(1/c+‖x‖²), x)onto the hyperboloid and its cancellation-free polar-framedist/logmap. Measured (step2c_pv_accuracy.out,c=0.5, dim 16, radial step of true Riemannian length 0.1, landing point in float64, coordinate-axis direction): olddist5.988811e-02 / 4.382994e+00 / 1.056287e+01 ata=8/10/12(true value 0.1), new relative error 9.54e-07 / 8.05e-07 / 4.62e-07 — inside the float32 storage floor of the same pairs, 9.24e-07 / 7.22e-07 / 4.92e-07. This is the favourable direction: on the same probe's PRNGKey(3) direction, the worst new relative error overa ∈ {8,10}is 1.13e-04 ata=10, against that pair's own storage floor of 1.41e-05. The full float32 chain (expmapin float32 too) used to return 3.167524e-01 ata=8and 4.369660e+00 ata=10for a true step of 0.1; it now returns 1.000014e-01 and 9.999371e-02. Equivalence (step2c_pv_equivalence.out): float64 new vs old ata≤3agree to 8.09e-14 max; against an 80-bit reference ata≤6,distis 7.11e-15 max against old's 3.64e-11, andlogmapis 4.39e-14 max relative error / 1.26e-12 max‖err‖_x;dist(x,x)andlogmap(x,x)are exactly 0 in both dtypes with a finite gradient there. Callers that inherit the fix unchanged:utils.helpers.compute_pairwise_distances,decomposition/frechet.py,nn_layers/poincare_batchnorm.py(with a PV manifold),manifolds/product.py. This retires Known limit 4 ofdocs/user-guide/numerical-stability.md.- Historical collinear-gradient repair from the preceding numerics sweep:
_logmap_direction, the helper shared byHyperboloid.logmap,.ptransp,.gyro_differenceand, through the exact lift,ProperVelocity.logmap, normalized a vector that is exactly zero on the whole collinear set, leaving an O(1) gradient error there while the forward value stayed correct. It returned(cos φ, sin φ, n̂)withn̂ = safe_normalize(ŷ_s − ⟨x̂_s, ŷ_s⟩·x̂_s); on a pair sharing a ray (ψ = 0orπ,y = xincluded) that argument is zero up to rounding, so the normalization's derivative is arbitrary, and multiplied by asin φthat is itself onlyO(rounding)rather than exactly 0, it left an O(1) error in the gradient. Pre-existing since the polar-framelogmapof 1.1.2 (2026-08-25). At that revision the helper returned(S·cos φ, perp_y)with no1/Sand no1/‖perp_y‖anywhere:perp_y = r_y·[(csum²/4)·(ŷ_s − x̂_s) + (chord²/4)·(x̂_s + ŷ_s)], a non-negative combination of two orthogonal vectors that vanishes exactly on both degenerate rays, and each consumer's own prefactor cancels the remainingS(log_x(y) = asinhc(S)·(2/√c)·(S·cos φ)·e_rad + (asinhc(S)/C)·(0, perp_y); similarly forptranspandgyro_difference— see the docstrings for the exact scales). Measured (step2e_gradients.out,a ≤ 3, old → new): float64∇‖log‖²/∇⟨w,log⟩on collinear/y = xpairs 2.81 → 1.8e-10; the Jacobian oflog_x(·)aty = xvs the identity 1.00 → 5.0e-16;ptransp's∇⟨w, PT v⟩f32-vs-f64 relative error 3.29 → 4.0e-6;gyro_difference's gradient f32-vs-f64 relative error 5.94 → 9.6e-7; PV∇‖log‖²on a collinear pair, float32, 4.1e-5 → 2.2e-5 (1.9x better than even the pre-lift ambient PV spelling; float64 unchanged at 3.3e-10 either way). Zero non-finite entries across every geometry and dtype. Forward values are unaffected: float64 new-vs-old equivalence ata ≤ 6over dims 2/5/64,c ∈ {0.1, 0.5, 1, 3}, 5 geometries, 5 seeds (step2e_equivalence.out) —logmap4.7e-16,ptransp5.8e-14,gyro_difference3.2e-15, PVlogmap1.5e-15 (budget 1e-12);dist/sqdist/_polar_frameare bitwise unchanged; float32_logmapata ∈ {9, 12}worst 1.7e-7 against 2.3e-7 old. New testtest_hyperboloid_logmap_squared_norm_gradient_is_exact_on_the_collinear_setmeasures 3.8e-15 (float64) / 1.4e-6 (float32) against bounds 2e-14 / 6e-6; the old code gives 6.3e-1 / 1.1 on the same grid (step2e_test_bounds.out)._gyro_differencealso then built its time slot with_time_slotdirectly instead of_proj(concatenate([0, s]))— bit-identical value and gradient over 2880 pairs, both dtypes (step2e_time_slot.out), the same GPU fusion-shape reason as the_additionentry below.
Changed¶
is_in_manifold/is_in_tangent_spacenow test the residual on the time slot instead of the Lorentz form. The old check compared⟨x,x⟩_Lagainst-1/c(or⟨v,x⟩_Lagainst0), a residual that grows like2·x₀times the honest time-slot discrepancy and is itself obtained as a difference of twoO(cosh²a)numbers. Comparingx₀(orv₀) against√(1/c + ‖x_s‖²)directly removes both factors: an explicitatolnow bounds|x₀ - √(1/c + ‖x_s‖²)|, where it previously bounded roughly2·x₀times that quantity.lorentz_midpoint's normalizer isO(N·M·D)— one(…, N, M, D)broadcast difference, not a pairwise(…, M, M, D)Gram. TheO(M²)key-Gram form never shipped in a release: on this branch it existed only between the accuracy fix and the variance-form rewrite that replaced it (see the### Fixedentry above). Cost: see the next entry.-
Historical cost of the preceding sweep at
5b756dfagainstb586169(as-is) — AOT-compiled executables, float32, batch 4096,c = 0.5, spatial radius ≈ 3, forward andnnx.value_and_gradforward+backward; CPU is XLA:CPU on the development box, GPU an A100 withXLA_FLAGS=--xla_gpu_autotune_level=0(logs/2026-09-08_hyperboloid_tangent_primitives/cost_summary.md,probe_cost_{b586169,5b756df}.out,probe_cost_gpu_{b586169,5b756df}.out). The rows are workload functions, plus the explicitly named single optimizer step; they are not complete training-update, current-performance, or convergence measurements. They predate757a910and the origin-derivative repairs.workload CPU as-is ms CPU new ms CPU ratio GPU as-is ms GPU new ms GPU ratio PLFC gyro-bias fwd 6.2048 2.2965 0.370 0.2561 0.2510 0.980 PLFC gyro-bias fwd+bwd 13.8245 6.3049 0.456 0.6084 0.6258 1.03 GyroBatchNorm(train) fwd 9.0924 5.5412 0.609 0.5463 0.4806 0.880 GyroBatchNorm(train) fwd+bwd 13.4201 7.6611 0.571 0.7203 0.5613 0.779 HyperboloidGyroRMSNorm fwd+bwd 3.5352 3.5132 0.994 — — — HyperbolicFullAttention fwd 12.0482 89.9417 7.47 0.6080 0.9836 1.62 HyperbolicFullAttention fwd+bwd 31.1128 139.1628 4.47 1.4532 2.1561 1.48 LorentzResidual fwd 0.8921 2.0828 2.33 — — — LorentzResidual fwd+bwd 1.7535 3.0969 1.77 — — — Busemann head fwd 2.1609 98.2874 45.5 — — — Busemann head fwd+bwd 4.4315 131.7908 29.7 — — — _busemann_scoreK=256 fwd+bwd— — — 0.3418 0.8373 2.45 _busemann_scoreK=1000 fwd+bwd— — — 0.5406 2.3974 4.43 riemannian_adam one step 21.2513 21.7737 1.02 — — — Poincare.dist (vmap) 5.2551 2.1213 0.404 — — — Poincare.addition (vmap) 4.5814 5.3327 1.16 — — — Poincare.logmap (vmap) 8.5312 7.9924 0.937 — — — HypLinearPoincarePP fwd 3.4088 3.3689 0.988 — — — HypLinearPV fwd 1.3097 1.2538 0.957 — — — ProperVelocity.expmap (vmap) 5.8779 6.7439 1.15 — — — horo_projection (vmap, K=3) 5.8367 7.2006 1.23 — — — frechet_mean (max_iters=100) 73.4981 52.3895 0.713 — — — prim Hyperboloid.addition value_and_grad(both) 17.3033 3.4826 0.201 — — — prim Hyperboloid.expmap 2.8512 4.9346 1.73 — — — prim Hyperboloid.tangent_inner 1.9195 6.7360 3.51 — — — prim Hyperboloid.ptransp 9.7918 8.8648 0.905 — — — prim lorentz_midpoint 3.9228 111.3655 28.4 — — — Every consumer of the gyro-addition is about 2x faster on CPU and unchanged on GPU.
GyroBatchNormis 0.57–0.61x as-is on CPU; on the A100 it measured 0.78–0.88x in one run and 0.96–0.97x on the repeat, i.e. unchanged within GPU noise — so the key-Gram intermediate's 148x (CPU) / 14.5x (GPU) never reached a release (the numbers in the key-Gram column of the summary). The rows above 1.5x and why: attention and thelorentz_midpointprimitive on CPU because XLA:CPU materialises the variance form's(…, N, M, D)difference (Mflop only 1.3x for attention) while XLA:GPU fuses it (attention 1.62x / 1.48x on the A100),LorentzResidualon CPU for its pairwise polar frame, the Busemann head (CPU streaming of the exact broadcast-reduce; 2.1–4.4x on the A100 at 0.41–2.40 ms absolute, the decided trade),prim Hyperboloid.expmapandtangent_inner(three reductions instead of one; only the Riemannian optimizer's second moment andfrechet_meancall them, and the optimizer step is 1.02x). GPU repeatability from the repeat runprobe_cost_gpu_5b756df_rep2.out: worst 39.4% on the float64-island GEMM K=1000 fwd row, 24.1% onGyroBatchNormfwd+bwd, so GPU ratios inside ±1.3x are noise. - The batched Busemann head,nn_layers.busemann_core._busemann_score, and the vmappedbusemannshared by the Busemann MLR/FC layers use the same projected-coordinate formula asHyperboloid.busemann. The measurements inprobe_midpoint_horopca_busemann_pv_9093ea7.outdescribe the preceding large-radius value repair; the current formula additionally preserves the constrained origin derivative. -Hyperboloid._additionbuilds its time slot with_time_slotdirectly instead of_proj(concatenate([0, s])). Bit-identical value and gradient; a GPU-only performance fix. The dead zero-slot pad/slice pair in the backward made XLA:GPU root a multi-output fusion in a column reduction instead of a row reduction: on an A100 (jax 0.9.1, float32,c=0.5,B=4096,D=64) the dominant kernel of that fusion,input_multiply_reduce_fusion, cost 1769.5 µs/call as the boost was first merged (diag_plfc_kernels_900f054.out) — against 87.9 µs/call for the same fusion before the boost rewrite existed at all (diag_plfc_kernels_b586169.out, the pre-boost round-trip spelling) — and now costs 53.9 µs/call (diag_plfc_kernels_fixed.out). Total device time forHypLinearHyperboloidPLFC(65, 65, use_gyro_bias=True)'s forward+backward kernels drops from 2052.2 µs/call to 356.4 µs/call; the AOT wall-clock forward+backward (median of 50 calls) is 0.5810 ms fixed (diag_plfc_gpu_fixed.out), forward alone 0.1738 ms. Output and∂L/∂gyro_biasare bit-identical to the round-trip spelling.
Added¶
ProperVelocity.gyro_difference(x, y, c)— the PV gyrovector difference(⊖x) ⊕ y, evaluated through the exact direct lift toHyperboloid.gyro_difference. Use it for centering and for differences expected to lie much closer to the origin than their operands.ProperVelocityGyroBatchNormuses it for centering.HyperbolicFullAttention(score_dtype=...). An opt-in float64 island for the Lorentzian similarity score: the two einsums and the2 + 2⟨Q,K⟩_L/ scale / bias / causal-mask arithmetic run inscore_dtypeand are cast back to the working dtype before the softmax.score_dtype=None(the default) leaves the score path unchanged op for op. The GEMM-formed score has no cancellation-free spelling — any matrix product of the ambient coordinates returns the Gram matrix to absoluteeps— so pasta ≈ 8(c=1,scale=1) the absolute score erroreps·cosh(a_q)·cosh(a_k)/(c·scale)exceeds what softmax can resolve;score_dtype=jnp.float64fixes the arithmetic but not float32 storage of the activations themselves — seedocs/user-guide/numerical-stability.md.Hyperboloid.gyro_difference(x, y, c)—(⊖x) ⊕ yfor centering a batch on its mean and differences expected to lie closer to the origin than their operands. It is mathematically identical toaddition(scalar_mul(-1, x), y), using a Cartesian inverse boost when either endpoint's scaled spatial radius is at most 1e-1 and the stable polar frame otherwise. The historical equivalence measurements instep2c_gyro_difference_equivalence.outpredate the Cartesian origin repair.HyperboloidGyroBatchNormuses this method for centering.
1.2.1 - 2026-09-06¶
Fixed¶
- The origin Jacobian of
Hyperboloid.expmap/expmap_0was√c·Iinstead ofIfor everyc < 1. It bit whenever the tangent vector satisfied‖v‖ ≲ 1e-15/√c, the zero tangent included: the divisor of thesinh(t)/tratio carried a secondMIN_NORMfloor (denom = floor_at(√c·‖v‖, MIN_NORM)) that the numerator did not, so atv = 0the ratio evaluated to√c·1e-15 / 1e-15 = √crather than 1 and the whole spatial Jacobian came out scaled by√c— a zero-initialised gyro-bias saw its first gradient scaled by 0.32 atc = 0.1, 0.55 atc = 0.3, in both dtypes (c ≥ 1was unaffected, since the floor is inactive there). Found by an independent numerics review. The divisor is now the same flooredt = √c·‖v‖, which is≥ √c·1e-15 > 0and normal in both dtypes, sosinh(t)/tis exactly 1 there; the Poincaré, stereographic and proper-velocity exponential maps already divided by a single floored quantity and are unchanged.test_hyperboloid_expmap_at_the_origin_has_the_identity_jacobianpins the identity atc ∈ {0.1, 0.3, 1, 2.5}in both dtypes, andtest_hyperboloid_gyro_bias_at_the_origin_has_a_nonzero_jacobiannow runs atc = 0.1as well asc = 1. - The norm-rescale divisor was not an exact power of two in float64 on CUDA, so the rescale it exists to make rounding-free put a rounding into every division it scales.
_pow2_divisorbuilt the divisor withjnp.ldexp, which computesm · 2**eand lowers to an XLApower— a ~1 ulp transcendental on CUDA rather than an exact exponent shift. On an A100 (jax 0.9.1) that came out an ulp low for 75 of the 600 binadesk ∈ [-300, 300);ldexp(1.0, -33)returns one ulp below2**-33. The divisor is now built by masking the mantissa bits offm, which leaves2**floor(log2 m)exactly on every backend, with the oldminexpfloor replaced by afinfo.tinyfloor (a subnormalmmasks to 0). Affectedsafe_norm,safe_hypot,safe_hypot_normandsafe_normalizeon GPU, in float64 only — float32 was already exact on both backends, and CPU float64 was too; values there are bit-identical before and after (checked over every binade of both dtypes plus0,inf,nan, the subnormals,finfo.tinyandfinfo.max). It showed up astest_the_norm_rescale_adds_no_rounding_of_its_ownfailing on GPU with mean ulp distance 0.27–0.34 against 0.000 on CPU.test_the_rescale_divisor_is_an_exact_power_of_two_on_every_backendnow pins zero mantissa bits and the correct binade over the full exponent range of both dtypes.
Changed¶
- Float32 matmul precision is now split by what the dot product computes, not by where it lives, and there is no hyperbolix-specific knob for it.
MATMUL_PRECISION = jax.lax.Precision.HIGHESTis pinned on the geometry and is not user-configurable: the vector-vector reductions inmanifolds/(behinddist,addition,gyration,expmap,logmap,ptransp,tangent_inner,egrad2rgrad, the Lorentz inner product, the Busemann coordinate and the boundary factors) and the HoroPCA contractions indecomposition/;lorentz_midpointand the Poincarépoincare_weighted_midpoint, the two Fréchet-mean normalizers whose cancellation-free identity only holds toO(eps)on float32-accurate inputs; theconv_general_dilated_patchespatch extraction in the hyperboloid, Poincaré and proper-velocity convolutions, which XLA implements as a convolution against a 0/1 filter — a pure data copy, where TF32 would round every input to a 10-bit mantissa for no throughput at all; the attention score and aggregation einsums inhyperboloid_attention.py(the Lorentzian similarity, the softmax scores and weighted values, the linear-attention kernel sums) and the spatial residual projection added to that aggregate; and the point-to-hyperplane einsums —HypRegressionHyperboloidandFGGLorentzMLRplus the three batched_compute_mlreinsums inmanifolds/hyperboloid.py,poincare.pyandproper_velocity.py— whoseasinhargument is a difference of a radial and an angular term that cancels. That last pin reaches into the hidden layers too:HypLinearHyperboloidPLFC,HypLinearPoincarePP,HypLinearPV,HypConv2DHyperboloidILNN,HypConv2DPoincareandHypConv2DPVare those einsums applied to their own kernel, so their weight GEMM runs atHIGHESTas well. What the head's pin costs, measured on an H100 against 1.1.2 (every dot at TF32): theHypRegressionHyperboloidforward alone, B=1e7, 10 classes, is 2.6x at D=128 and 2.0x at D=32 (1.02x of 1.2.0, which pinned it too); in a training stepexpmap_0 → HTCLinear ×2 → HypRegressionHyperboloidat B=262144, D=128 the pin is the residual 1.05x over 1.1.2 once the GEMM pin and the norms are given back (the same step was 1.00x on the tree before the split). The hyperbolic attention layers, whose score and aggregation einsums are pinned, are 1.25–1.31x of 1.1.2 at (8, 256, 257) and 0.76–0.80x of 1.2.0. On an A100 (jax 0.9.1) the float32-vs-float64 relative error oflorentz_midpointis 4.6e-5 … 2.6e-4 at the TF32 default against 2.6e-8 … 1.6e-7 underHIGHEST, a ~2000x difference; the eager float32 gradient of the hyperboloid MLR goes from 1.5e-4 to 2.7e-7 relative over the same switch. - The layer weight GEMMs carry no
precisionkeyword at all and follow JAX's ownjax_default_matmul_precision— TF32 on Ampere/Hopper.HTCLinear— the attention Q/K/V projections included —FGGLinear/FGGConv2D, the FHCNN and FHNN linear forwards,HypLinearPoincare,HypVQMLRPoincare's implicit-codebook matmul andhybrid_regularization'snnx.Linear. One of them carries a cancellation and is still left on the default: the FGG hidden dotx @ Vabsorbs the Minkowski metric intoV, so the-x0*V0 + <x_s, V_s>cancellation happens inside one accumulation — the same productFGGLorentzMLRpins — and the comment on thejnp.matmulinnn_layers/hyperboloid_linear._fgg_linear_forwardsays so. It is left there deliberately: at depth 16,c = 1, input geodesic radius 5, anFGGLinearstack's float32 parameter-gradient error under the default is 0.199 % relative L2 against a float64 reference and its input-gradient error 0.274 %, against 1.539 % / 2.013 % for anHTCLinearstack, which has no cancellation at all — so the in-accumulation cancellation is not what dominates there (independent A100 measurement, jax 0.9.1,logs/2026-09-06_numerics_independent_review/training/gpu/depth.json; under globalHIGHESTthe same four cells are 8.0e-7 / 1.0e-6 and 2.5e-6 / 1.2e-5). Those depth-16 numbers are the worst cell of a 24-cell grid (depths 2/8/16,c ∈ {0.1, 1}, input radius{0.5, 5}), one initialisation and one input draw per cell and no seeds — grid maxima atn = 1, not means, and the HTC stack's measured radius climb (≈0.35 nats per layer at large radius) and the hypothesis linking it to the depth-16 error are in thehyperbolix/utils/precision.pydocstring. At depth 2 the choice is invisible in training: 5 seeds per arm,D = 128,B = 256,c = 1, 2 000 Adam updates, mean heldout loss 0.27736 (default) against 0.27738 (HIGHEST) for HTC and 0.28610 against 0.28614 for FGG, on a seed spread of ~0.015–0.017.HTCLinearis where that choice is visible in the test suite:test_attn_output_shape_and_jitandtest_causal_first_token_self_onlycompare two lowerings of the same algebra at a 1e-5 tolerance, which TF32's run-to-run rounding exceeds, so both now wrap their forward passes injax.default_matmul_precision("highest")— the tolerances are unchanged and the TF32 values are not wrong. These are the sites whereHIGHESTactually costs throughput — it replaces one TF32 pass with a three-pass float32 emulation, measured +5.5 % on a jitted hyperbolic attention forward — so the trade is the user's to make, through JAX rather than through a hyperbolix-specific attribute:jax.config.update("jax_default_matmul_precision", "highest"), or scoped,with jax.default_matmul_precision("highest"):. Both are jit-cache aware (changing them re-traces), and both cover the pinned sites too, so one line runs the whole package in full float32. A deep, fully hyperbolic stack is a good reason to set it: a TF32 error introduced in an early layer's weight GEMM is carried by every layer after it, and it is not small. Measured on an A100 (jax 0.9.1, ambient dim 33, batch 64,c in {0.1, 1.0}x spatial radiusin {0.5, 5, 20}, float32 against a float64 reference):FGGLinear2.6e-4 at the TF32 default against 6.8e-8 underHIGHEST,FGGLorentzMLR1.3e-4 … 3.6e-4 against 3.6e-8 … 9.6e-8 — roughly ~1e-4 against ~1e-7 on the layers, three of float32's seven significant digits.HIGHESTis a no-op on CPU (no TF32 path) and for float64 anywhere. - The per-sample norms that 1.2.0 measurably made slower are a single reduction again — and only those. A site is converted where 1.2.0 measured slower (hyperboloid
expmap_01.28x,HTCLinearforward+backward 1.12x, on both A100 and H100) or where PR #75 raised the compiled kernel / reduction count. That is:Hyperboloid.proj/proj_batch/dist_0(both version slots); the shared gyrovectorproj/proj_batchbehindPoincareandStereographic, andPoincare.expmap; andspatial_to_hyperboloid(soHTCLinear), the FHCNN linear forward and the FGG linear forward. Everywhere else 1.2.0's max-scaled two-pass norm stays, with its full-range guarantee. In isolation that costs something — about 1.2–1.35x the one-pass form on a forward pass in float32 (h_logmap_0andPoincare.expmap_0atD = 32/B = 4096andD = 128/B = 262144,c ∈ {0.1, 1}: 1.202–1.343, independent A100 measurement, jax 0.9.1,logs/2026-09-06_numerics_independent_review/timing/norm/— this range rests on that measurement alone; the 1.28x above is a v1.2.0-vs-v1.1.2 tree ratio of a converted site, not a one-pass/two-pass swap of a retained one) — but inside a training step it shrinks to ≤ ~1.05x (0.92–1.05x on the same probe's complete-step and HTC-chart rows), which is why the two-pass norm is kept wherever the operand's magnitude is unbounded. The retained sites: hyperboloidlogmap_0(which measured faster in 1.2.0), the pairwisedist/logmappolar frame, hyperboloid and Poincarétangent_norm,Poincare.expmap_0(no measured change either way), the FHNN linear forward, the linear-attentionfocus_transform(converting it measured no speedup of its own), everyProperVelocityoperation and the proper-velocity isometry maps, the Poincaré metric-tensor distances, the rest ofStereographic,EuclideanandProductManifold, and the wrapped-normallog_prob. The converted spellings aresafe_sqrt(sum(v**2))where the input can be exactly zero, a plainsqrt(const + sum(v**2))where a strictly positive constant is added, andfloor_at(..., MIN_NORM)around either where the norm is a divisor. Every gradient fix from 1.2.0 is kept:safe_sqrt's double-wheregives the same exact0and exactly-zero VJP at the zero vector thatsafe_normdid, sojax.gradat coincident points and at the origin stays finite. - Past float32 coordinate 1.8e19 the converted sites give up their answer, and what they give instead was measured rather than argued. That coordinate is geodesic radius ~45 at
c = 1and ~139 atc = 0.1, in float32; a network out there is already diverging, andinfis the intended signal rather than a plausible finite answer. Measured, float32,c = 1:Hyperboloid.proj/proj_batchgivex0 = infwith the spatial part unchanged and no NaN;dist_0givesinfon both version slots;spatial_to_hyperboloid/HTCLinearand the FHCNN forward givex0 = infwith no NaN; the FGG linear forward gives a non-finite output (NaN orinf, depending on the input — an all-NaN output on the probe's 5e19 spatial input,infwith no NaN on a second, crafted one); the Poincaré and κ-stereographic boundary clamps give the origin — a finite point, with a finite (exactly zero) gradient there — becausex * (max_norm / inf)is the zero vector, the pre-1.2.0 behaviour; andPoincare.expmapgives the base point, a finite point, inheriting the same clamp. Two of the converted sites therefore do saturate to a finite point, and that is the clamp's documented behaviour. Everything on the two-pass norm —Poincare.expmap_0, which still returns the correct boundary point, and the linear-attentionfocus_transformincluded — behaves exactly as in 1.2.0. - The maximum radius the converted origin-chart operations can represent drops with it. For
projanddist_0the ceiling used to bex₀'s — the two-pass norm never formed‖x_s‖², so what bound the radius wascosh(a)/√c ≤ finfo.max, i.e.a = ln(2·finfo.max): radius ~89 in float32 / ~710 in float64 atc = 1(89.416 / 710.476, the same number asarcsinh(finfo.max), sincesinh(a)andcosh(a)leave the dtype together). It is now the coordinate limitsinh(a)/√c < sqrt(finfo.max)— radius ~45 in float32 and ~356 in float64.logmap_0and the pairwisedist/logmapkeep the two-pass norm and so keep a ceiling of that order:logmap_0reads only‖y_s‖and keeps the old ~89 / ~710 exactly, while the pairwise pair binds a fraction of a radius earlier ate^a/√c ≤ finfo.max(a = ln(finfo.max), 88.72 / 709.78), because_polar_frameformsu = x₀ + ‖x_s‖and returns±infonce that overflows. Every hyperbolic model in the literature lives four to five orders of magnitude inside every one of these limits. safe_norm,safe_hypot_normandsafe_normalizeremain public and are what every unconverted per-sample site and every once-per-forward weight norm still use.safe_hypotis a hot-path two-leg scalar composer, not a weight-norm primitive: the hyperboloid polar frame builds its radial and angular legs with it.- One deliberate value change: the hyperboloid time slot is now
sqrt(1/c + sum(x_s**2))instead ofsqrt((1/sqrt(c))**2 + sum(x_s**2)), one rounding fewer and in the more accurate direction (Hyperboloid.proj/proj_batch,nn_layers.hyperboloid_core.spatial_to_hyperboloid, and the FHCNN/FGG layer forwards;isometry_mappings.pv_to_hyperboloidkeeps 1.2.0's spelling). Everywhere elsesafe_norm/safe_hypot_normwere bit-identical tosqrt(sum)/sqrt(sum + q**2)on the finite domain, so values move only by XLA association noise (0-2 ulp). - The hyperboloid time slot carries a
custom_jvpwhose only job is the backward's XLA fusion shape. With the one-reductionsqrt(1/c + sum(x_s**2)), XLA:GPU fused the backward's reduction into a full-width Triton kernel and left the cotangent's re-embeddingpadas a standalone copy of the whole batch, sojax.gradofproj/expmap_0at B=1e7, D=128 ran 1.35x/1.76x slower than 1.1.2 on an H100 even though the forward was as fast; v1.1.2 avoided this only through themaximum(…, MIN_NORM)its VJP happened to place between the reduce and the sqrt. The module-private_time_slotrule states the same derivative AD derives (the1/ccotangent1/(2·x0)included, so a tracedLearnableCurvatureis unaffected) and puts alax.optimization_barrieron the per-row1/x0, which restores 1.1.2's kernel structure (proj.grad3/1,expmap_0.grad7/3 kernels/reductions at D=128). Forward values are bit-identical;jax.jvp/jacfwdkeep working.test_hyperboloid_time_slot_custom_jvp_matches_plain_autodiffchecks value, gradient, forward-mode tangent and the curvature cotangent against the rule-free spelling. The fusion effect it fixes is shape- and consumer-dependent, so it will not reproduce everywhere: it appeared in float32 on jax 0.9.1 atB ≥ 1e6, at bothD = 32andD = 128(expmap_0.grad1.48x of 1.1.2 atB = 1e6and 1.76x atB = 1e7forD = 128, and 1.60x atB = 1e7forD = 32, withproj.grad1.35x at either width; absent atB = 1e5, 0.98x atD = 128—logs/2026-09-04_safe_norm_hot_path_revert/RESULTS_31403c2.md,.../vda/timing_D{32,128}/and.../vda3/timing_D{32,128}/, two different H100 hosts with every ratio against a v1.1.2 arm from the same host and run), and only for a backward that materialises the full(B, n)cotangent, e.g.jax.gradof a sum over the output. With a scalar-loss consumer thepadfuses anyway: an independent A100 measurement ofjax.grad(mean(f(x)**2))atB ≤ 262144,D = 128put the barrier arm within ~1 % of the rule-free spelling forexpmap_0forward+backward at the large shape (1.003-1.006 at bothc = 1andc = 0.1, against either spelling without the barrier); theprojrows of the same run are noisier (one contaminated round). - One extreme-radius test row moved from float32 to float64. It was exercising the retired overflow guard rather than the algorithm, so it follows the guard rather than being loosened; tolerances are unchanged. In
tests/test_manifold_oracles.py,test_hyperboloid_dist_and_logmap_to_the_origin_match_the_origin_variantsnow takes a per-dtype radius grid — float32 stops at 43, float64 keeps 45. What binds is the spatial coordinatesinh(a)/sqrt(c), which passes float32's 1.845e19 at radius 45 forc = 0.3, where the converteddist_0returnsinfby policy; exactly that one cell of the grid crosses the threshold, and 43 is the repo's existing float32 radial ceiling. This narrows the float32 coverage rather than preserving it: the radius-45 cell is no longer exercised in float32 at all, only in float64. The pairwise oracle rows are untouched, because the pairwisedist/logmapkeep the two-pass norm.
Removed¶
- The
smooth_clampon theasinhargument of every MLR head is gone, and with it theclamping_factorandsmoothing_factorparameters ofHyperboloid.compute_mlr,Poincare.compute_mlr_pp,ProperVelocity.compute_mlrand the four_compute_mlrhelpers, plus every layer that only carried them to forward:HypRegressionHyperboloid,HypRegressionPoincare,HypRegressionPoincarePP,HypRegressionPV,HypLinearHyperboloidPLFC,HypLinearPoincarePP,HypLinearPV,HypConv2DHyperboloidILNN,HypConv2DPoincare,HypConv2DPVandHypVQMLRPoincare. This is a signature break: drop the two keywords at the call site.asinhis defined on all of R with derivative1/√(1+x²) ≤ 1, so it needs no guard — the only infinite argument comes from a point that has already overflowed the float32 manifold, and the clamp turned that into a finite, plausible logit and hid the divergence; the logit is nowinfand the loss NaN, which is the failure you want to see. The bound was also dtype-dependent (log(2/eps): ±16.6355 in float32 against ±36.7368 in float64), so the two dtypes disagreed by design: measured withHypRegressionHyperboloidatc = 1, geodesic radius 5, default init, batch 256 × 10 classes, the float32 logits sat 9.4e-2 (D = 128, 1.2% of cells clamped) and 1.8e-1 (D = 32, 22.4% clamped) from the float64 ones relative to the largest logit, identical under TF32 andHIGHEST; with the clamp gone the same cells agree to 6.4e-7 / 4.6e-7. Every clamped cell also had an exactly zero input gradient (smooth_clamp's slope past its bound isexp(-50·d)), freezing those points under SGD, and atc = 1with the shipped init the float32 bound first bit at geodesic radius 4.25 (D = 32) / 4.75 (D = 128) — well inside the range the library documents as float32-reliable. Neither reference clamps this quantity: HNN++ (mil-tokyo/hyperbolic_nn_plusplus) guards only the1 - c‖x‖²denominator and the weight norms at a flat1e-15, and HCNN'sLorentzMLR(kschwethelm/HyperbolicCV) has no guard at all; the line came from the author's earlier PyTorch code (univie-dm/hyperbolic_math,helpers.py, "Improve the performance by smoothly clamping the input of asinh()") with no recorded rationale.smooth_clampitself stays inhyperbolix.utils.math_utilsand is unchanged - The three float32 overflow oracles in
tests/test_manifold_oracles.pyare retired, since the guard they tested is gone.test_hyperboloid_proj_time_slot_survives_the_float32_overflowbecomestest_hyperboloid_proj_time_slot_is_exact_at_an_enormous_radiusin float64, andtest_poincare_proj_clamps_a_far_point_to_the_boundary_not_to_the_originmoves to float64; both then assert the algorithm rather than the dtype's range.test_hyperboloid_expmap_0_saturates_to_a_consistent_point_not_an_infinite_time_slotcannot move —sinhclips its argument at0.99*log(finfo.max)in both dtypes, so the capped spatial value squared overflows in float64 too — and is replaced bytest_hyperboloid_expmap_0_past_the_sinh_cap_is_infinite_not_nan, which pins the weaker but real contract:x0 = inf, spatial part finite, no NaN. Hyperboloid.dist/dist_0slots 2 and 3 (VERSION_LEGACY,VERSION_LEGACY_SMOOTHENED) are gone; aversion_idxoutside{0, 1}now raisesValueError. The explicit check is needed becauselax.switchsilently clamps an out-of-range index into range, so a staleversion_idx=2would have quietly run the smoothened arm instead of failing. The two slots were added in 1.1.2 / 1.2.0 by the very fixes that made them obsolete (the cancellation-freedistrewrite and the origin-chartdist_0rewrite); at 1.1.1 the switch had only two slots, so no pre-fix code ever passed 2 or 3, and pre-fix numbers remain reproducible by installinghyperbolix==1.1.1from PyPI. For the record, the four golden values the deleted regression test pinned — on-sheet point at spatial radius1e-3,c = 1, dim 8, directione1, true geodesic radius9.99999833e-4— were: slot 2 float320.0015440807910636067, slot 2 float640.0009999998333921221, slot 3 float640.16632065504083338, slot 3 float320.16632071137428284(CPU; ±1 ulp on an A100)
1.2.0 - 2026-09-04¶
Fixed¶
- Every zero-initialised hyperboloid gyro-bias was frozen at its init value:
∂(x ⊕ b)/∂batb = originwas exactly the zero matrix, in both dtypes.dist_0short-circuited on a bitwiseat_originguard (jnp.where(at_origin, 0.0, res));logmap_0scales the spatial part bydist_0(y)/‖y_s‖and inherited it; Lorentz gyro additionx ⊕ y = Exp_x(PT_{0→x}(Log_0(y)))inherited it in turn. A bias parameter that starts at the origin, which is whatuse_gyro_bias=Truedoes, therefore received an exactly-zero gradient at step 0 and never left. Affected layers:HypLinearHyperboloidPLFC,HypConv2DHyperboloidILNN,HypLinearHyperboloidBusemann. Measured gyro-bias gradient L2 at init (c = 1, dim 8, batch 4,dist_0loss, before → after): float320.0 → 1.37(PLFC),0.0 → 4.24(ILNN conv),0.0 → 3.07(Busemann FC); float640.0 → 1.48,0.0 → 5.37,0.0 → 1.83. In float32 the gradient was additionally ~1400x over-scaled the moment the bias left the origin, because theacoshfloor below was divided by the true radius: the PLFC gradient at bias radius1e-6was 1535x its value at1e-2, a ratio that is now 1.06x. The PoincaréHypLinearPoincareBusemanngyro-bias goes through Möbius addition and was never affected (7.64 before and after). A model trained with a gyro-bias on any of the three hyperboloid layers was trained with that bias pinned to the origin; retraining under this fix changes results. -
Hyperboloid
dist_0/logmap_0recovered the geodesic radius from the time coordinatex₀, which cannot resolve a small radius; they now read it off the spatial part.dist_0wasacosh(clip(√c·x₀, 1))/√c. On the sheetx₀ = cosh(√c·d)/√c ≈ (1 + c·d²/2)/√c, sodsurvives only tosqrt(eps)resolution (relative erroreps/(2·c·d²)), andacosh's1 + 10·epsdomain clamp flattened every float32 radius belowsqrt(20·eps)/√c = 1.5441e-3onto that floor value (1.5441e-3 was returned for every such point, 1500x too large at radius 1e-6; only the bitwise origin returned 0). The smoothened arm was worse:smooth_clamp_min(β = 50) addsln2/50to theacoshargument, i.e. a floor ofacosh(1 + ln2/50)/√c = 0.16632/√cunder every point that is not bitwise the origin, in both dtypes (measured: it returned 0.16632 at every radius ≤ 1e-2 and 0.1815 at radius 0.1, agreeing with the true value only from radius ≈ 1). Slot 0 is now the exact on-sheet identityarcsinh(√c·‖x_s‖)/√c, with no domain clamp and a derivative bounded by 1; slot 1 is the same with the spatial radius floored in quadrature at20·eps, a floor ofarcsinh(20·eps)/√c(2.4e-6/√c float32, 4.4e-15/√c float64) that equals the pairwise smoothened floor2·arcsinh(10·eps)/√cfrom 1.1.2 to first order.logmap_0is now[0, arcsinh(u)/u · y_s]withu = √c‖y_s‖: it no longer routes throughdist_0's version switch,‖log_0(y)‖ = dist_0(y)holds by construction instead of by cancelling a floored numerator against an unfloored denominator, and the trailingtangent_projis dropped (it is the identity at the origin, but it routes through the Minkowski inner product, which turns oneinfspatial coordinate into an all-NaN vector).scalar_mulis now literallyexp_0(r · log_0(x)); its old normalize-then-rescale detour carried asqrt(max(‖v‖², MIN_NORM))floor, an effective3.16e-8floor on‖log_0 x‖that was invisible only while the largeracoshfloor sat in front of it. Median relative error at c = 1, dim 8 (A100, jax 0.9.1; the CPU backend and jax 0.11.0 agree in every floored cell):radius float32 dist_0float32 log_0(exp_0(v))float64 dist_0float64 round trip 1e-6 1.5e3 → 2.5e-9 1.5e3 → 0 4.4e-5 → 0 4.4e-5 → 1.3e-16 1e-3 5.4e-1 → 9.8e-8 5.4e-1 → 0 5.9e-11 → 0 1.5e-10 → 1.2e-16 1e-2 5.0e-4 → 2.7e-8 5.2e-4 → 0 1.0e-12 → 1.7e-16 8.3e-13 → 1.2e-16 0.1 3.5e-6 → 1.8e-8 1.4e-7 → 3.9e-8 7.6e-15 → 1.4e-16 9.5e-15 → 1.1e-16 1 to 40 ≤7.1e-8 → ≤5.2e-8 ≤1.0e-7 → ≤8.8e-8 ≤1.3e-16 → ≤1.9e-16 ≤1.4e-16 → ≤1.4e-16 Consumers that inherit the fix with no change of their own: gyro addition,
scalar_mul,logmap's origin fallback,HyperboloidGyroRMSNorm(it divides bydist_0, so in float32 every sample inside radius 1.5e-3 was mis-normalised), and the three gyro-bias layers above. Pairwisedist(origin, x)is a separate code path and still carries anO(eps/r)relative error from the_polar_framegap term near the origin (float32: 4.6e-2 at radius 1e-6, ~1e-3 at 1e-4); closing that is a planned separate change, so preferdist_0for distances to the origin. Supersedes the claim in the 1.1.2 entry below that origin-chart operations "read the radius straight off the ambient time coordinate and were never affected": reading it off the time coordinate is precisely the defect fixed here. That entry's two-point cancellation claims, andexpmap_0, are unchanged -
On an Ampere or Hopper GPU,
lorentz_midpointand the three hyperbolic attention layers silently ran their matmuls in TF32, costing ~2000x accuracy in the one place the library cannot afford it. XLA:GPU defaults float32 matmuls to TF32, whose 10-bit mantissa carries ~1e-3 relative error against float32's ~1e-7.lorentz_midpoint's whole design is a cancellation-free identity in which every rounded term isO(‖delta‖²), so that the normalizer stays accurate at any radius — TF32 is far coarser than the effect that identity exists to remove. Measured float32-vs-float64 relative error oflorentz_midpoint(A100, jax 0.9.1,c ∈ {0.1, 1.0}×‖s‖ ∈ {0.5, 5, 20}): GPU default 4.6e-5 … 2.6e-4, GPU with the fix 2.6e-8 … 1.6e-7, CPU 2.6e-8 … 1.2e-7 — i.e. three of the seven significant digits were gone, with no warning, in every hyperbolic attention or Fréchet-mean computation on such a card. The worst site isHyperbolicFullAttention's Lorentzian similarity, which evaluates⟨Q,K⟩_L = -Q₀K₀ + ⟨Q_s,K_s⟩as the difference of two matmuls — the exact cancellation_polar_framewas written to avoid, with both halves produced by TF32 GEMMs, so the subtraction amplifies a ~1e-3 input error rather than a ~1e-7 one. Fixed by annotating the cancellation-sensitive dots withprecision=jax.lax.Precision.HIGHESTthrough one documented constant,hyperbolix.nn_layers.hyperboloid_core.MATMUL_PRECISION: the threejnp.einsums inlorentz_midpoint, the ten score / Lorentz-inner-product / aggregateeinsums inhyperboloid_attention.py, the spatial residual projection the linear and softmax variants add to that aggregate, andHTCLinear's matmul — the last because it produces the Q/K/V the Lorentz inner product then cancels, and a TF32 input makes an accurate cancellation pointless (annotating only the attentioneinsums left 6 of the 7 attention tests red; addingHTCLinearleft 2; adding the residual projection cleared them). This turned 14 of the 21 GPU-only test failures green (all 7 attention, all 7lorentz_midpoint).HIGHESTis a no-op on CPU (no TF32 path) and for float64 anywhere; the CPU outputs oflorentz_midpointand of aHyperbolicFullAttentionforward are bit-identical before and after, eager and jitted, in both dtypes. On a tensor-core GPU it does trade GEMM throughput for accuracy, sinceHIGHESTreplaces one TF32 pass with a three-pass float32 emulation: a jittedHyperbolicFullAttentionforward at B = 8, N = 256, 4 heads, head dim 64, float32 measured a median 1.84 ms with the fix vs 1.74 ms at the TF32 default, +5.5 % (A100-PCIE-40GB, 5 warmup + 20 timed calls; the card was idle but shared, so treat the ratio as indicative) - The hyperboloid MLR forward dot ran in TF32 on the same cards, for the same reason:
_compute_mlrformsalpha = -x₀·sinh(√c·r)·‖z‖ + cosh(√c·r)·⟨x_s, z⟩, a difference whose second term is a matmul. The einsum now carriesprecision=HIGHEST(spelled out locally —manifolds/must not import fromnn_layers/). Measured on an A100 against a float64 reference at identical inputs: the eager float32 gradient of_compute_mlrimproves from 1.5e-4 to 2.7e-7 relative; the forward was already accurate (1.1e-7) on both settings. This does not fix the separate, intermittent 1 % error in the jitted float32 gradient of the same function, which survives every precision setting; that one is thejnp.maximumtie-break in the next entry - The remaining float32 dots on manifold data still ran in TF32 on Ampere/Hopper — the
x @ Vmatmuls where the Minkowski metric is absorbed into the weight matrix, and the HoroPCA and Poincaré-MLR contractions. PR #70 closed the Lorentz cancellations that are written as an explicit difference of two dots (lorentz_midpoint, the attention scores, the hyperboloid MLR); this closes the rest.FGGLinear,FGGLorentzMLRandHypRegressionHyperboloidevaluate⟨x, V⟩_Las onex @ Vwith the metric folded intoV, so the-x₀V₀ + ⟨x_s, V_s⟩cancellation happens inside a single TF32 accumulation and the ~1e-3 input rounding lands directly on the cancelled result. Measured float32-vs-float64 relative error on an A100 (jax 0.9.1, ambient dim 33, batch 64,c ∈ {0.1, 1.0}× spatial radius∈ {0.5, 5, 20}; median over the batch, before → after):FGGLinear2.6e-4 → 6.8e-8 (a 3700-3900x improvement at every cell),FGGLorentzMLR1.3e-4 … 3.6e-4 → 3.6e-8 … 9.6e-8 (2200-3800x),horo_projection4.0e-4 … 4.9e-3 → 2.8e-7 … 2.4e-6 (1400-2600x, the ideal-span Minkowski projections),HoroPCA.transform1.9e-4 … 2.3e-3 → 3.4e-7 … 4.3e-6 (520-1560x, the Fréchet-mean Lorentz boostx @ Bᵀplus the component-frame read-off), and the Poincaré HNN++ MLRcompute_mlr_pp3.8e-5 … 1.4e-4 → 6.0e-8 … 2.2e-7 (440-1740x). The fix is one library-wide setting rather than a per-call keyword:MATMUL_PRECISION = jax.lax.Precision.HIGHESTnow lives inhyperbolix.utils.precision— a neutral home bothmanifolds/andnn_layers/can import from, somanifolds/hyperboloid.py::_compute_mlrimports it instead of spellinglax.Precision.HIGHESTlocally — and is attached to all 87 float32 dot products in the package that touch points, tangent vectors or hyperplane normals (70 of them newly).hyperbolix.nn_layers.hyperboloid_core.MATMUL_PRECISIONre-exports it, so existing imports keep working unchanged. Covered: the Poincaré/κ-stereographic/proper-velocity/gyrovector-corejnp.dotreductions behinddist,addition,gyration,expmap,logmap,ptransp,tangent_inner,egrad2rgradand the boundary factors1 - c‖x‖²; the hyperboloid_minkowski_inner,_projtime reconstruction, polar-frame Gram-Schmidt,tangent_normradial split and Busemann coordinate; the isometry maps between the three models;HypLinearHyperboloidFHCNN/FHNNandHypLinearPoincare's tangent-space matmuls; the Poincaré batch-norm weighted gyromidpoint;HypVQMLRPoincare's implicit-codebook matmul; and the hyperboloid/Poincaré/PV conv patch extraction (conv_general_dilated_patchescarries ambient channels, time slot included).HIGHESTis a no-op on CPU and for float64 anywhere, and the change is verified bit-identical: 280 CPU arrays covering every touched public entry point, forward andjax.grad, eager and jitted, in both dtypes, match the base commit exactly. The single-vectorjnp.dotsites measured no GPU change either way (XLA lowers a vector-vector dot to a reduction rather than a tensor-core GEMM), so those annotations are insurance against a future lowering or a batched rewrite rather than a behaviour change today - The
‖z‖floor in the hyperboloid MLR silently zeroed the entire∂‖z‖branch of its gradient on GPU, for one output channel at a time, in roughly two of every three process launches._compute_mlrfloored the hyperplane-normal norm withjnp.linalg.norm(z, ...).clip(min=min_enorm), i.e.jnp.maximum(n, eps). That op's JVP is jax's tie-breaking_balanced_eq,g · [n == ans] / (1 + [eps == ans])— it tests the operandnfor bit equality with the resultans, which is sound only while the two are literally the same value in the compiled graph. XLA:GPU emitsn = sqrt(sum(z*z))twice in the compiled backward — once as its own small fusion, once recomputed inside the fusion that evaluates the∂‖z‖branch — and its per-process fusion autotuner picks the emitter for the first one by measured runtime,NATIVE_EMITTERorBLOCK_LEVEL_EMITTER(Triton). The two emitters disagree in the last bit ofnfor some rows; when they do,[n == ans]isfalsefor that row, the derivative factor becomes0, and the gradient returned for that output channel is exactly the one you would get by treating‖z‖as a constant. Measured on an A100 (jax 0.9.1,linear_plfclayer-contract inputs, float32 vs a float64 reference): jitted gradient relative error 1.0e-2 → 1.5e-7, and in a failing launch the affected row matched the‖z‖-frozen gradient to 2.5e-8 while every other row was correct to 1.5e-7 — the branch was dropped, not perturbed. The reduced repro failed in 5 of 8 launches before and passed 7 of 7 after;test_gradient_contract[linear_plfc-f32]failed in 3 of 4 pytest launches before and passed 3 of 3 after. This was not conditioning: perturbing‖z‖by one float32 ulp in float64 — coherently, or independently at each of its three occurrences in the formula — moves the true gradient by at most 2.4e-7, five orders of magnitude short of the observed error. The floor is nowjnp.where(n > min_enorm, n, min_enorm), which comparesnagainst the constant (0.027 vs 1e-15 at these inputs) instead of against a differently-rounded copy of itself, so no 1-ulp disagreement can flip it. Forward values and the CPU gradient are bit-identical before and after in both dtypes, eager and jitted; only a NaNzbehaves differently (maximumpropagates the NaN,wherefloors it), which is already outside the function's contract. Flooring the squared sum instead (sqrt(maximum(Σz², eps²))) does not help — it keeps the samemaximumtie-break and still failed 4 of 6 launches. The three XLA flags that hid the symptom (--xla_gpu_enable_cublaslt=false,--xla_gpu_autotune_level=0,--xla_gpu_enable_triton_gemm=false) each did so only by removing the emitter choice, not by fixing anything. The same hazard applies to everyjnp.maximum(f(x), floor)on a differentiated path — the library has ~30 suchMIN_NORMfloors — but only this one has been observed to fire; a pure-JAX repro and a draft upstream report are inlogs/2026-09-03_plfc_jit_grad/upstream/ - The same GPU gradient-zeroing hazard is now closed at every other constant floor and clamp in the library — 76 sites. The mechanism is the one in the entry above:
jnp.maximum(f(x), CONST)'s JVP is jax's_balanced_eq, which tests the operand for bit equality with the result, and XLA:GPU may compute the operand twice with emitters chosen per process by its fusion autotuner. When the two copies disagree by 1 ulp the whole gradient branch through the operand is silently zeroed. Only the MLR site had been observed to fire, but every constant floor on a differentiated path is exposed, so all of them are rewritten as a comparison against the constant, through three new one-line helpers inhyperbolix.utils.math_utils:floor_at(x, lo) = where(x < lo, lo, x),cap_at(x, hi) = where(x > hi, hi, x), andclamp_to(x, lo, hi) = cap_at(floor_at(x, lo), hi). The comparison direction is chosen so a NaN operand still propagates exactly asmaximum/minimum/clippropagated it (NaN < lois false, so the NaN is selected), which makes the forward value identical for every input — finite, NaN, and ±inf — at all 76 sites, in both dtypes, eager and jitted. Converted: the whole ofmanifolds/(hyperboloid 23, poincaré 6, gyrovector core 8, stereographic 4, proper velocity 2, product 1, isometry mappings 3),distributions/(2),decomposition/(9),utils/(8), andnn_layers/(10). Deliberately not converted (9 sites): thesmooth_clampfamily, where the 0.5/0.5 tie split is the analytic derivative;safe_hypot's scale, which is understop_gradient; the two genuine elementwisemin/maxinget_delta's Gromov-product scan; and the two floors on non-differentiated paths (uniform-Poincaré direction sampling, Busemann weight-norm init). Two behavioural differences, both improvements, both from the fact that awhere's VJP is aselectrather than a multiply by a 0/1 factor: (1)_compute_mlr's NaN behaviour reverts — thewherelanded in the previous entry used the>direction, which floored a NaNz; it now usesfloor_at, i.e.<, restoring the NaN propagation the original.clip(min=…)had. (2) A saturatedsinh/cosh/tanhargument no longer leaks0 * inf = NaNinto a squared downstream gradient:grad((sinh∘clip)(x)²)past the overflow clamp was NaN in both dtypes and is now exactly 0. That is whattest_smooth_clamp_vs_clip.py::test_saturated_tail_gradient_is_degenerate_for_both_clampspins as a negative property, and its own docstring says to re-baseline it if it ever improves — it now needs that re-baseline (two assertions, both dtypes). Bit-identity was verified on CPU against the parent commit over 13 144 forward and gradient blob comparisons on 3 286 cases — every public method ofPoincare,Hyperboloid,Euclidean,ProperVelocity,StereographicandProductManifold, both MLR helpers, the isometry maps, thehyperboloid_core/busemann_corefunctional cores andHypRegressionPoincare, over near-origin, ordinary and near-boundary/large-radius inputs plus exact-zero, exact-MIN_NORM, exact-±1, NaN and±infrows - Both hyperbolic MLR heads returned an all-NaN gradient — for the whole kernel, not just the affected class — as soon as one hyperplane normal was exactly zero.
manifolds/hyperboloid._compute_mlrandnn_layers/poincare_regression.HypRegressionPoincare._compute_mlrdivide by the Euclidean norm of the per-class normal and floor that norm. The floor keeps the forward value finite, butjnp.linalg.norm's VJP at the zero vector isz/‖z‖ = 0/0 = NaN, created inside the norm's own VJP — where the floor's zero cotangent meets it as0 * NaN = NaN, so the NaN spreads to every row of the kernel gradient. An exactly-zero normal is an ordinary input (a dead or pruned output channel, or a zero-initialised head), and it was silently fatal: measured NaN in all 8 combinations of {hyperboloid MLR, Poincaré regression} × {float32, float64} × {eager, jitted}. Both now use the library'ssafe_norm, whose double-wheregives an exact0value and an exactly-zero VJP at the zero vector; thefloor_atguard stays in front of the division. After the fix all 8 are finite, the Poincaré head's dead row gets an exactly-zero gradient, and the hyperboloid head's dead row is inert at themin_enormscale (max |g| 1.8e-15 float32 / 3.0e-15 float64 against ~10 for the live rows — the residual is the genuined⟨x_s, z⟩path, not the norm). This is the one change in this release that is not bit-identical for ordinary inputs:safe_normis max-scaled (it divides bymax|v|before squaring, which is what makes it overflow-free past‖z‖ = 1.8e19in float32), so the norm itself moves. Measured against a float64 reference over 20 000 vectors per cell, dims 2/8/64 and scales 1e-8/1/1e3: the norm moves by at most 2–4 ulp, andsafe_norm's own error is at most ~1 ulp worse thanlinalg.norm's on in-range inputs (float32 max 3.2 vs 2.5 ulp, mean 0.48 vs 0.42). Downstream thealpha = -x₀·sinh(√c·r)·‖z‖ + cosh(√c·r)·⟨x_s, z⟩cancellation amplifies that, so the MLR forward and gradient move by up to 3.6e-7 relative to each array's own scale in float32 (≈3 ulp of scale) and 6.1e-16 in float64. Accuracy is unchanged: float32-vs-float64 relative error of the forward and ofgrad(Σ res²)is the same before and after to within noise acrossc ∈ {0.3, 1}× spatial scale ∈ {1e-8, 0.5, 8} (forward 1.5e-7…2.5e-7 both; the pre-existing 1.1e-1 float32 blow-up atc = 1, radius 8 is present in both and is a separate large-radius limitation). A bit-identical alternative exists — wrappingjnp.linalg.normin the same double-whereby hand — and was not taken, becausesafe_normis the library's own primitive for exactly this and additionally removes thesum(z²)overflow at large radius - Pairwise hyperboloid
dist/sqdist/logmaplosteps·x₀in the radial term of their polar decomposition, anO(eps/r)relative error near the origin; the gap is now built from the spatial radii._polar_frameneedsP = sinh((a−b)/2) = ½·(u_x − u_y)/(√u_x·√u_y)withu = x₀ + ‖x_s‖. Formingu_x − u_ydirectly subtracts two numbers of sizex₀ ≈ 1/√cto obtain a difference of size‖x_s‖ − ‖y_s‖, andx₀is only stored toeps·x₀, so near the origin the difference is mostly rounding. It is now evaluated through the on-sheet identityx₀ − y₀ = (r_x² − r_y²)/(x₀ + y₀), i.e.u_x − u_y = (r_x − r_y)·(1 + (r_x + r_y)/(x₀ + y₀))withr = ‖x_s‖: only the spatial radii enter the subtraction (exact by Sterbenz when they are close) and the bracket is a ratio of sums of positive numbers running from 1 at the origin to 2 at large radius, so it can neither cancel nor overflow.u_x,u_ystill supply the√u_x·√u_ydenominator and theisfiniteguard that returns±infpast the representable radius, so behavior there is unchanged. Relative error against a 250-digit Decimal reference evaluated on the dtype-rounded spatial parts, worst over c ∈ {0.3, 1, 2.5} and dim ∈ {8, 32}, median (max), before → after (logs/2026-09-03_polar_frame_gap/probe_polar_gap_accuracy.py, CPU backend, jax 0.9.1; the A100 agrees in every cell to within float32 rounding noise — its worst new-column value on the origin grid is 2.7e-7 against 3.1e-7 on CPU) — float32dist(origin, x): 1.0 (1.0) → 1.8e-7 (2.8e-7) at spatial radius 1e-8, 4.6e-2 → 1.9e-8 (1.3e-7) at 1e-6, 1.4e-4 → 9.5e-8 (2.4e-7) at 1e-4, 3.1e-5 → 2.4e-7 (2.6e-7) at 1e-3, 9.7e-6 → 1.7e-7 (2.6e-7) at 1e-2, 9.7e-7 → 1.5e-7 at 0.1; float32dist(x, y)for two points at geodesic radius 1e-3 separated by 1e-3: 3.0e-5 → 1.7e-7, at radius 0.1 separated by 1e-3: 2.0e-5 → 1.5e-6; float64 at radius 1e-3 separated by 1e-5: 1.3e-12 → 3.2e-15. No cell at large radius regresses: over the whole (geodesic radius 1 … 40) x (separation 1e-4·r … 10·r) grid every cell that gets worse does so within ulp noise — worst new/old median ratio 1.6 on a CPU float64 cell whose median relative error is 2.7e-15, 3.0 on a GPU float64 cell that moves from 1 to 3 ulp (1.1e-16 → 3.3e-16), 1.3 on a float32 cell at 1.1e-7 — plus one float32 cell sitting at 2e-4 where both arms are input-resolution-limited (ratio 1.1 CPU, 0.7 GPU); every cell at radius ≥ 10 (float32) / ≥ 20 (float64) reproduces the old median and max unchanged.dist(x, y) == dist(y, x)stays exact to the bit:r_x + r_yandx₀ + y₀are unchanged under the swap andr_y − r_xis the exact negation ofr_x − r_y. Consumers:dist,sqdist,logmap(itscos φreadsP/Sfrom the same frame), andtangent_normvialogmap. Supersedes the sentence in thedist_0/logmap_0entry above that calls this "a planned separate change" and advisesdist_0overdist(origin, x)— the two now agree to 3.1e-7 in float32 at every radius, thoughdist_0remains marginally tighter because theMIN_NORMfloor on‖y_s‖at the origin leaves a½·MIN_NORM/‖x_s‖relative residual in the pairwise arm (5e-12 at radius 1e-4, invisible in float32) Poincare.dist_0(..., version_idx=2)(VERSION_METRIC_TENSOR) was floored to one constant,acosh(1 + 10·eps)/√c≈ 1.5e-3/√c, for every float32 radius below ~7.7e-4/√c, and to exactly zero for every float64 radius below 2.2e-8/√c; it now uses the algebraically identicalarcsinhhalf-angle form. The arm evaluatedacosh(1 + 2c‖x‖²/(1 − c‖x‖²))/√c, the same defect class as the hyperboloid's oldacosh(√c·x₀)route: the entire radial signal sits in a perturbation of a leading 1, somath_utils.acosh's1 + 10·epsdomain clamp flattened everything belowsqrt(5·eps/c)onto that constant, and an extraarg < 1 + MIN_NORMshort-circuit zeroed a second band belowsqrt(MIN_NORM/2c)(in float64 only: in float321 + MIN_NORMrounds to 1). The identityacosh(1 + 2t) = 2·arcsinh(√t)moves the radius into an argument linear inr: witht = c‖x‖²/(1 − c‖x‖²)the arm is2·arcsinh(√c‖x‖/sqrt(1 − c‖x‖²))/√c, which needs no domain clamp at all. Median relative error vs a 60-digitdecimalreference, dim 8, before → after (CPU jax 0.9.1; the A100 agrees), float32:r=1e-87.7e4 → 1.4e-8,1e-67.7e2 → 1.4e-8,1e-46.7 → 2.9e-8,1e-36.6e-3 → 5.3e-8,1e-23.3e-5 → 8.6e-8,0.14.9e-7 → 3.4e-8,0.9/√c6.5e-8 → 3.5e-8 (all at c = 1; c = 0.3 and 2.5 differ only in the floored magnitude, up to 1.4e5 atr=1e-8); float64:1e-81.0 → 1.7e-16,1e-61.1e-5 → 0,1e-42.5e-9 → 1.4e-16,1e-32.8e-12 → 0,1e-21.4e-13 → 0,0.12.2e-15 → 0. Thejax.gradmagnitude in the floored band was exactly 0 instead of the analytic 2 (float32r ≤ 1e-6at every curvature,r ≤ 1e-3at c = 0.3; float64r ≤ 1e-8), so a parameter optimised through slot 2 near the origin received no gradient at all. Not a new version slot: slot 2 is the metric-tensor distance and it is the same function, now computed accurately. The boundary guard is untouched —1 − c‖x‖²still comes from the clamped conformal factor, so the representable ceiling stays 12.1/√c (float32) / 27.8/√c (float64) — andsafe_normsupplies the exactly-zero value and VJP at the origin, sod₀(0) = 0andjax.gradthere are both unchanged (logs/2026-09-03_poincare_origin_numerics/probe_item1_metric_tensor_dist_0.py). Slots 0 and 1 were never affected- The pairwise
Poincare.dist(..., version_idx=2)(VERSION_METRIC_TENSOR) had the same floor as itsdist_0twin: two points closer than ~1.2e-3/√c in float32 came back at exactly 0 distance with an exactly-zero gradient. The arm evaluatedacosh(1 + 2t)/√cwitht = c‖x - y‖²/((1 - c‖x‖²)(1 - c‖y‖²)), somath_utils.acosh's1 + 10·epsdomain clamp flattened every pair witht < 5·epsonto zero and anarg < 1 + MIN_NORMshort-circuit zeroed a second band belowt = MIN_NORM/2. The two(1 - c·r²)factors scale the threshold with the pair's radius: at c = 1 the float32 separation floor is 1.2e-3 at the origin and 9.2e-4 at radius 0.5. It is now the identical half-angle form2·arcsinh(√t)/√c,√t = √c‖x - y‖/sqrt((1 - c‖x‖²)(1 - c‖y‖²)), whose argument is linear in the separation. Median relative error vs a 60-digitdecimalreference routed through Möbius addition (independent of the formula under test), dim 8, c = 1, before → after — float32 at radius 1e-2: separation1e-87.7e4 → 3.0e-8,1e-67.7e2 → 2.6e-8,1e-46.7 → 2.3e-8,1e-26.7e-5 → 1.0e-7; at radius 0.5:1e-83.5e4 → 3.6e-8,1e-65.8e2 → 3.3e-8,1e-44.8 → 4.5e-8,1e-22.6e-6 → 6.1e-8. float64 at radius 1e-2:1e-81.0 → 1.7e-16,1e-65.4e-8 → 2.1e-16,1e-42.5e-9 → 6.8e-17,1e-21.9e-13 → 0; at radius 0.5:1e-81.0 → 1.2e-16,1e-66.3e-6 → 0,1e-43.6e-10 → 0. At c = 0.3 and 2.5 only the floored magnitude differs (up to 1.4e5). 23 of 60 probed gradient cells returned an exactly-zero gradient and now return the analytic λ(y) = 2/(1 - c‖y‖²) — a loss pulling two nearby points apart through slot 2 received no gradient at all.safe_normonx - ykeepsdist(x, x)exactly 0 with a finite (zero) gradient, which is what the removedwhere-guard used to provide (test_precision.py::test_poincare_dist_grad_at_coincident_points). Both boundary guards are unchanged — the two1 - c‖·‖²factors still come from the clamped conformal factors — and this is not a new version slot: slot 2 is the metric-tensor distance and it is the same function, now computed accurately (logs/2026-09-03_poincare_origin_numerics/probe_item5_metric_tensor_dist_pairwise.py). Slots 0 and 1 were never affected Hyperboloid.logmap_0returned an all-NaN vector for a point with an infinite spatial entry, wiping out the time slot too; it now returns±infon the infinite entries.safe_normdeliberately passes aninfthrough asinfso an out-of-range point stays visibly degenerate, which madeu = √c·‖y_s‖ = infand the scalearcsinh(u)/uaninf/infNaN that then multiplied every spatial entry. The pairwisedist/_polar_frameconvention for an out-of-range input is±inf, not NaN, andlogmap_0now matches it:scale = where(isfinite(u), arcsinh(u)/u, 1), so an infinite entry comes back as±infwith its sign, the finite entries keep their own values, and the time slot stays exactly 0 — the right limit, since the tangent vector toward an infinitely far point has infinite norm and its direction is the unit vector along the infinite coordinate. NaN in still gives NaN out, but only in the NaN entry rather than across the whole vector. The guard is awhereon the scalaru, so the finite path is unchanged. Over 2000 log-spaced spatial magnitudes 1e-20…1e10 in both dtypes the forward value is bit-identical on both backends (0 of 18000 bit patterns), and the gradient is bit-identical on XLA:CPU; on XLA:GPU the gradient moves by at most 2 ulps on 614 (float32) / 626 (float64) of 18000 entries, because the extrawherechanges how XLA:GPU fuses the VJP. That is below the 4-ulp spread the unchanged code already shows between the two backends (4294 of 18000 float32 gradient entries differ CPU-vs-GPU before the change), and each backend is deterministic run to run (logs/2026-09-03_poincare_origin_numerics/probe_item2_logmap_0_inf.py)- Every additive-epsilon norm in the library is gone:
sqrt(sum(x**2) + MIN_NORM**2)overflowed float32 above coordinate 1.8e19 and floored every genuinely small vector at 1e-15. The idiom was a gradient guard — it givessqrta finite derivative atx = 0, whichjnp.linalg.normdoes not (its VJP there is0/0 = NaN) — and it paid for that at both ends of the exponent range. Overflow:Hyperboloid.projat float32 spatial radius 5e19 returnedx0 = inf, and already at 1e19 its Minkowski residual-x0² + ‖x_s‖²evaluated to exactly0instead of-1/c;expmap_0inherited both through its trailing_proj. The Poincaré ball's boundary clamp failed the same way but louder: with‖x‖ = infthe clampx·(max_norm/‖x‖)is the zero vector, so a float32 point at radius 1e20 was projected onto the origin rather than onto the boundary (measured‖proj(x)‖ = 0.0; it is now 0.99999).pv_to_poincareandpv_to_hyperboloidhad the same ceiling ondot(x, x). Underflow: the+MIN_NORM² = 1e-30floor dominates any genuinely small vector, relative residualMIN_NORM²/(2r²)—Poincare.dist_0of a float32 point at radius 1e-15 returned 2.83e-15 for a true 2.00e-15 (41 % high, and every smaller radius collapsed onto that same value), and a float64 point at radius 1e-8 was 5.0e-15 high. 59 sites acrossmanifolds/,nn_layers/anddistributions/now usesafe_norm/safe_hypot/ the newsafe_sqrt— 47 here and 12 more on the hot path, split into their own commit so the kernel cost can be reverted independently — and no occurrence of the old idiom is left in the package. 36 floors that bound a value rather than a derivative (Minkowski forms, conformal factors, explicit divisor guards, BatchNorm and Adam epsilons) are deliberate and unchanged, each with its reason inlogs/2026-09-03_safe_norm_sweep/inventory.md. One consequence had to be undone: the old idiom'ssqrt(jnp.sum(x**2) + eps)reduces every axis, so on the(B, dim)arrays several call sites hand these single-point ops it produced a scalar that broadcast (against the whole batch, i.e. a Frobenius norm — silently not a per-row one), whilesafe_normreduces only the last axis and the(B,)result no longer broadcasts at all; 14 norms that scale a(..., dim)operand get the trailing axis back as[..., None](_gyrovector_core._proj,Poincare._expmap/_expmap_0, sixStereographicmaps plus_geodesic_unit/_antipode, andProperVelocity._scalar_mul/_expmap_0/_logmap_0/_logmap), andPoincare._scalar_mul/_logmap_0takeaxis=-1, keepdims=Trueon their whole-arrayjnp.sumfor the same reason. Bit-identical on the single-point contract (8100 evaluations across 5 manifolds × 15 ops × 2 dtypes × dims 2/5/12 × 3 curvatures × 6 seeds — 0 value and 0 shape differences) and free (A100 kernel/reduction counts unchanged on all five probed ops); on a batched input every one of them is now exactly the per-row result, whichtests/test_class_based_manifolds.py::test_implicitly_batched_call_equals_the_per_row_callpins. A second consequence is now gone too, and it cost accuracy rather than shapes: the rescaling divided bymax|v|itself, which is an inexact division, so the result carried 1–2 ulp that the oldsqrt(sum(v**2) + eps)did not — visible wherever a caller recomputes the same sum of squares, as the hyperboloid does (x₀ = sqrt(‖x_s‖² + 1/c)checked against-x₀² + ‖x_s‖² = -1/c, where atx₀ ≈ 34in float32 one ulp ofx₀²is 1.2e-4, larger than the 1e-4 tolerance the HRC norm layers are checked at). The divisor is now the exact power of two just belowmax|v|(jnp.frexp/jnp.ldexp), which shifts the exponent and nothing else, so it contributes no rounding of its own: over magnitudes 1e-15…1e15 (float32) and 1e-30…1e30 (float64), dims 2/4/16/64,safe_normmatches a jittedsqrt(sum(v**2))on all but 1 of 480 000 values, against 67 239 of 160 000 for the divide-by-max form. Bit-identity is not unconditional and is not claimed to be: which association XLA gives a last-axis reduction depends on the surrounding fusion, and at dim 8 the two programs happen to differ by 1–2 ulp (mean 0.13–0.17) where at dims 2/4/16/64 they agree exactly — the divide-by-max form is 1–3 ulp with mean 0.34–0.62 at every dim. The overflow-free property is untouched (a float32 vector at radius 1e20 still returns 2.83e20, notinf). The other half of the accuracy loss was the shape of the two-leg reconstruction:safe_hypot(safe_norm(v), q)rounds‖v‖and squares it again, which is up to one ulp ofsum(v**2)and cannot cancel. A newhyperbolix.utils.safe_hypot_norm(v, q)computessqrt(‖v‖² + q²)in one reduction, reproducing the association of thesqrt(sum(v**2) + q**2)it replaces, and the nine sites that reconstruct a hyperboloid time slot or an epsilon-floored norm use it (Hyperboloid._proj/_proj_batch,isometry_mappings.pv_to_hyperboloid,hyperboloid_core.spatial_to_hyperboloid/build_spacelike_V, bothhyperboloid_linearreconstructions, bothhyperboloid_attentionnorms). The Minkowski residual ofHRCBatchNorm/HRCRMSNormatc_in = 10 -> c_out = 0.1goes 6.1e-5/3.1e-5 (pre-sweep) -> 1.5e-4/1.2e-4 (sweep, both over the 1e-4 tolerance) -> 6.1e-5/6.1e-5. All 11 probed A100 ops are unchanged in kernels and reductions, so both halves are free. The threesqrt(1 + c‖x‖²)sites —ProperVelocity._beta_inv, its_compute_mlrtwin andisometry_mappings.pv_to_poincare— are converted too, assafe_hypot_norm(√c·x, 1). Measured against an 80-bitlongdoublereference overc ∈ {0.3, 1, 2.5}, dims 2/8/16, both dtypes and radii 1e-3…1e3, that is the most accurate of the three overflow-free spellings: mean 0.25 ulp / max 2 and exact on 75.0 % of values, against 0.32 / max 3 / 69.5 % for the two-legsafe_hypot(1, √c·safe_norm(x))it replaces and 0.30 / max 3 / 70.8 % for the variant that scales the scalar leg (√c·safe_hypot_norm(x, 1/√c), exact atc = 1but 0.45 ulp atc = 2.5in float64, where1/√cis itself inexact). Scaling the components cannot overflow where the result does not, since1/β_x ≥ √c·‖x‖ ≥ √c·max|xᵢ|: at float32 radius 1e20,_beta_invis 1.55e20/2.83e20/4.47e20 at those three curvatures andpv_to_poincarelands the point exactly on the ball boundary1/√c, with a finite (zero) gradient at the origin - Four norms had no guard at all and returned a NaN gradient at the zero vector:
Euclidean.dist,Euclidean.dist_0,Euclidean.tangent_normandProperVelocity.tangent_norm, plus all threeProductManifoldmethods that call them. The first three were barejnp.linalg.norm, whose VJP at the zero vector is0/0 = NaN;ProperVelocity.tangent_normandProductManifold.tangent_normweresqrt(floor_at(g_x(v,v), 0.0)), wheresqrt'(0) = infmeets a zero cotangent as0·inf = NaN. Measured on the parent (logs/2026-09-03_safe_norm_sweep/parent_gate/gate.py):grad(Euclidean.dist_0)(0),grad(Euclidean.dist)(x, x),grad(ProperVelocity.tangent_norm)(0)andProductManifold.dist_0/dist/tangent_normat the product origin all returned all-NaN (the product cases NaN only in the Euclidean factor's slots, poisoning the sum). All six now return exactly zero — the finite, direction-free choice where the derivative does not exist. Reachable from any model with a Euclidean factor in a product manifold, or any Riemannian-norm regulariser evaluated at a dead unit -
A new
hyperbolix.utils.math_utils.safe_sqrt, the scalar counterpart ofsafe_norm:sqrt(x)with the same double-where, so the derivative atx == 0is exactly0rather thaninf. For the quantities that arrive already squared — Minkowski and Riemannian formsg_x(v, v), sums of per-factor squared distances — whichsafe_normcannot take (its input is the vector, and a Minkowski form is not a Euclidean norm). Exported fromhyperbolix.utils -
Hyperboloid.projreturned an infinite time coordinate for any float32 point past spatial radius 1.8e19, and a Minkowski residual of exactly0instead of-1/cjust below it.x₀ = sqrt(floor_at(1/c + dot(x_s, x_s), MIN_NORM))forms the sum of squares, which overflows float32 as soon as a spatial coordinate passes 1.8e19 — while‖x_s‖itself, and thereforex₀, is a perfectly ordinary float. Measured on the parent atc = 1(logs/2026-09-03_safe_norm_sweep/parent_gate/gate.py): radius 5e19 and 1e20 givex₀ = inf; radius 1e19 gives a finitex₀ = 1e19whose constraint-x₀² + ‖x_s‖²evaluates to0.0rather than-1.0, becausesqrtof the (still finite) sum has lost the1/centirely.expmap_0inherited both through its trailing_proj— a tangent vector of length 1e19 came back as[inf, 7.0e37, 0, 0]. It is now the two-legsafe_hypot(1/√c, safe_norm(x_s)), which never materialises‖x_s‖²: the constraint holds to 1e-6 relative (checked in float64 against the float32 output) at every radius from 1e19 to 1e20, inproj,proj_batchandexpmap_0. Dropping theMIN_NORMfloor is a no-op on the finite domain —1/c + ‖x_s‖² ≥ 1/c > 1e-15for every curvature below 1e15 — and lets a non-finite input pass through asinf, the conventionsafe_normand the pairwisedistalready follow.nn_layerscarried three copies of the samesqrt(‖z‖² + 1/c)reconstruction (_fhcnn_forward,_fgg_linear_forward,hyperboloid_core.spatial_to_hyperboloid) andisometry_mappings.pv_to_hyperboloida fourth; all four are converted - The Poincaré ball's boundary clamp projected the farthest representable point onto the origin.
_gyrovector_core._projcomputeswhere(‖x‖ > max_norm, x·(max_norm/‖x‖), x)with the same overflowingsqrt(sum(x**2) + MIN_NORM**2). Past float32 coordinate 1.8e19 that norm isinf, so the scale factor ismax_norm/inf = 0and the clamp returns the zero vector — the point farthest from where it belongs. Measured on the parent:‖proj(x)‖ = 0.0at radius 1e20 (it is 0.99999, i.e.max_norm, at 1e19, where the norm has not yet overflowed). It is nowfloor_at(safe_norm(x), MIN_NORM): the floor stays, becausenormdivides in the untaken branch of thewhereas well and a zero cotangent against that branch'sinfis NaN._proj_batchhad the same defect and the same fix ProperVelocity._betacollapsed to 0 for any point past‖x‖ = 1.8e19/√c.1/sqrt(1 + c·dot(x, x))overflows the same way, and_betais the coefficient every PV gyro-operation is built from —_addition,_expmap,_logmap,_dpi_x,_tangent_inner— so one overflowing coordinate silently zeroed all of them.‖x‖ = 1.8e19is geodesic radiusarcsinh(1.8e19) ≈ 45, well inside the range PV exists to serve: it is the unconstrained model, chosen precisely because it stays stable where the ball saturates._beta_invis nowsafe_hypot(1, √c·safe_norm(x))and_betaits reciprocal;isometry_mappings.pv_to_poincarehad the same expression and the same fix (there the overflow mapped a far-out PV point to the ball origin)- The FHNN linear/conv forward returned an all-
infspatial row for any float32 time coordinate pasty0 = 1.844e19._fhnn_forwardrecovered the target spatial norm from the hyperboloid constraint assqrt(y0**2 - 1/c), andy0**2overflows float32 atsqrt(FLT_MAX) = 1.844e19— a regimecapped_expdeliberately allowsy0to reach, since it caps a runawayscaleatexp(0.99·log(FLT_MAX)) ≈ 6.1e37precisely so the value stays finite. Measured on the parent (logs/2026-09-04_flags_batch/probe_diff_of_squares.py, c = 1):y0 = 1e20gives[1.0e20, inf, -inf, inf]andd‖y_s‖/dy0 = 0instead of 1. It is now the factored difference of squaressqrt(y0 - 1/√c) · sqrt(y0 + 1/√c), whose two factors are each strictly positive becausey0 > 1/√c + epsholds by construction (additive floor, not amax): finite throughy0 = 3e38, with‖y_s‖/y0 → 1to 1e-6 relative and finite gradients. This is the difference-of-squares counterpart of thesafe_hypotsum-of-squares conversion above, and it was the one remaining site of its kind in the library. Values are not bit-identical in float32. Over a margin-stratified grid (y0 - 1/√cfrom 1e-2 to 1e19,cin {0.25, 0.5, 1, 2, 5},logs/2026-09-04_flags_batch/probe_ordinary_range.py) the two forms differ by at most 3.1e-6 relative, at the smallest margins; above margin 1 it is 1-2 ulps. Where they disagree materially the factored form is the more accurate of the two against a float64 reference (worst case 1.3e-6 vs the old form's 2.9e-6 at margin ≤ 1); in the large-margin bands the old form is exact and the new one carries 1 ulp
Changed¶
-
The hot-path half of the norm conversion (
proj,proj_batch,expmap_0,logmap_0on every manifold, plus the Proper-Velocity_beta/_beta_inv/_safe_normhelpers) is a separate commit, and it costs one XLA kernel. Compile-only counts forjax.jit(jax.vmap(op))at batch 1e7, dim 32, float32 on an A100 (jax 0.9.1,logs/2026-09-03_safe_norm_sweep/probe_xla_kernels.py, kernels/reductions, before -> after): Poincaréexpmap_03/1 -> 5/2 andproj3/1 -> 5/2; hyperboloidproj1/1 -> 2/2,expmap_02/2 -> 3/3, andaddition7/8 -> 9/9 (it callsproj). Unchanged: Poincarédist2/4,logmap_03/1,mobius_add3/5,ptransp3/5, and hyperboloidlogmap_03/2,dist6/6. The extra reduction is themax|x|that max-scaling needs, and it is unavoidable here: these are exactly the sites whose input is by definition unprojected, so the overflow they fix is reachable and the cheapsafe_sqrtspelling used elsewhere would not fix it. Reverting this commit alone restores the old kernel counts and leaves the other 47 conversions in place. -
The additive-epsilon norm replacement moves float32 values by 1-3 ulps and is free on GPU. Which primitive replaces which site is a cost decision:
safe_norm's max-scaling costs a second reduction over the input, so it is used only where the input magnitude is genuinely unbounded (tangent vectors, unprojected points, hyperboloid/PV coordinates, layer weights). Where the argument is a ball point —Poincare.dist,dist_0,logmap,scalar_mul, the Apollonian metric —sum(x**2) <= 4/cand overflow is unreachable, so those usesafe_sqrt(sum(x**2)), the same double-whereon the scalar. Compile-only kernel counts forjax.jit(jax.vmap(op))at batch 1e7, dim 32, float32 on an A100 (jax 0.9.1,logs/2026-09-03_safe_norm_sweep/probe_xla_kernels.py): every one of the 11 probed ops is unchanged in both kernels and reductions — Poincarédist2/4,expmap_03/1,logmap_03/1,mobius_add3/5,ptransp3/5,proj3/1; hyperboloidproj1/1,expmap_02/2,logmap_03/2,dist6/6,addition7/8. (SpellingPoincare.dist's numeratorsafe_norminstead would have cost it 2 -> 4 kernels and 4 -> 5 reductions for an overflow that cannot happen there; that measurement is in the same log directory.) One subtlety the conversion has to respect: where a floored norm feeds asinh(t)/t, the floor belongs ontitself and not only on the denominator, or the ratio is 0 instead of 1 att = 0 - The pairwise
distgap term readsx₀only through a well-conditioned sum, so the spatial part is now the source of truth for the radial split too. For an input that is off the sheet,dist/sqdist/logmapnow report the gap implied by its spatial radii — the same conventionproj(which rebuildsx₀fromx_s),dist_0andlogmap_0already follow — rather than one read off anx₀inconsistent with them. On-sheet inputs are unaffected beyond the accuracy change above. A rawjax.grad(dist)correspondingly moves its radial support from the time slot to the spatial slot; the two gradients differ by a multiple of the constraint normal, so afteregrad2rgrad/tangent_projthe Riemannian gradient is unchanged and the Riemannian optimizers are unaffected. Measured over 75 (curvature x radius x radius) cells, CPU and A100 alike (logs/2026-09-03_polar_frame_gap/probe_polar_gap_gradient.py): worst old-vs-new relative disagreement 3.6e-14 (float64) and 4.3e-7 median / 3.7e-5 worst (float32); in the three float32 cells above 1e-5 the old arm is the one that moved — against the same pair promoted to float64 the new gradient is within 1.1e-6 while the old carries the full 3.7e-5 - Breaking:
dist_0(..., version_idx=2)andversion_idx=3now return the pre-fixacosharms. Those two slots used to duplicate slots 0 and 1 for the origin distance; they now selectVERSION_LEGACY/VERSION_LEGACY_SMOOTHENED, mirroring what they have meant for the pairwisedistsince 1.1.2, and exist only to reproduce results computed before this fix. Code that passed 2 or 3 todist_0and expected default behavior must passVERSION_DEFAULT(0) orVERSION_SMOOTHENED(1) dist_0andlogmap_0read the radius offx_sand ignorex₀. An off-sheet input therefore gets the radius of itsprojprojection, which is the conventionprojitself follows (it rebuildsx₀fromx_s) and whatProperVelocity.dist_0already did. A rawjax.grad(dist_0)consequently has its support onx_sinstead of onx₀; the two gradients differ by a multiple of the constraint normal, so afteregrad2rgrad/tangent_projthe Riemannian gradient is identical and the Riemannian optimizers are unaffectedPoincare.expmap_0clamps the boundary on the scalar instead of re-projecting its output. It now computest = min(tanh(√c·‖v‖), √c·max_norm)andres = t/(√c·‖v‖) · v, so‖res‖ ≤ max_normholds by construction and the trailingproj(a second norm reduction over the op's own output) is gone. Underjax.jit(jax.vmap(...))at batch 1e7, dim 32 the op compiles to 3 kernels with 1 reduction instead of 5 with 2 (logs/2026-09-02_submission-numerics/probe_xla_kernels.py, A100, jax 0.9.1 and 0.11.0). Values move only on rows the projection clamps (‖v‖ ≳ 8/√c in float32): at most 3.4e-7 relative (float32, c ≤ 5) / 6.0e-16 (float64), overshootingmax_normby at most 2.2 eps, 50x inside theeps**0.75margin; Jacobians agree on unclamped rows._gyrovector_core._max_normis the factored bound;projitself is unchanged bit-for-bit.- Möbius addition
x ⊕ ycomputes its own output norm from reductions over the inputs, so the boundary clamp is a scalar comparison instead of a second pass over the result._gyrovector_core._additionused to buildnum = A·x + B·y(A = 1 + 2c⟨x,y⟩ + c‖y‖²,B = 1 − c‖x‖²) and callproj(num/denom, c), which reduces ‖·‖ over the op's own(dim,)output. It now regroups the numerator asnum = B·(x+y) + c‖x+y‖²·x— identical in exact arithmetic, sinceA − B = c‖x+y‖²— and expands‖num‖² = B²·s2 + 2·B·(c·s2)·⟨x,s⟩ + (c·s2)²·‖x‖²withs = x+y,s2 = ‖s‖², in the same two coefficients that builtnum. Five input reductions (‖x‖²,‖y‖²,⟨x,y⟩,s2,⟨x,s⟩) replace three plus one output reduction. Underjax.jit(jax.vmap(...))at batch 1e7, dim 32, float32 the op compiles to 3 kernels / 5 reductions / 5(B, dim)-sized memory passes, from 5 / 4 / 7 — XLA folds all five reductions into a single multi-outputkInputfusion and the unprojected(B, dim)intermediate, which previously had to be written and read back, is gone (logs/2026-09-02_submission-numerics/probe_xla_kernels.py, A100, jax 0.9.1;diststays 2 / 4 andexpmap_03 / 1). H100 timing pending — runlogs/2026-09-02_submission-numerics/probe_gpu_timing.py. The regrouping is what makes the analytic norm safe, and it is not interchangeable with the textbook‖num‖² = A²‖x‖² + 2AB⟨x,y⟩ + B²‖y‖². Takexnear the boundary,ε := 1 − c‖x‖², andy = −x + n:A·xandB·yare each of sizeε‖x‖but their sum isO(ε²), so every norm derived fromAandBis a difference of terms1/ε²larger than its own value, and the floating-point vectorfl(A·x) + fl(B·y)itself differs from the exactA·x + B·yby a relativeeps/ε— which means the clamp can scale a row to sit outside the ball even when the norm formula has no cancellation of its own.B·(x+y)andc‖x+y‖²·xare individually the same order as their sum (cancelling only in the collinear case, and there by at most a factor 2 for ayinside the ball), which is why this grouping keeps norm and vector consistent. Measured on 2.7M adversarial rows per dtype — random pairs,x ⊕ (−x), coincident points, and a near-boundary antipodal grid spanningε ∈ {1e-2 … the eps**0.75 ceiling margin}×‖n‖/(εR) ∈ {0.01 … 10}× three directions ofn, atc ∈ {0.3, 1, 2.5}(logs/2026-09-03_b2_mobius_norm/probe_mobius_norm.py): worst overshoot ofmax_normis 10 ulps and no row exceedsmax_norm·(1 + 16·eps), leaving the result inside the true radius1/√cwith 54x (float32) / 26000x (float64) of theeps**0.75margin to spare. The three-dot form overshoots by up to 3.5e5 ulps and the(A+B)/2,(A−B)/2form — cancellation-free as a formula, but a norm of the exactA·x + B·y— by up to 6.5e9; both put 9% of the antipodal rows more than 1% outside the ball. Zero NaN or inf in values or ingrad(Σ dist)/grad(Σ logmap)on every family. Values are not bit-identical to the previous release. On well-conditioned inputs rows move by at most 5.7e-7 (float32) / 1.5e-15 (float64) of the ball radius, i.e. 2–3 ulps, and the clamp decision differs on ≤ 1.3e-4 of rows. Where the two forms disagree materially the new one is more accurate: against a float64 reference its error is 0.48–0.60x the old form's at everyεin the antipodal grid;x ⊕ (−x)is now exactly zero, where the old form left a residue of up to 1.3e-3 of the ball radius in float32; and at the float64 ceiling margin (ε ≈ 4e-12) the error is ~1e-7 of the radius against the old form's 1.0, i.e. the old numerator there was pure rounding noise. On the near-boundary antipodal grid the clamp decisions differ on 20–70% of rows, which is expected and not a regression: that is the regime in which the old implementation's own decision was made on a numerator with no significant bits left.projandproj_batchare untouched, and every other caller of them is unaffected. - Float32
tanhandatanhinhyperbolix.utils.math_utilsare closer to correctly rounded (exact bit-pattern ulps vs a float64 reference, 20k inputs per range, max ulp before → after).atanhbelow 1/8 uses the odd Maclaurin series through x⁹ (float32 only; float64 keeps the single-log1pform bit-for-bit): GPU 3 → 1, CPU 2 → 1.tanhfor |x| ≥ 1/8 (float32; 1/2 in float64) usest/(t + 2)witht = expm1(2|x|): GPU [0.125, 0.9] 4 → 3 and [0.9, 7] 5 → 2; CPU [0.9, 7] 4 → 1; float64 CPU [0.9, 7] 5 → 1. No range regresses on either backend; both wrappers stay bitwise odd with derivative exactly 1 at 0, seams are continuous to ≤ 2 ulp, and the float32 derivative's error vs1 − tanh²drops from 1.2e-6 to 2.4e-7. Effect on the float32 Poincaré round triplogmap_0(expmap_0(v))(dim 32, c = 1, median relative error): radius 4: 1.69e-5 → 5.4e-6 (GPU) and 5.7e-6 (CPU); radius 1e-3 on CPU 2.4e-7 → 1.2e-7; GPU at radius ≤ 1 unchanged (already at the noise floor). Below 1/8tanhuses neither kernel: it evaluates the odd Maclaurin seriesx − x³/3 + 2x⁵/15 − 17x⁷/315(Horner inx²on|x|, float32 only — float64 keepsjnp.tanhbelow its own 1/2 seam bit-for-bit). On [1e-4, 0.125], 20k log-uniform inputs at both signs, max / mean ulp: GPU 4 / 0.87 → 1 / 0.16, CPU 4 / 0.96 → 1 / 0.16. The series' first dropped term is 62x⁹/2835, i.e. 1.6e-10 absolute at x = 1/8 against a float32 eps of 1.2e-7, so on that range it is exact to rounding; theexpm1form cannot be used there (6 ulp on CPU). Nothing above the seam moves — [0.125, 0.9] and [0.9, 7] are bit-for-bit identical on both backends — and the float32 tanh seam gap shrinks from 0/1/0 ulp (CPU) and 2/1/2 (GPU) to 1/1/1 and 1/0/1. Poincaré round trip at radius 1e-3 (dim 32, c = 1, median relative error) drops a second time on CPU, 1.2e-7 → exactly 0, matching the GPU; radius 0.1: 1.0e-7 → 5.2e-8; radius ≥ 1 unchanged. Poincare.scalar_mulandPoincare.expmaproute theirtanhthroughhyperbolix.utils.math_utils.tanh, the accurate wrapperexpmap_0already used. The two were the last rawjnp.tanhcalls in the module. The wrapper is more accurate in float32 (odd Maclaurin series below |x| = 1/8,expm1form above it, vs XLA's ~4 ulp rational approximation) and its±(1 - 10·eps)output clip pairs withatanh's own domain guard, so anatanh/tanhround trip cannot reach the pole. Values are not bit-identical in float32. Measured over 1152 rows per op (dim 16, radii log-spaced across the whole in-ball range,cin {0.3, 1, 2.5},rin [-2.5, 2.5]), max relative movement:scalar_mul3.2e-7 andexpmap2.6e-7 in float32 (2-3 ulps; ~36% of entries move), and 4.2e-16 / 5.9e-16 in float64 — where movement occurs only above the wrapper's own float64 seam at |x| = 1/2; below it the wrapper falls back to XLA'stanhand every entry is bit-identical (0 of 3072 bit patterns changed) (logs/2026-09-03_poincare_origin_numerics/probe_item3_tanh_wrapper_and_proj_batch.py)_gyrovector_core._proj_batchtakes its boundary bound from the_max_normhelper instead of re-inlining the expression._max_normreads only the array's dtype, so the bound is a scalar either way and the clamp is bit-identical: 0 of 3072 bit patterns move in either dtype over a (64, 16) batch atcin {0.3, 1, 2.5} with rows inside, exactly at, and up to 1e8 past the boundary plus an exact-zero row, and_proj_batch(X, c)still equals row-wise_projbit for bit- Developer tooling: undefined names are checked again.
[tool.pyright]listed"hyperbolix"in bothincludeandexclude, so pyright analysed 0 of 57 modules and always reported "0 errors"; the tree is analysed again undertypeCheckingMode = "off"withreportUndefinedVariable(plus the existing unused/duplicate-import rules) enabled explicitly. Ruff'sF821is now on fortests/and ignored only underhyperbolix/**, where jaxtyping shape strings produce 572 false positives and no true ones. Newtests/test_imports.pyimports every module in the package, one test per module. - Developer tooling: pyright runs in
typeCheckingMode = "basic"and the package is clean — 0 errors, with no rule disabled and no# type: ignoreadded to get there. Basic mode reported 110 errors when it was first switched on (reportOperatorIssue49,reportArgumentType46,reportReturnType5, 10 others). 93 of them were one thing: theCurvatureunionScalarCurvature | Sequence[ScalarCurvature]was the annotation on every manifold'sc, sojnp.sqrt(c),c * xand1/cwere all checked against a sequence that supports none of them. Every single manifold and theManifoldprotocol itself now declarec: ScalarCurvature— 286 annotations across 19 modules — and onlyProductManifoldkeeps the union, which still satisfies the protocol because an implementation's parameter may be wider than the one it implements.ScalarCurvatureis exported fromhyperbolix.manifoldsalongsideCurvature, and no runtime behaviour changes: this is the annotation catching up with what the code always required. Three real defects came out with it: theManifoldprotocol was missing the trailingversion_idxondist/dist_0andatolonis_in_manifold/is_in_tangent_spacethat its own docstring promised (socompute_pairwise_distances, which forwardsversion_idx, did not type-check against it);hyperbolix.utils.__all__listedMATMUL_PRECISION, which moved tohyperbolix.utils.precisionand was never re-imported, sofrom hyperbolix.utils import *raisedAttributeError; andhyp_pad2d(pad_mode="origin")documentscas required but never checked it, failing with an opaqueTypeError: unsupported operand type(s) for /— it now raises aValueErrornaming the argument.scalar_mul'sris widened fromfloattofloat | Float[Array, ""], which is whatGyroBatchNorm/GyroRMSNormalready pass and whatProperVelocity._scalar_mulalready declared. The remaining handful were values whose type@jax.jiterases: jax annotates the decorator as returningjax.stages.Wrapped, whose__call__returnsAny, sosafe_norm(x)and every other jitted helper inhyperbolix.utils.math_utilshanded its callers an untyped value, which pyright then widened intoArray | tuple[Array, ...]at the nextjnp.whereand reported against whatever declared type that union eventually reached. The 13 decorators in that module now go through a one-line_jitwrapper typedCallable[P, R] -> Callable[P, R], so the declared return type survives; it returns exactly the objectjax.jitreturns, so tracing, the compilation cache,__name__,__doc__andstatic_argnamesare all unchanged. - API reference now covers the full
hyperbolix.utilsexport surface andhyperbolix.utils.precision, with several stale version/count claims and numeric docstring constants corrected.
Notes¶
- Four tests and one test oracle asserted properties no GPU backend promises, and now assert what the backend can actually deliver. None of the tolerances that guard a library defect moved. (1) XLA:GPU's float32 divide is only faithfully rounded —
x / x != 1.0for 16.25 % of 200 000 random float32 values, error up to 2 ulp (float64 is exact; CPU is exact in both). That 1-ulp perturbation of a unit direction is amplified by√(r_x·r_y) ≈ e^((a+b)/2)/(2√c)in the pairwise distance's angular term, sotest_hyperboloid_dist_stable_exact_along_radial_geodesicdrops its(29, 30)radius pair from the float32 leg (float64 keeps its own(19, 20)and(55, 60)pairs), andtest_hyperboloid_dist_on_a_shared_ray_is_the_radius_differencecaps its float32 legs ata ≤ 5. This is not a GPU-only limit: float32 cannot resolve collinearity in the ambient chart past radius ≈16 on any backend — with a generic (rather than all-components-equal) direction the same construction fails on CPU from radius 20 — so_hyperboloid_basis's docstring claim of a radius-80 threshold is corrected to the measured ≈16. (2)test_poincare_proj_batch_matches_the_vmapped_single_point_projassertedrtol=0, atol=0between reductions over(8, 10)and(2, 8, 10); XLA:GPU picks its reduce kernel per shape by autotuning, so the two disagreed by 1–2 ulp in 1 of 3 process launches. Now 2 ulp of the dtype. (3)test_activation_applies_euclidean_fn_to_spatialasserted bit equality between a jitted and an eager transcendental; float64tanhdiffers by 1 ulp on one element in ten on GPU. Now 1 ulp — the two value assertions in that test stay strict. (4)_naive_lorentz_midpoint, the baselinetest_lorentz_midpoint_small_norm_matches_naivecompares the library against, carries the sameMATMUL_PRECISIONas the library: with the library fixed and the baseline still on TF32, that comparison measured TF32 rather than the difference between the two algebraic forms - Near-origin float32 accuracy depends on the backend, and the gap is XLA's transcendental kernels, not the formulas. Exact bit-pattern ulp error against a float64 reference (20k inputs in
[1e-4, 0.9], max / mean):tanh4 / 0.85 (XLA GPU), 4 / 0.90 (XLA CPU), 1 / 0.01 (torch CPU), 2 / 0.17 (torch CUDA);atanh3 / 0.45 (XLA GPU), 2 / 0.25 (XLA CPU), 1 / 0.00 (torch CPU), 3 / 0.45 (torch CUDA, bit-identical to XLA GPU);arcsinh2 on all four;expm11 (GPU) / 5 (CPU). Consequence for float32 Poincarélogmap_0(expmap_0(v))at radius 1e-3 (dim 32, median relative error): 2.4e-7 on the CPU backend before thetanh/atanhchange above (1.2e-7 with theexpm1seam, exactly 0 once the below-1/8 series landed), exactly 0 on GPU throughout. A torch-based library reaches ~1.5e-8 on CPU because torch's CPUtanh/atanhare correctly rounded; on CUDA it has no such edge. The closed forms are identical and nothing in hyperbolix is wrong here, but quote the backend alongside any near-origin float32 accuracy number - Poincaré round-trip ceiling.
projholds points inside1/√cby a margin ofeps**0.75(_gyrovector_core._get_max_norm_eps), which caps the largest representable tangent norm at‖v‖ = atanh(1 − eps**0.75)/√c— a geodesic radius of2·atanh(1 − eps**0.75)/√c ≈ 12.65/√c(float32) /27.7/√c(float64) atc = 1. Past itexpmap_0saturates andlogmap_0(expmap_0(v))returns the ceiling instead ofv. Measured ceilings (median returned‖v‖, in units of1/√c; double for the geodesic radius): hyperbolix 6.32 (float32) / 13.86 (float64); geoopt and hypLL both 3.11 / 6.10, from fixed margins of 4e-3 and 1e-5; the unguarded closed form 8.66 / 18.72. The wider margin is deliberate, capping the conformal factor at ~3e5 (float32) / ~1e12 (float64) - The float64 CPU
log1phole that 1.1.1'satanhrewrite worked around is fixed upstream (openxla/xla#46765, shipped in jax ≥ 0.11.1; tracked as jax-ml/jax#39707). The rewrite stays: it costs nothing and still protects jax ≤ 0.11.0, which is what the lockfile pins (0.9.1) - Removed the tautological
tests/test_manifolds.py::test_hyperboloid_scalar_mul_eq2. It assertedt ⊙ x == expmap_0(t · logmap_0(x)), which became a comparison ofHyperboloid.scalar_mulagainst its own implementation once that was rewritten to_expmap_0(r * _logmap_0(x, c), c)— the paper's Eq. 2 verbatim. The property it was meant to pin is covered non-circularly bytest_hyperboloid_scalar_mul_matches_the_closed_form_near_the_origin, which checkst ⊙ xagainst the analytic[cosh(√c·t·d₀)/√c, sinh(√c·t·d₀)/√c · x̂_s]down to spatial radius 1e-8
1.1.2 - 2026-08-25¶
Fixed¶
- Hyperboloid
dist/logmap/sqdist/tangent_normlost all precision for two points that were each far from the origin and close together — now cancellation-free at any representable radius. Every one of these routed through the Minkowski inner product⟨x,y⟩_L = -x₀y₀ + ⟨x_s,y_s⟩, a subtraction of two positive terms each roughlye^(√c·(d₀(x)+d₀(y)))in size; the number of significant digits lost is set by the Gromov-product-like quantity√c·(d₀(x)+d₀(y)-d(x,y)), and pastln(1/eps)— 15.9 (float32) / 36.0 (float64) — every digit of the result is cancellation noise, not signal. Measured before this fix: float32distreturned0.0015for a true distance of1.0between two points at radius 10;logmapreturnedNaNfrom radius ~10 (float32) / ~20 (float64);tangent_normreturned ~0 (a 100% error, no warning) on exactly-unit tangent vectors past radius 8 (float32) / 20 (float64). Deep metric-learning embeddings routinely sit at radius 30–60, so this was not an edge case.dist,sqdist, andlogmapare rewritten to share a_polar_framedecomposition built from the hyperbolic law of cosines in half-angle (haversine) form — a sum of non-negative terms with nothing to cancel;tangent_normeliminatesv₀through the tangency condition, trading one power ofx₀out of the error (now exact to radius ~15 float32 / ~25 float64, up from ~8/~20). Values inside the previously-trusted regime change within the old float32/float64 noise level; values past the threshold change from silent garbage to correct.VERSION_LEGACY(2) andVERSION_LEGACY_SMOOTHENED(3) reproduce the pre-fix acosh-based arms bit-for-bit, for reproducing results computed before this fix —VERSION_DEFAULT(0) andVERSION_SMOOTHENED(1) now point at the stable forms.expmap(two-point),ptransp,tangent_proj,tangent_inner,egrad2rgrad, andis_in_manifoldstill route through the Minkowski inner product and remain unsafe past the same threshold; origin-chart operations (dist_0,logmap_0,expmap_0) read the radius straight off the ambient time coordinate and were never affected. Newhyperbolix.utils.safe_norm/safe_hypot/safe_normalize— overflow- and underflow-free norm primitives the new decomposition depends on — are exported alongside the fix. Supersedes theVERSION_SMOOTHENEDfloor value (≈ 0.166/√c) quoted in thesmooth_clampentry below (1.1.0): that floor belonged to the old acosh-based arm now atVERSION_LEGACY_SMOOTHENED. The newVERSION_SMOOTHENED's floor is2·arcsinh(10·eps)/√c ≈ 2.4e-6/√c(float32) — see the numerical-stability guide for the full version breakdown lorentz_residualandlorentz_midpointlost the Minkowski square to catastrophic cancellation at large spatial radius. Both build a raw ambient vectorhand normalize it back onto the sheet bysqrt(|<h,h>_L|), and both computed<h,h>_L = -h_0^2 + ||h_s||^2naively: for on-sheet inputsh_0 ≈ ||h_s||, so each square is~||s||^2(spatial radius of the inputs) while their difference is onlyO(1/c)— float32 relative error therefore grows aseps32 * c * ||s||^2witheps32 ≈ 1.19e-7. Measured against float64 atc=0.1,x ≈ y,d=16(forward / gradient relative error):9.9e-5/3.0e-4at||s||=1e2,6.1e-3/1.8e-2at1e3,6.4e3/1.0at1e4— past||s|| ~ 1e4the computed square flips sign, theabs()in the normalizer hides the flip, and themaximum(., 1e-7)floor silently inflates the output by2/sqrt(1e-7) ≈ 6325×(measured 6324.6 atc=0.1,||s||=2e4,x == y). Never a NaN, never a warning, and dormant at norm-capped activations (||s|| ≲ 20); the gradient path degrades ~3× earlier in||s||than the forward, from a second cancellation in the normalizer's Jacobian. Both functions now evaluate<h,h>_Lthrough exact identities — valid for any weights given inputs on the sheet (<x,x>_L = -1/c), verified in exact rational arithmetic: for the residualh = x + w·y,<h,h>_L = -(1+w)^2/c - w·<x-y, x-y>_L; for the midpoint with referencepthe vertex-nearest input,delta_m = x_m - p,W = Σ_m w_mandDelta = Σ_m w_m·delta_m,<h,h>_L = -W^2/c - W·Σ_m w_m·<delta_m, delta_m>_L + <Delta, Delta>_L. Every rounded term is nowO(||x-y||^2)instead ofO(||s||^2): new float32 error at||s||=1e4is2.1e-5forward /6.0e-4gradient (residual) and1.6e-5/4.3e-4(midpoint, M=8 softmax weights), and no regime where the old form was still usable measured worse (sweptc ∈ {0.01, 0.1, 1},||s||from 1 to1e5, near/far/same-direction/identical points; at||s|| ≤ 20old and new agree to ~2e-7 relative, not bit-identical — different rounding order). The one float32 limit that remains is the differencex - yitself: points that share a direction at||s|| ≳ 1e4lose it to rounding before either form sees it, and neither form is trustworthy there — that regime needs float64. Forw_y >= 0resp. non-negative weights the identities givec·|<h,h>_L| >= (1+w)^2resp.>= W^2, so theabs()and theepsfloor are now provably inactive (both kept as insurance). Affected layers:LorentzResidual,HypformerPositionalEncoding,HyperbolicFullAttention(attention aggregation and head averaging),HyperboloidGyroRMSNorm, hyperboloidfrechet_mean, and any direct caller of the two functions. The LResNet reference implementation (He et al. 2025) has the same defect. Both outputs additionally have their time coordinate reconstructed from the spatial part viaspatial_to_hyperboloid(x_0 = sqrt(||x_s||^2 + 1/c), the same convention ashrc/htc), so they are on-sheet by construction — as the old self-normalizingh/sqrt(-c<h,h>_L)was — even for inputs float storage cannot keep on the sheet (it needseps·x_0^2 << 1/c, violated past||s|| ~ 3e3in float32 /~1e8in float64, e.g. a Poincaré ball-boundary point lifted tox_0 ≈ 5.5e11): the identity assumes exactly on-sheet inputs, so for those it returned a point off the sheet by 4.8e-3 and hyperboloidfrechet_mean's Karcher loop diverged to NaN from it; the midpoint's referencepis now the vertex-nearest input rather thanpoints_0, bounding every||delta_m|| <= 2||x_m||. No API change; cost is O(1) extra for the residual and one extra einsum for the midpoint
1.1.1 - 2026-08-04¶
Added¶
hyperbolix.utils.capped_exp—expwith the argument capped at0.99*log(finfo.max), forexpof unconstrained trainable log-scale parameters. A runaway parameter otherwise overflows toinf, which turns into NaN downstream (inf - infin the hyperboloid time-coordinate algebra) and poisons the whole parameter tree within one optimizer step;capped_expsaturates finite instead, with a zero (not NaN) gradient past the cap. Below the cap it is a bitwise value- and gradient-identity tojnp.exp. Same idiomLearnableCurvature's"log"parameterization already used internally, now shared. Applied to the three call sites that had a barejnp.expon such a parameter: the Busemann FC layer'salpha = exp(log_scale), and both FHCNN/FHNN forward passes'exp(scale_val) * sigmoid(...)time-coordinate scaling
Fixed¶
atanh/sinh/coshfloat64 accuracy: XLA's CPU lowerings have large ulp errors that hyperbolix's wrappers previously inherited.jnp.atanhis lowered to0.5*(log1p(x) - log1p(-x)), and XLA's CPU float64log1pis up to ~129 ulps off for arguments in[-0.53, -0.28](NumPy's is <1 ulp there) —atanhinherited ~129 ulp error forxin~[0.28, 0.53], peaking atsqrt(2)-1.jnp.sinh/jnp.coshare separately inaccurate for large arguments: ~17 ulps for|x|in[16, 512]and ~496 ulps for[512, 710](float64; the jump sits exactly at the power-of-two boundary 512), and ~24.5 ulps in float32 across the full range. Float32atanhwas unaffected.hyperbolix.utils.math_utils.atanhis rewritten as the odd-symmetrized single-log1pidentityatanh(x) = sign(x)*0.5*log1p(2|x|/(1-|x|))(computed on|x|so thelog1pargument never enters the bad window, with the sign restored viawhererather thansign(x)*...— asign-multiplied form has zero gradient atx=0, not the analytic 1).sinhis rewritten as0.5*(expm1(x) - expm1(-x))(cancellation-free everywhere: the twoexpm1terms have opposite signs) andcoshas0.5*(exp(x) + exp(-x))with acustom_jvprouting its gradient to the accuratesinhform (a bare exp-formcosh's autodiff gradient is the naive cancellingsinh, inaccurate near 0). All three rewrites measure at a few ulps across their full domain (vs. the errors above) and are the same speed or faster than the builtins. Rawjnp.sinh/jnp.cosh/jnp.acoshcall sites that bypassed the wrappers (the FGG spatial lift, the Busemann FC output map, the wrapped-normal log-density, and the uniform-Poincaré volume/samplers) now route through them, closing the same accuracy gap plus, in theacoshcase, a singular-gradient exposure at an exact-1.0 domain boundary. No API changes; every downstream distance/logmap/MLR computation using these functions gets more accurate for free
1.1.0 - 2026-08-01¶
A correctness release. A full audit of the test suite replaced shape-only checks and
self-comparisons with independently transcribed NumPy/SciPy oracles, and every library
defect it exposed is fixed below. No new capability beyond hyp_flatten2d; several
corrections change behavior or call signatures, each marked Breaking and each with the
migration in its entry.
Added¶
hyp_flatten2d(hyperbolix.nn_layers) — radius-preserving flatten of an NHWC hyperboloid feature map into one manifold point per image viaHyperboloid.log_radius_concat:(B, H, W, A) → (B, H·W·(A−1)+1). The naive alternative (reshape +hcat) inflates the expected spatial radius by≈ √(H·W)(a 4×4 map: 4×); LogCat's digamma rescale hands the classifier head the per-pixel radius unchanged. This is the flatten step forHypConv2DHyperboloidILNNstacks feedingHypRegressionHyperboloid/FGGLorentzMLRPoincare.proj_batch— batched sibling ofHyperboloid.proj_batch(arbitrary leading axes, bit-identical tovmap(proj)); HoroPCA and CO-SNE now use it instead of hand-rolled vmapshyperbolix.manifolds._base.default_atol(dtype) = sqrt(finfo(dtype).eps)— the library-wide constraint-tolerance convention (float32 3.45e-4, float64 1.49e-8) thatis_in_manifold/is_in_tangent_spaceresolveNonethrough on every manifoldHypformerPositionalEncodingacceptsparam_dtypeand forwards it to its internalHTCLinear— float64 models were previously impossible (weights pinned to float32)- New exports:
hcat_ambient_dimandbusemann_fc_poincare_outputfromhyperbolix.nn_layers(both already served as test oracles and answer user-facing sizing questions);lift_idealsandorthonormalize_rowsfromhyperbolix.decomposition
Fixed¶
Hyperboloid.log_radius_concatscaled the wrong way, amplifying the spatial radius instead of preserving it. The two digamma arguments were swapped: the shippedexp(½·(ψ(N·d/2) − ψ(d/2)))is≈ √N, so concatenatingNblocks inflated the expected log spatial radius by≈ log N— worse than the plainhcatthe rescale exists to correct. The correct factor is the shrinkexp(½·(ψ(d/2) − ψ(N·d/2))) ≈ 1/√N: for Gaussian spatial parts‖v‖² ~ χ²_kgivesE[log‖v‖] = ½(ψ(k/2) + log 2), so restoring the per-block value after wideningd → N·drequires dividing by the ratio of the two chi radii. Nothing raised, because the mis-scaled output is still a valid manifold point (Lorentz residual ~1e-13) — only its radius was wrong. The Shi et al. 2026 reference implementation has the same sign error. Sole affected layer:HypConv2DHyperboloidILNN, where it inflated the spatial radius ≈9.4× per 3×3 conv, compounding with depth (hcat-based layers — FGG, FHNN — never used this path). Behavior change — see the coupled default-init change belowhyperbolix.optim.has_manifold_paramsalways returnedFalse.nnx.Variableis itself a registered pytree node whose single child is the raw array, so the unguardedjax.tree_util.tree_leavescall unwrapped everyManifoldParaminto anArrayImplbefore theisinstancecheck ran — the function reported "no manifold parameters" for a bareManifoldParam, a dict of parameters,nnx.state(model, nnx.Param)(its own documented usage) and a model alike. The traversal now stops atnnx.Variableleaves. The Riemannian optimizers were not affected:_riemannian_basealready flattened with that guard everywhere it inspects Variable types, so only callers usinghas_manifold_paramsas a guard saw the false negative- Wrapped-normal
log_probcrashed onsample()'s own output whenever the mean was batched andsample_shapenon-empty (bothdistributions.wrapped_normal_poincareandwrapped_normal_hyperboloid). Step 2 of the density computation vmapped the sample axisSand the mean's batch axisBtogether, so any call withmu.ndim > 1plus a non-emptysample_shaperaised aValueError/TypeErroron shapes the sampler itself produces; step 1 was also mis-batched (2-Dmupushed through the single-pointlogmap, relying on broadcasting). Both steps now share a_vmap_sample_and_batchhelper that vmaps batch axes innermost and sample axes outermost, matching the(*S, *B, dim)layout of the sampling side; previously-working shape combinations are bit-for-bit unchanged.log_probis now pinned from four independent directions (2-D polar quadrature integrating to 1, change-of-variables vsjacfwdof the sampling map, the flatc → 0limit vsscipyMVN, and the Poincaré↔hyperboloid isometry cross-check with no Jacobian — the density is w.r.t. Riemannian volume) - Poincaré wrapped-normal
log_probgradient atz == muwas NaN — in float64 too, not just float32. The radial norm entered the log-det Jacobian without a floor, so the gradient of the norm at the mean produced NaN; it is now floored at1e-15exactly like the hyperboloid sibling (the zero gradientmaximumcontributes on the clamped side is correct — the log-det is stationary atr = 0). Separately, the shared_log_det_jacobian_from_rhelper used a singlejnp.whereacross its Taylor gate, so reverse-mode AD propagated NaN from the unselectedlog(sinh(x)) − log(x)branch at exactlyr = 0; it now uses the double-where idiom. That second defect is unreachable from eitherlog_probonceris floored, but is fixed for direct callers of the helper smooth_clampcould exceed its own bounds on narrow windows. All three clamps (smooth_clamp,smooth_clamp_min,smooth_clamp_max) are re-derived as gate-free closed forms: the two-sided clamp is the difference formmin + softplus_β(x−min) − softplus_β(x−max), provably inside(min, max)for every window and β — composing the two one-sided clamps (the old construction) overshoots a narrow window by up toln(1+e^(−βw))/β, which forβw ≲ 1is the size of the window itself; a test now pins that the composition fails so it can't be "simplified" back. Evaluation uses the hinge+remainder splitclip(x) + tail − tail(tails ≤ln 2/β), avoiding float32 catastrophic cancellation, and the gradient is exactlysigmoid(β(x−min)) − sigmoid(β(x−max))with correct one-sided values at the hinge. Downstream consequence: theVERSION_SMOOTHENEDhyperboloid distance is now monotone with flooracosh(1+ln2/β)/√c ≈ 0.166/√cand agrees withVERSION_DEFAULTbeyond≈ 0.8/√c(it was previously non-monotone near coincident points)Euclidean.is_in_manifoldreturned constantTrue, accepting NaN/Inf — it now checks finiteness. The same defect existed onis_in_tangent_spaceforEuclidean,Poincare, andStereographic(the tangent space of an open subset of R^n is R^n — finiteness is the only constraint); all three fixed- Wrapped-normal log-det-Jacobian Taylor gate is now dtype-aware. The
log(sinh(x)/x)series switch used a float32-tuned threshold in float64 too; it now sits at(10³·eps)^(1/6)per dtype — the crossover where the 2-term series' truncation error (~x⁶/2835) meets the direct branch's cancellation error (~eps·|log x|) — with the series extended to two terms. Validated against a high-precision oracle on both sides of both gates LearnableCurvature's straight-through clamp amplified gradients in the clamped region. Withparameterization="log"at the exponent cap, the pass-through handed the raw parameter a gradient scaled bydc/draw = c— up toe^15at the cap — so one step could catapult the parameter across its whole range. The pass-through now divides the clamped-region gradient bymax(dc/draw, 1)(implemented as a stop-gradient carrier swap, so no reciprocal is formed that would flush to zero in float32 at the cap). Interior gradients are bit-identical, the forward value is unchanged, and gradients below the lower clamp are never amplified eitherProperVelocity.dist/dist_0returned NaN gradients at the origin (grad dist(0,0),grad dist_0(0)): barejnp.linalg.normhas a0/0VJP at the zero vector. Both now use the module's_safe_norm, whose gradient at 0 is exactly 0 — the correct subgradient. Value shifts by at most1e-15, below float64 resolution of any distanceuniform_poincarehardcoded float64 and broke its own shape contract.log_probnow returnsx.dtype(was always float64) and honours the documented(..., n) → (...)signature at any rank (ndim > 2raised adot_generalTypeError);sampleinfers its dtype fromcenter, thenmanifold_module, then JAX's default float;volumetakes adtypeargument. The Gauss-Legendre tables are plain Python tuples now, soimport hyperbolixno longer emits threeUserWarnings (and silently truncated float32 tables) whenjax_enable_x64is off- The two
hyperbolix.utils.helpersdocstring examples raisedAttributeError(they calledprojon the module, not an instance); both rewritten and verified via doctest
Changed¶
HypConv2DHyperboloidILNNdefault kernel init is now fan-out and norm-preserving.kernel_init_stdacceptsNone(the new default), which resolves tosqrt(1 / out_spatial). Near the origin the PLFC chain linearizes toy_spatial ≈ W @ u_spatial(bothasinhandsinhare identity to first order, and the bias starts at 0), so a GaussianWof shape(O, I)has RMS gainstd·sqrt(O); the corrected LogCat hands over the per-pixel spatial radius unchanged, leavingstd = 1/sqrt(O)as the unit-gain choice. This is coupled to the LogCat fix above and is not optional: the previous fixed0.02was calibrated against the pre-fix ~√N amplification (the two errors cancelled at width ~64,0.02·sqrt(64)·9 ≈ 1.4for a 3×3 kernel), and under the corrected shrink it contracts the mean spatial norm by 7–15× per layer — a depth-3 stack sits on the manifold origin at init, with no clamp or warning to show for it. Probe-measured per-layer spatial-norm ratios at depth 3 (c=0.1, 3×3, 8×8 input, float64): 0.82–0.95 with the new default versus 0.05–0.15 with0.02.kernel_init_std=0.02still reproduces the Shi et al. 2026 draw bit-for-bit, but it now restores a regime that implicitly assumed the pre-fix LogCat.HypLinearHyperboloidPLFCis unchanged — it has no LogCat- Breaking:
LorentzConv2Drequiresmanifold_moduleas its first positional argument, consistent with every other hyperboloid convolution. It is used as a family-identity check (a Poincaré manifold now fails validation instead of being silently misread as[time, space]); no manifold method is called in the forward pass. Update:LorentzConv2D(in_ch, ...)→LorentzConv2D(Hyperboloid(), in_ch, ...) - Breaking: Riemannian optimizer learning-rate schedules are resolved at the pre-increment step count, matching optax's
scale_by_schedule: the k-thupdate()readsschedule(k−1), so the first update usesschedule(0). Previously the schedule ran one step ahead of every optax reference (a warmup's step-0 rate was never used). Constant learning rates are unaffected; Adam-style bias correction deliberately keeps the post-increment count, which is also optax's convention — the two timings are different counters by design - Breaking:
HypRegressionPoincarekernel init changed fromnormal(0, 1)tostd = (2·in_dim·out_dim)^{-0.5}, matchingHypRegressionPoincarePPandHypRegressionHyperboloid(van Spengler et al. 2023). The unscaled init gave row norms≈ sqrt(in_dim)that reappear as the outer‖a‖multiplier in the MLR score, scaling the logits linearly: at 128→64 the logit std at init was 74, now 0.58. There is no flag to restore the old init - Breaking: one
atolconvention across all manifolds.is_in_manifold/is_in_tangent_spacetakeatol: float | None = None, resolved viadefault_atol(see Added); an explicit value is never floored, clamped, or dropped. PreviouslyHyperboloid.is_in_manifoldsilently flooredatolat1e-4(no caller could tighten it),Poincareignored it entirely, andHyperboloid.is_in_tangent_spacenever forwarded the one it accepted. Ball membership now tests the dimensionless residualc‖x‖² − 1, so one tolerance means the same at every curvature. Float64 hyperboloid membership is much stricter: genuinely on-sheet points past hyperbolic distance ~11 need an explicitatol - Breaking (widening):
Euclidean,Stereographic, andProductManifolddist/dist_0accept a trailingversion_idx(accept-and-ignore, per theProperVelocityprecedent), socompute_pairwise_distancesandget_deltanow work with all six manifolds instead of raisingTypeErroron three.ProductManifoldcannot forward it to heterogeneous factors — usecomponent_distfor per-factor control. The helpers' dead legacy module-API (_dist) fallback is removed - Breaking (trivial):
import hyperbolixexposes all six subpackages (decomposition,distributions,manifolds,nn_layers,optim,utils) in__all__;hyperbolix.distributionspreviously raisedAttributeErrorfrom a fresh interpreter until another module imported it. The lone root layer re-exporthyperbolix.PoincareBatchNorm2Dis removed with no alias — import it fromhyperbolix.nn_layers - Breaking: internal plumbing marked private —
busemann_core.init_weight_norm_params→_init_weight_norm_params,busemann_core.busemann_score→_busemann_score,gyro_normalization.GyroBatchNormBase→_GyroBatchNormBase,GyroRMSNormBase→_GyroRMSNormBase - Internal consolidation: the
1e-15gradient-safety floor has one canonical home,hyperbolix.utils.math_utils.MIN_NORM(the copies in_gyrovector_core,hyperboloid,proper_velocity,busemann_core,hyperboloid_linear, and the three distribution modules are gone;isometry_mappings.MIN_DENOMrenamed away); PV's private_mobius_gyrationcopy is deleted in favour of the shared_gyrovector_core._gyration;_batched_transformis a thin proven-bit-identical wrapper over_vmap_sample_and_batch;hope()'s time reconstruction delegates tospatial_to_hyperboloid(proven bit-identical);frechet_varianceis typed manifold-generic (Manifold, matching its Hyperboloid/PV callers);HypLinearPoincare/HypRegressionPoincaredrop the never-calledcompute_mlr_ppfrom their required manifold methods
Documentation¶
- Fixed four doc examples that raised on construction (
HypRegressionHyperboloid,HyperbolicSoftmaxAttention,PoincareBatchNorm2D,HypConv2DHyperboloid), theriemannian_adamb1/b2example, and theuniform_poincareexample (nonexistentdim=argument, sample count passed as the dimension, wrong volume value) — all now execute - Rewrote the layer initialization-scale table to match actual defaults (split
HypLinear*PPfrom the regression heads; addedHypLinearHyperboloidPLFCandHypConv2DHyperboloidILNNrows); fixed ambient-vs-spatial channel-convention contradictions (documented theHTCLinear.out_features-is-spatial exception; HCat growth is internal — output width is alwaysout_channels); corrected "manifold-valued weights" to "manifold-valued bias" for the legacy Ganea layers and repositionedmark_manifold_paramas guidance for hand-rolled parameters (built-in layers self-tag) - Real Hypformer citation (Yang et al. 2025) in 7 docstrings;
LorentzConv2Dattribution unified on LResNet; superseded-by notes onLorentzConv2D,HypLinearPoincare,HypRegressionPoincare;param_dtypecompute-precision wording corrected across the manifold-free layers; GyroBN shift/weight comment labels un-swapped;DEVELOPER_GUIDE.mdpointers fixed - Deleted the three placeholder "coming soon" tutorial notebooks and the dead commented-out
mkdocs-jupyterconfiguration; updated staledocs/index.mdcounts - As a one-off release audit, every
pythonfence indocs/,README.md, andDEVELOPER_GUIDE.mdwas executed by hand to confirm it actually runs (this is not an automated CI check). Four more raised:smooth_clamp(min_val=, max_val=)(the arguments aremin_value/max_value),get_delta(seed=42)(it takes akey),wrapped_normal_hyperboloid.sample(std=)(it takessigma), and theis_in_manifoldexample, whose "hyperboloid point" was never on the sheet (-1.5² + 0.2² + 0.3² + 0.1² = -2.11, not-1) — it now builds the ambient point withspatial_to_hyperboloid. The HoroPCA example requestedfloat64without enabling x64, so it silently truncated to float32 with threeUserWarnings - New sections for two breaking changes that previously appeared only in this changelog: the
atolconvention anddefault_atol(Numerical Stability) and learning-rate-schedule timing (Optimizers) - Corrected the layer and test counts in
README.mdanddocs/index.md: 20+ → 40+ layers, and "3,500+ tests / 850+ test functions" → 3,551 items across 735 test functions
1.0.0 - 2026-07-24¶
First stable release. The public API is considered complete and stable, reaching functional parity with the broader hyperbolic deep learning ecosystem; future changes follow semantic versioning.
Added¶
- CO-SNE (
hyperbolix.decomposition.CoSNE) — dimensionality reduction and visualization for hyperbolic data (Guo et al. 2022), the hyperbolic analogue of t-SNE. A thin sklearn-style class (fit/fit_transform; non-parametric, so no out-of-sampletransform, matching sklearn'sTSNE) over a pure, JIT-friendly functional core (fit_cosne,conditional_probabilities,joint_probabilities,low_dim_probabilities,kl_divergence_loss,magnitude_loss). High-dimensional similarities are perplexity-calibrated on squared hyperbolic distances (paper Eq. 2); low-dimensional similarities use a heavy-tailed Student-t / Cauchy kernel on Poincaré-ball distances (paper Eq. 9 — both the author's-code plain-distance form, default, and the exact squared-distance form viaexact_cauchy=True). On top of the t-SNE KL divergence it adds a magnitude lossH = (1/N)·Σᵢ(‖xᵢ‖² − ‖yᵢ‖²)²(paper Eq. 10) that preserves each point's distance-to-origin (the hierarchy depth). Optimization is two-stage projected gradient descent on the ball (early-exaggeration KL-only exploration, then KL + magnitude), with the KL gradient Riemannian-scaled by(1 − c‖y‖²)²/4and the magnitude gradient Euclidean (paper §3.7). Curvature-general (a singlecfor both spaces, passed at fit time); Poincaré input(N, D)→(N, K)ball coordinates, Hyperboloid input(N, A)→(N, K+1). Uses exact autodiff gradients of the declared losses — a deliberate deviation from the reference's demonstrably buggy hand gradients — so the reference learning rates do not transfer; thelearning_ratedefault (0.5) is calibrated on a synthetic-cluster recovery test and documented on the class. Double precision recommended for fitting - HoroPCA (
hyperbolix.decomposition.HoroPCA) — hyperbolic dimensionality reduction via horospherical projections (Chami et al. 2021). A thin sklearn-style class (fit/transform/fit_transform) over a pure, independently usable and JIT-friendly functional core (fit_horopca,transform_horopca,horo_projection,horopca_loss). All computation runs on the hyperboloid (Poincaré input is mapped in via the exact isometry); K ideal points are jointly optimized with Adam + gradient clipping to maximize the pairwise-distance variance of the horospherically projected data, which preserves every Busemann coordinate. Poincaré input(N, D)→(N, K)ball coordinates; Hyperboloid input(N, A)→(N, K+1).K = 1is supported via a closed form (the reference's Sherman–Morrison inverse is singular there). Exposescomponents_,mean_,boost_,losses_, and pairwise-variance-basedexplained_variance_/total_variance_/explained_variance_ratio_. Double precision recommended for fitting hyperbolix.decomposition.frechet_mean— manifold-generic Karcher (Fréchet) mean via fixed-point iteration in alax.while_loop(Lorentz-centroid init on the hyperboloid, projected-mean init on the Poincaré ball). The data-centering primitive HoroPCA builds on; configurablestep_size/tol/max_itersHyperboloid.lorentz_boost(mu, c)— the exact Lorentz boost matrixBwithB @ mu = origin(symmetric, proper, orthochronous), used to Fréchet-mean-center data before fitting. Closes a docs–code gap (the method was already advertised in the manifolds API reference)
0.11.1 - 2026-07-21¶
Changed¶
HTCLineardefault init is now fan-in-aware and norm-preserving.init_boundacceptsNone(the new default), which resolves tosqrt(3 / in_features)— per-layer input-Jacobian gain ≈ 1, sincehtcapplies no nonlinearity to the matmul output. The previous fixedU(-0.02, 0.02)was width-dependent contractive (gain0.02/sqrt(3)·sqrt(in_features)≈ 0.09 at fan-in 65): stacks of ≥ 2 layers collapsed input variation below the float32 noise floor, becoming a constant map with ≈0 gradients — training silently frozen from step 0 (observed in goal-conditioned RL: depth-2 HTC head, c=0.5, frozen through 3.1M steps; escape time monotone in the bound). The0.02was an in-house convention inherited from the FHNN/FHCNN family, not the Hypformer reference — the official Hypformer code initializes with Xavier-uniform gainsqrt(2)(bound = 2·sqrt(3/(in+out)), ~15× larger than 0.02 at fan-in 65), intended for its ReLU + LayerNorm regime; recover it by passing that bound explicitly. The attention layers (HyperbolicLinearAttention,HyperbolicSoftmaxAttention,HyperbolicFullAttention) andHypformerPositionalEncodingnow defaultinit_bound=Noneand inherit the fan-in-aware init for their HTC projections (matching the reference, whose Wq/Wk/Wv and positional encoding use the same Xavier init). FHNN/FHCNN/PLFC layers are unchanged — their0.02matches their references (verified against the official Chen 2021, Bdeir 2023, and Shi 2026 code). Behavior change — existing HTC models pick up the new init unless they passinit_bound=0.02explicitly (bit-for-bit reproduction of the old init)
0.11.0 - 2026-07-14¶
Added¶
- κ-Stereographic manifold (
hyperbolix.manifolds.Stereographic) — a single constant-curvature manifold spanning hyperbolic, Euclidean, and spherical geometry via a signed curvaturec(Bachmann et al. 2020):c > 0is hyperbolic and reproducesPoincare(c)exactly (both now build on a shared internal_gyrovector_coremodule, so Möbius addition, gyration, conformal factor, and projection are bit-identical),c = 0is the flat limit (carrying the conformal factor-2 metric — see the API reference), andc < 0is the stereographic projection of the sphere. Note the sign flip vs the paper/geoopt (κ = -c), chosen socmatches every other hyperbolix manifold. Implements the fullManifoldprotocol plusconformal_factor,gyration,geodesic,geodesic_unit, andantipode, using curvature-generalized trig functions with a dtype-aware Taylor branch nearc = 0— gated on both|κ|and the series argument|κ|·‖x‖², so extreme chart radii (e.g. near-antipodal spherical points) always keep the exact closed form — and an exact closed-form antipodex/(c‖x‖²). Verified compatible withProductManifoldfactors and the Riemannian optimizers (ManifoldParam+riemannian_adam/riemannian_sgd). The κ-GCN neural-network layers (mobius_matvec, weighted gyromidpoint,dist2plane,sproj) are not yet included. Double precision recommended when training a signed curvature that may cross zero, per the reference hyperbolix.utils.tanh— clamped hyperbolic tangent whose output stays strictly inside(-1, 1): clips the input at the analytic saturation bound±0.5·log(2/eps)and the output at±(1 − 10·eps), because XLA's float32tanhsaturates to exactly1.0slightly before the input bound bites. Matchesatanh's own domain guard, soatanh(tanh(x))can never reach the pole. Used by the κ-stereographic maps in the hyperbolic regime- Signed
identityreparameterization forLearnableCurvature(parameterization="identity",c = raw) — signed, crossing zero smoothly with gradient 1, for learning the sign of curvature with theStereographicmanifold;init_cmay be zero or negative, and the default clamp resolves to a symmetric[-10.0, 10.0](deliberately including 0) instead of the positive[0.1, 10.0]used bysoftplus/log. Thelogscheme's exponent is now capped at0.99·log(finfo.max), so a drifting raw parameter yields a large finite curvature instead ofinf; the cap is gradient-transparent understraight_through_clamp=True
0.10.2 - 2026-07-02¶
Changed¶
- Legacy Ganea layers (
HypLinearPoincare,HypRegressionPoincare) accept acurvatureconstructor argument (float or callable, default 1.0) for their manifold-valuedbiastag instead of hardcoding 1.0. The Riemannian optimizer uses this tag for the bias update, so it must match thecpassed at call time — previously anyc ≠ 1.0silently applied the wrong Riemannian correction to the bias
Fixed¶
- Kernel-init corrections across hyperbolic layers:
HypRegressionHyperboloidnow uses the fan-scaled kernel init matchingHypRegressionPoincarePP, andHypConv2DHyperboloidgains an opt-inreset_params="fan_in"for BatchNorm-free encoders GyroBatchNormBasegains amin_varfloor that prevents collapsed-variance saturationFGGConv2Ddocstring stated the default weight init is"kaiming"; the actual default is"lorentz_kaiming"PoincareBatchNorm2Dnow documents that the learned variance is an unconstrained scalar under a sqrt (NaN if driven negative) — kept as-is to match the van Spengler reference, with a workaround noted
0.10.1 - 2026-06-30¶
Added¶
GyroBatchNormandGyroRMSNormnormalization layers for the Hyperboloid and Proper Velocity manifolds
0.10.0 - 2026-06-29¶
Added¶
- LResNet
lorentz_scale(He et al. 2025, Eq. 10) — Klein-geodesic output rescaling that slides a hyperboloid point along the geodesic ray from the origin to control output norm while staying on the manifold — and a constrainedLorentzResidualmodule built on it - Busemann MLR and BFC layers (Chen et al. 2026)
Changed¶
- FGG layer init defaults changed to norm-preserving.
FGGLinearandFGGConv2Dnow default toreset_params="fan_out"(Gaussian,std=sqrt(1/out_spatial)) withinit_bias=0.0and a newgain=1.0multiplier, so the output spatial norm tracks the input (‖z‖ ≈ gain·‖x_spatial‖) instead of growing assqrt(out_channels)from step 0. This is a deliberate deviation from the Klis et al. 2026 classification reference (which normalizes magnitude away with BatchNorm/FGGMeanOnlyBatchNormafter each layer): it is motivated by unnormalized stacks — e.g. an RL backbone feeding a bounded Poincaré-ball projection, where the fan-in default saturated the projection. The newgainknob sets the effective column std togain/sqrt(out_spatial); it is a no-op forreset_params="eye"and is renormalized away underuse_weight_norm=True. Restore the previous reference-style init withreset_params="eye", init_bias=0.5(FGGLinear) orreset_params="lorentz_kaiming", init_bias=0.5(FGGConv2D).FGGLorentzMLR(a terminal Euclidean-logits head) is intentionally unchanged. Behavior change — existing FGG models pick up the new init unless they pass the oldreset_params/init_biasexplicitly
0.9.0 - 2026-06-23¶
Changed¶
- Performance improvements across the hyperboloid layers
- Unified the patch-extraction path into a shared
hyperboloid_core._extract_patcheshelper (deduplication, no behavior change)
0.8.2 - 2026-06-12¶
Changed¶
- Renamed
HypConv2DHyperboloidPP→HypConv2DHyperboloidILNN— the Shi et al. 2026 Lorentz convolution (LogCat vialog_radius_concat+ PLFC), with origin padding (pad_mode="origin") and ILNN improvements
0.8.1 - 2026-06-12¶
Changed¶
- Renamed
HypLinearHyperboloidPP→HypLinearHyperboloidPLFCwith PLFC (parametrized Lorentz fully-connected) improvements (Shi et al. 2026)
0.8.0 - 2026-06-11¶
Added¶
- Poincaré vector quantization layers (
hyperbolix.nn_layers):HypVQEmbeddingPoincare: HVQ-VAE quantizer (Chen et al. 2025) — explicit on-ball codebook held as a non-parameternnx.Variablebuffer, geodesic nearest-neighbour selection, copy-gradient straight-through estimator, and a hyperbolic-EMA codebook update (GGBall, Bu et al. 2026, Eqs. 41-43) with optional dead-code revival via theema_updatemethod (called afteroptimizer.update; the optimizer never touches the codebook, only the commitment loss trains the encoder)HypVQMLRPoincare: HyperVQ quantizer (Goswami et al. 2025) — implicit codebook = the rows of an internalHypRegressionPoincarePP, Gumbel-Softmax straight-through selection on the categorical weights (so plainoptax.adamtrains it), with adeterministicflag (toggled bymodel.eval()/model.train()) for a deterministic argmax MAP estimate at inferencePoincareVQOutput: shared pytree-friendlyNamedTuplereturn type(quantized, indices, loss, perplexity, z);quantizedis cast to float32 at the manifold→decoder boundarypoincare_weighted_midpoint: reusable Poincaré weighted gyromidpoint (GGBall Eq. 41), the Poincaré analog oflorentz_midpointand a weighted generalization ofpoincare_midpointsquared_commitmentflag onHypVQEmbeddingPoincare(defaultFalse). The cited references genuinely disagree on the commitment penalty: HVQ-VAE uses the plain geodesic distanced(z, sg(q)), GGBall's L_HVQVAE usesd²(the Euclidean VQ-VAE convention). The flag selects between them without touching library code
Hyperboloid.log_radius_concat— log-radius-preserving concatenation of N Lorentz points (Shi et al. 2026, Sec. 4.3), the hyperboloid analog of Poincaré β-concatenation. Rescales each block's spatial part byexp(½·(ψ(N·d/2) − ψ(d/2)))(digammaψ) so the expected log spatial radius stays invariant to the post-concat dimension, then recomputes the time coordinate to keep the result on the manifold. Reduces tohcatwhenN = 1; convolutional layers keep using the unscaledhcatby default- Isometry mappings now span all three models — Poincaré ↔ Hyperboloid, Poincaré ↔ Proper Velocity, and Hyperboloid ↔ Proper Velocity. New functions:
pv_to_poincare,poincare_to_pv,pv_to_hyperboloid,hyperboloid_to_pv(inhyperbolix.manifolds.isometry_mappings). All six maps are exact, curvature-correct Riemannian isometries (PVNN Eq. 4; Chen et al. 2026). The directpv_to_hyperboloid(PV coords are the hyperboloid's spatial part; time reconstructed from⟨z,z⟩_L = -1/c) avoids the near-boundary blow-up of composing through the ball - Self-hosted MathJax with a CI external-host allowlist guard
Changed¶
- All NN layers now take a
param_dtypeconstructor argument (defaultjnp.float32) controlling the storage dtype of every trainable parameter and persistent state (batch-norm statistics, VQ codebooks, scalar scales/temperatures). The manifold'sdtypecontrols compute precision only. Under globaljax_enable_x64, parameters previously materialized as float64 (2× parameter/optimizer memory, float64 checkpoints); they now stay float32 unlessparam_dtype=jnp.float64is passed explicitly. The Riemannian optimizers complete the contract:egrad2rgrad/expmap/ptransprun in the manifold dtype, but returned updates and momentum buffers are cast back to the parameter's storage dtype (previously a float32ManifoldParamnext to a float64 manifold silently promoted its optimizer state to float64 after one step). See Numerical Stability — Storage vs. Compute Dtype. Breaking changes:FGGMeanOnlyBatchNorm(dtype=...)renamed toparam_dtype=...PoincareBatchNorm2DandHypVQEmbeddingPoincarestate is no longer pinned tomanifold.dtype— it defaults to float32; passparam_dtype=manifold.dtypeto restore the old behavior- Checkpoints saved under global x64 before this change carry float64 leaves and will dtype-mismatch on restore into float32-storage modules — re-initialize or cast the state tree on load
Hyperboloid.additionnow implements the Lorentz gyrovector additionx ⊕ y = Exp_x(PT_{0→x}(Log_0(y)))(Chen et al. 2025b; Shi et al. 2026, Eq. 1), andProductManifold.additiondelegates it per factor. It forms a gyrocommutative gyrogroup (identity = origin, inverse⊖x = (-1) ⊙ x = [x₀, -x_s]) and coincides with Poincaré Möbius addition under the stereographic isometry. This replaces the earlier coordinate-wise formula, which was incorrect at every curvature (e.g.origin ⊕ y ≠ y) and failed silently via a trailing projection.Hyperboloid.scalar_mul(geodesic scaling, = Eq. 2) is unchanged. Breaking change —additionno longer raisesNotImplementedError- Breaking:
VERSION_LORENTZIAN_PROXYremoved from the Poincaré manifold. The formula treated Poincaré ball coordinate 0 as a Lorentz time component, so it was only meaningful for hyperboloid inputs and returneddist(x, x) = -2/c ≠ 0for ball points; the docs additionally mis-advertised it as "best near boundary". The reference implementation never had it.dist/dist_0now select between 3 versions (VERSION_MOBIUS_DIRECT,VERSION_MOBIUS,VERSION_METRIC_TENSOR). For a true Lorentzian (squared Minkowski) proxy, convert to the hyperboloid viaisometry_mappings.poincare_to_hyperboloidfirst
Fixed¶
- Poincaré ↔ Hyperboloid isometry maps were only correct at
c=1.poincare_to_hyperboloid/hyperboloid_to_poincareused unit-ball stereographic formulas missing their√cfactors, so round-trips and distance preservation silently failed at any other curvature (the recommended default isc=0.1). Both are now curvature-correct at allc, verified by round-trip, isometry, commutative-diagram, and extreme-curvature tests across dtypes - Test fixture
uniform_pointsgenerated hyperboloid points at the wrong geodesic radius forc ≠ 1(an extra/√con the spatial coordinate, masked by a trailing projection). Corrected so generated points are the exact Poincaré images at any curvature - Silent float64 promotion under x64 in hyperboloid layers. Runtime buffers created without an explicit dtype (
FGGConv2DSAME/origin padding buffer, causal linear-attention scan carries, full-attention uniform head-averaging weights) now derive their dtype from the input, and the scalar attention parameters (temperature,scale,attn_bias) are cast to the compute dtype at use. Previously, withjax_enable_x64active, these defaulted to float64 and promoted float32 activations through the rest of the layer
0.7.2 - 2026-05-22¶
Changed¶
ProductManifoldcurvature API redesigned — every geometry method (dist,expmap,logmap,proj,origin,tangent_inner, etc.) now takes a positionalcargument that must be a sequence of lengthn_factors(one curvature per factor) instead of the silently-ignored scalarc. There is no default and no scalar broadcast: passproduct.curvaturesfor static curvatures, or build the sequence fromLearnableCurvaturecalls for trainable ones. The protocol-levelCurvaturetype was widened toScalarCurvature | Sequence[ScalarCurvature]soProductManifoldsatisfies theManifoldprotocol —isinstance(product, Manifold)isTrueand generic code typed againstManifoldaccepts product instances. The product still has nocattribute (useproduct.curvatures). Breaking change — call sites that passedc=0.0(or any scalar) must now pass a per-factor sequence(c_0, c_1, …)
Fixed¶
- Corrected the
ProductManifoldAPI examples and the protocol-conformance claim in the documentation
0.7.1 - 2026-05-21¶
Added¶
LearnableCurvature(nnx.Module)— canonical module for trainable curvature inhyperbolix.utils.curvature, also exported at top level (from hyperbolix import LearnableCurvature). Introduces thesoftplus(default,c = softplus(raw), bounded gradient via sigmoid — geoopt'sStereographic/PoincareBallconvention, also the code default in the van Spengler et al. 2023 Poincare ResNet reference implementation) andlog(c = exp(raw), scale-invariant gradientdc/draw = c, MERU convention, preferred for compiled RL loops) reparameterizations. The default clamp is applied to the recoveredc(not the raw parameter) as a hard stability guard for long compiled training loops —[0.1, 10.0]for both schemes; passc_min=None, c_max=Noneto disable. Updated by any standard Euclideannnx.Optimizer— no Riemannian optimizer needed
Changed¶
- Manifolds are now plain Python classes (not
nnx.Module). This structurally prevents shared-manifold bugs innnx.scan/nnx.fori_loop— manifolds become static graphdef attributes with no state pytree entries learnable=Trueremoved from manifold constructors. Use theLearnableCurvaturemodule instead — assign one instance per distinct curvature on your model. See the Manifolds User GuideProductManifoldis now a plain class;from_signatureaccepts 3- and 4-tuple specs only (5-tuplelearnableoverride removed)learnable_curvature()/get_curvature()functional helpers replaced by theLearnableCurvature(nnx.Module)class. The class bundles the raw parameter, reparameterization scheme, and clamp bounds in one object, making accidental init/recovery mismatches structurally impossible. Call sites change fromc = get_curvature(self.c_raw)toc = self.curvature(). Breaking change — no deprecation shim
0.7.0 - 2026-05-18¶
Added¶
- Product manifold (
hyperbolix.manifolds.ProductManifold) — heterogeneous-curvature composition \(M_1 \times M_2 \times \dots \times M_n\) where each factor may be any base manifold with its own curvature (Gu et al. 2019). Points are flat concatenated arrays of shape(total_dim,); geometry methods take a per-factor curvature sequence as positionalcat call time. Provides Pythagorean L2 geodesic distance plus auxiliarydist_l1/dist_min/component_distreductions, full per-factor decomposition ofexpmap/logmap/ptransp/proj/egrad2rgrad/tangent_inner, anorigin(c)helper, and afrom_signaturefactory accepting 3- and 4-tuple specs - Learnable curvature via an
nnx.Module— first-class trainable curvature assigned per distinct curvature on the model (later canonicalized intoLearnableCurvaturein v0.7.1)
0.6.0 - 2026-04-20¶
Added¶
- Proper Velocity (PV) manifold (
hyperbolix.manifolds.ProperVelocity) — unconstrained \(\mathbb{R}^n\) model of hyperbolic geometry from Chen et al. (2026), with complete geometric operations:addition,scalar_mul,dist,expmap/logmap(at origin and arbitrary base points),ptransp/ptransp_0,egrad2rgrad, and Riemannian inner product - Proper Velocity neural-network layers:
HypLinearPV: PV fully-connected layer (Thm 5.3 / Eq. 22)HypConv2DPV: PV 2D convolution with raw Euclidean patch concatenation (Sec 5.3) — no beta-scaling, dimension-preservingHypRegressionPV: PV multinomial-logistic-regression head (Thm 5.2 / Eq. 19)
0.5.3 - 2026-04-14¶
Added¶
- Hyperbolic average-pooling layer
0.5.2 - 2026-04-02¶
Added¶
HypLinearHyperboloidFHNNandHypConv2DHyperboloidFHNNlayers (fully-hyperbolic neural network, Bdeir et al. 2023)
0.5.1 - 2026-03-27¶
Added¶
PoincareBatchNorm2D— Poincaré ball BatchNorm between conv layers (van Spengler et al. 2023)
0.5.0 - 2026-03-26¶
Removed¶
HypRegressionPoincareHDRLlayer and its tests
0.4.2 - 2026-03-24¶
Changed¶
- Removed
HypConv3DHyperboloid;beta_scaleis now wrapped infloat
0.4.1 - 2026-03-19¶
Changed¶
- Flattened conv-layer parameter paths via forward-function extraction (cleaner param trees, no behavior change)
0.4.0 - 2026-03-17¶
Added¶
- MkDocs Material documentation system
- Complete API reference documentation
- Getting Started guide
- CI/CD workflow for documentation builds
Changed¶
- Adopted Flax NNX layer naming convention (
kernel/bias) across all layers
0.3.0 - 2026-03-10¶
Added¶
- FGG-LNN layers (
FGGLinear,FGGConv2D,FGGLorentzMLR) — fully-generalized Lorentz layers (Klis et al. 2026)
0.2.1 - 2026-03-06¶
Changed¶
- Migrated benchmarks to Grain data loading
0.2.0 - 2026-03-05¶
Added¶
- Class-based manifold API with automatic dtype casting (
Poincare,Hyperboloid,Euclidean) Manifoldstructural protocol for type-safe manifold dispatch- Poincaré convolution layers
- Positional encoding layers for hyperbolic Transformers:
lorentz_residual: Lorentzian midpoint-based residual connectionhope: Hyperbolic Rotary Positional Encoding (functional)HyperbolicRoPE: NNX module wrapper for HOPEHypformerPositionalEncoding: Learnable positional encoding with HTCLinear
- Causal attention masking (
causal=True) for all three hyperbolic attention variants:HyperbolicSoftmaxAttention: lower-triangular-infmask before softmaxHyperbolicFullAttention: lower-triangular-infmask on Lorentzian similarity scoresHyperbolicLinearAttention: O(N) cumulative-sum recurrence viajax.lax.scan(Katharopoulos et al. 2020), keeping O(N) complexity in causal mode
- Tiny Shakespeare character-level benchmark (
benchmarks/bench_shakespeare_attention.py) comparing all four model variants (Euclidean + 3 hyperbolic) with causal attention
Changed¶
- Breaking: Manifold public functions renamed to private (
dist()→_dist()); use class methods instead - Replaced
with_precision()wrapper with thePoincare(dtype=jnp.float64)pattern - Breaking:
HypformerPositionalEncoding.epsilonis no longer a learnablennx.Param— it is a fixed, non-negative constructor float (default 1.0), matching the Hypformer reference (which keeps it a plain non-trainable tensor). A learnable epsilon could be driven below -1 by gradient descent, wherex + epsilon * pleaves the upper hyperboloid sheet and theabs()in thelorentz_residualnormalizer silently masks the violation.lorentz_residualnow documents thew_y >= 0requirement
0.1.4 - 2026-02-10¶
Added¶
- Pure JAX implementation of hyperbolic manifolds (Euclidean, Poincaré, Hyperboloid)
- 13+ neural network layers (linear, convolutional, regression)
- Hypformer components: HTC/HRC with curvature-change support
- 4 hyperbolic activation functions (ReLU, Leaky ReLU, Tanh, Swish)
- Riemannian optimizers (RSGD, RAdam) with automatic manifold detection
- Isometry mappings between the Poincaré ball and hyperboloid models
- Wrapped normal distributions for VAEs
- Comprehensive test suite (1,400+ tests)
- CI/CD pipeline with benchmarking
- vmap-native API design
Changed¶
- Migrated from PyTorch to pure JAX/Flax NNX
- Unified package structure:
hyperbolix_jax→hyperbolix
References¶
- Based on research by Ganea et al. (2018), Bécigneul & Ganea (2019), Bdeir et al. (2023)