diff --git a/.github/action.yml b/.github/action.yml index f2f9016c..b3f35b13 100644 --- a/.github/action.yml +++ b/.github/action.yml @@ -4,7 +4,7 @@ runs: using: "composite" steps: - name: Checkout actions - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 diff --git a/.github/workflows/aws.yml b/.github/workflows/aws.yml index 750955d9..369aa43d 100644 --- a/.github/workflows/aws.yml +++ b/.github/workflows/aws.yml @@ -51,10 +51,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 + uses: aws-actions/configure-aws-credentials@v4 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/bandit.yml b/.github/workflows/bandit.yml index 850a3cd4..aeb83a65 100644 --- a/.github/workflows/bandit.yml +++ b/.github/workflows/bandit.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Bandit Scan uses: shundor/python-bandit-scan@9cc5aa4a006482b8a7f91134412df6772dbda22c with: # optional arguments diff --git a/.github/workflows/bearer.yml b/.github/workflows/bearer.yml index 1b81311d..a18c9332 100644 --- a/.github/workflows/bearer.yml +++ b/.github/workflows/bearer.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest steps: # Checkout project source - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Scan code using Bearer CLI - name: Run Report id: report diff --git a/.github/workflows/codacy.yml b/.github/workflows/codacy.yml index 8e6936bc..5a66681e 100644 --- a/.github/workflows/codacy.yml +++ b/.github/workflows/codacy.yml @@ -36,7 +36,7 @@ jobs: steps: # Checkout the repository to the GitHub Actions runner - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis - name: Run Codacy Analysis CLI diff --git a/.github/workflows/crda.yml b/.github/workflows/crda.yml index 5054e09a..e48aea48 100644 --- a/.github/workflows/crda.yml +++ b/.github/workflows/crda.yml @@ -81,7 +81,7 @@ jobs: steps: - name: Check out repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 # ******************************************************************* # Required: Instructions to setup project diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index b0dedc42..4e751977 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -15,6 +15,6 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Dependency Review' uses: actions/dependency-review-action@v3 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5ec5cfe8..a69556bd 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,8 +13,8 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.x - - run: pip install mkdocs-material - - run: pip install "mkdocstrings[python]" - - run: pip install mkdocs-glightbox + python-version: '3.10' + - run: pip install --no-cache-dir mkdocs-material + - run: pip install --no-cache-dir "mkdocstrings[python]" + - run: pip install --no-cache-dir mkdocs-glightbox - run: mkdocs gh-deploy --force diff --git a/.github/workflows/generator-generic-ossf-slsa3-publish.yml b/.github/workflows/generator-generic-ossf-slsa3-publish.yml index a36e782c..35c829b1 100644 --- a/.github/workflows/generator-generic-ossf-slsa3-publish.yml +++ b/.github/workflows/generator-generic-ossf-slsa3-publish.yml @@ -23,7 +23,7 @@ jobs: digests: ${{ steps.hash.outputs.digests }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # ======================================================== # diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2a79688f..fb8f5879 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8] + python-version: [3.10] steps: - name: 🛎️ Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index d3f42fb1..f334972b 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.9", "3.10"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -16,7 +16,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip + python -m pip install --no-cache-dir --upgrade pip pip install pylint - name: Analysing the code with pylint run: | diff --git a/.github/workflows/pyre.yml b/.github/workflows/pyre.yml index 5ff88856..2e4713d3 100644 --- a/.github/workflows/pyre.yml +++ b/.github/workflows/pyre.yml @@ -33,7 +33,7 @@ jobs: security-events: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true diff --git a/.github/workflows/pysa.yml b/.github/workflows/pysa.yml index 01f39f5b..c420e3cb 100644 --- a/.github/workflows/pysa.yml +++ b/.github/workflows/pysa.yml @@ -35,7 +35,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index e4262374..1da8d6bd 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -18,11 +18,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.10 uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: '3.10' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml index 20c2b2de..51c99bba 100644 --- a/.github/workflows/python-package-conda.yml +++ b/.github/workflows/python-package-conda.yml @@ -9,7 +9,7 @@ jobs: max-parallel: 5 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.10 uses: actions/setup-python@v5 with: diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index cf809820..8fd1faab 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -19,15 +19,15 @@ jobs: python-version: ["3.9", "3.10", "3.11"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest + python -m pip install --no-cache-dir --upgrade pip + python -m pip install --no-cache-dir flake8 pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index aef7b002..424e5e7d 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -18,10 +18,10 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.x' + python-version: '3.10' - name: Install dependencies run: | - python -m pip install --upgrade pip + python -m pip install --no-cache-dir --upgrade pip pip install build - name: Build package run: python -m build diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml index acee01e2..28d6b416 100644 --- a/.github/workflows/super-linter.yml +++ b/.github/workflows/super-linter.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # Full git history is needed to get a proper list of changed files within `super-linter` fetch-depth: 0 diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 73aabe31..2609d47a 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -66,7 +66,7 @@ jobs: steps: # Checkout the repository to the GitHub Actions runner - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token - name: Setup Terraform diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 65dc68d9..e2fb311a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,6 @@ jobs: strategy: matrix: python-version: - - "3.8" - "3.9" - "3.10" - "3.11" diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index aaf4a614..8fd36915 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -21,7 +21,7 @@ jobs: python-version: '3.10' - name: Install dependencies - run: pip install -r requirements.txt + run: pip install --no-cache-dir -r requirements.txt - name: Run Python unit tests run: python3 -m pytest diff --git a/.github/workflows/welcome.yml b/.github/workflows/welcome.yml index c328046a..51372fe2 100644 --- a/.github/workflows/welcome.yml +++ b/.github/workflows/welcome.yml @@ -10,6 +10,7 @@ jobs: build: name: 👋 Welcome runs-on: ubuntu-latest + permissions: write-all steps: - uses: actions/first-interaction@v1.3.0 with: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..32050298 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# ================================== +# Use an official Python runtime as a parent image +FROM python:3.10-slim +RUN apt-get update && apt-get -y install libgl1-mesa-dev libglib2.0-0 build-essential; apt-get clean +RUN pip install opencv-contrib-python-headless + +# Set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# Set the working directory in the container +WORKDIR /usr/src/zeta + + +# Install Python dependencies +# COPY requirements.txt and pyproject.toml if you're using poetry for dependency management +COPY requirements.txt . +RUN pip install --no-cache-dir --upgrade pip +RUN pip install --no-cache-dir -r requirements.txt + +RUN pip install --no-cache-dir zetascale + +# Copy the rest of the application +COPY . . + diff --git a/example.py b/example.py index 5436652d..6c3c1b5b 100644 --- a/example.py +++ b/example.py @@ -1,3 +1,7 @@ +""" +This script demonstrates the usage of the FlashAttentionmodule from zeta.nn as an example. +""" + import torch from zeta.nn import FlashAttention diff --git a/playground/cross_attend.py b/playground/cross_attend.py index dd73fc29..9ad4ab1e 100644 --- a/playground/cross_attend.py +++ b/playground/cross_attend.py @@ -1,3 +1,7 @@ +""" +Docstring for playground/cross_attend.py +""" + import torch from zeta.nn.attention.cross_attention import CrossAttend from zeta.structs.transformer import Encoder diff --git a/playground/example_mqqa.py b/playground/example_mqqa.py deleted file mode 100644 index 4a2a2476..00000000 --- a/playground/example_mqqa.py +++ /dev/null @@ -1,26 +0,0 @@ -import torch -from zeta.nn.attention.mgqa import MGQA - -# Initialize the MGQA model -model = MGQA( - dim=512, - n_layers=6, - head_dim=64, - hidden_dim=2048, - n_heads=8, - n_kv_heads=8, - sliding_window=512, - norm_eps=1e-5, - vocab_size=30522, - max_batch_size=0, - attn_dropout=0.1, - flash=True, -) - -# Create random inputs -x = torch.randn(10, 512) # batch size of 10, sequence length of 512 - -# Forward pass -output = model(x) - -print(output.shape) # should be the same shape as x diff --git a/playground/flash_attention.py b/playground/flash_attention.py index ecb1721e..61f248e6 100644 --- a/playground/flash_attention.py +++ b/playground/flash_attention.py @@ -1,3 +1,7 @@ +""" +Flash Attention example code +""" + import torch from zeta.nn.attention import FlashAttention diff --git a/playground/token_monster.py b/playground/token_monster.py index 3575117d..98627d30 100644 --- a/playground/token_monster.py +++ b/playground/token_monster.py @@ -1,3 +1,7 @@ +""" +This is a playground for the TokenMonster tokenizer. +""" + import torch from zeta.tokenizers import TokenMonster diff --git a/playground/transformer.py b/playground/transformer.py index 8b15e321..16c09eb3 100644 --- a/playground/transformer.py +++ b/playground/transformer.py @@ -1,3 +1,7 @@ +""" +This is a playground for the Transformer model. +""" + import torch from zeta.nn import Transformer, Decoder diff --git a/scripts/delpycache.py b/scripts/delpycache.py index f688d204..c17bcad4 100644 --- a/scripts/delpycache.py +++ b/scripts/delpycache.py @@ -1,9 +1,17 @@ +""" +Delete all __pycache__ directories in a given directory. +Usage: python delpycache.py +""" + import os import shutil import sys def delete_pycache(directory): + """ + Delete all __pycache__ directories in a given directory. + """ for root, dirs, files in os.walk(directory): if "__pycache__" in dirs: shutil.rmtree(os.path.join(root, "__pycache__")) diff --git a/scripts/get_package_requirements.py b/scripts/get_package_requirements.py index 0d57c028..43324452 100644 --- a/scripts/get_package_requirements.py +++ b/scripts/get_package_requirements.py @@ -1,9 +1,17 @@ +""" +This script extracts the package names and versions from a requirements.txt file and writes them to a new file. +The new file can be used to install the same package versions on another machine. +""" + import pkg_resources def get_package_versions(requirements_path, output_path): + """ + Extract package names and versions from a requirements.txt file and write them to a new file. + """ try: - with open(requirements_path, "r") as file: + with open(requirements_path, "r", encoding="utf-8") as file: requirements = file.readlines() except FileNotFoundError: print(f"Error: The file '{requirements_path}' was not found.") diff --git a/zeta/nn/attention/__init__.py b/zeta/nn/attention/__init__.py index 613e265c..a2bc526c 100644 --- a/zeta/nn/attention/__init__.py +++ b/zeta/nn/attention/__init__.py @@ -9,7 +9,6 @@ from zeta.nn.attention.local_attention import LocalAttention from zeta.nn.attention.local_attention_mha import LocalMHA -# from zeta.nn.attention.mgqa import MGQA # from zeta.nn.attention.spatial_linear_attention import SpatialLinearAttention from zeta.nn.attention.mixture_attention import ( MixtureOfAttention,