(model, cal_dataset, chunk_idx: str)
| 374 | |
| 375 | |
| 376 | def calibrate_model(model, cal_dataset, chunk_idx: str): |
| 377 | with torch.no_grad(): |
| 378 | for inp in tqdm(cal_dataset, desc="Calibrating Model: "): |
| 379 | # pass prompt and response |
| 380 | for batch in tqdm(inp[chunk_idx].keys(), desc="Batch: "): |
| 381 | if inp[chunk_idx][batch] is not None: |
| 382 | inputs_embeds = torch.tensor(inp[chunk_idx][batch]["hidden_state"]) |
| 383 | mask = torch.tensor(inp[chunk_idx][batch]["mask"]) |
| 384 | pos_emb = torch.tensor(inp[chunk_idx][batch]["pos_emb"]) |
| 385 | cache = torch.tensor(inp[chunk_idx][batch]["cache"]) |
| 386 | cross_cache = torch.tensor(inp[chunk_idx][batch]["cross_cache"]) |
| 387 | model( |
| 388 | inputs_embeds, |
| 389 | mask, |
| 390 | pos_emb, |
| 391 | cross_cache, |
| 392 | *torch.split(cache, 1, dim=0), |
| 393 | ) |
| 394 | |
| 395 | |
| 396 | def export_to_et_ir( |
no test coverage detected