feat(dqn): checkpoint architecture validation via safetensors metadata
Embed DQNConfig architecture hash (SHA-256 of state_dim, num_actions, hidden_dims, dueling/distributional/noisy/IQN flags) in safetensors file header on save. Validate hash on load to catch shape mismatches before touching the VarMap - prevents silent corruption from loading checkpoints trained with different network architectures. All 5 save paths (trainable_adapter, trainer serialize_model, DQNAgentType::save_checkpoint, RegimeConditionalDQN per-head) now embed metadata. All 3 load paths (DQN::load_from_safetensors, trainable_adapter::load_checkpoint, ensemble adapter) validate. No backward compatibility: checkpoints without metadata are rejected with a clear error message to re-train. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -145,6 +145,7 @@ once_cell = "1.19"
|
||||
lazy_static.workspace = true
|
||||
flate2 = "1.0"
|
||||
sha2 = "0.10"
|
||||
safetensors = "0.4" # Direct dep for checkpoint metadata (config hash validation)
|
||||
hmac = "0.12" # HMAC for checkpoint signatures (SEC-001 fix)
|
||||
hex = "0.4" # Hex encoding for signatures
|
||||
bincode = "1.3"
|
||||
|
||||
Reference in New Issue
Block a user