Skip to main content

Module switch

Module switch 

Source
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§

ModelSwitch
Model Switch: Bidirectional conversion between Safetensors and GodGraph
TensorReshapeError
Error type for tensor reshape operations
TopologyReport
Topology validation report
WeightDiff
Weight difference report
WeightTensor
64-byte aligned weight tensor with stride support for efficient N-dimensional access

Enums§

OperatorType
Operator types for LLM computation graph nodes