Skip to content

Default engine

Engine(mode: str = 'cpu', *, slot_count: int | None = None, use_bootstrap: bool = False, use_multiparty: bool = False, thread_count: int = 0, cuda_grid_size_multiplier: int = 4, device_id: int = 0)
Creates an engine to execute operations.
  • Input:
    • mode: 'cpu', 'parallel', or 'gpu'. parallel refers to parallel processing using the CPU.
    • slot_count: Specifies the engine slot count.
    • use_bootstrap: Whether to use bootstrap.
    • use_multiparty: Whether to use multiparty computation.
    • thread_count: Specifies the number of threads to use when the mode is 'parallel' or 'gpu'.
    • cuda_grid_size_multiplier: Specifies the CUDA kernel call grid size multiplier when the mode is 'gpu'.
    • device_id: Specifies which GPU to use when the mode is 'gpu'.
  • Output:
    • Engine

use_bootstrap and use_multiparty cannot both be enabled in a single engine.

from desilofhe import Engine

engine1 = Engine()
engine2 = Engine(mode="parallel", use_multiparty=True, thread_count=256)
engine3 = Engine(mode="gpu", use_bootstrap=True, thread_count=512, decive_id=1)

Create with Max Level

Engine(max_level: int, mode: str = 'cpu', *, use_multiparty: bool = False, thread_count: int = 0, cuda_grid_size_multiplier: int = 4, device_id: int = 0)

  • Input:
    • max_level: Specifies the maximum number of multiplications allowed.
    • mode: 'cpu', 'parallel', or 'gpu'. parallel refers to parallel processing using the CPU.
    • use_multiparty: Whether to use multiparty computation.
    • thread_count: Specifies the number of threads to use when the mode is 'parallel' or 'gpu'.
    • cuda_grid_size_multiplier: Specifies the CUDA kernel call grid size multiplier when the mode is 'gpu'.
    • device_id: Specifies which GPU to use when the mode is 'gpu'.
  • Output
    • Engine
from desilofhe import Engine

engine1 = Engine(max_level=10)
engine2 = Engine(max_level=12, mode="parallel", thread_count=128)
engine3 = Engine(
    max_level=15, mode="gpu", use_multiparty=True, thread_count=512, decive_id=1
)

Create with Slot Count

Engine(*, slot_count: int, max_level: int, mode: str = 'cpu', *, use_multiparty: bool = False, thread_count: int = 0, cuda_grid_size_multiplier: int = 4, device_id: int = 0)

  • Input:
    • max_level: Specifies the maximum number of multiplications allowed.
    • mode: 'cpu', 'parallel', or 'gpu'. parallel refers to parallel processing using the CPU.
    • slot_count: Specifies the engine slot count.
    • use_multiparty: Whether to use multiparty computation.
    • thread_count: Specifies the number of threads to use when the mode is 'parallel' or 'gpu'.
    • cuda_grid_size_multiplier: Specifies the CUDA kernel call grid size multiplier when the mode is 'gpu'.
    • device_id: Specifies which GPU to use when the mode is 'gpu'.
  • Output
    • Engine
from desilofhe import Engine

engine1 = Engine(slot_count=1024, max_level=10)
engine2 = Engine(
    slot_count=1024, max_level=12, mode="parallel", thread_count=16
)
engine3 = Engine(
    slot_count=1024,
    max_level=15,
    mode="gpu",
    use_multiparty=True,
    thread_count=512,
    decive_id=1,
)

Create with Custom Parameters

Engine(log_coeff_count: int, special_prime_count: int, mode: str = 'cpu', *, log_slot_count: int | None = None, use_multiparty: bool = False, thread_count: int = 0, cuda_grid_size_multiplier: int = 4, device_id: int = 0)

  • Input:
    • log_coeff_count: The logarithm of the ciphertext coefficient count. Can range from 13 to 17.
    • special_prime_count: The size of a single partition for key-switching.
    • mode: 'cpu', 'parallel', or 'gpu'. parallel refers to parallel processing using the CPU.
    • log_slot_count: The logarithm of the engine slot count. Can range from 1 to log_coeff_count - 1.
    • use_multiparty: Whether to use multiparty computation.
    • thread_count: Specifies the number of threads to use when the mode is 'parallel' or 'gpu'.
    • cuda_grid_size_multiplier: Specifies the CUDA kernel call grid size multiplier when the mode is 'gpu'
    • device_id: Specifies which GPU to use when the mode is 'gpu'.
  • Output
    • Engine
from desilofhe import Engine

engine1 = Engine(log_coeff_count=14, special_prime_count=1)
engine2 = Engine(log_coeff_count=14, special_prime_count=1, log_slot_count=10)
engine3 = Engine(
    log_coeff_count=15, special_prime_count=2, mode="parallel", thread_count=16
)
engine4 = Engine(
    log_coeff_count=16,
    special_prime_count=4,
    mode="gpu",
    use_multiparty=True,
    thread_count=512,
    decive_id=1,
)