()
| 253 | |
| 254 | #[test] |
| 255 | fn load_index_from_json_file() { |
| 256 | let tmp = tempfile::tempdir().unwrap(); |
| 257 | let index_json = serde_json::json!({ |
| 258 | "weight_map": { |
| 259 | "model.layers.0.self_attn.q_proj.weight": "shard-00001.safetensors", |
| 260 | "model.layers.0.self_attn.k_proj.weight": "shard-00001.safetensors", |
| 261 | "model.layers.1.self_attn.q_proj.weight": "shard-00002.safetensors" |
| 262 | } |
| 263 | }); |
| 264 | fs::write( |
| 265 | tmp.path().join("model.safetensors.index.json"), |
| 266 | serde_json::to_string(&index_json).unwrap(), |
| 267 | ) |
| 268 | .unwrap(); |
| 269 | |
| 270 | let index = load_index(tmp.path()).unwrap(); |
| 271 | assert_eq!(index.weight_map.len(), 3); |
| 272 | assert_eq!( |
| 273 | index.weight_map["model.layers.0.self_attn.q_proj.weight"], |
| 274 | "shard-00001.safetensors" |
| 275 | ); |
| 276 | } |
| 277 | |
| 278 | #[test] |
| 279 | fn load_index_missing_both_files() { |
nothing calls this directly
no test coverage detected