Buckets:
| #!/usr/bin/env python3 | |
| """Convert the latest Megatron checkpoint to HuggingFace DepthDelta (bf16).""" | |
| from __future__ import annotations | |
| import argparse | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| if str(ROOT) not in sys.path: | |
| sys.path.insert(0, str(ROOT)) | |
| TRAINING_BASELINE = ROOT / "training" / "baseline" | |
| if str(TRAINING_BASELINE) not in sys.path: | |
| sys.path.insert(0, str(TRAINING_BASELINE)) | |
| from utils.megatron_launcher import load_config | |
| from utils.paths import resolve | |
| def export_checkpoint( | |
| config_path: Path, | |
| *, | |
| checkpoint_root: Path | None = None, | |
| output_dir: Path | None = None, | |
| iteration: int | None = None, | |
| ) -> Path: | |
| config = load_config(config_path) | |
| if config["model"].get("attention_variant") == "depth_delta": | |
| from training.depth_delta.hf.export import export_depth_delta | |
| else: | |
| from depth_delta.export import export_depth_delta | |
| return export_depth_delta( | |
| model_cfg=config["model"], | |
| export_cfg=config.get("export", {}), | |
| paths=config["paths"], | |
| resolve_path=resolve, | |
| checkpoint_root=checkpoint_root, | |
| output_dir=output_dir, | |
| iteration=iteration, | |
| ) | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument( | |
| "--config", | |
| type=Path, | |
| default=ROOT / "training" / "baseline" / "config.toml", | |
| ) | |
| parser.add_argument("--checkpoint-root", type=Path) | |
| parser.add_argument("--output-dir", type=Path) | |
| parser.add_argument("--iteration", type=int) | |
| args = parser.parse_args() | |
| export_checkpoint( | |
| args.config.resolve(), | |
| checkpoint_root=args.checkpoint_root, | |
| output_dir=args.output_dir, | |
| iteration=args.iteration, | |
| ) | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 1.84 kB
- Xet hash:
- 195c8fd7b13f8c89a85a104f96432b54a89350d2152ead2edde89eac53b79085
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.