ZMC2019's picture
Reorganise: group 313 tasks into 17 families under tasks/, generators under tools/ (part 10)
0f775e2 verified
Raw
History Blame Contribute Delete
1.18 kB
"""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))