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
24 changes: 24 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: pytest

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade uv pytest pytest-cov
uv pip install -e . --system
uv pip install -e ".[dev]" --system
- name: Analysing the code with pytest
run: |
pytest -vvvv --cov=shadow-peft tests/
5 changes: 2 additions & 3 deletions tests/test_shadow_peft.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def test_save_load_roundtrip_matches_outputs(tmp_path: Path):
torch.manual_seed(0)
base1 = _tiny_llama(num_layers=4)
base1.eval()
base1_state = {k: v.detach().clone() for k, v in base1.state_dict().items()}

cfg = ShadowConfig(
num_shadow_layers=1,
Expand All @@ -107,7 +108,7 @@ def test_save_load_roundtrip_matches_outputs(tmp_path: Path):

# Create a new base with identical weights.
base2 = _tiny_llama(num_layers=4)
base2.load_state_dict(base1.state_dict())
base2.load_state_dict(base1_state)
base2.eval()

m2 = ShadowPeftModel.from_pretrained(base2, save_dir, is_trainable=False)
Expand Down Expand Up @@ -217,5 +218,3 @@ def test_implicit_shadow_model_uses_shadow_intermediate_size():
)
m = get_shadow_model(base, cfg)
assert m.shadow_model.config.intermediate_size == 12


Loading