Skip to main content

A high-performance AI model optimization library

Project description

Solv AI

Solv AI is a high-performance AI model optimization library designed to enhance the efficiency and speed of running large-scale models on local, resource-constrained hardware. By leveraging advanced techniques such as custom quantization, pruning, mixed precision inference, and efficient memory management, Solv AI enables seamless deployment and inference of sophisticated AI models even on slower machines.

Key Features

  • Custom Quantization: Reduce model precision for faster computation without significant loss of accuracy.
  • Pruning: Remove less important parameters to reduce model size and computational load.
  • Layer-wise Loading: Load model layers incrementally to optimize memory usage.
  • Mixed Precision Inference: Utilize both 16-bit and 32-bit operations to accelerate processing.
  • Efficient Memory Management: Advanced techniques to reuse memory allocations and minimize overhead.
  • Lightweight Architectures: Optimized model architectures for resource efficiency.
  • Layer Fusion: Combine multiple layers into a single operation to reduce memory access and improve computational efficiency.
  • Batch Normalization Folding: Fold batch normalization into preceding convolution layers to reduce the number of operations.
  • Weight Sharing: Share weights across different layers to reduce the model size.
  • Knowledge Distillation: Use a smaller "student" model trained to mimic a larger "teacher" model.
  • Dynamic Quantization: Apply quantization dynamically during inference to adapt to different input data distributions.
  • Distributed Computing: Utilize multiple devices to accelerate model training and inference.

Installation

To install Solv AI, use pip:

pip install solv-ai

Usage

Custom Quantization

from solv_ai import QuantizedLayer
import numpy as np
weights = np.random.rand(5, 10)
quant_layer = QuantizedLayer(weights, bits=8)
x = np.random.rand(3, 10)
output = quant_layer.forward(x)
print("Quantized output:")
print(output)

Pruning

from solv_ai import PrunedLayer
import numpy as np
weights = np.random.rand(5, 10)
prune_layer = PrunedLayer(weights, pruning_rate=0.5)
x = np.random.rand(3, 10)
output = prune_layer.forward(x)
print("Pruned output:")
print(output)

Mixed Precision Inference

import torch
import torch.nn as nn
import torch.optim as optim
from solv_ai import MixedPrecisionLayer
class SimpleModel(nn.Module):
def init(self):
super(SimpleModel, self).init()
self.fc = nn.Linear(10, 5)
def forward(self, x):
return self.fc(x)
model = SimpleModel()
optimizer = optim.Adam(model.parameters(), lr=0.001)
mp_layer = MixedPrecisionLayer(model, optimizer)
x = torch.randn(3, 10)
output = mp_layer.forward(x)
loss = output.sum()
mp_layer.backward(loss)

Efficient Models

from solv_ai import EfficientNet
import torch
model = EfficientNet()
x = torch.randn(3, 3, 224, 224)
output = model(x)
print("EfficientNet output:")
print(output)

Distributed Computing

import torch
import torch.nn as nn
from solv_ai import ModelParallelLayer, DataParallelLayer, PipelineParallelLayer
class SimpleModel(nn.Module):
def init(self):
super(SimpleModel, self).init()
self.fc = nn.Linear(10, 5)
def forward(self, x):
return self.fc(x)
model = SimpleModel()
device_ids = [0, 1]
mp_layer = ModelParallelLayer(model, device_ids)
dp_layer = DataParallelLayer(model, device_ids)
pipeline_layer = PipelineParallelLayer([model], chunks=2)
x = torch.randn(3, 10)
output_mp = mp_layer(x)
output_dp = dp_layer(x)
output_pipeline = pipeline_layer(x)
print("Model Parallel output:")
print(output_mp)
print("Data Parallel output:")
print(output_dp)
print("Pipeline Parallel output:")
print(output_pipeline)

Profiling

from solv_ai import profile_model
import torch.nn as nn
class SimpleModel(nn.Module):
def init(self):
super(SimpleModel, self).init()
self.fc = nn.Linear(10, 5)
def forward(self, x):
return self.fc(x)
model = SimpleModel()
profile_model(model, (3, 10))

License

Solv AI is licensed under the MIT License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solv_ai-0.2.5.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solv_ai-0.2.5-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file solv_ai-0.2.5.tar.gz.

File metadata

  • Download URL: solv_ai-0.2.5.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for solv_ai-0.2.5.tar.gz
Algorithm Hash digest
SHA256 b32ca713aa892c72f5c259ab71998e3f2b341d454c82daa12922dd1a9b44fadf
MD5 aa673b352b30b255226d49564952f7da
BLAKE2b-256 1c218cf7e4479bb9ce572de3cdbcc2afb2b16755c4d9c681fa2a6bd85f99ec30

See more details on using hashes here.

File details

Details for the file solv_ai-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: solv_ai-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for solv_ai-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 881e10b472973f66fd9679277933ba062aebb948888fe4850473c8007d4d7f99
MD5 c23b377a7b0110d8f442efa6d0f3a527
BLAKE2b-256 7147aba606fd4309807d75ebbbabda98c76f8b4778fcd6978324655138a520e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page