Skip to content

Releases

CROSS 3.0.0

Choose a tag to compare

@JianmingTONG JianmingTONG released this 18 Sep 16:35
e652a56

CROSS 3.0.0

This release brings the public repository up to the v3 tree (jaxite_word.__version__ == "3.0.0") in one release commit on top of v2.0.0 (69c46d2), plus the fixes from a full validation pass on an eight-chip TPU v6e host. It supersedes the reverted #2.

Scope

Only the library, demos, documentation and test configuration are included: jaxite_word/ (library, tests, perf tests, artifact scripts, API_REFERENCE.md), demos/ (the canonical pipeline, the four demos, trainers and tests), README.md, profile_analysis/, pytest.ini and .gitignore. Eight v2 modules superseded by the reorganized kernels are removed (add, sub, matvec, ciphertext and their tests). Not included, to keep the PR to the logic changes: the reference OpenFHE sources and security probe (openfhe_ref_code/), and the notebook and figure updates under figure_drawer/ (the notebook had grown to 5.5 MB of embedded outputs).

What v3 adds over v2

  • Compiler-style deployment path. A model enters once as an ordinary torch.nn.Module and crosses four owners: nn.vectorize (torch.fx trace, one vectorization template per layer, polynomial activation), packing.pack (global slot-layout reconciliation, the PP-op DAG with its constants, and a 128-bit-secure RingConfig derived from the program's own slot demand and depth), Mapping (levels, scales, noise, BSGS plans, keys, controls, device placement, one AOT-compiled executable) and CKKSContext (codec, primitives, operators). Serving is mapping.infer(x) or mapping.execute(ciphertext).
  • Device-parallel batches inside one executable. A global batch B on D chips is split B/D per chip; the public ciphertext boundary stays a rank-5 Polynomial.
  • New Montgomery reduction support. Montgomery reduction is now a first-class backend across the stack, selectable per operator beside Barrett: MontgomeryContext for modular arithmetic, NTTCiphertextMontgomeryContext for the NTT, BConvMontgomery and the Montgomery-BAT basis conversion, and Montgomery paths for HEAdd/HESub, PtCt multiply, Rescale, HEMul and HERot. Ciphertexts stay in the backend's representation during evaluation, with explicit exactly-once conversions at encryption, ModRaise, key setup and decryption. On TPU v6e it is the faster backend for every operator measured (HEMul 3.99 ms vs 4.69 ms Barrett; Rescale 607 µs vs 774 µs; HEAdd 36 µs vs 69 µs; modular multiply over 51 moduli 74 µs vs 87 µs), and bootstrapping_montgomery_test.py gates bit-canonical parity of a full N=256 bootstrap between the two backends.
  • Reorganized HE kernels and operators with per-level operator caches and CKKS bootstrapping matched to OpenFHE (N=256 parity gates, opt-in larger rings).
  • Four encrypted demos on the canonical path (LoLA, LeNet, AlexNetTiny, AlexNetFull) with an asset script that downloads MNIST/CIFAR-10 and trains the checkpoints, plus HPCA'26 artifact scripts (tabV, tabVI, tabVII, tabIX) and a Barrett-vs-Montgomery bootstrap parity gate.

Fixes from the TPUv6e-8 validation pass (from the CROSS_dev branch v3.0.0-release-fixes)

  • Mapping.release(): a materialized Mapping kept its HBM after its Python reference was dropped, because JAX's tracing caches hold the compiled program's closure and, through it, the Mapping with its captured keys and constants. release() drops the executable and bindings, evicts the id(ctx)-keyed codec caches (ckks_ctx.evict_context_caches), clears the JAX caches and marks the Mapping unusable; a build that fails part-way now discards its traced program. CanonicalDemo.release() and the demo adapters delegate to it.
  • LeNetRegressionTest keeps one resident model at a time (three resident models plus a build exhausted the 32 GiB HBM of one chip); the LoLA, LeNet and AlexNet performance gates release their models when done.
  • nn_test.py and mapping_compile_test.py failed at import when launched the documented way from inside jaxite_word/; both now put the repository root on sys.path.
  • profiler.write_results merges results on the union of columns instead of appending rows under a stale header.
  • tabVII.py skips sharded NTT batches that cannot fit 32 GiB HBM with a printed reason instead of a swallowed RESOURCE_EXHAUSTED; tabV.py re-enables its vectorized baseline (BAT 1.63× at 2048³, no gain at launch-bound small shapes).
  • Release hygiene from a pre-publication audit: the demos import the library through a sys.path shim so every demo and test runs from demos/ with no PYTHONPATH as documented; README install and API samples match the code (torch for the demos, rank-5 Polynomial boundary, rescale(), two-argument plaintext mul, real test-file names, source tabVIII.sh); demos README commands name existing test classes and its pre-unification tables are marked historical; a stray curses import and two leftover comments are gone; accidental executable bits cleared; the MIT LICENSE is tracked.

Validation on TPU v6e-8 (8 × TPU v6 lite, JAX 0.11.1, Python 3.13)

Every *_test.py and *_perf_test.py in the tree was executed serially, one process on the slice at a time.

suite files cases result
library functional tests 29 654 all pass (4 opt-in skips)
demo functional tests 10 271 all pass (3 opt-in skips)
kernel performance tests 11 70 all pass
artifact scripts (tabV, tabVI, tabVII, tabIX, bootstrap sweep) 5 187 all pass
encrypted model gates (LoLA, LeNet, AlexNetTiny; B=1, B=8, B=32, B=64) 8 runs — all pass after the fixes

Headline numbers, warm, 128-bit rings:

workload result
LoLA B=1 / B=32 (8 chips × 4) 566 ms / 397 ms per image, all argmax match cleartext
LeNet B=1 / B=32 / B=64 (8 × 8), trained MNIST weights 714 / 475 / 475 ms per image, 200/200 HE argmax = cleartext
AlexNetTiny B=1 / B=32 / B=8-on-8 662 / 463 / 458 ms per image
HEMul (degree 65536, 51 limbs) 3.99 ms one chip; per-shard 3.91 ms with a batch of 8 over 8 chips (7.6× throughput)
NTT degree 65536, 48 limbs, batch 8 1.88 ms one chip → 318 µs sharded over 8
BAT basis conversion fastest in 9 of 10 configurations, up to 7.6× over the default path

Known, documented gaps: the PtCt BAT path is ~2,400× slower than the VPU path (the VPU path is what Mapping uses); AlexNetFull has no TPU inference entrypoint at degree 65536; N=4096/N=8192 bootstrap gates remain opt-in.

Suggested release steps after merge

  1. Tag v3.0.0 on main and publish a GitHub release (previous releases: v2.0.0, v1.0.1); the earlier v3.0.0 tag that pointed at the reverted merge was removed.
  2. Delete the release-v3.0.0 branch.

CROSS v2.0.0

Choose a tag to compare

@JianmingTONG JianmingTONG released this 30 Apr 07:24

This release adds a layer of higher-level CKKS infrastructure on top of the
HPCA'26 paper artifact: a context-level operator API, scan-fused BSGS
matrix-vector multiplication, NumPy-vectorized encrypt/decrypt, an end-to-end
encrypted-CNN MNIST demo, a bootstrap kernel, a standalone Polynomial
primitive, and composite-degree CKKS (composite_degree > 1).

The seven sections below document what was added. The original kernel
(NTT, BConv, BAT, Add/Sub) is unchanged. Refer to its source
files and the API reference (jaxite_word/API_REFERENCE.md) for low-level
details. HE-Mul, HE-Rot are improved by 30% from engineering optimizations

Quickstart

conda create --name jaxite python=3.13 && conda activate jaxite
pip install -U "jax[tpu]" xprof absl-py pandas gmpy2

A ciphertext is a 3-D jax.Array of (num_elements, num_towers, degree).
Fresh ciphertexts live at max_level = (num_q - 1) // composite_degree; each
rescale consumes one level.


1. Context-level HE operator API

jaxite_word/he_ops.py, jaxite_word/he_params.py, jaxite_word/ptct_mul.py,
plus extensions to ckks_ctx.py, hemul.py, finite_field.py, ntt_mm.py,
ciphertext.py. Documented in jaxite_word/API_REFERENCE.md.

CKKSContext.program_initialization(...) is an offline step that builds a
shared HEParameterCache (NTT / Barrett / per-level BConv / pre-allocated
ciphertext helpers) and exposes level-indexed accessors.

ctx = CKKSContext(params)
ctx.program_initialization(
    total_hemul_levels=3,
    total_rotation_indices=[1, 2],
    dnum=3, r=4, c=4, batch=1)

result = ctx.he_mul[level].mul(ct1, ct2)              # ct × ct (rescale + relin)
ct3   = ctx.he_mul[level].hemul_no_relin(ct1, ct2)    # 3-element output
ct2   = ctx.he_mul[level].relinearize(ct3)            # back to 2-element
rot   = ctx.he_rot[level, k].rotate(ct)
op    = ctx.ptct_mul[level]; op.set_plaintext(pt_ntt); ct_out = op.mul(ct_in)
ct_lo = ctx.he_rescale[src, dst](ct)

Underlying classes added: HEMulAtLevel, HERotAtLevel, HERescaleOp,
HEPtCtMulAtLevel, HEBsgsMatVecAtLevel, plus SlicedNTTContext and
SlicedBarrettContext that share parent twiddle/Barrett tables.

Tests: ckks_ctx_test.py, hemul_test.py, herot_test.py, ptct_mul_test.py.

2. BSGS matrix-vector multiplication

jaxite_word/bsgs.py, jaxite_word/bsgs_test.py, jaxite_word/bsgs_perf_test.py.
Underlying primitives in jaxite_word/matvec.py (+ matvec_test.py,
matvec_perf_test.py).

A scan-fused Baby-Step Giant-Step diagonal matvec. The diagonal method writes
A·v = Σ_k Rot_k(v) · diag_k(A); BSGS with n1·n2 = n cuts this from n to
n1 + n2 rotations (e.g. n=1024 → 64). Two zero-skip levels are implemented:

  1. Whole-giant-step skip drops any j where every baby diagonal in
    [j·n1, (j+1)·n1) is zero.
  2. Per-diagonal skip groups active giant steps by their non-zero baby
    count so the inner scan iterates only over non-zero diagonals.

Rectangular m × k matrices (m, k ≤ n) are zero-padded to n × n before
diagonal extraction. One rescale per mul.

bsgs = ctx.bsgs_matvec[level, n]            # auto-split n1, n2
# or: ctx.bsgs_matvec[level, n, n1, n2]     # explicit
bsgs.encode_matrix(W)                       # rectangular OK; zero-padded
ct_out = bsgs.mul(ct_in)                    # consumes 1 level

3. Vectorized encrypt / decrypt

jaxite_word/encrypt_fast.py, jaxite_word/decrypt_fast.py, paired tests
(encrypt_fast_test.py, decrypt_fast_test.py), and the combined gate
jaxite_word/run_fast_path_tests.py.

NumPy-vectorized uint64 paths replace the pure-Python triple-loop forward NTT

  • sample/NTT(v, e0, e1) (encrypt) and SK-multiply + per-tower INTT (decrypt).
    Bit-equal to the reference paths in ckks_ctx.CKKSContext.encrypt/decrypt at
    every level.
  • encrypt: ≈770 ms → ≈30 ms (~28× speedup at 9Q)
  • decrypt: ≈155 ms → ≈5 ms (~30× speedup at L3, 4 moduli)

Run before any change to the fast paths or to LoLAHE.encrypt/decrypt:

python3 jaxite_word/run_fast_path_tests.py

4. End-to-end LoLA-MNIST encrypted CNN demo

demos/lola_he.py (+ demos/lola_he_test.py, demos/lola_he_perf_test.py).

Full encrypted LoLA-MNIST inference (Conv → Square → FC1 → Square → FC2) at
CKKS degree=2048, num_slots=1024. The single LoLAHE class bundles every
optimization the codebase offers:

  • per-level JIT-compiled ptct_mul + rescale,
  • cached Polynomial templates + encoded bias plaintexts,
  • fast he_mul squaring via _FastHEMulPath,
  • JIT-compiled pure rotation per (level, rot_idx),
  • scan-fused sum_reduce_all,
  • BSGS diagonal matmul for FC1 and FC2,
  • JIT-compiled bias-add and conv1 mod-add (one fused closure per nq),
  • vectorized NumPy encrypt + encode and decrypt + decode.

Canonical config: 7 Q-towers + 3 P-towers, dnum=3, max_level=6, depth-5
schedule. Level budget:
L6 → conv1 BSGS → L5 → square → L4 → FC1 BSGS → L3 → bias+square → L2 → FC2 BSGS → L1 → bias → decrypt.

Run a single image:

cd CROSS/demos
python3 lola_he.py --n 1

Each inference prints [i] label=<true digit> pt=<plaintext argmax> he=<ciphertext argmax> |he-pt|=<L∞ distance> wall=<seconds>. A correctly
working model matches he == pt and keeps |he-pt| inside the CKKS noise
budget (≤ 5e-2 at the scaling factor used here).

lola_he_test.py is the single-image correctness gate (argmax + max-error
vs cleartext); lola_he_perf_test.py writes per-image wall+accuracy to
demos/log/lola_he_perf.csv.

5. Bootstrap kernel

jaxite_word/bootstrap.py, jaxite_word/bootstrap_test.py,
jaxite_word/bootstrap_perf_test.py.

CKKS bootstrapping kernel built on the context-level operator API.

Known issue: on some JAX/TPU runtimes bootstrap_test.py triggers
xprecision_rewriter.cc:2100 ("Unsupported CVT X{64,128} expansion from f64 to c128") inside the JAX TPU compiler. This is unrelated to the kernel
itself; functional correctness should be verified on CPU until the runtime
issue is resolved.

6. Polynomial primitive surface

jaxite_word/polynomial.py, jaxite_word/polynomial_test.py.

Reusable Polynomial template separated from ciphertext logic, used by the
context-level API, BSGS matvec, and the LoLA demo for cached encoded plaintexts.

7. Composite-degree CKKS

jaxite_word/rescale.py, plus ckks_composite_ctx_test.py,
hemul_double_rescaling_test.py, rescale_double_rescaling_test.py.

CKKSContext now accepts composite_degree > 1: the last composite_degree
moduli form the per-level scale factor and one rescale drops
composite_degree towers at once. program_initialization and the
level-indexed accessors above all respect this. Double-rescaling correctness
is gated by the new *_double_rescaling_test.py files.

CROSS v1.0.0

Choose a tag to compare

@JianmingTONG JianmingTONG released this 28 Dec 18:13

Why your AI ASICs like TPU only serve AI training or inference?

CROSS turns TPU into Homomorphic Encryption (HE) Accelerator, breaking the records established by GPUs, being the new SoTA throughput and energy efficiency solution for HE operators. We let the code speak.

CROSS redefines the boundary of what AI ASICs can accelerate. We proves that applications with static scheduling of modular arithmetic could be transformed into kernels suitable for TPU, inheriting the SoTA energy efficiency and throughput of modern AI ASICs without any hardware modification. By proving that statically scheduled modular arithmetic can be transformed into TPU-suitable layout-invariant low-precision matrix multiplication and vectorized arithmetic, and by introducing BAT and MAT as reusable compiler instruments, CROSS opens a paradigm for the AI-ASIC ecosystem to support privacy-preserving AI and cryptography-based computing at scale.

The key of CROSS have two computation transformations techniques

  1. Basis Aligned Transformation: reform high-precision modular multiplication as a low-precision dense matrix multiplication to be accelerated by Matrix Multiplication Engine (MXU) in TPU.

  2. Memory Aligned Transformation: embed explicit memory reorganization into computation to directly generate results in the expected layout without paying runtime layout transformation overhead.

CROSS has been recognized with (1) 2nd award at university Demo @ DAC'25, (2) GT Startup Launch, (3) GT NEXT Award. And we open-source CROSS and will give tutorial with Google at ASPLOS'26 @ Pittsburgh. And we will consistently maintain CROSS for enabling community to further pushing the boundary of homomorphic encryption.

Feel free to drop me a line for questions / feature request and welcome to contribute -- your voice would be valued!

Enjoy CROSS at following links!