Implémenter GRPO (Group Relative Policy Optimization), l’algorithme clé de DeepSeek-R1
GRPO élimine le besoin d’un critic séparé en utilisant des récompenses relatives intra-groupe
L’avantage est calculé par normalisation au sein d’un groupe de G trajectoires pour le même état
Appliquer au trading multi-actif sur le panier anti-biais 24 symbols
Validation multi-seed (0/1/7/42) avec edge ≥ 2σ
Pourquoi GRPO ?
Aspect
PPO
GRPO
Value function
Oui (Critic network)
Non (basé sur le groupe)
Avantage
GAE (λ-returns)
Normalisation intra-groupe
Complexité
2 réseaux
1 seul réseau
Stabilité
Clip + entropy
Clip + KL + baseline groupe
L’hypothèse GRPO : la relative performance d’une action par rapport aux alternatives au même instant est un signal plus robuste qu’une estimation absolue de valeur.
L’idée centrale de GRPO : 1. Pour chaque état, échantillonner G trajectoires (group) 2. Calculer l’avantage par normalisation intra-groupe : A_i = (R_i - mean(R)) / std(R) 3. Pas besoin de Critic — la baseline est implicite dans le groupe 4. PPO-clip + penalty KL vs old policy
print("="*70)print("VERDICT -- QC-Py-RL-06: GRPO (Group Relative Policy Optimization)")print("="*70)deltas = [r["delta_sharpe"] for r in results]mean_delta = np.mean(deltas)std_delta = np.std(deltas, ddof=1) iflen(deltas) >1elsefloat("nan")sigma_edge = mean_delta / std_delta if std_delta >1e-9elsefloat("nan")n_positive =sum(1for d in deltas if d >0)mean_port = np.mean([r["sharpe_port"] for r in results])mean_bh = np.mean([r["sharpe_bh"] for r in results])print(f"GRPO Portfolio Sharpe (mean): {mean_port:+.3f}")print(f"Equal-Weight Sharpe: {mean_bh:.3f}")print(f"Delta mean: {mean_delta:+.3f}")print(f"Sigma edge: {sigma_edge:+.2f}")print(f"Seeds positive vs EW: {n_positive}/{len(results)}")print()if sigma_edge >=2.0and n_positive >=3: verdict ="BEATS"elif n_positive ==0: verdict ="NO BEATS"else: verdict ="INCONCLUSIVE"print(f">>> VERDICT: {verdict} <<<")print()if verdict =="NO BEATS":print("GRPO (sans critic, avantage relatif intra-groupe) ne depasse pas")print("l'allocation equal-weight passive sur le panier anti-biais.")elif verdict =="INCONCLUSIVE":print("Signal partiel mais non robuste cross-seed.")else:print("GRPO capture un signal exploitable — premier BEATS de la serie !")print()print("="*70)print("RL Series Progress (#1461)")print("="*70)series = [ ("RL-1. Q-Learning Tabulaire", "NO BEATS", "PR #1581"), ("RL-2. PPO (numpy)", "NO BEATS", "PR #1583"), ("RL-3. Reward Shaping (PyTorch)", "NO BEATS", "PR #1584"), ("RL-4. Multi-Asset PPO", "NO BEATS", "PR #1585"), ("RL-5. Tactical Overlay", "NO BEATS", "PR #1587"), ("RL-6. GRPO (Group Relative)", verdict, "This PR"),]for name, v, pr in series:print(f" {name:40s} | {v:15s} | {pr}")
======================================================================
VERDICT -- QC-Py-RL-06: GRPO (Group Relative Policy Optimization)
======================================================================
GRPO Portfolio Sharpe (mean): +0.677
Equal-Weight Sharpe: 0.697
Delta mean: -0.020
Sigma edge: -1.93
Seeds positive vs EW: 0/4
>>> VERDICT: NO BEATS <<<
GRPO (sans critic, avantage relatif intra-groupe) ne depasse pas
l'allocation equal-weight passive sur le panier anti-biais.
======================================================================
RL Series Progress (#1461)
======================================================================
RL-1. Q-Learning Tabulaire | NO BEATS | PR #1581
RL-2. PPO (numpy) | NO BEATS | PR #1583
RL-3. Reward Shaping (PyTorch) | NO BEATS | PR #1584
RL-4. Multi-Asset PPO | NO BEATS | PR #1585
RL-5. Tactical Overlay | NO BEATS | PR #1587
RL-6. GRPO (Group Relative) | NO BEATS | This PR
Lecture du verdict
GRPO — avantage relatif intra-groupe, sans critic — atterrit au même plateau que l’overlay tactique : Sharpe moyen +0.677 contre 0.697 pour l’equal-weight (delta -0.020, edge -1.93σ, 0/4 graines positives). Changer l’algorithme d’optimisation ne change pas le verdict sur ce panier anti-biais ; la barre reste l’allocation passive.