File size: 1,183 Bytes
0f775e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Generate one 2-GPU `dist-*` task: run the shared factory, then apply the 2-rank hand-adaptation.

    python _dist_factory/make.py _dist_factory/specs/dist_allreduce_rmsnorm.py

`_factory/build.py` and `_factory/spec.py` are shared with other agents and are NOT modified; this driver
only calls build() and then rewrites the four files listed in _dist_factory/postgen.py.
"""
import importlib.util
import pathlib
import sys

HERE = pathlib.Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
sys.path.insert(0, str(HERE.parent / "_factory"))

from build import build            # noqa: E402  (shared factory, untouched)
from postgen import postgen        # noqa: E402


def load(path):
    path = pathlib.Path(path).resolve()
    s = importlib.util.spec_from_file_location(path.stem, path)
    m = importlib.util.module_from_spec(s)
    s.loader.exec_module(m)
    return m.SPEC


if __name__ == "__main__":
    spec = load(sys.argv[1])
    out = build(spec, out_root=HERE.parent)
    postgen(spec, out_root=HERE.parent)
    print("generated + hand-adapted", out)
    for p in sorted(out.rglob("*")):
        if p.is_file():
            print("   ", p.relative_to(out))