Skip to content

Commit

Permalink
Merge branch 'main' into test-trfs
Browse files Browse the repository at this point in the history
  • Loading branch information
echarlaix committed Nov 18, 2024
2 parents 1917d1e + e8b0332 commit 3c1f85f
Show file tree
Hide file tree
Showing 37 changed files with 65 additions and 78 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/dev_test_benckmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version:
- 3.8
- 3.9
os:
- ubuntu-20.04
runs-on: ${{ matrix.os }}
python-version: ['3.9', '3.11']
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/dev_test_bettertransformer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version:
- 3.8
os:
- ubuntu-20.04
- macos-13
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
python-version: '3.9'
- name: Install dependencies
run: |
pip install .[tests]
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/dev_test_dummy_inputs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version:
- 3.8
- 3.9
python-version: ['3.9', '3.11']
os:
- ubuntu-20.04
- macos-13
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/dev_test_exporters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version:
- 3.8
- 3.9
os:
- ubuntu-20.04
runs-on: ${{ matrix.os }}
python-version: ['3.9', '3.11']
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/dev_test_fx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version:
- 3.8
- 3.9
python-version: ['3.9', '3.11']
os:
- ubuntu-20.04
- macos-13
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/dev_test_onnx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version:
- 3.8
- 3.9
python-version: ['3.9', '3.11']
os:
- ubuntu-20.04
- macos-13
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/dev_test_onnxruntime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version:
- 3.8
- 3.9
python-version: ['3.9', '3.11']
os:
- ubuntu-20.04
- windows-2019
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/dev_test_optimum_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version:
- 3.7
- 3.8
- 3.9
python-version: ['3.9', '3.11']
os:
- ubuntu-20.04
- windows-2019
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_export_onnx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.9]
python-version: ['3.9']
os: [ubuntu-20.04]

runs-on: ${{ matrix.os }}
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test_export_tflite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
os: [ubuntu-20.04]
python-version: ['3.9', '3.11']

runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test_export_tflite_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
os: [ubuntu-20.04]
python-version: ['3.9', '3.11']

runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
os: [ubuntu-20.04]
python-version: ['3.9']

runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
os: [ubuntu-20.04]
python-version: ['3.9']

runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
os: [ubuntu-20.04]
python-version: ['3.9']

runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
os: [ubuntu-20.04]
python-version: ['3.9']

runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
os: [ubuntu-20.04]
python-version: ['3.9']

runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
os: [ubuntu-20.04]
python-version: ['3.9']

runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test_exporters_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.9]
os: [ubuntu-20.04]
python-version: ['3.9', '3.11']

runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test_exporters_slow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.9]
os: [ubuntu-20.04]
python-version: ['3.9']

runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_fx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.9]
python-version: ['3.9']
os: [ubuntu-20.04, macos-13]

runs-on: ${{ matrix.os }}
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test_offline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.9]
os: [ubuntu-20.04]
python-version: ['3.9']

runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_onnx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.9]
python-version: ['3.9']
os: [ubuntu-20.04, macos-14]

runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_onnxruntime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: '3.9'

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_onnxruntime_slow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.9]
python-version: ['3.9']
os: [ubuntu-20.04]

runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_optimum_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.9]
python-version: ['3.9']
os: [ubuntu-20.04, windows-2019, macos-13]

runs-on: ${{ matrix.os }}
Expand All @@ -36,5 +36,5 @@ jobs:
shell: bash
run: |
# Setting HUGGINGFACE_CO_STAGING to true for only one job of the matrix as the staging tests cannot run in parallel.
export HUGGINGFACE_CO_STAGING=${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-20.04' }}
export HUGGINGFACE_CO_STAGING=${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-20.04' }}
pytest tests/test_*.py
2 changes: 1 addition & 1 deletion .github/workflows/test_utils.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-13]
python-version: [3.9]
python-version: ['3.9']

runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nikolaik/python-nodejs:python3.8-nodejs18
FROM nikolaik/python-nodejs:python3.9-nodejs18

ARG commit_sha
ARG clone_url
Expand Down
5 changes: 5 additions & 0 deletions optimum/exporters/onnx/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ class GemmaOnnxConfig(LlamaOnnxConfig):
MIN_TRANSFORMERS_VERSION = version.parse("4.38.0")


class GraniteOnnxConfig(LlamaOnnxConfig):
MIN_TRANSFORMERS_VERSION = version.parse("4.45.0")
MIN_TORCH_VERSION = version.parse("2.5.0")


class PhiOnnxConfig(TextDecoderWithPositionIdsOnnxConfig):
DEFAULT_ONNX_OPSET = 14 # Phi now uses F.scaled_dot_product_attention by default for torch>=2.1.1.
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig
Expand Down
1 change: 1 addition & 0 deletions optimum/exporters/onnx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"phi",
"phi3",
"qwen2",
"granite",
}


Expand Down
7 changes: 7 additions & 0 deletions optimum/exporters/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,13 @@ class TasksManager:
"text-classification",
onnx="LlamaOnnxConfig",
),
"granite": supported_tasks_mapping(
"feature-extraction",
"feature-extraction-with-past",
"text-generation",
"text-generation-with-past",
onnx="GraniteOnnxConfig",
),
"pegasus": supported_tasks_mapping(
"feature-extraction",
"feature-extraction-with-past",
Expand Down
2 changes: 1 addition & 1 deletion optimum/onnxruntime/modeling_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def prepare_past_key_values(
if self.model_type == "gemma":
num_attention_heads = self.normalized_config.num_key_value_heads
embed_size_per_head = self.normalized_config.head_dim
elif self.model_type in {"mistral", "llama", "qwen2"}:
elif self.model_type in {"mistral", "llama", "qwen2", "granite"}:
num_attention_heads = self.normalized_config.num_key_value_heads
else:
num_attention_heads = self.normalized_config.num_attention_heads
Expand Down
1 change: 1 addition & 0 deletions optimum/onnxruntime/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class ORTConfigManager:
"gpt-neo": "gpt2",
"gpt-neox": "gpt2",
"gptj": "gpt2",
"granite": "gpt2",
# longt5 with O4 results in segmentation fault
"longt5": "bert",
"llama": "gpt2",
Expand Down
1 change: 1 addition & 0 deletions optimum/utils/normalized_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ class NormalizedConfigManager:
"xlm-roberta": NormalizedTextConfig,
"yolos": NormalizedVisionConfig,
"qwen2": NormalizedTextConfig,
"granite": NormalizedTextConfigWithGQA,
}

@classmethod
Expand Down
Loading

0 comments on commit 3c1f85f

Please sign in to comment.