diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md deleted file mode 100644 index 233768d52a..0000000000 --- a/CONTRIBUTORS.md +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - -# How to Contribute - -We'd love to accept your patches and contributions to this project. There are -just a few small guidelines you need to follow. - -## Contributor License Agreement - -Contributions to this project must be accompanied by a Contributor License -Agreement. You (or your employer) retain the copyright to your contribution; -this simply gives us permission to use and redistribute your contributions as -part of the project. - -You generally only need to submit a CLA once, so if you've already submitted one -(even if it was for a different project), you probably don't need to do it -again. - -## Changes Accepted - -Please file issues before doing substantial work; this will ensure that others -don't duplicate the work and that there's a chance to discuss any design issues. - -Changes only tweaking style are unlikely to be accepted unless they are applied -consistently across the project. Most of the code style is derived from the -[Google Style Guides](http://google.github.io/styleguide/) for the appropriate -language and is generally not something we accept changes on (as clang-format -and clang-tidy handle that for us). The compiler portion of the project follows -[MLIR style](https://mlir.llvm.org/getting_started/DeveloperGuide/#style-guide). -Improvements to code structure and clarity are welcome but please file issues to -track such work first. - -## AUTHORS file - -If you would like to receive additional recognition for your contribution, you -may add yourself (or your organization) to the AUTHORS file. This keeps track of -those who have made significant contributions to the project. Please add the -entity who owns the copyright for your contribution. The source control history -remains the most accurate source for individual contributions. - -## Pull Requests -We actively welcome your pull requests. - -1. Fork the repo and create your branch from `main`. -2. If you've added code that should be tested, add tests. -3. If you've changed APIs, update the documentation. -4. Ensure the test suite passes. -5. Make sure your code lints. -6. If you haven't already, complete the Contributor License Agreement ("CLA"). - -## Issues - -We use GitHub issues to track public bugs. Please ensure your description is -clear and has sufficient instructions to be able to reproduce the issue. - diff --git a/README.md b/README.md index bc58270702..5db67b52f3 100644 --- a/README.md +++ b/README.md @@ -41,10 +41,10 @@ FLUX_FINAL_RELEASE=0 ./build.sh --arch 80 --package PYTHONPATH=./python:$PYTHONPATH python3 test/test_gemm_only.py 4096 12288 6144 --dtype=float16 # gemm fused with reduce-scatter -./launch.sh test/test_gemm_rs.py 4096 12288 49152 --dtype=float16 --iters=10 +./scripts/launch.sh test/test_gemm_rs.py 4096 12288 49152 --dtype=float16 --iters=10 # all-gather fused with gemm -./launch.sh test/test_ag_kernel.py 4096 49152 12288 --dtype=float16 --iters=10 +./scripts/launch.sh test/test_ag_kernel.py 4096 49152 12288 --dtype=float16 --iters=10 ``` diff --git a/gen_version.py b/gen_version.py deleted file mode 100644 index c551d7863c..0000000000 --- a/gen_version.py +++ /dev/null @@ -1,114 +0,0 @@ -################################################################################ -# -# Copyright 2023 ByteDance Ltd. and/or its affiliates. All rights reserved. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -################################################################################ - -import argparse -import os -import subprocess -from pathlib import Path -import shutil -import re -from typing import Optional, Tuple - -CUR_DIR = os.path.dirname(os.path.realpath(__file__)) - - -def _check_env_option(opt, default=""): - return os.getenv(opt, default).upper() in ["ON", "1", "YES", "TRUE"] - - -def check_final_release(): - return _check_env_option("FLUX_FINAL_RELEASE", "1") - - -def get_git_commit(src_dir): - try: - return ( - subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=src_dir) - .decode("ascii") - .strip() - ) - except Exception: - return "unknown" - - -def cuda_version() -> Tuple[int, ...]: - """CUDA Toolkit version as a (major, minor) by nvcc --version""" - - # Try finding NVCC - nvcc_bin: Optional[Path] = None - if nvcc_bin is None and os.getenv("CUDA_HOME"): - # Check in CUDA_HOME - cuda_home = Path(os.getenv("CUDA_HOME")) - nvcc_bin = cuda_home / "bin" / "nvcc" - if nvcc_bin is None: - # Check if nvcc is in path - nvcc_bin = shutil.which("nvcc") - if nvcc_bin is not None: - nvcc_bin = Path(nvcc_bin) - if nvcc_bin is None: - # Last-ditch guess in /usr/local/cuda - cuda_home = Path("/usr/local/cuda") - nvcc_bin = cuda_home / "bin" / "nvcc" - if not nvcc_bin.is_file(): - raise FileNotFoundError(f"Could not find NVCC at {nvcc_bin}") - - # Query NVCC for version info - output = subprocess.run( - [nvcc_bin, "-V"], - capture_output=True, - check=True, - universal_newlines=True, - ) - match = re.search(r"release\s*([\d.]+)", output.stdout) - version = match.group(1).split(".") - return tuple(int(v) for v in version) - - -def get_flux_version(version_txt, *, dev=False): - with open(version_txt) as f: - version = f.readline() - version = version.strip() - cuda_version_major, cuda_version_minor = cuda_version() - version = version + f"+cu{cuda_version_major}{cuda_version_minor}" - if dev: - commit_id = get_git_commit(CUR_DIR) - - version += ".dev{}".format(commit_id[:8]) - # version = version + (f'.{os.getenv("ARCH")}' if os.getenv("ARCH") else "") - return version - - -def generate_versoin_file(version_txt, version_file, *, dev=False): - flux_ver = get_flux_version(version_txt, dev=dev) - - with open(version_file, "w") as f: - f.write("__version__ = '{}'\n".format(flux_ver)) - f.write("git_version = {}\n".format(repr(get_git_commit(CUR_DIR)))) - cuda_version_major, cuda_version_minor = cuda_version() - f.write("cuda = {}.{}\n".format(cuda_version_major, cuda_version_minor)) - - return flux_ver - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="generate version.py") - parser.add_argument("--input", type=str, required=True) - parser.add_argument("--output", type=str, required=True) - parser.add_argument("--dev", action="store_true") - args = parser.parse_args() - - generate_versoin_file(args.input, args.output, dev=args.dev) diff --git a/python/flux/__init__.py b/python/flux/__init__.py index 30dea49398..a56d62674d 100644 --- a/python/flux/__init__.py +++ b/python/flux/__init__.py @@ -15,6 +15,9 @@ # ################################################################################ +# version info +__version__ = "1.0.0" + from .cpp_mod import * from .ag_gemm import * diff --git a/launch.sh b/scripts/launch.sh similarity index 100% rename from launch.sh rename to scripts/launch.sh diff --git a/setup.py b/setup.py index 7d0a58df80..3221050cfa 100644 --- a/setup.py +++ b/setup.py @@ -18,20 +18,101 @@ import glob import os import re +import shutil +import subprocess from pathlib import Path +from typing import Optional, Tuple import setuptools from torch.utils.cpp_extension import BuildExtension -from gen_version import generate_versoin_file, check_final_release +CUR_DIR = os.path.dirname(os.path.realpath(__file__)) + + +def _check_env_option(opt, default=""): + return os.getenv(opt, default).upper() in ["ON", "1", "YES", "TRUE"] + + +def check_final_release(): + return _check_env_option("FLUX_FINAL_RELEASE", "1") + + +def get_git_commit(src_dir): + try: + return ( + subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=src_dir) + .decode("ascii") + .strip() + ) + except Exception: + return "unknown" + + +def cuda_version() -> Tuple[int, ...]: + """CUDA Toolkit version as a (major, minor) by nvcc --version""" + + # Try finding NVCC + nvcc_bin: Optional[Path] = None + if nvcc_bin is None and os.getenv("CUDA_HOME"): + # Check in CUDA_HOME + cuda_home = Path(os.getenv("CUDA_HOME")) + nvcc_bin = cuda_home / "bin" / "nvcc" + if nvcc_bin is None: + # Check if nvcc is in path + nvcc_bin = shutil.which("nvcc") + if nvcc_bin is not None: + nvcc_bin = Path(nvcc_bin) + if nvcc_bin is None: + # Last-ditch guess in /usr/local/cuda + cuda_home = Path("/usr/local/cuda") + nvcc_bin = cuda_home / "bin" / "nvcc" + if not nvcc_bin.is_file(): + raise FileNotFoundError(f"Could not find NVCC at {nvcc_bin}") + + # Query NVCC for version info + output = subprocess.run( + [nvcc_bin, "-V"], + capture_output=True, + check=True, + universal_newlines=True, + ) + match = re.search(r"release\s*([\d.]+)", output.stdout) + version = match.group(1).split(".") + return tuple(int(v) for v in version) + + +def get_flux_version(version_info, *, dev=False): + with open(version_info) as f: + (version,) = re.findall('__version__ = "(.*)"', f.read()) + cuda_version_major, cuda_version_minor = cuda_version() + version = version + f"+cu{cuda_version_major}{cuda_version_minor}" + if dev: + commit_id = get_git_commit(CUR_DIR) + + version += ".dev{}".format(commit_id[:8]) + # version = version + (f'.{os.getenv("ARCH")}' if os.getenv("ARCH") else "") + return version + + +def generate_versoin_file(version, version_file, *, dev=False): + flux_ver = get_flux_version(version, dev=dev) + + with open(version_file, "w") as f: + f.write("__version__ = '{}'\n".format(flux_ver)) + f.write("git_version = {}\n".format(repr(get_git_commit(CUR_DIR)))) + cuda_version_major, cuda_version_minor = cuda_version() + f.write("cuda = {}.{}\n".format(cuda_version_major, cuda_version_minor)) + + return flux_ver + # Project directory root root_path: Path = Path(__file__).resolve().parent -version_txt = os.path.join(root_path, "version.txt") +version = os.path.join(root_path, "python/flux/__init__.py") version_file = os.path.join(root_path, "python/flux/version.py") is_dev = not check_final_release() -flux_version = generate_versoin_file(version_txt, version_file, dev=is_dev) +flux_version = generate_versoin_file(version, version_file, dev=is_dev) def pathlib_wrapper(func): diff --git a/version.txt b/version.txt deleted file mode 100644 index 3eefcb9dd5..0000000000 --- a/version.txt +++ /dev/null @@ -1 +0,0 @@ -1.0.0