Binary Usage and Configuration

All compiled FHEON model binaries (such as LeNet5, ResNet20Basic, ResNet20Diagonal, BResNet20N16 or tuneResNet20) accept command-line options to configure runtime behaviors dynamically.

This configuration is processed in the global utils::parse_runtime_args helper function to set runtime parameters, dataset paths, weights directories, and prediction file outputs.

Example Usage

To run the LeNet5 binary with customized configuration:

./LeNet5 --verbose 2 --test-size 2 --index-value 0 --weights-folder "./../weights/lenet5/" --prediction-file "./../results/lenet5/fhepredictions.txt" --keys-folder "../AllHEKeys"

Parameter Documentation

The following options can be passed to configure runtime behavior:

Runtime Command-Line Options

Parameter

Description

Default Value

--test-size <int>

The number of input images to process during the inference evaluation. Batch programs take any number: they run batches (or pipeline groups) of their batch size and complete the last one with blank images, which are not reported.

Model-dependent default (e.g., 250)

--index-value <int>

The start index for reading images from the dataset, allowing evaluations on specific slices of data.

0

--verbose <int>

Verbosity level. Controls timing and telemetry output (0: silent/minimal, 1: basic, 2: detailed layer timings).

2

--threads <int>

Largest number of worker threads of the multithreaded programs (the standard batch models and the training) and of the batched bootstrapping. Every worker holds its own ciphertexts and bootstrapping temporaries, so fewer workers trade a little speed for much less memory. 0 also means all the system threads.

All the system threads

--keys-folder <path>

Directory path where serialized evaluation keys and context are stored or loaded.

"./../AllHEKeys/"

--weights-folder <path>

Directory path containing the model weights and biases CSV files.

"./../weights/"

--training-data-dir <path>

Training models: directory of the encrypted parameters and of the caches of the forward pass.

"./../encrypted_training_data/"

--prediction-file <path>

File path where model prediction outputs (inferred labels) are written. (Aliases: --predictions-file, --output-file, --output)

"./fhepredictions.txt" or model-dependent path

--images-path <path>

Globally overrides the path to the dataset. (Alias: --images-folder)

Model-dependent path

--cifar10-path <path>

Specifies the CIFAR-10 test batch binary file path.

"./../images/cifar-10-batches-bin/test_batch.bin"

--cifar100-path <path>

Specifies the CIFAR-100 test binary file path.

"./../images/cifar-100-binary/test.bin"

--mnist-path <path>

Specifies the MNIST dataset images file path.

"./../images/mnist_images/raw/t10k-images-idx3-ubyte"

--load-context [true/false]

If true (or given without a value), reloads the context and keys from serialized files on disk instead of generating new ones.

false

--peak-memory [true/false]

Measures and prints the peak memory of every layer.

true

Importance of Configuration Parameters

These configuration parameters play a critical role in the usability, portability, and optimization of FHEON models:

  1. Flexibility and Path Portability: In homomorphic encryption frameworks, file structures (like directories for weights, keys, and datasets) vary between different execution environments (e.g., local machines, HPC clusters). Instead of hardcoding paths, --weights-folder, --keys-folder, and dataset paths enable execution anywhere without recompiling the binary.

  2. Automatic Dataset Path Resolution: Depending on the executable name (resolved automatically inside parse_runtime_args), the framework maps the active dataset. For example, if the binary name contains lenet or mnist (case-insensitive), it defaults to the MNIST dataset, whereas a name containing resnet34 (ResNet34, BResNet34N16, ResNet34Diagonal, …) maps to CIFAR-100, and other models map to CIFAR-10. This default behavior can be overridden using --images-path or dataset-specific options.

  3. Key Serialization and Performance Optimization: Generating homomorphic encryption keys (especially rotation and bootstrapping keys) is computationally expensive. Setting --keys-folder and --load-context true enables reusing serialized keys from past runs, avoiding redundant key generation overhead and speeding up test executions.

  4. Output Logging and Telemetry: The --verbose parameter dictates the amount of console logging. High verbosity allows auditing execution timings of individual layers (convolutions, activations, pooling), which is vital for evaluating FHE performance bottlenecks. The --prediction-file automates output validation and stores predicted results for batch analysis.

Model-specific Options

The training model tuneResNet20 also reads --training-data-dir, the folder that keeps its encrypted parameters between steps (see Training and Fine-Tuning Examples).