Repository: mosaicml/composer (branch: composer_lora)
Commit date: 2024-01-18T22:03:17Z

Workflow file: .github/workflows/code-quality.yaml (Code Quality Checks)
name: Code Quality Checks
on:
  push:
    branches:
      - dev
      - main
      - release/**
  pull_request:
  workflow_call:
  workflow_dispatch:
# Cancel old runs when a new commit is pushed to the same branch if not on main or dev
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
defaults:
  run:
    working-directory: .
jobs:
  code-quality:
    runs-on: ubuntu-20.04
    services:
      pypi_wayback:
        image: ghcr.io/waleko/pypi-wayback
        ports:
          - 8629:8080
    timeout-minutes: 15
    strategy:
      matrix:
        python_version:
          - "3.8"
          - "3.9"
          - "3.10"
        pip_deps:
          - "[dev]"
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python_version }}
      - name: Setup
        run: |
          set -ex
          python -m pip install --upgrade 'pip<23' wheel
          python -m pip install --upgrade .${{ matrix.pip_deps }}
      - name: Run checks
        run: |
          pre-commit run --all-files

env:
  PIP_INDEX_URL: http://localhost:8629/2024-01-18
  UV_INDEX_URL: http://localhost:8629/2024-01-18


Failed build logs:
step_name: code-quality (3.9, [dev])/5_Run checks.txt
log: ##[group]Run pre-commit run --all-files
[36;1mpre-commit run --all-files[0m
shell: /usr/bin/bash -e {0}
env:
  pythonLocation: /opt/hostedtoolcache/Python/3.9.18/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.18/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.18/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.18/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.18/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.18/x64/lib
##[endgroup]
[INFO] Initializing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Initializing environment for https://github.com/google/yapf.
[INFO] Initializing environment for https://github.com/google/yapf:toml.
[INFO] Initializing environment for https://github.com/pycqa/isort.
[INFO] Initializing environment for https://github.com/PyCQA/pydocstyle.
[INFO] Initializing environment for https://github.com/PyCQA/pydocstyle:toml.
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/Lucas-C/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/kynan/nbstripout.
[INFO] Initializing environment for local:pyright@1.1.310.
[INFO] Initializing environment for https://github.com/trufflesecurity/trufflehog.git.
[INFO] Installing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/google/yapf.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pycqa/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/PyCQA/pydocstyle.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/Lucas-C/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/kynan/nbstripout.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for local.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/trufflesecurity/trufflehog.git.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
ruff.....................................................................Passed
yapf.....................................................................Passed
isort....................................................................Failed
- hook id: isort
- files were modified by this hook

Fixing /home/runner/work/composer/composer/tests/models/test_hf_model.py
Skipped 1 files

pydocstyle...............................................................Passed
check for added large files..............................................Passed
check python ast.........................................................Passed
check builtin type constructor use.......................................Passed
check for case conflicts.................................................Passed
check docstring is first.................................................Passed
check that executables have shebangs.....................................Passed
check json...............................................................Passed
check that scripts with shebangs are executable..........................Passed
pretty format json.......................................................Passed
check for merge conflicts................................................Passed
check for broken symlinks................................................Passed
check toml...............................................................Passed
check vcs permalinks.....................................................Passed
check xml................................................................Passed
check yaml...............................................................Passed
debug statements (python)................................................Passed
detect destroyed symlinks................................................Passed
fix double quoted strings................................................Passed
fix end of files.........................................................Passed
fix utf-8 byte order marker..............................................Passed
mixed line ending........................................................Passed
trim trailing whitespace.................................................Passed
Insert license in comments...............................................Passed
nbstripout...............................................................Passed
pyright..................................................................Passed
secret scan..............................................................Passed
##[error]Process completed with exit code 1.


Changed files:
composer/models/huggingface.py
tests/models/test_hf_model.py

Fix diff:
diff --git a/composer/models/huggingface.py b/composer/models/huggingface.py
index f3855ce6..c223a917 100644
--- a/composer/models/huggingface.py
+++ b/composer/models/huggingface.py
@@ -111,6 +111,13 @@ class HuggingFaceModel(ComposerModel):
                                                     conda_package='peft',
                                                     conda_channel='conda-forge')
 
+        if peft_config is not None:
+            # Hugging Face requires the peft type and task type to be upper case, so we do that here
+            # https://github.com/huggingface/peft/blob/ebbff4023ad276cbcb2466fd7e99be7d3ae0ae11/src/peft/utils/peft_types.py#L22-L51
+            if isinstance(peft_config.peft_type, str):
+                peft_config.peft_type = peft_config.peft_type.upper()
+            if isinstance(peft_config.task_type, str):
+                peft_config.task_type = peft_config.task_type.upper()
         if peft_config is not None and peft_config.peft_type != 'LORA':
             raise ValueError(
                 f'PEFT type {peft_config.peft_type} is not supported by HuggingFaceModel. Only LORA is supported.')
diff --git a/tests/models/test_hf_model.py b/tests/models/test_hf_model.py
index c3c59e1c..a69b56b5 100644
--- a/tests/models/test_hf_model.py
+++ b/tests/models/test_hf_model.py
@@ -28,8 +28,6 @@ from tests.common.markers import device, world_size
 from tests.common.models import (configure_tiny_bert_model, configure_tiny_bert_tokenizer, configure_tiny_gpt2_model,
                                  configure_tiny_gpt2_tokenizer, configure_tiny_mistral_model,
                                  configure_tiny_mistral_tokenizer, configure_tiny_t5_model, configure_tiny_t5_tokenizer)
-from tests.common.models import (configure_tiny_bert_model, configure_tiny_bert_tokenizer, configure_tiny_gpt2_model,
-                                 configure_tiny_gpt2_tokenizer, configure_tiny_t5_model, configure_tiny_t5_tokenizer)
 from tests.loggers.test_remote_uploader_downloader import DummyObjectStore
 
 if TYPE_CHECKING: