|
| 1 | +#!/usr/bin/env python |
| 2 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | +# All rights reserved. |
| 4 | +# |
| 5 | +# This source code is licensed under the BSD-style license found in the |
| 6 | +# LICENSE file in the root directory of this source tree. |
| 7 | + |
| 8 | +import itertools |
| 9 | +import json |
| 10 | +import os |
| 11 | +from typing import Any |
| 12 | + |
| 13 | + |
| 14 | +MODEL_REPOS = { |
| 15 | + "tinyllamas/stories15M": "https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.pt,https://github.com/karpathy/llama2.c/raw/master/tokenizer.model,https://github.com/karpathy/llama2.c/raw/master/tokenizer.bin", |
| 16 | + # "tinyllamas/stories42M": "https://huggingface.co/karpathy/tinyllamas/resolve/main/stories42M.pt,https://github.com/karpathy/llama2.c/raw/master/tokenizer.model,https://github.com/karpathy/llama2.c/raw/master/tokenizer.bin", |
| 17 | + "tinyllamas/stories110M": "https://huggingface.co/karpathy/tinyllamas/resolve/main/stories110M.pt,https://github.com/karpathy/llama2.c/raw/master/tokenizer.model,https://github.com/karpathy/llama2.c/raw/master/tokenizer.bin", |
| 18 | +} |
| 19 | + |
| 20 | +JOB_RUNNERS = { |
| 21 | + "32-core-ubuntu": "linux x86", |
| 22 | + "macos-12": "macos x86", |
| 23 | + "macos-14": "macos M1", |
| 24 | +} |
| 25 | + |
| 26 | + |
| 27 | +def set_output(name: str, val: Any) -> None: |
| 28 | + """ |
| 29 | + Set the GitHb output so that it can be accessed by other jobs |
| 30 | + """ |
| 31 | + print(f"Setting {val} to GitHub output") |
| 32 | + |
| 33 | + if os.getenv("GITHUB_OUTPUT"): |
| 34 | + with open(str(os.getenv("GITHUB_OUTPUT")), "a") as env: |
| 35 | + print(f"{name}={val}", file=env) |
| 36 | + else: |
| 37 | + print(f"::set-output name={name}::{val}") |
| 38 | + |
| 39 | + |
| 40 | +def export_models_for_ci() -> dict[str, dict]: |
| 41 | + """ |
| 42 | + This gathers all the models that we want to test on GitHub OSS CI |
| 43 | + """ |
| 44 | + |
| 45 | + # This is the JSON syntax for configuration matrix used by GitHub |
| 46 | + # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs |
| 47 | + models = {"include": []} |
| 48 | + |
| 49 | + for repo_name, runner in itertools.product( |
| 50 | + MODEL_REPOS.keys(), |
| 51 | + JOB_RUNNERS.keys(), |
| 52 | + ): |
| 53 | + record = { |
| 54 | + "repo_name": repo_name, |
| 55 | + "resources": MODEL_REPOS[repo_name], |
| 56 | + "runner": runner, |
| 57 | + "platform": JOB_RUNNERS[runner], |
| 58 | + "timeout": 90, |
| 59 | + } |
| 60 | + |
| 61 | + models["include"].append(record) |
| 62 | + |
| 63 | + set_output("models", json.dumps(models)) |
| 64 | + |
| 65 | + |
| 66 | +if __name__ == "__main__": |
| 67 | + export_models_for_ci() |
0 commit comments