API Reference

Complete reference for all public classes and methods in the ARC library.

Arc

The primary controller class for monitoring and protecting training loops.

arc.api.callback
class Arc(
    config: Optional[Config] = None,
    model_path: Optional[str] = None,
    auto_intervene: bool = False,
    verbose: bool = True,
)

Methods

MethodReturnsDescription
attach(model, optimizer)ArcAttach ARC to a model and optimizer
detach()NoneRemove all hooks and detach
on_batch_end(loss, step)NoneCall after each batch to record loss
on_epoch_end(epoch, val_loss, train_loss)FailurePredictionCall at epoch end, returns failure prediction
get_report()strGenerate text report of training health
save_state(path)NoneSave internal state to disk
load_state(path)NoneLoad previously saved state
reset()NoneReset all internal state

Properties

PropertyTypeDescription
overhead_percentagefloatCurrent ARC overhead as % of training time
Context Manager

Arc supports the context manager protocol. Use with Arc(...) as arc: for automatic cleanup.

ArcV2

The high-level wrapper that automatically configures ARC based on model size and task type.

arc.api.v2
arc = ArcV2.auto(
    model, 
    optimizer,
    task_type="classification",
    safety_level="standard"
)
MethodReturnsDescription
auto(model, optimizer, **kwargs)ArcV2Class method to auto-initialize
step(loss)dictRecords loss and performs online interventions
begin_task(task_id)NoneStarts a new continual learning task (EWC)
consolidate_task(dataloader)NoneComputes Fisher information for EWC
get_ewc_loss()TensorReturns the EWC penalty for the current batch

ArcCallback

PyTorch Lightning callback for zero-code integration.

usage
from arc import ArcCallback

trainer = pl.Trainer(callbacks=[ArcCallback(
    auto_intervene=True,
    verbose=True,
)])

Config

FieldTypeDefault
signalSignalConfigDefault signal settings
featureFeatureConfigWindow size 10, min history 3
predictionPredictionConfigGRU hidden 64, 2 layers
thresholdsFailureThresholdsStandard thresholds
overheadOverheadConfig5% max overhead
devicestr"auto"

Class Methods

MethodDescription
Config.low_overhead()Production preset: 5% sampling, no curvature, 2% max overhead
Config.high_accuracy()Research preset: 30% sampling, curvature proxy, spectral features
Config.from_json(str)Deserialize from JSON string
Config.from_dict(dict)Create from dictionary

SignalConfig

FieldTypeDefaultDescription
collect_every_n_stepsint1Collection frequency
activation_sample_ratiofloat0.1Fraction of activations to sample
compute_gradient_entropyboolTrueCompute gradient entropy metric
compute_curvature_proxyboolFalseEnable Hessian-vector product estimation
track_effective_rankboolTrueTrack effective rank of weight matrices

PredictionConfig

FieldTypeDefault
temporal_hidden_sizeint64
num_gru_layersint2
mc_dropout_samplesint20
high_risk_thresholdfloat0.7
medium_risk_thresholdfloat0.4

FailureThresholds

FieldTypeDefault
loss_explosion_factorfloat10.0
loss_nan_detectionboolTrue
vanishing_grad_thresholdfloat1e-7
exploding_grad_thresholdfloat1e4
activation_similarity_thresholdfloat0.95
effective_rank_collapse_ratiofloat0.3
overfit_gap_thresholdfloat0.5

Signal Collectors

CollectorSignals
GradientCollectorGradient norms, entropy, histogram
ActivationCollectorActivation stats, similarity, effective rank
WeightCollectorWeight norms, NaN/Inf check, variance
OptimizerCollectorOptimizer state integrity, momentum norms
LossCollectorLoss trajectory, EMA, acceleration
CurvatureCollectorHessian-vector products (optional)

PINNStabilizer

MethodDescription
__init__(model, n_loss_terms)Initialize with model and number of loss components
get_stabilized_loss(losses)Compute adaptively weighted combined loss
stabilize_step()Apply gradient clipping and stabilization
update(epoch, loss)Update internal state for curriculum scheduling

ConformalPredictor

MethodDescription
__init__(model, alpha)Initialize with model and significance level
calibrate(loader)Calibrate on held-out data
predict(input)Return prediction set with coverage guarantee

AdversarialDetector

MethodDescription
__init__(model)Initialize with model to protect
fit(clean_loader)Fit detector on clean data distribution
detect(input)Check if input is adversarial

ElasticWeightConsolidation

MethodDescription
__init__(model, lambda_)Initialize with model and EWC strength
consolidate(dataloader)Compute Fisher Information and store parameters
penalty()Compute EWC penalty loss

BulletproofTrainer

bulletproof.py
from arc import BulletproofTrainer, BulletproofConfig

config = BulletproofConfig(max_epochs=100)
trainer = BulletproofTrainer(model, optimizer, config)
trainer.fit(train_loader, val_loader)