Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Export Refactor] Feature Branch #1858

Merged
merged 21 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5058120
initial commit
dbogunowicz Nov 28, 2023
bb5887e
respond to PR comments
dbogunowicz Dec 4, 2023
2930dea
[Export Refactor][Image Classification] `create_model` function (#1878)
dbogunowicz Dec 11, 2023
5ac4d35
[Export Refactor][Image Classification] `create_dummy_input` function…
dbogunowicz Dec 11, 2023
59f3f5a
[Export Refactor][Image Classification] `export_model` function (#1883)
dbogunowicz Dec 11, 2023
9096b0d
[Export Refactor][Image Classification] `apply_optimizations` functio…
dbogunowicz Dec 11, 2023
16c9bf3
[Export Refactor][Image Classification] `export_sample_inputs_outputs…
dbogunowicz Dec 11, 2023
4d66402
remove duplicated function
dbogunowicz Dec 11, 2023
ed04d3f
[Export Refactor][Image Classification] `create_deployment_folder` fu…
dbogunowicz Dec 12, 2023
571aed8
[Export Refactor][Image Classification] `validate_correctness` functi…
dbogunowicz Dec 12, 2023
627ddd6
[Export Refactor] End to end testing (#1898)
dbogunowicz Dec 14, 2023
3da5f23
[Export Refactor] Prepare the module to be more general (before inclu…
dbogunowicz Dec 19, 2023
c65ab6e
[Export Refactor][Transformers] Enable loading SparseModels (#1921)
dbogunowicz Dec 21, 2023
e4770c8
Fix the tests
dbogunowicz Dec 29, 2023
7b28881
fix tests with help from sara
dbogunowicz Jan 2, 2024
6179cb2
[Export][Transformers] Enable loading `text-generation` datasets (#1938)
dbogunowicz Jan 5, 2024
7f166a1
tests fixed
dbogunowicz Jan 6, 2024
c3c90a4
fix test
dbogunowicz Jan 6, 2024
57a4dd0
[Export refactor] final manual testing fixes (#1948)
bfineran Jan 10, 2024
ee78625
Export Refactor CLI (#1949)
bfineran Jan 10, 2024
8c647b8
Merge branch 'main' into feature/damian/feature_branch_export
bfineran Jan 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/test-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
deepsparse: ${{ steps.deepsparse-check.outputs.output }}
onnx: ${{ steps.onnx-check.outputs.output }}
pytorch: ${{ steps.pytorch-check.outputs.output }}
export: ${{ steps.export-check.outputs.output }}
transformers: ${{ steps.transformers-check.outputs.output }}
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -54,6 +55,10 @@ jobs:
((git diff --name-only origin/main HEAD | grep -E "[src|tests]/sparseml/pytorch|setup.py|.github")
|| (echo $GITHUB_REF | grep -E "refs/heads/[release/|main]"))
&& echo "::set-output name=output::1" || echo "::set-output name=output::0"
- name: "Checking if sparseml.export was changed"
id: export-check
run: >
((git diff --name-only origin/main HEAD | grep -E "[src|tests]/sparseml/export|setup.py|.github")
- name: "Checking if sparseml.transformers was changed"
id: transformers-check
run: >
Expand Down Expand Up @@ -228,3 +233,28 @@ jobs:
run: pip3 install .[dev,torch,transformers]
- name: "🔬 Running transformers tests"
run: make test TARGETS=transformers
export-tests:
runs-on: ubuntu-22.04
env:
SPARSEZOO_TEST_MODE: "true"
needs: test-setup
if: ${{needs.test-setup.outputs.export == 1}}
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
repository: "neuralmagic/sparsezoo"
path: "sparsezoo"
ref: ${{needs.test-setup.outputs.branch}}
- name: "⚙️ Install sparsezoo dependencies"
run: pip3 install -U pip && pip3 install setuptools sparsezoo/
- name: "Clean sparsezoo directory"
run: rm -r sparsezoo/
- name: "⚙️ Install dependencies"
run: pip3 install .[dev,torch,transformers,torchvision,onnxruntime]
- name: "🔬 Running export tests"
run: make test TARGETS=export

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MDCHECKFILES := CODE_OF_CONDUCT.md CONTRIBUTING.md DEVELOPING.md README.md
SPARSEZOO_TEST_MODE := "true"

BUILD_ARGS := # set nightly to build nightly release
TARGETS := "" # targets for running pytests: deepsparse,keras,onnx,pytorch,pytorch_models,pytorch_datasets,tensorflow_v1,tensorflow_v1_models,tensorflow_v1_datasets
TARGETS := "" # targets for running pytests: deepsparse,keras,onnx,pytorch,pytorch_models,export,pytorch_datasets,tensorflow_v1,tensorflow_v1_models,tensorflow_v1_datasets
PYTEST_ARGS ?= ""
PYTEST_INTEG_ARGS ?= ""
ifneq ($(findstring deepsparse,$(TARGETS)),deepsparse)
Expand All @@ -18,6 +18,9 @@ endif
ifneq ($(findstring transformers,$(TARGETS)),transformers)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/transformers
endif
ifneq ($(findstring export,$(TARGETS)),export)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/export
endif
ifneq ($(findstring keras,$(TARGETS)),keras)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/keras
endif
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ def _setup_extras() -> Dict:
def _setup_entry_points() -> Dict:
entry_points = {
"console_scripts": [
# export
"sparseml.export=sparseml.export.export:main",
# sparsification
"sparseml.framework=sparseml.framework.info:_main",
"sparseml.sparsification=sparseml.sparsification.info:_main",
Expand Down
2 changes: 1 addition & 1 deletion src/sparseml/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def pre_initialize_structure(
This will run the pre-initialize structure method for each modifier in the
session's lifecycle. This will also set the session's state to the
pre-initialized state. Takes care of cases when the model(s) structure
has been previosuly modified by a modifier.
has been previously modified by a modifier.

:param model: the model to pre-initialize the structure for
:param recipe: the recipe to use for the sparsification, can be a path to a
Expand Down
17 changes: 17 additions & 0 deletions src/sparseml/export/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# flake8: noqa

from .export import *
Loading
Loading