Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GHA] Enabled llm accuracy tests (#37283)

Mikhail Ryzhov05265954860d
diff --git a/.github/dockerfiles/docker_tag b/.github/dockerfiles/docker_tag
index 49a22590a86..86e7036f74f 100644
--- a/.github/dockerfiles/docker_tag
+++ b/.github/dockerfiles/docker_tag
@@ -1 +1 @@
-pr-37363
+pr-37283
\ No newline at end of file
diff --git a/.github/dockerfiles/ov_test/ubuntu_24_04_x64/Dockerfile b/.github/dockerfiles/ov_test/ubuntu_24_04_x64/Dockerfile
index 0b955d9e790..2e311b8a6b0 100644
--- a/.github/dockerfiles/ov_test/ubuntu_24_04_x64/Dockerfile
+++ b/.github/dockerfiles/ov_test/ubuntu_24_04_x64/Dockerfile
@@ -27,6 +27,8 @@ RUN apt-get update && \
pigz \
# Samples
clang \
+ # required by cv2 (pulled in via diffusers → imwatermark)
+ libgl1 \
# Python
python3-full \
libhdf5-dev \
diff --git a/.github/dockerfiles/ov_test/ubuntu_24_04_x64_dgpu/Dockerfile b/.github/dockerfiles/ov_test/ubuntu_24_04_x64_dgpu/Dockerfile
index c2c45e7dd3f..b86c5239aab 100644
--- a/.github/dockerfiles/ov_test/ubuntu_24_04_x64_dgpu/Dockerfile
+++ b/.github/dockerfiles/ov_test/ubuntu_24_04_x64_dgpu/Dockerfile
@@ -30,6 +30,8 @@ RUN apt-get update && \
pigz \
# Samples
clang \
+ # required by cv2 (pulled in via diffusers → imwatermark)
+ libgl1 \
# Python
python3-full \
libhdf5-dev \
diff --git a/.github/workflows/job_llm_accuracy_tests.yml b/.github/workflows/job_llm_accuracy_tests.yml
new file mode 100644
index 00000000000..fee21fdfe48
--- /dev/null
+++ b/.github/workflows/job_llm_accuracy_tests.yml
@@ -0,0 +1,126 @@
+name: LLM accuracy tests
+on:
+ workflow_call:
+ inputs:
+ runner:
+ description: 'Runner on which to run the job. JSON string: either an array of labels (e.g. ''["aks-linux-4-cores-16gb"]'') or an object with group and labels (e.g. ''{"group": "Intel-GPU", "labels": ["self-hosted", "igpu", "Linux"]}'')'
+ type: string
+ required: true
+ image:
+ description: 'Docker image to use for the job'
+ type: string
+ required: true
+ container-options:
+ description: 'Additional docker container options (e.g. GPU device mounts)'
+ type: string
+ required: false
+ default: ''
+ device:
+ description: 'Device filter passed to pytest -k (CPU or GPU)'
+ type: string
+ required: true
+ timeout-minutes:
+ description: 'Job timeout in minutes'
+ type: number
+ required: false
+ default: 90
+ test-suffix:
+ description: 'Suffix appended to artifact name to avoid collisions (e.g. CPU, iGPU, dGPU)'
+ type: string
+ required: true
+ use-pip-proxy:
+ description: 'Whether the runner can reach the internal pip caching proxy (true for cloud AKS runners, false for iGPU/dGPU self-hosted runners)'
+ type: boolean
+ required: true
+
+permissions: read-all
+
+jobs:
+ LLM_Accuracy_Tests:
+ name: LLM accuracy ${{ inputs.device }} tests
+ timeout-minutes: ${{ inputs.timeout-minutes }}
+ runs-on: ${{ fromJSON(inputs.runner) }}
+ container:
+ image: ${{ inputs.image }}
+ volumes:
+ - /mnt/caches:/mnt/caches
+ - /opt/home/actions_runner/actions-runner/secrets/:/secrets:ro # HF auth token file (HF_TOKEN_PATH_LIN)
+ - /usr/local/share/ca-certificates:/usr/local/share/ca-certificates:ro
+ - ${{ github.workspace }}:${{ github.workspace }}
+ options: ${{ inputs.container-options }}
+ defaults:
+ run:
+ shell: bash
+ env:
+ DEBIAN_FRONTEND: noninteractive
+ INSTALL_DIR: ${{ github.workspace }}/install
+ LLM_TEST_DIR: ${{ github.workspace }}/tests/llm
+ HF_HUB_CACHE: /mnt/caches/huggingface
+ HUGGINGFACE_HUB_CACHE: /mnt/caches/huggingface
+ HF_TOKEN_PATH: /secrets/huggingface/token-secondary
+ NODE_EXTRA_CA_CERTS: /usr/local/share/ca-certificates/IntelProxyRootCA-Base64.crt
+ PIP_CERT: /etc/ssl/certs/ca-certificates.crt
+ REQUESTS_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
+ SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt
+ steps:
+ - name: Update CA certificates
+ run: update-ca-certificates
+
+ - name: Checkout
+ uses: ababushk/checkout@dd591a6a2ac25618db4eda86e7e0d938f88cf01b # cherry_pick_retries
+ timeout-minutes: 15
+ with:
+ sparse-checkout: |
+ .github/actions
+ tests/llm
+ tests/constraints.txt
+ sparse-checkout-cone-mode: false
+ submodules: 'false'
+
+ - name: Download OpenVINO artifacts (wheels)
+ uses: akashchi/download-artifact@d59a9c15fec3fdb7c9adf09464124d00f9c11415 # main
+ with:
+ pattern: 'openvino_{wheels,tokenizers_wheel}'
+ path: ${{ env.INSTALL_DIR }}
+ merge-multiple: true
+
+ - name: Setup Python 3.12
+ uses: ./.github/actions/setup_python
+ with:
+ version: '3.12'
+ pip-cache-path: '/mnt/caches/pip'
+ set-pip-install-path: 'false'
+ self-hosted-runner: true
+ use-pip-proxy: ${{ inputs.use-pip-proxy }}
+
+ - name: Install OpenVINO Python wheels
+ uses: ./.github/actions/install_ov_wheels
+ with:
+ wheels-dir-path: ${{ env.INSTALL_DIR }}
+ wheels-to-install: 'openvino openvino_tokenizers'
+
+ - name: Install LLM accuracy test requirements
+ run: python3 -m pip install -r ${LLM_TEST_DIR}/requirements.txt
+
+ - name: LLM accuracy ${{ inputs.device }} tests
+ env:
+ DEVICE: ${{ inputs.device }}
+ run: |
+ python3 -m pytest ${LLM_TEST_DIR}/accuracy_conformance.py \
+ -k "$DEVICE" \
+ --tb native \
+ --log-level INFO \
+ --log-cli-level ERROR \
+ --junitxml=${LLM_TEST_DIR}/llm_accuracy.xml \
+ --html=${LLM_TEST_DIR}/llm_accuracy.html \
+ --self-contained-html
+
+ - name: Upload LLM accuracy test results
+ uses: ababushk/upload-artifact@ebc7d74ace101c08868aed05dba2aaf274b9a2c7 # main
+ if: always()
+ with:
+ name: test-results-llm-accuracy-${{ inputs.test-suffix }}
+ path: |
+ ${{ env.LLM_TEST_DIR }}/llm_accuracy.xml
+ ${{ env.LLM_TEST_DIR }}/llm_accuracy.html
+ if-no-files-found: 'ignore'
diff --git a/.github/workflows/ubuntu_24.yml b/.github/workflows/ubuntu_24.yml
index 2ff8cd9bb1a..2612b56af27 100644
--- a/.github/workflows/ubuntu_24.yml
+++ b/.github/workflows/ubuntu_24.yml
@@ -174,6 +174,62 @@ jobs:
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
python-version: '3.12'
+ LLM_Accuracy_CPU:
+ name: LLM accuracy CPU tests
+ needs: [ Docker, Build, Smart_CI, Openvino_tokenizers ]
+ if: |
+ github.event_name != 'schedule' && (
+ fromJSON(needs.smart_ci.outputs.affected_components).CPU ||
+ fromJSON(needs.smart_ci.outputs.affected_components).transformations ||
+ fromJSON(needs.smart_ci.outputs.affected_components).Core
+ )
+ uses: ./.github/workflows/job_llm_accuracy_tests.yml
+ with:
+ runner: '["aks-linux-4-cores-16gb"]'
+ image: ${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_24_04_x64 }}
+ device: 'CPU'
+ test-suffix: 'CPU'
+ use-pip-proxy: true
+ timeout-minutes: 30
+
+ LLM_Accuracy_iGPU:
+ name: LLM accuracy iGPU tests
+ needs: [ Docker, Build, Smart_CI, Openvino_tokenizers ]
+ if: |
+ github.event_name != 'schedule' && (
+ fromJSON(needs.smart_ci.outputs.affected_components).GPU ||
+ fromJSON(needs.smart_ci.outputs.affected_components).transformations ||
+ fromJSON(needs.smart_ci.outputs.affected_components).Core
+ )
+ uses: ./.github/workflows/job_llm_accuracy_tests.yml
+ with:
+ runner: '{"group": "Intel-GPU", "labels": ["self-hosted", "igpu", "Linux"]}'
+ image: ${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_24_04_x64_dgpu }}
+ container-options: '--group-add 44 --group-add 993 --device /dev/dri/renderD128:/dev/dri/renderD128'
+ device: 'GPU'
+ test-suffix: 'iGPU'
+ use-pip-proxy: false
+ timeout-minutes: 30
+
+ LLM_Accuracy_dGPU:
+ name: LLM accuracy dGPU tests
+ needs: [ Docker, Build, Smart_CI, Openvino_tokenizers ]
+ if: |
+ github.event_name != 'schedule' && (
+ fromJSON(needs.smart_ci.outputs.affected_components).GPU ||
+ fromJSON(needs.smart_ci.outputs.affected_components).transformations ||
+ fromJSON(needs.smart_ci.outputs.affected_components).Core
+ )
+ uses: ./.github/workflows/job_llm_accuracy_tests.yml
+ with:
+ runner: '{"group": "Intel-GPU", "labels": ["self-hosted", "dgpu", "Arc-B580", "Battlemage", "Linux"]}'
+ image: ${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_24_04_x64_dgpu }}
+ container-options: '--group-add 44 --group-add 993 --device /dev/dri/renderD129:/dev/dri/renderD129'
+ device: 'GPU'
+ test-suffix: 'dGPU'
+ use-pip-proxy: false
+ timeout-minutes: 30
+
Pytorch_Layer_Tests:
name: Pytorch Layer Tests
needs: [ Docker, Build, Smart_CI ]
@@ -229,7 +285,14 @@ jobs:
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
python-version: '3.12'
target-branch: ${{ inputs.target-branch }}
- if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERS && github.event_name != 'schedule'
+ if: |
+ github.event_name != 'schedule' && (
+ fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERS ||
+ fromJSON(needs.smart_ci.outputs.affected_components).CPU ||
+ fromJSON(needs.smart_ci.outputs.affected_components).GPU ||
+ fromJSON(needs.smart_ci.outputs.affected_components).transformations ||
+ fromJSON(needs.smart_ci.outputs.affected_components).Core
+ )
dGPU_B50_Nightly:
name: dGPU Arc-B50 Tests Nightly
@@ -269,7 +332,7 @@ jobs:
Overall_Status:
name: ci/gha_overall_status_ubuntu_24
- needs: [Smart_CI, Build, Debian_Packages, Samples, Python_Unit_Tests, Pytorch_Layer_Tests, TensorFlow_Layer_Tests, Openvino_tokenizers]
+ needs: [Smart_CI, Build, Debian_Packages, Samples, Python_Unit_Tests, Pytorch_Layer_Tests, TensorFlow_Layer_Tests, Openvino_tokenizers, LLM_Accuracy_CPU, LLM_Accuracy_iGPU, LLM_Accuracy_dGPU]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
diff --git a/tests/llm/accuracy_conformance.py b/tests/llm/accuracy_conformance.py
index 2fd46a72680..79276efb47e 100644
--- a/tests/llm/accuracy_conformance.py
+++ b/tests/llm/accuracy_conformance.py
@@ -142,7 +142,7 @@ def setup_model(model_id):
int8_model_path = get_model_path(model_id, PREC_INT8)
if not os.path.exists(int8_model_path):
logger.info(f'Creating INT8 OpenVINO model: {int8_model_path}')
- ov_model = OVModelForCausalLM.from_pretrained(model_cached, local_files_only=True, load_in_8bit=True)
+ ov_model = OVModelForCausalLM.from_pretrained(model_id, local_files_only=True, load_in_8bit=True)
ov_model.save_pretrained(int8_model_path)
tokenizer.save_pretrained(int8_model_path)
del ov_model
@@ -155,7 +155,7 @@ def setup_model(model_id):
logger.info(f'Creating INT4 OpenVINO model: {int4_model_path}')
quantization_config = OVWeightQuantizationConfig(bits=4, ratio=0.8)
quantized_model = OVModelForCausalLM.from_pretrained(
- model_cached,
+ model_id,
local_files_only=True,
quantization_config=quantization_config,
)
@@ -231,7 +231,7 @@ def test_accuracy_conformance(model_id, precision, device):
print(f"Testing model: {model_path}, precision: {precision}, device: {actual_device}")
target_model = load_model(task, model_path, actual_device, ov_config, hf, use_genai, dont_use_llamacpp)
- tokenizer = AutoTokenizer.from_pretrained(model_path)
+ tokenizer = AutoTokenizer.from_pretrained(model_path, local_files_only=True)
use_chat_template = tokenizer is not None and tokenizer.chat_template is not None
@@ -253,6 +253,6 @@ def test_accuracy_conformance(model_id, precision, device):
threshold = get_threshold(model_id, device, precision)
- abs_metric_diff = abs(expected_reference - metric)
+ metric_drop = expected_reference - metric
print(f"Metric: {metric}, Expected: {expected_reference}, Model: {model_id}, Precision: {precision}")
- assert abs_metric_diff <= threshold, f"Metric difference {abs_metric_diff} exceeds threshold {threshold}"
+ assert metric_drop <= threshold, f"Metric drop {metric_drop} exceeds threshold {threshold}"
diff --git a/tests/llm/requirements.txt b/tests/llm/requirements.txt
index ca289cea8c5..87ccb6615d0 100644
--- a/tests/llm/requirements.txt
+++ b/tests/llm/requirements.txt
@@ -3,4 +3,5 @@
optimum-intel[tests,nncf]
whowhatbench[llm-test-openvino] @ git+https://github.com/openvinotoolkit/openvino.genai.git#subdirectory=tools/who_what_benchmark
pytest
+pytest-html
jinja2>=3.1.0