Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
cbalioglu committed Dec 11, 2023
1 parent 73cdf45 commit ea9ff46
Show file tree
Hide file tree
Showing 226 changed files with 91 additions and 101 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/_build_doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
steps:
- name: Check-out the repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Create the Python virtual environment
run: |
python${{ inputs.py }} -m venv ~/venv
Expand All @@ -41,17 +43,21 @@ jobs:
torch==${{ inputs.torch }}
- name: Install requirements
run: |
pip install --requirement fairseq2n/python/requirements-build.txt
pip install --requirement native/python/requirements-build.txt
- name: Install Sphinx
run: |
pip install --requirement doc/requirements.txt
- name: Override project version
if: inputs.version_override
run: |
tools/set-project-version.sh ${{ inputs.version_override }}
- name: Configure fairseq2n
working-directory: native
run: |
cmake -GNinja -B build
- name: Install fairseq2n
run: |
pip install --editable fairseq2n/python
pip install --editable native/python
- name: Install fairseq2
run: |
pip install --editable .
Expand Down
20 changes: 9 additions & 11 deletions .github/workflows/_build_wheel-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
torch==${{ inputs.torch }}
- name: Install requirements
run: |
pip install --requirement fairseq2n/python/requirements-build.txt
pip install --requirement native/python/requirements-build.txt
- name: Override project version
if: inputs.version_override
run: |
Expand All @@ -83,7 +83,7 @@ jobs:
tools/set-project-version.sh $version+$VARIANT
fi
- name: Build fairseq2n
working-directory: fairseq2n
working-directory: native
env:
VARIANT: ${{ inputs.variant }}
SANITIZERS: ${{ inputs.sanitizers }}
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
cmake --build build
- name: Package fairseq2n
working-directory: fairseq2n/python
working-directory: native/python
run: |
pip wheel\
--use-pep517\
Expand All @@ -141,8 +141,8 @@ jobs:
name: ${{ inputs.artifacts_name }}-pt${{ inputs.torch }}-py${{ inputs.py }}-linux_${{ inputs.arch }}-${{ inputs.variant }}-${{ inputs.sanitizers }}
path: |
build/wheelhouse/*.whl
fairseq2n/build/tests/run-tests
fairseq2n/python/build/wheelhouse/*.whl
native/build/tests/run-tests
native/python/build/wheelhouse/*.whl
retention-days: 1

test:
Expand Down Expand Up @@ -185,9 +185,7 @@ jobs:
fi
- name: Install fairseq2n
run: |
whl=$(ls ~/artifacts/fairseq2n/python/build/wheelhouse/*.whl)
pip install --no-cache-dir "fairseq2n@file://$whl"
pip install --no-cache-dir ~/artifacts/native/python/build/wheelhouse/*.whl
- name: Install fairseq2
run: |
whl=$(ls ~/artifacts/build/wheelhouse/*.whl)
Expand All @@ -204,7 +202,7 @@ jobs:
# in non-instrumented dependencies.
echo ASAN_OPTIONS=detect_container_overflow=0
echo LSAN_OPTIONS=suppressions=fairseq2n/LSan.supp,exitcode=0,log_path=$HOME/lsan.out
echo LSAN_OPTIONS=suppressions=native/LSan.supp,exitcode=0,log_path=$HOME/lsan.out
for sanitizer in ${SANITIZERS//_/ }; do
# LIBASAN and LIBTSAN environment variables are defined in the
Expand All @@ -225,12 +223,12 @@ jobs:
} >> "$GITHUB_ENV"
- name: Run native tests
run: |
chmod 755 ~/artifacts/fairseq2n/build/tests/run-tests
chmod 755 ~/artifacts/native/build/tests/run-tests
site_packages=~/venv/lib/python${{ inputs.py }}/site-packages
LD_LIBRARY_PATH=~/venv/lib:$site_packages/torch/lib:$site_packages/fairseq2n/lib:$LD_LIBRARY_PATH\
~/artifacts/fairseq2n/build/tests/run-tests
~/artifacts/native/build/tests/run-tests
- name: Run Python tests
env:
RUN_INTEGRATION_TESTS: ${{ inputs.run_integration_tests }}
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/_build_wheel-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ jobs:
pip install torch==${{ inputs.torch }}
- name: Install requirements
run: |
pip install --requirement fairseq2n/python/requirements-build.txt
pip install --requirement native/python/requirements-build.txt
- name: Override project version
if: inputs.version_override
run: |
tools/set-project-version.sh ${{ inputs.version_override }}
- name: Build fairseq2n
working-directory: fairseq2n
working-directory: native
run: |
cmake\
-GNinja\
Expand All @@ -69,7 +69,7 @@ jobs:
cmake --build build
- name: Package fairseq2n
working-directory: fairseq2n/python
working-directory: native/python
run: |
pip wheel\
--use-pep517\
Expand All @@ -86,8 +86,8 @@ jobs:
name: ${{ inputs.artifacts_name }}-pt${{ inputs.torch }}-py${{ inputs.py }}-macos_${{ inputs.arch }}-cpu
path: |
build/wheelhouse/*.whl
fairseq2n/build/tests/run-tests
fairseq2n/python/build/wheelhouse/*.whl
native/build/tests/run-tests
native/python/build/wheelhouse/*.whl
retention-days: 1

test:
Expand Down Expand Up @@ -121,16 +121,16 @@ jobs:
pip install --requirement requirements-devel.txt
- name: Install fairseq2n
run: |
pip install --no-cache-dir ~/artifacts/fairseq2n/python/build/wheelhouse/*.whl
pip install --no-cache-dir ~/artifacts/native/python/build/wheelhouse/*.whl
- name: Install fairseq2
run: |
pip install --no-cache-dir ~/artifacts/build/wheelhouse/*.whl
- name: Run native tests
run: |
chmod 755 ~/artifacts/fairseq2n/build/tests/run-tests
chmod 755 ~/artifacts/native/build/tests/run-tests
DYLD_LIBRARY_PATH=~/venv/lib:~/venv/lib/python${{ inputs.py }}/site-packages/torch/lib:~/venv/lib/python${{ inputs.py }}/site-packages/fairseq2n/lib\
~/artifacts/fairseq2n/build/tests/run-tests
~/artifacts/native/build/tests/run-tests
- name: Run Python tests
run: |
pytest -rP --verbose
13 changes: 8 additions & 5 deletions .github/workflows/_lint_cc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 2
- name: Create the Python virtual environment
run: |
python${{ inputs.py }} -m venv ~/venv
Expand All @@ -41,19 +40,23 @@ jobs:
torch==${{ inputs.torch }}\
- name: Install requirements
run: |
pip install --requirement fairseq2n/python/requirements-build.txt
pip install --requirement native/python/requirements-build.txt
- name: Build the compilation database
id: setup
working-directory: fairseq2n
working-directory: native
run: |
# Since we are only building the compilation database, we can ignore
# CUDA compatibility.
export CUDAFLAGS="--allow-unsupported-compiler"
CC=clang CXX=clang++ cmake -GNinja -DCMAKE_BUILD_TYPE=Release -B build
# TODO: set FAIRSEQ2N_USE_CUDA once lint issues are fixed.
CC=clang CXX=clang++ cmake\
-GNinja -DFAIRSEQ2N_PYTHON_DEVEL=OFF -B build
cmake --build build
- name: Run clang-tidy
if: success() || (failure() && steps.setup.outcome == 'success')
working-directory: fairseq2n
working-directory: native
run: |
echo "::add-matcher::./ci/problem-matchers/gcc.json"
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/_lint_py.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
steps:
- name: Check-out the repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Create the Python virtual environment
run: |
python${{ inputs.py }} -m venv ~/venv
Expand All @@ -38,12 +40,16 @@ jobs:
torch==${{ inputs.torch }}
- name: Install requirements
run: |
pip install --requirement fairseq2n/python/requirements-build.txt
pip install --requirement native/python/requirements-build.txt
pip install --requirement requirements-devel.txt
- name: Configure fairseq2n
working-directory: native
run: |
cmake -GNinja -B build
- name: Install fairseq2n
run: |
pip install --editable fairseq2n/python
pip install --editable native/python
- name: Install fairseq2
id: install_fairseq2
run: |
Expand Down Expand Up @@ -100,7 +106,6 @@ jobs:
trap remove_matcher EXIT
mypy
mypy setup.py
mypy fairseq2n/python/setup.py
mypy native/python
mypy recipes/llama
mypy recipes/mistral
2 changes: 1 addition & 1 deletion .github/workflows/_publish_pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Publish fairseq2n
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: artifacts/fairseq2n/python/build/wheelhouse
packages-dir: artifacts/native/python/build/wheelhouse
- name: Publish fairseq2
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_publish_s3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
echo S3_PREFIX=$s3_prefix >> "$GITHUB_ENV"
- name: Upload wheel
run: |
for pkg in ~/artifacts/fairseq2n/python/build/wheelhouse/*.whl; do
for pkg in ~/artifacts/native/python/build/wheelhouse/*.whl; do
aws s3 cp "$pkg" s3://$S3_BUCKET/$S3_PREFIX/fairseq2n/
done
Expand Down
14 changes: 7 additions & 7 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
[submodule "third-party/pybind11"]
path = fairseq2n/third-party/pybind11
path = native/third-party/pybind11
url = https://github.com/pybind/pybind11.git
ignore = dirty
[submodule "third-party/fmt"]
path = fairseq2n/third-party/fmt
path = native/third-party/fmt
url = https://github.com/fmtlib/fmt.git
ignore = dirty
[submodule "third-party/gtest"]
path = fairseq2n/third-party/gtest
path = native/third-party/gtest
url = https://github.com/google/googletest.git
ignore = dirty
[submodule "third-party/sentencepiece"]
path = fairseq2n/third-party/sentencepiece
path = native/third-party/sentencepiece
url = https://github.com/google/sentencepiece.git
ignore = dirty
[submodule "third-party/zip"]
path = fairseq2n/third-party/zip
path = native/third-party/zip
url = https://github.com/kuba--/zip.git
ignore = dirty
[submodule "third-party/kaldi-native-fbank"]
path = fairseq2n/third-party/kaldi-native-fbank
path = native/third-party/kaldi-native-fbank
url = https://github.com/csukuangfj/kaldi-native-fbank.git
ignore = dirty
[submodule "fairseq2n/third-party/libpng"]
path = fairseq2n/third-party/libpng
path = native/third-party/libpng
url = https://github.com/glennrp/libpng.git
ignore = dirty
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

import fairseq2n.config
import fairseq2n

fairseq2n.config.DOC_MODE = True
fairseq2n.DOC_MODE = True

import fairseq2

Expand Down
13 changes: 0 additions & 13 deletions fairseq2n/python/src/fairseq2n/config.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ endif()

if(FAIRSEQ2N_USE_CUDA)
set(USES_CUDA "True")

set(CUDA_VERSION "(${CUDAToolkit_VERSION_MAJOR}, ${CUDAToolkit_VERSION_MINOR})")
else()
set(USES_CUDA "False")

set(CUDA_VERSION "None")
endif()

configure_file(config.py.in ${CMAKE_CURRENT_SOURCE_DIR}/config.py @ONLY)
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
from pathlib import Path
from typing import TYPE_CHECKING, List, Optional, Tuple

from fairseq2n.config import _SUPPORTS_CUDA, _SUPPORTS_IMAGE, DOC_MODE
from fairseq2n.config import _CUDA_VERSION, _SUPPORTS_CUDA, _SUPPORTS_IMAGE

__version__ = "0.2.1.dev0"

# Indicates whether we are run under Sphinx.
DOC_MODE = False


# Keeps the shared libraries that we load using our own extended lookup logic
# in memory.
Expand Down Expand Up @@ -116,10 +119,16 @@ def _check_cuda_runtime() -> None:
if not _SUPPORTS_CUDA:
return

assert _CUDA_VERSION is not None

major_cuda_ver, minor_cuda_ver = _CUDA_VERSION

libcudart = _load_shared_library("libcudart.so")
if libcudart is None:
cuda = f"CUDA {major_cuda_ver}.{minor_cuda_ver}"

raise OSError(
"fairseq2 is built with CUDA, but the CUDA runtime cannot be found. Either install the CUDA Toolkit or a CPU-only version of fairseq2 (see https://github.com/facebookresearch/fairseq2#variants)."
f"fairseq2 is built with {cuda}, but {cuda} runtime cannot be found on your system. Either install {cuda} Toolkit or a CPU-only version of fairseq2 (see https://github.com/facebookresearch/fairseq2#variants)."
)


Expand All @@ -138,7 +147,7 @@ def get_include() -> Path:

def get_cmake_prefix_path() -> Path:
"""Return the directory that contains fairseq2n CMake package."""
return Path(__file__).parent.joinpath("lib", "cmake")
return Path(__file__).parent.joinpath("lib/cmake")


def supports_image() -> bool:
Expand All @@ -151,14 +160,10 @@ def supports_cuda() -> bool:
return _SUPPORTS_CUDA


if TYPE_CHECKING or DOC_MODE:

def cuda_version() -> Optional[Tuple[int, int]]:
"""Return the version of CUDA that fairseq2n supports.
:returns:
The major and minor version segments.
"""
def cuda_version() -> Optional[Tuple[int, int]]:
"""Return the version of CUDA that fairseq2n supports.
else:
from fairseq2n.bindings import cuda_version as cuda_version
:returns:
The major and minor version segments.
"""
return _CUDA_VERSION
Loading

0 comments on commit ea9ff46

Please sign in to comment.