Skip to main content

(EasyDel Former) is a utility library designed to simplify and enhance the development in JAX

Project description

eformer (EasyDel Former)

License Python JAX PyPI version

eformer (EasyDel Former) is a utility library designed to simplify and enhance the development of machine learning models using JAX. It provides a comprehensive collection of tools for distributed computing, custom data structures, numerical optimization, and high-performance operations. Eformer aims to make it easier to build, scale, and optimize models efficiently while leveraging JAX's capabilities for high-performance computing.

Project Structure Overview

The library is organized into several core modules:

  • aparser: Advanced argument parsing utilities with dataclass integration
  • callib: Custom function calling and Triton kernel integration
  • common_types: Shared type definitions and sharding constants
  • escale: Distributed sharding and parallelism utilities
  • executor: Execution management and hardware-specific optimizations
  • jaximus: Custom PyTree implementations and structured array utilities
  • mpric: Mixed precision training and dynamic scaling infrastructure
  • ops: Optimized operations including Flash Attention and quantization
  • optimizers: Flexible optimizer configuration and factory patterns
  • pytree: Enhanced tree manipulation and transformation utilities

Key Features

1. Mixed Precision Training (mpric)

Advanced mixed precision utilities supporting float8, float16, and bfloat16 with dynamic loss scaling, enabling faster training and reduced memory footprint.

2. Distributed Sharding (escale)

Tools for efficient sharding and distributed computation in JAX, allowing you to scale your models across multiple devices with various sharding strategies:

  • Data Parallelism (DP)
  • Fully Sharded Data Parallel (FSDP)
  • Tensor Parallelism (TP)
  • Expert Parallelism (EP)
  • Sequence Parallelism (SP)

3. Custom PyTrees (jaximus)

Enhanced utilities for creating custom PyTrees and ArrayValue objects, updated from Equinox, providing flexible data structures for your models.

4. Triton Integration (callib)

Custom function calling utilities with direct integration of Triton kernels in JAX, allowing you to optimize performance-critical operations.

5. Optimizer Factory

A flexible factory for creating and configuring optimizers like AdamW, Adafactor, Lion, and RMSProp, making it easy to experiment with different optimization strategies.

6. Optimized Operations (ops)

  • Flash Attention 2 implementation for GPUs/TPUs (via Triton and Pallas) for faster attention computations
  • 8-bit and NF4 quantization for efficient model deployment
  • Additional optimized operations under active development

API Documentation

For detailed API references and usage examples, see:

Installation

You can install eformer via pip:

pip install eformer

Getting Started

Mixed Precision Handler with mpric

from eformer.mpric import PrecisionHandler

# Create a handler with float8 compute precision
handler = PrecisionHandler(
    policy="p=f32,c=f8_e4m3,o=f32",  # params in f32, compute in float8, output in f32
    use_dynamic_scale=True
)

Custom PyTree Implementation

import jax
from eformer.jaximus import ArrayValue, implicit
from eformer.ops.quantization.quantization_functions import dequantize_row_q8_0, quantize_row_q8_0

class Array8B(ArrayValue):
    scale: jax.Array
    weight: jax.Array
    
    def __init__(self, array: jax.Array):
        self.weight, self.scale = quantize_row_q8_0(array)
    
    def materialize(self):
        return dequantize_row_q8_0(self.weight, self.scale)

array = jax.random.normal(jax.random.key(0), (256, 64), "f2")
qarray = Array8B(array)

Contributing

We welcome contributions! Please read our Contributing Guidelines to get started.

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

eformer-0.0.47.tar.gz (96.6 kB view details)

Uploaded Source

Built Distribution

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

eformer-0.0.47-py3-none-any.whl (138.0 kB view details)

Uploaded Python 3

File details

Details for the file eformer-0.0.47.tar.gz.

File metadata

  • Download URL: eformer-0.0.47.tar.gz
  • Upload date:
  • Size: 96.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for eformer-0.0.47.tar.gz
Algorithm Hash digest
SHA256 c11c89c6e5292bea73300a030af7cba62ed68f68c6349ce71f620c5b7e012a7b
MD5 b75dcbca1a9083911c4103e508798cd1
BLAKE2b-256 1380eb4101d5ca7216100fabc337956bdd5d16def3e98139e0c4f67cfa60872e

See more details on using hashes here.

File details

Details for the file eformer-0.0.47-py3-none-any.whl.

File metadata

  • Download URL: eformer-0.0.47-py3-none-any.whl
  • Upload date:
  • Size: 138.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for eformer-0.0.47-py3-none-any.whl
Algorithm Hash digest
SHA256 4ef9c2e46a230c623a89de57529cfaca05e8f666c67e2508c8a526bf1bf65959
MD5 3d0d51a1432509044fdd4714e21e2779
BLAKE2b-256 1ab93026cf65dc121376c70981345764193953bbaaabcd393ca193d44e979d01

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