Add 11 financial fields (sharpe, sortino, win_rate, max_drawdown, profit_factor, total_return, avg_return, total_trades, action distribution) to TrainingSession (fields 36-46), a new GetEpochHistory RPC with request/response messages, and wire the Prometheus metric mapping in the monitoring service with a stub RPC handler for task 7. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
141 lines
3.4 KiB
Protocol Buffer
141 lines
3.4 KiB
Protocol Buffer
syntax = "proto3";
|
|
package monitoring;
|
|
|
|
service MonitoringService {
|
|
// Single snapshot of all active training sessions
|
|
rpc GetLiveTrainingMetrics(GetLiveTrainingMetricsRequest)
|
|
returns (GetLiveTrainingMetricsResponse);
|
|
|
|
// Server-streaming: pushes updates every N seconds
|
|
rpc StreamTrainingMetrics(StreamTrainingMetricsRequest)
|
|
returns (stream GetLiveTrainingMetricsResponse);
|
|
|
|
// Epoch history for a specific session (ring buffer, max 50 epochs)
|
|
rpc GetEpochHistory(GetEpochHistoryRequest)
|
|
returns (GetEpochHistoryResponse);
|
|
}
|
|
|
|
message GetLiveTrainingMetricsRequest {
|
|
string model_filter = 1; // optional: "dqn", "ppo", etc.
|
|
}
|
|
|
|
message StreamTrainingMetricsRequest {
|
|
string model_filter = 1;
|
|
uint32 interval_seconds = 2; // 0 = server default (3s)
|
|
}
|
|
|
|
message GetLiveTrainingMetricsResponse {
|
|
repeated TrainingSession sessions = 1;
|
|
GpuSnapshot gpu = 2;
|
|
uint32 active_k8s_jobs = 3;
|
|
int64 timestamp = 4;
|
|
}
|
|
|
|
message TrainingSession {
|
|
string model = 1;
|
|
string fold = 2;
|
|
bool is_hyperopt = 3;
|
|
|
|
// Epoch/progress
|
|
float current_epoch = 4;
|
|
float epoch_loss = 5;
|
|
float validation_loss = 6;
|
|
|
|
// Throughput
|
|
float batches_per_second = 7;
|
|
float batches_processed = 8;
|
|
float iteration_seconds = 9;
|
|
|
|
// Eval metrics
|
|
float eval_accuracy = 10;
|
|
float eval_precision = 11;
|
|
float eval_recall = 12;
|
|
float eval_f1 = 13;
|
|
|
|
// Checkpoint
|
|
float checkpoint_size_bytes = 14;
|
|
uint32 checkpoint_saves = 15;
|
|
uint32 checkpoint_failures = 16;
|
|
|
|
// Health counters
|
|
uint32 nan_detected = 17;
|
|
uint32 gradient_explosions = 18;
|
|
uint32 feature_errors = 19;
|
|
|
|
// Hyperopt fields (populated when is_hyperopt=true)
|
|
uint32 hyperopt_trial_current = 20;
|
|
uint32 hyperopt_trial_total = 21;
|
|
float hyperopt_best_objective = 22;
|
|
uint32 hyperopt_trials_failed = 23;
|
|
|
|
// RL diagnostics
|
|
float q_value_mean = 24;
|
|
float q_value_max = 25;
|
|
float policy_entropy = 26;
|
|
float kl_divergence = 27;
|
|
float advantage_mean = 28;
|
|
uint32 replay_buffer_size = 29;
|
|
|
|
// Gradient & training health
|
|
float gradient_norm = 30;
|
|
float learning_rate = 31;
|
|
float epoch_duration_seconds = 32;
|
|
|
|
// Hyperopt intra-trial
|
|
uint32 hyperopt_trial_epoch = 33;
|
|
float hyperopt_trial_best_loss = 34;
|
|
float hyperopt_elapsed_seconds = 35;
|
|
|
|
// Epoch-level financial metrics
|
|
float epoch_sharpe = 36;
|
|
float epoch_sortino = 37;
|
|
float epoch_win_rate = 38;
|
|
float epoch_max_drawdown = 39;
|
|
float epoch_profit_factor = 40;
|
|
float epoch_total_return = 41;
|
|
float epoch_avg_return = 42;
|
|
uint32 epoch_total_trades = 43;
|
|
// Action distribution
|
|
float action_buy_pct = 44;
|
|
float action_sell_pct = 45;
|
|
float action_hold_pct = 46;
|
|
}
|
|
|
|
message GpuSnapshot {
|
|
float utilization_percent = 1;
|
|
float memory_used_mb = 2;
|
|
float memory_total_mb = 3;
|
|
float temperature_celsius = 4;
|
|
float power_watts = 5;
|
|
}
|
|
|
|
message GetEpochHistoryRequest {
|
|
string model = 1;
|
|
string fold = 2;
|
|
uint32 max_epochs = 3; // 0 = all (up to 50)
|
|
}
|
|
|
|
message EpochFinancialSnapshot {
|
|
uint32 epoch = 1;
|
|
float sharpe = 2;
|
|
float sortino = 3;
|
|
float win_rate = 4;
|
|
float max_drawdown = 5;
|
|
float profit_factor = 6;
|
|
float total_return = 7;
|
|
float avg_return = 8;
|
|
uint32 total_trades = 9;
|
|
float loss = 10;
|
|
float val_loss = 11;
|
|
float learning_rate = 12;
|
|
float action_buy_pct = 13;
|
|
float action_sell_pct = 14;
|
|
float action_hold_pct = 15;
|
|
}
|
|
|
|
message GetEpochHistoryResponse {
|
|
string model = 1;
|
|
string fold = 2;
|
|
repeated EpochFinancialSnapshot epochs = 3;
|
|
}
|