feat: scaffold FCES-native C++ project with libtorch integration

- CMakeLists.txt with libtorch, GoogleTest, GoogleBenchmark, OpenMP, pybind11
- Header files: config, controller, population, fitness, evolution, spectral, oscillation, telemetry, optimizer
- Source implementations: controller (full micro-MLP forward pass, mutation, crossover), fitness (Welford's algorithm), oscillation (DFT), spectral (SVD rank), optimizer (sign-SGD stub)
- Tests: controller, population, fitness, optimizer (Google Test)
- Benchmarks: evolve throughput, optimizer step (Google Benchmark)
- Examples: simple optimization, PyTorch/libtorch integration
- Python extension: pybind11 bindings with setup.py
- README with architecture diagram and build instructions
This commit is contained in:
AI-anonymous
2026-05-19 16:05:15 +02:00
commit 9bbe253810
32 changed files with 2182 additions and 0 deletions

25
benchmarks/bench_step.cpp Normal file
View File

@@ -0,0 +1,25 @@
#include <benchmark/benchmark.h>
#include <torch/torch.h>
#include "fces/optimizer.hpp"
using namespace fces;
static void BM_OptimizerStep(benchmark::State& state) {
auto model = torch::nn::Linear(state.range(0), state.range(0) / 2);
std::vector<torch::Tensor> params;
for (auto& p : model->parameters()) params.push_back(p);
FCESOptimizer opt(params, FCESConfig{}.set_lr(1e-3f));
auto x = torch::randn({8, state.range(0)});
for (auto _ : state) {
auto y = model->forward(x);
auto loss = y.sum();
loss.backward();
opt.step();
opt.zero_grad();
benchmark::DoNotOptimize(loss);
}
}
BENCHMARK(BM_OptimizerStep)->Arg(64)->Arg(256)->Arg(1024);