function init
python
init(
project: str,
baseline: str,
experiment: str | None = None,
duplicate_from: str | None = None,
description: str | None = None,
device: str | None = None
) → OwLite
Initialize the projects, baselines, and/or experiments.
- A project comprises one or more baselines, the unmodified models you want to compress.
- For each baseline in a project, you can create one or more experiments to benchmark various compression configurations for the baseline.
- The project, baseline, or experiment name must only include alphanumeric characters and special characters among ()-_@:*&.
Args:
project
(str
): The new (or an existing) project name.baseline
(str
): The new baseline name.experiment
(str
.optional
): The experiment name you want to create or load. Ifexperiment
is not provided, the process defaults tobaseline mode
; however, ifexperiment
is specified, the process operates inexperiment mode
.duplicate_from
(str
.optional
): The experiment name you want to clone.description
(str
.optional
): A brief description of your project within 140 characters. (Required only for creating a new project.)device
(str
.optional
): The name of the device to override the currently connected device.
Raises:
RuntimeError
: When issues related to OwLite's operation are indicated.- If the current OwLite version is deprecated.
- If not authenticated.
- When the baseline is not found in the given project.
- When the baseline and the connected device have different runtimes.
- When the experiment to duplicate from is not found in the given baseline.
ValueError
: When provided values are invalid.- When the given baseline name is invalid.
- When the given experiment name is invalid.
- When the description length exceeds the limit.
Returns:
OwLite
: Anowlite.OwLite
object configured for the designated project, baseline, and/or experiment.
Two different modes triggered by owlite.init
- Baseline mode: Creating or loading a project and its baseline
If you want to create a new project named "myproject" with a new baseline named "mymodel", add the following line in your code:
python
owl = owlite.init(project="my_project", baseline="my_model")
This function call can behave in different ways depending on the circumstances.
- If the project named
"my_project"
already exists, the existing one will be loaded. - In contrast, if the baseline
"my_model"
already exists in the project"my_project"
, it will still create a new baseline. The name of the newly created baseline will be renamed automatically by appending an appropriate postfix (e.g.,"my_model_1"
or"my_model_2"
)
- Experiment mode: Creating or loading an experiment
After creating a compression configuration at owlite.ai, you can benchmark the (compressed) model from your experiment as follows:
```python import owlite
owl = owlite.init(project="myproject", baseline="mymodel", experiment="my_experiment") ```
This function call can behave in different ways depending on the circumstances.
- If the experiment
"my_experiment"
is not found, OwLite will create a new one. In this case, the compression configuration for the newly created experiment will be empty. By callingowl.convert
andowl.benchmark
for this experiment, you can benchmark the baseline. - If the experiment
"my_experiment"
already exists, it downloads the compression configuration from the experiment. By callingowl.convert
andowl.benchmark
, you can benchmark the compressed model from the experiment.
Furthermore, you can clone an existing experiment by providing its name to duplicate_from
.
```python import owlite
owl = owlite.init(project="myproject", baseline="mymodel", experiment="newexperiment", duplicatefrom="existing_experiment") ```
If "new_experiment"
already exists, the newly created experiment will be renamed appropriately (e.g., "new_experiment_1"
or "new_experiment_2"
.)
By performing these tasks, the init
function ensures that the necessary setup is done for the project, baseline, and experiment within OwLite.
Examples:
- Baseline Mode:
```python import owlite
owl = owlite.init(project="testProject", baseline="sampleModel") ```
This code creates a new project named "testProject"
and a new baseline named "sampleModel"
provided that the project with the same name does not already exist. owlite.init
returns an owlite.OwLite
object, which you will need for converting or benchmarking your baseline model.
A typical output of this code is as follows:
OwLite [INFO] Created a new project 'testProject'
OwLite [INFO] Device connected: NVIDIA RTX A6000 [TensorRT]
OwLite [INFO] Created a new baseline 'sampleModel' in the project 'testProject'
OwLite [INFO] Experiment data will be saved in /home/sqzb/workspace/owlite/testProject/sampleModel
- Experiment Mode:
```python import owlite
owl = owlite.init(project="testProject", baseline="sampleModel", experiment="conv") ```
This code loads the experiment named "conv"
for the baseline "sampleModel"
in the project "testProject"
. Likewise, owlite.init
returns an owlite.OwLite
object, which you will need for benchmarking the experiment.
A typical output of this code is as follows:
OwLite [INFO] Loaded the existing project 'testProject'
OwLite [INFO] Device connected: NVIDIA RTX A6000 [TensorRT]
OwLite [INFO] Loaded the existing experiment 'conv' for the baseline 'sampleModel' in the project 'testProject'
OwLite [INFO] Compression configuration found for 'conv'
OwLite [INFO] Experiment data will be saved in /home/sqzb/workspace/owlite/testProject/sampleModel/conv
OwLite stores files, such as ONNX or TensorRT engine, generated from your code at ${OWLITE_HOME}/<project>/<baseline>/<experiment>
, where OWLITE_HOME is an environment variable that defaults to ./owlite
.
- Targeting A Device: If you want your baseline or experiment to target a different device from the one configured via OwLite CLI, use the
device
argument to specify a device of your choice. (Runowlite device ls
to see the available devices.)
For example, you may add the keyword argument device="NVIDIA RTX A4000"
to create an experiment specifically targeting the device "NVIDIA RTX A4000".
```python import owlite
owl = owlite.init(project="testProject", baseline="sampleModel", experiment="conv", device="NVIDIA RTX A4000") ```
OwLite [INFO] Loaded the existing project 'testProject'
OwLite [INFO] Device connected: NVIDIA RTX A4000 [TensorRT]
OwLite [INFO] Loaded the existing experiment 'conv' for the baseline 'sampleModel' in the project 'testProject'
OwLite [INFO] Compression configuration found for 'conv'
OwLite [WARNING] Connected device not matching baseline 'sampleModel': NVIDIA RTX A6000 [TensorRT].
Results may vary from latency breakdowns shown in the editor.
OwLite [WARNING] Existing local directory found at /home/sqzb/workspace/owlite/testProject/sampleModel/conv.
Continuing this code will overwrite the data
Warnings:
Version mismatch
If your current version of OwLite is not the latest supported version, you'll receive the following warning message:
OwLite [WARNING] A new version of OwLite is available. To ensure the best usage,
please update the package to the latest version with the following command:
pip install owlite --extra-index-url https://pypi.squeezebits.com/ --upgrade
To ensure optimal performance and access to new features, it's recommended to update OwLite using the provided command.
Baseline device mismatch
If the device connected does not match the device associated with the baseline, you'll receive the following warning message:
OwLite [WARNING] Connected device does not match baseline 'sampleModel': NVIDIA RTX A6000 [TensorRT].
Results may vary from latency breakdowns shown in the editor.
Ensure that the connected device matches the baseline device to obtain accurate latency breakdowns.
Experiment directory exists
When the local directory for your baseline or experiment already exists, OwLite will overwrite existing files.
OwLite [WARNING] Existing local directory found at {target.home}. Continuing this code will overwrite the data.
If you proceed, the existing data in the directory will be overwritten.
The warning messages have been documented to provide insights into potential issues or actions that users may need to take into consideration.
Updated: 2024-06-13T23:42:42