From ba84c51e754e880884d233723e4853319cb5eb46 Mon Sep 17 00:00:00 2001 From: Sean Date: Wed, 22 Apr 2026 13:34:29 +0800 Subject: [PATCH 1/8] fix test case --- tests/test_shadow_peft.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_shadow_peft.py b/tests/test_shadow_peft.py index ffae772..7ae5ece 100644 --- a/tests/test_shadow_peft.py +++ b/tests/test_shadow_peft.py @@ -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, @@ -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) @@ -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 - - From 3c4f9056abba83a986fc0764aca472d87a15f877 Mon Sep 17 00:00:00 2001 From: LeeTszFung <77471196+LeeTszFung@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:41:12 +0800 Subject: [PATCH 2/8] Create pytest.yml --- .github/workflows/pytest.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/pytest.yml diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..0f0eb07 --- /dev/null +++ b/.github/workflows/pytest.yml @@ -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 + uv pip install -e . --system + uv pip install -e ".[dev]" --system + - name: Analysing the code with pytest + run: | + pytest -vvvv --cov=shadow-peft tests/ From 0967c3a95cf7c27ce39b985158c687dc33293bfd Mon Sep 17 00:00:00 2001 From: LeeTszFung <77471196+LeeTszFung@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:45:35 +0800 Subject: [PATCH 3/8] Delete .github/workflows/pytest.yml --- .github/workflows/pytest.yml | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 .github/workflows/pytest.yml diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml deleted file mode 100644 index 0f0eb07..0000000 --- a/.github/workflows/pytest.yml +++ /dev/null @@ -1,24 +0,0 @@ -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 - uv pip install -e . --system - uv pip install -e ".[dev]" --system - - name: Analysing the code with pytest - run: | - pytest -vvvv --cov=shadow-peft tests/ From 10a9ceab76922fa974d02d3f577e3b9378a18934 Mon Sep 17 00:00:00 2001 From: LeeTszFung <77471196+LeeTszFung@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:46:21 +0800 Subject: [PATCH 4/8] Create pytest --- .github/workflows/pytest | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/pytest diff --git a/.github/workflows/pytest b/.github/workflows/pytest new file mode 100644 index 0000000..0f0eb07 --- /dev/null +++ b/.github/workflows/pytest @@ -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 + uv pip install -e . --system + uv pip install -e ".[dev]" --system + - name: Analysing the code with pytest + run: | + pytest -vvvv --cov=shadow-peft tests/ From faf6f8ba1e078c627a96446c6926cc9d722c5bb6 Mon Sep 17 00:00:00 2001 From: LeeTszFung <77471196+LeeTszFung@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:47:40 +0800 Subject: [PATCH 5/8] Delete .github/workflows/pytest --- .github/workflows/pytest | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 .github/workflows/pytest diff --git a/.github/workflows/pytest b/.github/workflows/pytest deleted file mode 100644 index 0f0eb07..0000000 --- a/.github/workflows/pytest +++ /dev/null @@ -1,24 +0,0 @@ -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 - uv pip install -e . --system - uv pip install -e ".[dev]" --system - - name: Analysing the code with pytest - run: | - pytest -vvvv --cov=shadow-peft tests/ From 4bd90efae97ce42f42a9bb63c23394624b89503e Mon Sep 17 00:00:00 2001 From: LeeTszFung <77471196+LeeTszFung@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:48:23 +0800 Subject: [PATCH 6/8] Create pytest.yaml --- .github/workflows/pytest.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/pytest.yaml diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml new file mode 100644 index 0000000..0f0eb07 --- /dev/null +++ b/.github/workflows/pytest.yaml @@ -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 + uv pip install -e . --system + uv pip install -e ".[dev]" --system + - name: Analysing the code with pytest + run: | + pytest -vvvv --cov=shadow-peft tests/ From b23fc65cbba7ebd70ef131bd860d94d9fae96074 Mon Sep 17 00:00:00 2001 From: LeeTszFung <77471196+LeeTszFung@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:55:28 +0800 Subject: [PATCH 7/8] Update pytest.yaml --- .github/workflows/pytest.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 0f0eb07..a6b21ae 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -8,17 +8,20 @@ jobs: 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 - uv pip install -e . --system - uv pip install -e ".[dev]" --system + python -m pip install --upgrade pip + pip install -e ".[dev]" + - name: Analysing the code with pytest run: | - pytest -vvvv --cov=shadow-peft tests/ + python -m pytest -vvvv --cov=shadow-peft tests/ From 00d2652ffab04aff7075d213ec0a19fb8b40dc74 Mon Sep 17 00:00:00 2001 From: LeeTszFung <77471196+LeeTszFung@users.noreply.github.com> Date: Wed, 22 Apr 2026 14:01:10 +0800 Subject: [PATCH 8/8] Fix pytest.yaml error --- .github/workflows/pytest.yaml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index a6b21ae..15a98e7 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -8,20 +8,17 @@ jobs: 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 pip - pip install -e ".[dev]" - + 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: | - python -m pytest -vvvv --cov=shadow-peft tests/ + pytest -vvvv --cov=shadow-peft tests/