abCROWN
The CTRAIN abCROWN integration exports the model to ONNX, writes per-instance
VNNLIB specifications, and records complete-verification results as JSON. The
evaluation API supports resumable runs via warm_start and chunked verification
with start_idx/end_idx; see CTRAIN.eval.eval_complete_abcrown and
CTRAIN.model_wrappers.CTRAINWrapper.evaluate_complete.
The vendored verifier is updated to abCROWN commit
6b8bbcfac1c01da1cabd240a87e4dce1a65f5a2b and uses the matching newer default
configuration schema. Run complete verification in an environment with the
matching auto_LiRPA package installed; the training-experiments venv currently
provides auto_LiRPA 0.7.0.
abcrown_eval(config, seed, instance, vnnlib_path='../../vnnlib/', model_name='mnist_6_100', model_path='./abCROWN/complete_verifier/models/eran/mnist_6_100_nat.pth', model_onnx_path=None, input_shape=[-1, 1, 28, 28], timeout=600, no_cores=28, par_factor=10)
Runs the abCROWN verification process with the given configuration. abCROWN is invoked from inside the program code, so a crash/freeze can only be handled partially.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict
|
Configuration dictionary for the verification process. |
required |
seed
|
int
|
Seed for random number generation. |
required |
instance
|
str
|
Path to the VNN-LIB instance file. |
required |
vnnlib_path
|
str
|
Path prefix for VNN-LIB files. Defaults to '../../vnnlib/'. |
'../../vnnlib/'
|
model_name
|
str
|
Name of the model to be verified. Defaults to 'mnist_6_100'. |
'mnist_6_100'
|
model_path
|
str
|
Path to the model file. Defaults to './abCROWN/complete_verifier/models/eran/mnist_6_100_nat.pth'. |
'./abCROWN/complete_verifier/models/eran/mnist_6_100_nat.pth'
|
model_onnx_path
|
str
|
Path to the ONNX model file. Defaults to None. |
None
|
input_shape
|
list
|
Shape of the input tensor. Defaults to [-1, 1, 28, 28]. |
[-1, 1, 28, 28]
|
timeout
|
int
|
Timeout for the verification process in seconds. Defaults to 600. |
600
|
no_cores
|
int
|
Number of CPU cores to use for parallel solvers, when abCROWN is configured to use MIP Solvers. Defaults to 28. |
28
|
par_factor
|
int
|
Penalty factor for running time in case of timeout. Defaults to 10. |
10
|
Returns:
| Type | Description |
|---|---|
tuple
|
Running time of the verification process and the result of the verification (sat/unsat or timeout/unknown). |
Source code in CTRAIN/complete_verification/abCROWN/verify.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
limited_abcrown_eval(work_dir, runner_path='CTRAIN/complete_verification/abCROWN/runner.py', *args, **kwargs)
Executes the abCROWN verification using a specified verification process with a specified timeout and handles the results. This increases robustness, since a crash of abCROWN does not result in a crash of the python script. This function serializes the provided arguments and keyword arguments, runs a separate Python script to perform the verification, and handles the process execution including timeout management. The results are deserialized and returned if the process completes successfully within the timeout period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
work_dir
|
str
|
The working directory where temporary files will be stored. |
required |
runner_path
|
str
|
The path to the runner script that performs the verification. Defaults to 'src/complete_verification/abCROWN/runner.py'. |
'CTRAIN/complete_verification/abCROWN/runner.py'
|
*args
|
Additional positional arguments to be passed to the runner script. |
()
|
|
**kwargs
|
Additional keyword arguments to be passed to the runner script. Must include 'timeout' (float) which specifies the timeout period in seconds. |
{}
|
Returns:
| Type | Description |
|---|---|
tuple
|
A tuple containing the running time and the result (sat/unsat or timeout/unknown) if the verification completes successfully. If the verification fails or times out, returns (MAX_LOSS, 'unknown'). |
Raises:
| Type | Description |
|---|---|
Exception
|
If there is an error running the process. |
Source code in CTRAIN/complete_verification/abCROWN/verify.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
get_abcrown_standard_conf(timeout=600, no_cores=28)
Generates the standard configuration for abCROWN. This function reads the standard configuration from a predefined string, updates the device setting based on the available hardware, and sets the timeout and number of parallel solvers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
int
|
The timeout value for the BAB solver in seconds. Defaults to 600. |
600
|
no_cores
|
int
|
The number of parallel solvers to use. Defaults to 28. |
28
|
Returns:
| Type | Description |
|---|---|
dict
|
The updated standard configuration dictionary. |
Source code in CTRAIN/complete_verification/abCROWN/util.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
instances_to_vnnlib(indices, data, vnnlib_path, experiment_name, eps, eps_temp, data_min, data_max, no_classes)
Converts a set of inputs and an epsilon value into VNN-LIB format files for adversarial robustness verification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
list of int
|
List of indices of the data instances to be converted. |
required |
data
|
Dataset
|
Dataset containing the data instances. |
required |
vnnlib_path
|
str
|
Path where the VNN-LIB files will be saved. |
required |
experiment_name
|
str
|
Name of the experiment for documentation purposes. |
required |
eps
|
float
|
Epsilon value for the adversarial robustness property. |
required |
eps_temp
|
float
|
Temporary epsilon value used for domain calculation. |
required |
data_min
|
float
|
Minimum value for data normalization/clamping. |
required |
data_max
|
float
|
Maximum value for data normalization/clamping. |
required |
no_classes
|
int
|
Number of classes in the classification task. |
required |
Returns:
| Type | Description |
|---|---|
list of str
|
List of file paths to the generated VNN-LIB files. |
Source code in CTRAIN/complete_verification/abCROWN/util.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
write_adversarial_robustness_vnnlib(filename, initial_comment, input_domain, ground_truth, n_classes=10)
Create a vnnlib specification for an adversarial robustness property.
The function writes the following to the specified file
- A comment at the top of the file.
- Declarations for input and output variables.
- Input constraints based on the provided input domain.
- Output constraints encoding the conditions for a property counter-example.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the file to write the vnnlib specification to. |
required |
initial_comment
|
str
|
A comment to include at the top of the vnnlib file. |
required |
input_domain
|
Tensor
|
A tensor representing the input domain, i.e. lower und upper bounds per input, with shape (n, 2), where n is the number of input variables. |
required |
ground_truth
|
int
|
The index of the ground truth class. |
required |
n_classes
|
int
|
The number of output classes. Default is 10. |
10
|
Source code in CTRAIN/complete_verification/abCROWN/util.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |