Skip to content

Commit 26bf602

Browse files
committed
refactor(tuning): keep curriculum parameter layouts uniform
Remove the unused phase-local semantics selector after the compression audit showed bootstrap and current move-score phases use incompatible parameterizations. Mixed-semantics stage merging would not be an honest equivalent recipe.
1 parent 67b62d1 commit 26bf602

3 files changed

Lines changed: 33 additions & 52 deletions

File tree

‎Rapfi/command/tuning.cpp‎

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ struct CurriculumPhaseInput
326326
uint8_t boardSizeMax;
327327
size_t batchSize;
328328
uint64_t seed;
329-
TrainingSemantics trainingSemantics;
330329
double multiPVPolicyTemperature;
331330
double multiPVPolicyEvalScale;
332331
MoveScoreObjective moveScoreObjective;
@@ -373,7 +372,7 @@ std::vector<CurriculumPhaseInput> parseCurriculum(const std::filesystem::path &m
373372
std::vector<CurriculumPhaseInput> phases;
374373
phases.reserve(static_cast<size_t>(std::distance(phaseArray->begin(), phaseArray->end())));
375374
for (const auto &table : *phaseArray) {
376-
static constexpr std::array<const char *, 24> PhaseKeys = {
375+
static constexpr std::array<const char *, 23> PhaseKeys = {
377376
"name",
378377
"epochs",
379378
"training_dataset",
@@ -386,7 +385,6 @@ std::vector<CurriculumPhaseInput> parseCurriculum(const std::filesystem::path &m
386385
"max_boardsize",
387386
"batch_size",
388387
"seed",
389-
"training_semantics",
390388
"multipv_policy_temperature",
391389
"multipv_policy_eval_scale",
392390
"move_score_objective",
@@ -451,12 +449,8 @@ std::vector<CurriculumPhaseInput> parseCurriculum(const std::filesystem::path &m
451449
"curriculum phase batch_size must be positive and fit size_t");
452450
if (seed < 0)
453451
throw std::invalid_argument("curriculum phase seed must be nonnegative and fit int64");
454-
phase.batchSize = static_cast<size_t>(batchSize);
455-
phase.seed = static_cast<uint64_t>(seed);
456-
phase.trainingSemantics = parseTrainingSemantics(
457-
getOptionalPhaseValue<std::string>(*table, "training_semantics")
458-
.value_or(defaults.trainingSemantics == TrainingSemantics::Bootstrap ? "bootstrap"
459-
: "current"));
452+
phase.batchSize = static_cast<size_t>(batchSize);
453+
phase.seed = static_cast<uint64_t>(seed);
460454
phase.multiPVPolicyTemperature =
461455
getOptionalPhaseValue<double>(*table, "multipv_policy_temperature")
462456
.value_or(defaults.multiPVPolicyTemperature);
@@ -511,10 +505,10 @@ std::vector<CurriculumPhaseInput> parseCurriculum(const std::filesystem::path &m
511505
if (recomputeInterval < 0)
512506
throw std::invalid_argument(
513507
"tuning curriculum phase recompute_interval must be nonnegative and fit size_t");
514-
phase.recomputeInterval = static_cast<size_t>(recomputeInterval);
515-
phase.localLearningRateSchedule = table->contains("learning_rate")
516-
|| table->contains("learning_rate_schedule")
517-
|| table->contains("final_learning_rate");
508+
phase.recomputeInterval = static_cast<size_t>(recomputeInterval);
509+
phase.localLearningRateSchedule =
510+
table->contains("learning_rate") || table->contains("learning_rate_schedule")
511+
|| table->contains("final_learning_rate");
518512
phase.localRecomputeSchedule = table->contains("recompute_interval");
519513
phase.projectMoveScoreAtEnd =
520514
getOptionalPhaseValue<bool>(*table, "project_move_score_at_end").value_or(false);
@@ -934,34 +928,33 @@ int Command::tuning(int argc, char *argv[])
934928
createDataset(input.validationType, input.validationPaths);
935929

936930
TuningPhase phase;
937-
phase.name = input.name;
938-
phase.trainingDataset = input.trainingDataset.get();
939-
phase.validationDataset = input.validationDataset.get();
940-
phase.epochs = input.epochs;
941-
phase.preparedCachePath = input.preparedCachePath;
942-
phase.trainDatasetFormat = datasetFormatName(input.trainingType);
943-
phase.validationDatasetFormat = datasetFormatName(input.validationType);
944-
phase.rebuildPreparedCache = input.rebuildPreparedCache;
945-
phase.boardSizeMin = input.boardSizeMin;
946-
phase.boardSizeMax = input.boardSizeMax;
947-
phase.batchSize = input.batchSize;
948-
phase.seed = input.seed;
949-
phase.trainingSemantics = input.trainingSemantics;
950-
phase.multiPVPolicyTemperature = input.multiPVPolicyTemperature;
951-
phase.multiPVPolicyEvalScale = input.multiPVPolicyEvalScale;
952-
phase.moveScoreObjective = input.moveScoreObjective;
953-
phase.tuneEval = input.tuneEval;
954-
phase.tuneMoveScore = input.tuneMoveScore;
955-
phase.trainCompactPolicy = input.trainCompactPolicy;
956-
phase.learningRate = input.learningRate;
957-
phase.finalLearningRate = input.finalLearningRate;
958-
phase.weightDecay = input.weightDecay;
959-
phase.learningRateSchedule = input.learningRateSchedule;
960-
phase.recomputeInterval = input.recomputeInterval;
931+
phase.name = input.name;
932+
phase.trainingDataset = input.trainingDataset.get();
933+
phase.validationDataset = input.validationDataset.get();
934+
phase.epochs = input.epochs;
935+
phase.preparedCachePath = input.preparedCachePath;
936+
phase.trainDatasetFormat = datasetFormatName(input.trainingType);
937+
phase.validationDatasetFormat = datasetFormatName(input.validationType);
938+
phase.rebuildPreparedCache = input.rebuildPreparedCache;
939+
phase.boardSizeMin = input.boardSizeMin;
940+
phase.boardSizeMax = input.boardSizeMax;
941+
phase.batchSize = input.batchSize;
942+
phase.seed = input.seed;
943+
phase.multiPVPolicyTemperature = input.multiPVPolicyTemperature;
944+
phase.multiPVPolicyEvalScale = input.multiPVPolicyEvalScale;
945+
phase.moveScoreObjective = input.moveScoreObjective;
946+
phase.tuneEval = input.tuneEval;
947+
phase.tuneMoveScore = input.tuneMoveScore;
948+
phase.trainCompactPolicy = input.trainCompactPolicy;
949+
phase.learningRate = input.learningRate;
950+
phase.finalLearningRate = input.finalLearningRate;
951+
phase.weightDecay = input.weightDecay;
952+
phase.learningRateSchedule = input.learningRateSchedule;
953+
phase.recomputeInterval = input.recomputeInterval;
961954
phase.localLearningRateSchedule = input.localLearningRateSchedule;
962-
phase.localRecomputeSchedule = input.localRecomputeSchedule;
963-
phase.projectMoveScoreAtEnd = input.projectMoveScoreAtEnd;
964-
phase.boardSizeWeighting = input.boardSizeWeighting;
955+
phase.localRecomputeSchedule = input.localRecomputeSchedule;
956+
phase.projectMoveScoreAtEnd = input.projectMoveScoreAtEnd;
957+
phase.boardSizeWeighting = input.boardSizeWeighting;
965958
for (const std::filesystem::path &path : input.trainingPaths)
966959
phase.trainDatasetPaths.emplace_back(path);
967960
for (const std::filesystem::path &path : input.validationPaths)

‎Rapfi/tuning/tuner.cpp‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,6 @@ Tuning::TuningConfig configForPhase(Tuning::TuningConfig config, const Tuning::T
364364
config.batchSize = *phase.batchSize;
365365
if (phase.seed)
366366
config.seed = *phase.seed;
367-
if (phase.trainingSemantics)
368-
config.trainingSemantics = *phase.trainingSemantics;
369367
if (phase.multiPVPolicyTemperature)
370368
config.multiPVPolicyTemperature = *phase.multiPVPolicyTemperature;
371369
if (phase.multiPVPolicyEvalScale)
@@ -418,7 +416,6 @@ Tuning::TuningConfig validatedCurriculumConfig(const std::vector<Tuning::TuningP
418416
throw std::invalid_argument(
419417
"tuning curricula require scaling-factor calibration at phase boundaries");
420418

421-
std::optional<Tuning::TrainingSemantics> moveScoreSemantics;
422419
for (size_t i = 0; i < phases.size(); i++) {
423420
const Tuning::TuningPhase &phase = phases[i];
424421
if (phase.name.empty())
@@ -463,12 +460,6 @@ Tuning::TuningConfig validatedCurriculumConfig(const std::vector<Tuning::TuningP
463460
if (!(phase.tuneEval || phase.tuneMoveScore))
464461
throw std::invalid_argument(
465462
"tuning curriculum phases require a value or move_score objective");
466-
if (phase.tuneMoveScore) {
467-
if (moveScoreSemantics && *moveScoreSemantics != phaseConfig.trainingSemantics)
468-
throw std::invalid_argument(
469-
"tuning curriculum move_score phases require one training semantics");
470-
moveScoreSemantics = phaseConfig.trainingSemantics;
471-
}
472463
if (!std::isfinite(phaseConfig.learningRate) || phaseConfig.learningRate <= 0)
473464
throw std::invalid_argument(
474465
"tuning curriculum phase learning rate must be finite and positive");
@@ -520,8 +511,6 @@ Tuning::TuningConfig validatedCurriculumConfig(const std::vector<Tuning::TuningP
520511
Tuning::TuningConfig layoutConfig = configForPhase(config, phases.front());
521512
layoutConfig.tuneEval = config.tuneEval;
522513
layoutConfig.tuneMoveScore = config.tuneMoveScore;
523-
if (moveScoreSemantics)
524-
layoutConfig.trainingSemantics = *moveScoreSemantics;
525514
return layoutConfig;
526515
}
527516

‎Rapfi/tuning/tuner.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ struct TuningPhase
185185
uint8_t boardSizeMax = MAX_BOARD_SIZE;
186186
std::optional<size_t> batchSize;
187187
std::optional<uint64_t> seed;
188-
std::optional<TrainingSemantics> trainingSemantics;
189188
std::optional<double> multiPVPolicyTemperature;
190189
std::optional<double> multiPVPolicyEvalScale;
191190
std::optional<MoveScoreObjective> moveScoreObjective;

0 commit comments

Comments
 (0)