Checkpoint the party/runtime stack before share-program and malicious-mode work.

Ship the TLS mesh, composer, Beaver/Yao/leaf MPC, prep/online paths, apps, and docs so the tree is pushable before elevating share_expr, security_mode, and prep resume.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ryan Henry 2026-09-28 05:59:19 -06:00
parent 695f8e84f7
commit 0d22946a0e
1835 changed files with 170291 additions and 2849 deletions

View file

@ -8,7 +8,14 @@
/// table. `probit` is stored on `(0, 1/2]` and mirrored. The tail
/// below 1/20 is a cubic in `ln(p)` (knots at scale `2^{k+10}`),
/// because a cubic in `p` cannot meet half an ulp on the first
/// input step once `k` is large.
/// input step once `k` is large. `hardelish` is exact outside
/// `[-1, 1]` and an exact quadratic on `[0, 1]`; only `(-1, 0)` is
/// a cubic table. `lecun_tanh` is an odd cubic table out to where
/// the value sits within a quarter ulp of `1.7159`, then a constant
/// tail. `one_minus_sigmoid` is `1` minus the sigmoid table.
/// Those two cubics are the Appendix D maps that had no fixed-point
/// table. Knots come from Sollya; each cubic is the lowest-error
/// polynomial among Sollya, Mathematica, Maple, and MATLAB.
#ifndef LIBDPF_INCLUDE_GROTTO_WINDOW_LUT_HPP__
#define LIBDPF_INCLUDE_GROTTO_WINDOW_LUT_HPP__
@ -40,6 +47,12 @@ enum class window : unsigned
asin,
acos,
probit,
/// Appendix D HardELiSH. Exact outside `[-1, 1]`, quadratic on `[0, 1]`.
hardelish,
/// Appendix D LeCun tanh, `1.7159 tanh(2x/3)`.
lecun_tanh,
/// `1 - sigmoid(x)`, the same table as `sigmoid`.
one_minus_sigmoid,
};
namespace window_detail
@ -57,6 +70,7 @@ struct window_table
};
#include "grotto/window_tables.inc"
#include "grotto/window_extra_tables.inc"
inline unsigned slot_of(unsigned fractional_bits)
{
@ -232,7 +246,7 @@ static constexpr std::uint64_t probit_ln_anchor_mag[32] = {
/// @brief `round_half_away(ln(probability / 2^k) * 2^{k+10})`.
/// @param fractional_bits the number of fractional bits
/// @param probability the `probability`
/// @param probability probability as a raw fixed-point word
/// @return `round_half_away(ln(probability / 2^k) * 2^{k+10})`
inline std::int64_t probit_ln_argument(unsigned fractional_bits, std::int64_t probability)
{
@ -260,11 +274,11 @@ inline std::int64_t probit_ln_argument(unsigned fractional_bits, std::int64_t pr
}
/// @brief Horner, then one extra right shift so a tail argument at scale `k+10` rounds onto scale `k`.
/// @param piece the `piece`
/// @param q the `q`
/// @param piece cubic piece
/// @param q Horner input in raw units
/// @param raw the underlying integer
/// @param fractional_bits the number of fractional bits
/// @param extra_shift the `extra_shift`
/// @param extra_shift extra right shift onto the caller's scale
/// @return Horner, then one extra right shift so a tail argument at scale `k+10` rounds onto scale
/// `k`
inline std::int64_t eval_cubic_extra(
@ -323,6 +337,18 @@ inline std::int64_t eval_smoothstep(unsigned fractional_bits, std::int64_t raw)
}
} // namespace window_detail
/// \complexity `piece_of` binary-searches `nparts` knots, then one cubic Horner. `smoothstep` is three multiplies and no table.
/// `asin` / `acos` also call the principal square root. `hardelish` does that search only on `(-1, 0)`;
/// on `[0, 1]` it is one rounded quadratic and elsewhere a compare. `lecun_tanh` searches the positive
/// knots of `|x|` or returns the constant tail. `one_minus_sigmoid` is the sigmoid search plus one subtraction.
/// Time `Θ(log P)` plus `Θ(1)` arithmetic. Extra space `Θ(1)`.
/// @see grotto::eval_principal
/// @see grotto::eval_reduced
/// @see grotto::eval_closed
/// @param which the window map
/// @param fractional_bits one of 8, 12, ..., 32
/// @param raw fixed-point argument
/// @return fixed-point result at the same scale
inline std::int64_t eval_window(window which, unsigned fractional_bits, std::int64_t raw)
{
@ -382,6 +408,34 @@ inline std::int64_t eval_window(window which, unsigned fractional_bits, std::int
return -eval_probit_abs(fractional_bits, one - raw);
return eval_probit_abs(fractional_bits, raw);
}
case window::hardelish:
{
const auto one = std::int64_t{1} << fractional_bits;
if (raw <= -one)
return 0;
if (raw >= one)
return raw;
if (raw >= 0)
return round_half_away_i128(
static_cast<__int128>(raw) * (raw + one), fractional_bits + 1u);
return eval_table(at(HARDELISH, fractional_bits), fractional_bits, raw);
}
case window::lecun_tanh:
{
const std::int64_t tail = LECUN_TAIL[slot_of(fractional_bits)];
const window_table & table = at(LECUN, fractional_bits);
const std::int64_t last = table.knots[table.nparts];
if (raw >= last)
return tail;
if (raw <= -last)
return -tail;
const std::int64_t mag = raw < 0 ? -raw : raw;
const std::int64_t y = eval_table(table, fractional_bits, mag);
return raw < 0 ? -y : y;
}
case window::one_minus_sigmoid:
return (std::int64_t{1} << fractional_bits)
- eval_tailed(SIGMOID, tail_zero, tail_one, fractional_bits, raw);
}
throw std::invalid_argument("window lut: unknown function");
}