98 lines
2.2 KiB
C++
98 lines
2.2 KiB
C++
#pragma once
|
|
|
|
/**
|
|
* @file config.hpp
|
|
* @brief FCES Configuration — compile-time defaults and runtime overrides.
|
|
*
|
|
* Maps directly from Python's FCESConfig (Pydantic model) to a C++ struct
|
|
* with constexpr defaults and builder-pattern construction.
|
|
*/
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace fces {
|
|
|
|
/**
|
|
* Core configuration for the FCES optimizer.
|
|
* All fields have sensible defaults matching the Python V49.0 implementation.
|
|
*/
|
|
struct FCESConfig {
|
|
// Learning rate (V49 optimal default)
|
|
float lr = 1.6e-3f;
|
|
|
|
// Weight decay coefficient
|
|
float weight_decay = 0.0f;
|
|
|
|
// Population size for evolutionary search
|
|
int population_size = 200;
|
|
|
|
// Total training steps (for progress-aware scheduling)
|
|
int total_steps = 5000;
|
|
|
|
// Signal mode for loss velocity calculation
|
|
std::string signal_mode = "relative";
|
|
|
|
// Grokking awareness coefficient (0.0 = disabled)
|
|
float grokking_coefficient = 0.1f;
|
|
|
|
// Spectral sensing frequency (every N steps)
|
|
int spectral_frequency = 10;
|
|
|
|
// Curriculum Spectral Regularization
|
|
bool csr_enabled = false;
|
|
int csr_warmup_steps = 500;
|
|
int csr_ramp_steps = 1000;
|
|
|
|
// Trust region clipping
|
|
float trust_region_clip = 0.01f;
|
|
|
|
// Rollback threshold
|
|
float rollback_threshold = 1.5f;
|
|
|
|
// Adaptive weight decay
|
|
bool adaptive_wd = false;
|
|
|
|
// Parasitic mode (gradient alignment reward)
|
|
bool parasitic_mode = false;
|
|
|
|
// Ablation mode: "", "force_sign", "force_grad"
|
|
std::string ablation_mode = "";
|
|
|
|
// Fractional factorial scoring (CRO trick)
|
|
bool use_fractional_scoring = false;
|
|
|
|
// Direct construction mode (pop_size=1)
|
|
bool direct_construction = false;
|
|
|
|
// Banach-Tarski fission
|
|
bool use_banach_fission = false;
|
|
|
|
// Auto-population (stabilize on divergence)
|
|
bool auto_population = false;
|
|
|
|
// Builder pattern
|
|
FCESConfig &set_lr(float v) {
|
|
lr = v;
|
|
return *this;
|
|
}
|
|
FCESConfig &set_population_size(int v) {
|
|
population_size = v;
|
|
return *this;
|
|
}
|
|
FCESConfig &set_total_steps(int v) {
|
|
total_steps = v;
|
|
return *this;
|
|
}
|
|
FCESConfig &set_grokking_coefficient(float v) {
|
|
grokking_coefficient = v;
|
|
return *this;
|
|
}
|
|
FCESConfig &set_direct_construction(bool v) {
|
|
direct_construction = v;
|
|
return *this;
|
|
}
|
|
};
|
|
|
|
} // namespace fces
|