Skip to content

Commit c874a1f

Browse files
Fix for diffusers 0.35 (and fix and speedup documentation build with uv) (#1426)
* fix * remove software-properties-common from doc build * create pr docs without docker * Apply suggestions from code review * test * faster doc build with uv * fix * fix uv * fix
1 parent e9c57b9 commit c874a1f

File tree

5 files changed

+51
-63
lines changed

5 files changed

+51
-63
lines changed

.github/workflows/build_documentation.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
- doc-builder*
99
- v*-release
1010

11+
env:
12+
UV_SYSTEM_PYTHON: 1
13+
UV_TORCH_BACKEND: auto
14+
1115
jobs:
1216
build_documentation:
1317
runs-on: ubuntu-22.04
@@ -21,13 +25,13 @@ jobs:
2125
- uses: actions/checkout@v4
2226
- uses: actions/setup-node@v4
2327
with:
24-
node-version: '18'
28+
node-version: "18"
2529
cache-dependency-path: "kit/package-lock.json"
2630

2731
- name: Set up Python
2832
uses: actions/setup-python@v4
2933
with:
30-
python-version: '3.11'
34+
python-version: "3.11"
3135

3236
- name: Set environment variables
3337
run: |
@@ -45,11 +49,9 @@ jobs:
4549
4650
- name: Setup environment
4751
run: |
48-
python -m pip install --upgrade pip
49-
python -m pip install --upgrade setuptools
50-
python -m pip install git+https://github.com/huggingface/doc-builder
51-
python -m pip install .[quality]
52-
python -m pip install openvino nncf neural-compressor[pt] diffusers accelerate
52+
pip install --upgrade pip uv
53+
uv pip install git+https://github.com/huggingface/doc-builder
54+
uv pip install .[quality] nncf openvino neural-compressor[pt]>3.4 diffusers accelerate
5355
5456
- name: Make documentation
5557
shell: bash

.github/workflows/build_pr_documentation.yml

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ concurrency:
99
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1010
cancel-in-progress: true
1111

12+
env:
13+
UV_SYSTEM_PYTHON: 1
14+
UV_TORCH_BACKEND: auto
15+
1216
jobs:
1317
build_documentation:
1418
runs-on: ubuntu-22.04
15-
1619
env:
1720
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
1821
PR_NUMBER: ${{ github.event.number }}
@@ -21,42 +24,34 @@ jobs:
2124

2225
steps:
2326
- uses: actions/checkout@v4
27+
- uses: actions/setup-node@v4
2428
with:
25-
repository: "huggingface/doc-builder"
26-
path: doc-builder
29+
node-version: "18"
30+
cache-dependency-path: "kit/package-lock.json"
2731

28-
- uses: actions/checkout@v4
32+
- name: Set up Python
33+
uses: actions/setup-python@v4
2934
with:
30-
repository: "huggingface/optimum-intel"
31-
path: optimum-intel
32-
33-
- name: Setup Python
34-
uses: actions/setup-python@v5
35-
with:
36-
python-version: 3.9
35+
python-version: "3.11"
3736

3837
- name: Setup environment
3938
run: |
40-
pip install --upgrade pip
41-
pip uninstall -y doc-builder
42-
cd doc-builder
43-
git pull origin main
44-
pip install .
45-
pip install black
46-
cd ..
39+
pip install --upgrade pip uv
40+
uv pip install git+https://github.com/huggingface/doc-builder
41+
uv pip install .[quality] nncf openvino neural-compressor[pt]>3.4 diffusers accelerate
4742
4843
- name: Make documentation
44+
shell: bash
4945
run: |
50-
cd optimum-intel
51-
make doc BUILD_DIR=intel-doc-build VERSION=pr_$PR_NUMBER COMMIT_SHA_SUBPACKAGE=$COMMIT_SHA CLONE_URL=$PR_CLONE_URL
52-
cd ..
53-
54-
- name: Save commit_sha & pr_number
55-
run: |
56-
cd optimum-intel
57-
sudo chmod -R ugo+rwx intel-doc-build
46+
doc-builder build optimum.intel docs/source/ \
47+
--repo_name optimum-intel \
48+
--build_dir intel-doc-build/ \
49+
--version pr_${{ env.PR_NUMBER }} \
50+
--version_tag_suffix "" \
51+
--html \
52+
--clean
5853
cd intel-doc-build
59-
sudo mv optimum.intel optimum-intel
54+
mv optimum.intel optimum-intel
6055
echo ${{ env.COMMIT_SHA }} > ./commit_sha
6156
echo ${{ env.PR_NUMBER }} > ./pr_number
6257

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,12 @@ doc: build_doc_docker_image
5959
--version_tag_suffix "" \
6060
--html \
6161
--clean
62+
63+
clean:
64+
rm -rf build
65+
rm -rf dist
66+
rm -rf .pytest_cache
67+
rm -rf .ruff_cache
68+
rm -rf .mypy_cache
69+
rm -rf optimum_intel.egg-info
70+
rm -rf *__pycache__

docs/Dockerfile

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

optimum/intel/openvino/modeling_diffusion.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@
122122
SanaSprintPipeline = object
123123

124124

125+
if is_diffusers_version(">=", "0.35.0"):
126+
from diffusers.models.cache_utils import CacheMixin
127+
else:
128+
CacheMixin = object
129+
125130
DIFFUSION_MODEL_TRANSFORMER_SUBFOLDER = "transformer"
126131
DIFFUSION_MODEL_TEXT_ENCODER_3_SUBFOLDER = "text_encoder_3"
127132

@@ -1072,7 +1077,7 @@ def __call__(self, *args, **kwargs):
10721077
return self.auto_model_class.__call__(self, *args, **kwargs)
10731078

10741079

1075-
class OVPipelinePart(ConfigMixin):
1080+
class OVPipelinePart(ConfigMixin, CacheMixin):
10761081
config_name: str = CONFIG_NAME
10771082

10781083
def __init__(
@@ -1161,6 +1166,11 @@ def __call__(self, *args, **kwargs):
11611166
def modules(self):
11621167
return []
11631168

1169+
def named_modules(self):
1170+
# starting from diffusers 0.35.0 some model parts inherit from `CacheMixin` which uses `named_modules` method
1171+
# to register some hooks for attention caching, we return empty list here since it can't be used with OpenVINO
1172+
yield from []
1173+
11641174

11651175
class OVModelTextEncoder(OVPipelinePart):
11661176
def __init__(self, model: openvino.Model, parent_pipeline: OVDiffusionPipeline, model_name: str = ""):

0 commit comments

Comments
 (0)