Skip to content

Commit 6104ea7

Browse files
committed
refactore requirements files
1 parent e20d8f8 commit 6104ea7

8 files changed

Lines changed: 51 additions & 53 deletions

File tree

.claude/skills/ov-update-pytorch-version/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Before editing anything, confirm with the user:
1414
- Target versions for `torch`, `torchvision`:
1515
- `torchvision` minor = torch minor **+ 15** — e.g. torch `2.9.0` ↔ torchvision `0.24.0`, torch `2.12.0` ↔ torchvision `0.27.0`. Always confirm against the official release matrix.
1616
- `torchaudio` is **not** pinned by [tests/requirements_pytorch](../../../tests/requirements_pytorch): it is unused by these tests and PyTorch removed it from the official installation instructions starting with the 2.8 release. **Do not re-add it.** If a future task genuinely needs torchaudio, note that it is in a maintenance phase and its latest release can lag torch by one or more minors (e.g. torch `2.12.0` ↔ torchaudio `2.11.0`), so `torchaudio==<torch version>` may not exist — look up the latest available wheel at `https://download.pytorch.org/whl/cpu/torchaudio/`. Recent torchaudio wheels carry **no** `Requires-Dist: torch` pin, so a slightly older torchaudio installs cleanly alongside a newer torch.
17-
- Whether [tests/model_hub_tests/pytorch/envs/compile_gptq.txt](../../../tests/model_hub_tests/pytorch/envs/compile_gptq.txt) (pinned at `torch==2.3.1`, `torchaudio==2.3.1` for auto-gptq) should be touched. **Default: leave it alone.**
17+
- Whether [tests/model_hub_tests/transformation_tests/envs/compile_gptq.txt](../../../tests/model_hub_tests/transformation_tests/envs/compile_gptq.txt) (pinned at `torch==2.3.1`, `torchaudio==2.3.1` for auto-gptq) should be touched. **Default: leave it alone.**
1818
- Both the default TorchScript path **and** `PYTORCH_TRACING_MODE=EXPORT` (FX) path must be validated. Skip the FX run only if the user explicitly opts out.
1919

2020
## Step 1: Update Version Pins

.github/workflows/job_pytorch_models_tests.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,20 @@ jobs:
188188
python3 -m pip uninstall -y gptqmodel triton kernels torchao 2>/dev/null || true
189189
python3 -m pip install \
190190
-r ${INSTALL_TEST_DIR}/requirements_pytorch \
191-
-r ${MODEL_HUB_TESTS_INSTALL_DIR}/pytorch/envs/optimum_intel.txt
191+
-r ${MODEL_HUB_TESTS_INSTALL_DIR}/transformation_tests/envs/requirements.txt
192192
193193
- name: PagedAttention Test
194194
if: ${{ inputs.model_scope == 'precommit' }}
195195
run: |
196196
export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH
197-
python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/transformation_tests/test_pa_transformation.py -m precommit --html=${INSTALL_TEST_DIR}/TEST-torch_pagedattention_tests.html --self-contained-html -vvv -s --tb=short -n 2
197+
python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/transformation_tests/test_pa_transformation.py -m precommit -k "not gemma4" --html=${INSTALL_TEST_DIR}/TEST-torch_pagedattention_tests.html --self-contained-html -vvv -s --tb=short -n 2
198+
199+
# gemma4 needs a much newer transformers/optimum-intel than the rest of the suite, so it
200+
# runs last under its own requirements. optimum-onnx (installed earlier) pins
201+
# optimum/transformers versions incompatible with those, and is unused from here on.
202+
python3 -m pip uninstall -y optimum-onnx
203+
python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/transformation_tests/envs/paged_attention.txt
204+
python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/transformation_tests/test_pa_transformation.py -m precommit -k gemma4 --html=${INSTALL_TEST_DIR}/TEST-torch_pagedattention_gemma4_tests.html --self-contained-html -v --tb=short
198205
env:
199206
TEST_DEVICE: CPU
200207

@@ -212,7 +219,7 @@ jobs:
212219
export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH
213220
# compile_gptq.txt downgrades torch to 2.3.1; remove packages incompatible with it
214221
python3 -m pip uninstall -y triton torchao autoawq 2>/dev/null || true
215-
python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/pytorch/envs/compile_gptq.txt
222+
python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/transformation_tests/envs/compile_gptq.txt
216223
python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/transformation_tests/test_gptq_torchfx_transformations.py -m precommit --html=${INSTALL_TEST_DIR}/TEST-torch_gptqpattern_tests.html --self-contained-html -v --tb=short
217224
env:
218225
TEST_DEVICE: CPU
@@ -221,7 +228,7 @@ jobs:
221228
if: ${{ inputs.model_scope == 'precommit' }}
222229
run: |
223230
export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH
224-
python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/pytorch/envs/moe.txt
231+
python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/transformation_tests/envs/moe.txt
225232
python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/transformation_tests/test_moe_transformation.py -m precommit --html=${INSTALL_TEST_DIR}/TEST-torch_moe_tests.html --self-contained-html -vvv -s --tb=short -n 2
226233
env:
227234
TEST_DEVICE: CPU
@@ -237,19 +244,6 @@ jobs:
237244
env:
238245
TEST_DEVICE: CPU
239246

240-
# gemma4 requires a much newer transformers/optimum-intel than the other transformation
241-
# tests, so it gets its own requirements file and runs last. optimum-intel pulls in a
242-
# PyPI openvino release as a dependency, so PYTHONPATH points at the test archive's
243-
# python bindings instead of relying on whatever pip installed to import openvino.
244-
- name: Gemma4 PagedAttention Test
245-
if: ${{ inputs.model_scope == 'precommit' }}
246-
run: |
247-
export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH
248-
python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/transformation_tests/envs/gemma4.txt
249-
python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/transformation_tests/test_pa_transformation_gemma4.py -m precommit --html=${INSTALL_TEST_DIR}/TEST-torch_pagedattention_gemma4_tests.html --self-contained-html -v --tb=short
250-
env:
251-
TEST_DEVICE: CPU
252-
253247
- name: Reformat unsupported ops file
254248
if: ${{ inputs.model_scope != 'precommit' && !cancelled()}}
255249
run: |

tests/model_hub_tests/pytorch/envs/compile_gptq.txt renamed to tests/model_hub_tests/transformation_tests/envs/compile_gptq.txt

File renamed without changes.
File renamed without changes.

tests/model_hub_tests/transformation_tests/envs/gemma4.txt renamed to tests/model_hub_tests/transformation_tests/envs/paged_attention.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# gemma4 architecture is only recognized starting with a much newer transformers
2-
# release than the one pinned in pytorch/envs/optimum_intel.txt (transformers<4.52),
2+
# release than the common transformation-test stack (envs/requirements.txt, transformers<4.52),
33
# so this test uses its own isolated set of versions.
44
transformers==5.5.4
55
optimum-intel==2.1.0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# optimum-intel required by transformation tests (PA, StatefulToStateless, etc.)
2+
# Pinned to a known-working commit for compatibility.
3+
# optimum-intel@8ba536cd requires transformers>=4.36,<4.52
4+
transformers==4.51.3
5+
optimum==1.25.0; python_version < "3.12"
6+
auto-gptq==0.7.1; platform_system == "Linux" and platform_machine == "x86_64" and python_version < "3.12"
7+
autoawq==0.2.7; platform_system == "Linux" and platform_machine == "x86_64"
8+
git+https://github.com/huggingface/optimum-intel.git@8ba536cd0a2bf93e9e88408b0048a7695db5be0b; python_version < "3.12"

tests/model_hub_tests/transformation_tests/test_pa_transformation.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,33 @@ def test_pa_precommit(tmp_path, model_info_tuple, ie_device, use_optimizations):
228228
allow_xattention=False,
229229
allow_adaptive_rkv=False,
230230
allow_qq_bias=False,
231-
ie_device=ie_device)
231+
ie_device=ie_device)
232+
233+
234+
GEMMA4_MODEL_ID = "optimum-intel-internal-testing/tiny-random-gemma4"
235+
236+
237+
@retry(3, exceptions=(OSError,), delay=1)
238+
def get_gemma4_language_model(model_id):
239+
model_cached = snapshot_download(model_id) # required to avoid HF rate limits
240+
# gemma4 needs a newer optimum-intel (see requirements_gemma4.txt) whose VLM API
241+
# exposes the language model graph via .language_model.model rather than .lm_model.
242+
model = OVModelForVisualCausalLM.from_pretrained(model_cached, export=True, trust_remote_code=True)
243+
return model.language_model.model
244+
245+
246+
@pytest.mark.precommit
247+
def test_pa_gemma4(ie_device):
248+
# gemma4's rotary embedding derives its batch dimension from attention_mask via a
249+
# Broadcast+MatMul; BroadcastMatMulFusion must remove that broadcast so
250+
# SDPAToPagedAttention can safely drop the attention_mask parameter.
251+
if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:
252+
pytest.skip("PagedAttention tests are not enabled on ARM")
253+
254+
ov_model = get_gemma4_language_model(GEMMA4_MODEL_ID)
255+
256+
paged_attention_transformation(ov_model, False, False, False, False, False, False, False)
257+
ov.Core().compile_model(ov_model, ie_device)
258+
259+
pa_count = sum(1 for op in ov_model.get_ordered_ops() if isinstance(op, _PagedAttentionExtension))
260+
assert pa_count > 0, "PagedAttentionExtension nodes were not created"

tests/model_hub_tests/transformation_tests/test_pa_transformation_gemma4.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)