Catalog PyPI
PACKAGE EXPLORERView in registry

ace-fhe

PyPI

ACE-Compiler: An FHE Domain-Specific Compiler

Versions collected1
Direct dependencies10From release 0.2.2
Last observed20 Oct, 18:06 UTC

README

Version 0.2.2 documentation

ACE-Compiler: An FHE Domain-Specific Compiler

ACE-Compiler is the compiler component of the ANT-ACE framework. It compiles PyTorch models, Python functions, and ONNX models into optimized FHE ciphertext programs, targeting multiple libraries (CPU/GPU) and encryption schemes (CKKS, TFHE).

Plaintext and FHE computation are seamlessly integrated: write code using familiar PyTorch/ONNX/Python, and the framework automatically converts it to encrypted execution.

Features

  • Multi-frontend input: PyTorch (FX trace), Python AST, ONNX file, or via-ONNX conversion
  • Multi-target execution: CPU (antlib, SEAL, OpenFHE) and GPU (phantom, acelib) targets
  • CKKS scheme support: Configurable polynomial degree, scaling factor, and multiplication depth
  • One-step or two-step workflow: @fhe.compute for compile+run; @fhe.compile for compile-then-run
  • Batch and dataset inference: Single input, batch parallelism, or full dataset with accuracy metrics
  • CUDA Graph acceleration: Replay captured GPU execution graph for reduced launch overhead
  • Built-in profiler: Profile FHE execution with program.profile() using torch.profiler

Quick Start

  • One-step: compile and run
import torch
from ace import fhe

@fhe.compute(frontend="torch", library="ant", validate=True)  # device auto-derives from library
def add(x, y):
    return x + y

x = torch.ones(1, 4)
y = torch.ones(1, 4) * 2
result = add(x, y)                  # FHE inference with auto-validation
  • Two-step: compile first, then run
@fhe.compile(frontend="torch", library="ant")  # device auto-derives from library
def add(x, y):
    return x + y

program = add.compile([x, y])       # Compile
result = program(x, y)              # Run inference
program.validate()                  # Verify correctness
  • GPU inference with compile options
@fhe.compile(frontend="torch", library="phantom", device="cuda",
             ckks={"N": 65536, "sf": 56})
def add(x, y):
    return x + y

program = add.compile([x, y])
result = program(x, y)
  • Batch inference with accuracy metrics
program = model.compile([example_input])
result = program.run_dataset(images, labels, top_k=1)
print(f"Top-1 accuracy: {result.top1_accuracy:.2%}")

Compilation Pipeline

Compilation Pipeline

Installation

pip install ace-fhe

The published wheel bundles the prebuilt runtime and compiler binaries, so pip install is enough to start using ACE on a supported platform — no source build required.

TBD: the ace-fhe PyPI package is being published; until it is available, use the from-source build below.

From source

The compiler backend sources (compiler/air-infra/, compiler/nn-addon/, compiler/fhe-cmplr/) are included directly in this repository, so a source build needs no extra credentials or fetches beyond the runtime backends (phantom / ckks-infra / spdlog), which are pulled from public GitHub at configure time. See Developer Guide for the full workflow:

./scripts/dev-build.sh                                  # build + install (Release)
python -c "from ace import frontend, runtime; print('OK')"

Build type defaults: ./scripts/dev-build.sh defaults to Release, while make defaults to Debug. Both write to the same build/ directory — pick one and stick with it to avoid stale-cache confusion.

libFHErt_common.so not found? Set the runtime library path: export LD_LIBRARY_PATH=$(python -c "import sysconfig; print(sysconfig.get_path('platlib'))")/ace/lib:$LD_LIBRARY_PATH

Ant Group internal developers: building inside the internal network needs a CI_TOKEN, the internal Docker registry (reg.docker.alibaba-inc.com/ace/...), and internal git mirrors. See the Internal Onboarding Guide.

API Reference

APIDescriptionDetails
@fhe.compileCompile function/model to FHE programDecorators API
@fhe.computeCompile and run in one stepDecorators API
@fhe.exportExport IR to file (AIR/ONNX)Decorators API
program(x, y)High-level FHE inferenceRuntime API
program.run_dataset()Batch inference with accuracyRuntime API
KernelExecutorLow-level kernel management, CUDA GraphRuntime API
ckks, vec, p2c, ...Compile optionsCompile Options

Libraries

LibraryDeviceBinaryStatus
antCPUlibFHErt_antAvailable
phantomCUDAlibFHErt_phantomAvailable
acelibCUDAlibFHErt_aceAvailable
sealCPUMicrosoft SEALPlanned
openfheCPUOpenFHEPlanned

Project Structure

ace-compiler/
├── fhe_dsl/                # FHE DSL source (Python + C++)
│   ├── python/             # Python package (installed as `ace-fhe`)
│   └── csrc/               # C++ extension (frontend, runtime)
├── fhe_lib/                # FHE runtime libraries
│   ├── ant/                # antlib (CPU)
│   ├── ace/                # acelib (CUDA)
│   └── common/             # Shared runtime code
├── compiler/               # FHE compiler (fhe_cmplr)
├── examples/               # Example scripts
├── tests/                  # Test suites
└── scripts/                # Build and development scripts

Publications

  • CGO '26 — FHEFusion: Enabling Operator Fusion in FHE Compilers for Depth-Efficient DNN Inference
  • OOPSLA '25 — MetaKernel: Enabling Efficient Encrypted Neural Network Inference through Unified MVM and Convolution
  • ASPLOS '25 — ReSBM: Region-based Scale and Minimal-Level Bootstrapping Management for FHE via Min-Cut
  • CGO '25 — ANT-ACE: An FHE Compiler Framework for Automating Neural Network Inference

Contributing

See CONTRIBUTING.md for code style, lint setup, and pull request guidelines.

License

Apache License 2.0 with LLVM-exception

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.2.221 Jul 202610

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
ant-research/ace-compiler

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:06 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:0f310fc54cb152c27f889e974cadcb48ed9df622d95ede1c06f0938e3644bc36