Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Deltatuner

Deltatuner is an extension for Peft to improve LLM fine-tuning speed through multiple optimizations, including: leverage the compact model constructor DE-NAS to construct/modify the compact delta layers in a hardware-aware and train-free approach, and adding more new deltatuning algorithms.

Introduction

Key Components

  • Supported parameter efficient finetuning algorithms
    • LoRA algorithm
    • Scaling and Shifting(SSF) algorithm: Scale and Shift the deep features in a pre-trained model with much less parameters to catch up with the performance of full finetuning
    • WIP on adding more algos (AdaLora etc.)
  • De-Nas: Automatically construct compact and optimal delta layers with train-free and hardware-aware mode (more details here)
    • step1: Generate search space for delta layers
    • step2: Search algorithm populates delta layers for LM
    • step3: Train-free score evaluates LM with adaptive delta layers

Features

  • Easy-to-use: provide package install, just need to inject few codes into the original code
  • Auto-tuning: automatically select best algorithms and delta structure for finetuning model

Values

  • Saving computation power: reduce the computation power and time required to fine-tune a model by reducing parameter size as well as memory footprint.
  • Improve accuracy: ensure same or no accuracy regression.

Get Started

Installation

  • install the python package
pip install deltatuner

Fast Fine-tuning on Base models

Below is an example of optimizing MPT model by adding the following few-lines to use the delatuner optimizations. It use the DE-NAS in delatuner to optimize a LLM with LoRA layers to a LLM with compact LoRA layers, so as to efficiently improve the LLM fine-tuning process in peak memory reduction and time speedup.

from delta import deltatuner, deltatuner_args
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import LoraConfig, get_peft_model
from deltatuner import deltatuner, deltatuner_args

# import model from huggingface
model_id =  "mosaicml/mpt-7b"
model = AutoModelForCausalLM.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
# adding the lora componenents with peft
config = LoraConfig()
lora_model = get_peft_model(model, config) 
# delatuner optimize the model with best lora layer configuration
deltatuning_args = deltatuner_args.DeltaTunerArguments()
deltatuner_model = deltatuner.optimize(model=lora_model, tokenizer=tokenizer, deltatuning_args=deltatuning_args)
...

API reference

In above examples, deltatuner.optimize is a python function to using deltatuner supported optimization algorithms to optimize the model.

def optimize(model, tokenizer, algo: str="auto", deltatuning_args: DeltaTunerArguments=None) -> DeltaTunerModel:
    '''
    Parameters:
        model  - a PreTrainedModel or LoraModel. Specifies what model should be optimized
        tokenizer - a tokenizer for preprocess text
        algo (str, optional) – the algorithm. Specifies what type of adapter algorithm (default: “auto”)
            "auto" – If the input model is mpt, the algorithm is ssf; elif the algorithm is lora
            "lora" – use the lora algotihm
            "ssf" – use the ssf algotithm
        deltatuning_args (optional) – the deltatuner configuration. Specifically, deltatuning_args.denas is to use the denas in the optimization (default: True)
    Return 
        DeltaTunerModel - a wrapper of model, which composed of the original properties/function together with adavance properties/function provided by deltatuner
    '''

Detailed examples

Please refer to example page for more use cases on fine-tuning other LLMs with the help of DeltaTuner.

Model supported matrix

Causal Language Modeling

Model LoRA SSF
GPT-2 ✅
GPT-J ✅ ✅
Bloom ✅ ✅
OPT ✅ ✅
GPT-Neo ✅ ✅
Falcon ✅ ✅
LLaMA ✅ ✅
MPT ✅ ✅

Metadata

Release files for deltatuner 1.0b202310231007

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deltatuner 1.0b202310231007
File Size Uploaded Provenance Actions
deltatuner-1.0b202310231007.tar.gz 24.7 kB Without provenance Details for deltatuner-1.0b202310231007.tar.gz

Release files / deltatuner-1.0b202310231007.tar.gz

Download URL deltatuner-1.0b202310231007.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
996e195edaef7ecb4481cb74c02a1a28f9e1ab4251883b7431500ba86b7c02ef
BLAKE2b-256 checksum
How to use checksums
82c33f9c87dd67cc44ec6adc1a93865fa259e69a6940f6104279f5699a3eb87f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Security for deltatuner 1.0b202310231007

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page