Transpose ffn_down matrices for Axpy ops.
(model: LazyModel)
| 1036 | return out |
| 1037 | |
| 1038 | def postprocess_transpose(model: LazyModel) -> LazyModel: |
| 1039 | """Transpose ffn_down matrices for Axpy ops.""" |
| 1040 | out: LazyModel = {} |
| 1041 | |
| 1042 | for name, lazy_tensor in model.items(): |
| 1043 | if name.endswith(".ffn_down.weight"): |
| 1044 | out[name.replace("ffn_down", "ffn_down_t")] = lazy_tensor.transposed() |
| 1045 | else: |
| 1046 | out[name] = lazy_tensor |
| 1047 | |
| 1048 | return out |
| 1049 | |
| 1050 | def nth_multifile_path(path: Path, n: int) -> Path | None: |
| 1051 | '''Given any path belonging to a multi-file model (e.g. foo.bin.1), return |