()
| 804 | # --------------------------------------------------------------------------- |
| 805 | |
| 806 | def main() -> None: |
| 807 | parser = argparse.ArgumentParser( |
| 808 | description=( |
| 809 | "Export an optimized AutoKernel kernel to HuggingFace Kernels format. " |
| 810 | "Supports both CUDA C++ and Triton backends." |
| 811 | ), |
| 812 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 813 | epilog=textwrap.dedent("""\ |
| 814 | examples: |
| 815 | # Export the default kernel.py |
| 816 | uv run export_hf.py --name my_matmul |
| 817 | |
| 818 | # Export a specific kernel file with repo ID |
| 819 | uv run export_hf.py --name my_matmul --kernel workspace/kernel_matmul_1.py \\ |
| 820 | --repo-id rightnow-ai/matmul-kernel |
| 821 | |
| 822 | # Custom output directory |
| 823 | uv run export_hf.py --name my_matmul --output /tmp/hf_export/ |
| 824 | """), |
| 825 | ) |
| 826 | parser.add_argument( |
| 827 | "--name", |
| 828 | type=str, |
| 829 | required=True, |
| 830 | help=( |
| 831 | "Name for the exported kernel project. Must be a valid Python identifier " |
| 832 | "(e.g., 'my_matmul', 'fused_attention')." |
| 833 | ), |
| 834 | ) |
| 835 | parser.add_argument( |
| 836 | "--kernel", |
| 837 | type=str, |
| 838 | default=DEFAULT_KERNEL_PATH, |
| 839 | help=f"Path to the kernel file to export (default: kernel.py)", |
| 840 | ) |
| 841 | parser.add_argument( |
| 842 | "--output", |
| 843 | type=str, |
| 844 | default=DEFAULT_OUTPUT_DIR, |
| 845 | help=f"Output directory for the HF Kernels project (default: workspace/hf_export/)", |
| 846 | ) |
| 847 | parser.add_argument( |
| 848 | "--repo-id", |
| 849 | type=str, |
| 850 | default=None, |
| 851 | help=( |
| 852 | "HuggingFace repo ID (e.g., 'rightnow-ai/matmul-kernel'). " |
| 853 | "Used in documentation and usage examples." |
| 854 | ), |
| 855 | ) |
| 856 | |
| 857 | args = parser.parse_args() |
| 858 | |
| 859 | export_kernel( |
| 860 | kernel_path=args.kernel, |
| 861 | name=args.name, |
| 862 | output_dir=args.output, |
| 863 | repo_id=args.repo_id, |
no test coverage detected