diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml new file mode 100644 index 0000000..58a733a --- /dev/null +++ b/.github/workflows/python-test.yml @@ -0,0 +1,51 @@ +name: Python Test + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.8', '3.11', '3.x'] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y graphviz make g++ + + - name: Upgrade pip and basic tools + run: | + python -m pip install --upgrade pip + pip install wheel setuptools + + - name: Build and install Accelergy submodules + run: ./scripts/setup_submodules.sh + + - name: Install TransInferSim + run: pip install . + + - name: Run example.py + run: python example.py + + - name: Upload stats output + uses: actions/upload-artifact@v4 + if: always() + with: + name: stats-output-python-${{ matrix.python-version }} + path: stats_out.txt + if-no-files-found: warn diff --git a/README.md b/README.md index 961ec91..d338746 100755 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ git clone --recurse-submodules https://github.com/ehw-fit/TransInferSim cd TransInferSim python3 -m venv venv source venv/bin/activate -pip install --upgrade pip -pip install wheel setuptools +pip install --upgrade pip wheel setuptools +./scripts/setup_submodules.sh pip install . ``` diff --git a/analyzer/model_architectures/transformers/layers/__init__.py b/analyzer/model_architectures/transformers/layers/__init__.py index 2b1c12e..f928082 100755 --- a/analyzer/model_architectures/transformers/layers/__init__.py +++ b/analyzer/model_architectures/transformers/layers/__init__.py @@ -10,8 +10,4 @@ from .multi_head_latent_attention import MultiHeadLatentAttention - - from .test import Test - -from .test2 import Test2 \ No newline at end of file diff --git a/example.py b/example.py index 3e753bd..3db0658 100755 --- a/example.py +++ b/example.py @@ -111,9 +111,9 @@ """ METRICS RETRIEVAL """ # NOTE: To see the contents of individual memories (per-tensor read/write log data) turn to True, but it may generate a lot of details stats = accelerator.get_statistics(log_mem_contents=False) - GenericAccelerator.pretty_print_stats(stats, verbose=False, file_path="stats_out_1.txt") + GenericAccelerator.pretty_print_stats(stats, verbose=False, file_path="stats_out.txt") - analyzer.reset() - analyzer.run_simulation_analysis(verbose=False, permutation_seed=42, scheduling_seed=None, engine_type="static") - stats = accelerator.get_statistics(log_mem_contents=False) - GenericAccelerator.pretty_print_stats(stats, verbose=False, file_path="stats_out_2.txt") + #analyzer.reset() + #analyzer.run_simulation_analysis(verbose=False, permutation_seed=42, scheduling_seed=None, engine_type="static") + #stats = accelerator.get_statistics(log_mem_contents=False) + #GenericAccelerator.pretty_print_stats(stats, verbose=False, file_path="stats_out_2.txt") diff --git a/requirements.txt b/requirements.txt index 39fe78d..78b7075 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ graphviz==0.20.3 -numpy==1.26.4 # for Python 3.12 -PyYAML==6.0.2 +numpy>=1.24,<2.0 +PyYAML>=6.0 \ No newline at end of file diff --git a/scripts/setup_submodules.sh b/scripts/setup_submodules.sh new file mode 100755 index 0000000..3926a93 --- /dev/null +++ b/scripts/setup_submodules.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -e + +echo "Initializing git submodules..." +git submodule update --init --recursive + +echo "Installing Accelergy core..." +cd accelergy +pip install . +cd .. + +echo "Installing Accelergy plugins..." +for plug in \ + accelergy_plugins/accelergy-aladdin-plug-in \ + accelergy_plugins/accelergy-library-plug-in \ + accelergy_plugins/accelergy-cacti-plug-in \ + accelergy_plugins/accelergy-adc-plug-in \ + accelergy_plugins/accelergy-neurosim-plugin; do + + echo "Building and installing $plug" + cd "$plug" + + if [[ "$plug" == *"accelergy-cacti-plug-in" ]]; then + make build + fi + + if [[ "$plug" == *"accelergy-neurosim-plugin" ]]; then + python setup.py build_ext + fi + + pip install . + cd - >/dev/null +done + +echo "All submodules installed successfully." \ No newline at end of file diff --git a/setup.py b/setup.py index c377548..387667c 100755 --- a/setup.py +++ b/setup.py @@ -1,46 +1,8 @@ from setuptools import setup, find_packages -from setuptools.command.install import install -import os -import subprocess -import shutil - def read_requirements(): - with open('requirements.txt') as req: - return req.readlines() - - -class InstallCommand(install): - """Customized setuptools install command to handle submodules.""" - def run(self): - # Initialize submodules - subprocess.check_call(['git', 'submodule', 'update', '--init', '--recursive']) - - # Build and install each submodule - submodules = [ - 'accelergy', - 'accelergy_plugins/accelergy-aladdin-plug-in', - 'accelergy_plugins/accelergy-library-plug-in', - 'accelergy_plugins/accelergy-cacti-plug-in', - 'accelergy_plugins/accelergy-adc-plug-in', - 'accelergy_plugins/accelergy-neurosim-plugin', - ] - - for submodule in submodules: - os.chdir(submodule) - if submodule == 'accelergy_plugins/accelergy-cacti-plug-in': - subprocess.check_call(['make', 'build']) - if submodule == 'accelergy_plugins/accelergy-neurosim-plugin': - subprocess.check_call([os.sys.executable, 'setup.py', 'build_ext']) - subprocess.check_call([os.sys.executable, '-m', 'pip', 'install', '.']) - os.chdir('../..' if 'accelergy_plugins' in submodule else '..') - - super().run() - - # Clean the build lib (it is just a Python module) - build_lib_dir = os.path.join('build', 'lib') - if os.path.exists(build_lib_dir): - shutil.rmtree(build_lib_dir) + with open("requirements.txt") as f: + return f.read().splitlines() setup( name='transinfersim', @@ -51,7 +13,4 @@ def run(self): url='https://github.com/ehw-fit/TransInferSim', packages=find_packages(), install_requires=read_requirements(), - cmdclass={ - 'install': InstallCommand, - } ) \ No newline at end of file