Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
```

Expand Down
4 changes: 0 additions & 4 deletions analyzer/model_architectures/transformers/layers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,4 @@

from .multi_head_latent_attention import MultiHeadLatentAttention



from .test import Test

from .test2 import Test2
10 changes: 5 additions & 5 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions scripts/setup_submodules.sh
Original file line number Diff line number Diff line change
@@ -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."
45 changes: 2 additions & 43 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -51,7 +13,4 @@ def run(self):
url='https://github.com/ehw-fit/TransInferSim',
packages=find_packages(),
install_requires=read_requirements(),
cmdclass={
'install': InstallCommand,
}
)