peal.entrypoints.run_cfkd

Run Counterfactual Knowledge Distillation (CFKD) from a YAML config.

Drives the CFKD adaptor in peal/adaptors/counterfactual_knowledge_distillation.py: load the student predictor, explain it with counterfactuals from the configured generator and explainer, collect feedback (oracle, human or SAE based) on the counterfactuals and finetune the student on them, for finetune_iterations rounds.

Invocation:

python run_cfkd.py --config <adaptor.yaml> [--<any CFKDConfig field> value]

Every field of CFKDConfig is exposed as an optional --flag that overrides the YAML value (add_class_arguments / integrate_arguments). Set PEAL_CUDA_SYNC=1 to make CUDA launches synchronous while debugging a kernel fault.

Reads the adaptor config and the predictor, data, generator and explainer configs it references. Writes into base_dir: config.yaml, logs/ (TensorBoard), platform.txt, one <iteration>/ directory per round with the explainer collages and the train_dataset / validation_dataset of counterfactuals, and the finetuned student as model.cpl.

Functions

main

Load the CFKDConfig, apply command-line overrides and run CFKD.