Expand description
Model Switch: Bidirectional lossless conversion between Safetensors and GodGraph
This module implements the Model Switch tool for converting between HuggingFace Safetensors format and GodGraph graph structure.
§Features
- Safetensors → GodGraph loading
- GodGraph → Safetensors exporting
- Topology integrity validation
- Weight precision verification (lossless check)
§Example
use god_gragh::transformer::optimization::ModelSwitch;
// Load from Safetensors
let graph = ModelSwitch::load_from_safetensors("model.safetensors")?;
// Validate topology
let report = ModelSwitch::validate_topology(&graph)?;
println!("Topology valid: {}", report.is_valid);
// Verify weights against original
let diff = ModelSwitch::verify_weights(&graph, &graph)?;
println!("Max L2 difference: {}", diff.max_l2_diff);
// Save to Safetensors
ModelSwitch::save_to_safetensors(&graph, "optimized.safetensors")?;Structs§
- Model
Switch - Model Switch: Bidirectional conversion between Safetensors and GodGraph
- Tensor
Reshape Error - Error type for tensor reshape operations
- Topology
Report - Topology validation report
- Weight
Diff - Weight difference report
- Weight
Tensor - 64-byte aligned weight tensor with stride support for efficient N-dimensional access
Enums§
- Operator
Type - Operator types for LLM computation graph nodes