← HomOps Reference
HomMax
Element-wise maximum of two encrypted values via polynomial comparison.
MxComparison
RunsServer
Changes shapeYes - broadcast
Changes scaleYes - via nested ops
Levels spentTunable - poly depth + mul
RotatesNo
KeysSquare key
What it does
HomMax computes the element-wise maximum of two encrypted values using a soft comparison:a_is_greater = Compare(a, b), then max(a, b) = b + (a − b) · a_is_greater.It is a composite, not a registered leaf: the compiler expands it into nested HomCompare / HomSign poly stages plus multiply and add/sub (including HomSub). Inputs must lie in
[0, 1]; the current calibration rejects any other domain.Signature
HomMax( x_accuracy=10, y_accuracy=10, left=0.0, right=1.0, tol=1e-8, rows_budget=None, )
Two ciphertext inputs. No
set_data. Internally builds Compare with sign accuracy derived from x_accuracy.Parameters
ParameterTypeDefaultDescription
x_accuracyint10Horizontal accuracy α. Must be in {4, …, 14}. Converted to sign accuracy via the α→ζ table below.left, rightfloat0.0, 1.0Input domain. Must be 0.0 and 1.0; any other pair raises ValueError.tolfloat1e-8Poly eval tolerance, forwarded to nested stages.Rules that depend on the value
SettingRuleIf you break it
left, rightMust be exactly 0.0 and 1.0 (α–ζ calibration).ValueError at construction.x_accuracyMust be a key in the α→ζ table (4–14).ValueError at construction.α→ζ mapping used to derive Sign accuracy:
α (x_accuracy)ζ
45
55
610
711
812
913
1013
1115
1215
1316
1417
Requirements
- Domain [0, 1]. Both inputs must lie in
[0, 1], andleft/rightmust stay at those defaults. - Square key. Nested Sign / PolyEval / Mul stages need the square key (generated for you during key generation).
- Two inputs. Broadcast-compatible encrypted tensors.
- Not a leaf.
HomMaxexpands into nested ops; it is not a registered backend leaf.
Shape effect - yes
Element-wise; the output shape follows the broadcast of
a and b through the child arithmetic.Scale effect - yes
Scale is set by nested Compare → Sign poly stages, plus one multiply and add/sub. Check the compile-time simulation for the output scale.
How scale moves through a pipeline is on Ciphertext state - Scale.
Level budget
Plan levels like a multi-stage PolyEval plus one Mul: depth follows nested Compare / Sign accuracy, then the correction multiply. Tunable via
x_accuracy / y_accuracy.How primes are organized in the chain is explained on Level budget - The chain.
Keys
Square key (relinearization key). Required through nested children. Generated for you during key generation. No rotation key unless a child introduces rotations.
Example
Element-wise max on values in
[0, 1]:pipeline.pyPYTHON
from lattica_build.operators import HomMax h_max = HomMax(x_accuracy=7, y_accuracy=7, left=0.0, right=1.0) # out = h_max(a, b)
See also
- HomMin - the matching element-wise minimum
- HomMinMax - shared min/max core; prefer HomMax in graphs
- HomCompare - soft comparison underneath
- HomSign - multi-stage Chebyshev sign
- HomSub - ciphertext difference in the correction