Skip to main content

Package containing builders for block-pruned transformer models in PyTorch

Project description

ptblop

Package containing builders for block-pruned transformer models in PyTorch.

Installation

You can install ptblop package via pip:

pip install ptblop

Creating a block-pruned model

To create a block-pruned model, you need a bp_config usually serialized in a JSON file. A code sample for loading block pruned language model Qwen/Qwen1.5-4B from transformers library is included below. Sample bp_configs for Qwen/Qwen1.5-4B are here.

import json

import ptblop
import transformers
import torch

bp_config_path = "./bp_config.json"
model_name = "Qwen/Qwen1.5-4B"
dtype = torch.bfloat16

model = transformers.AutoModelForCausalLM.from_pretrained(
        model_name,
        torch_dtype=dtype,
        trust_remote_code=True,
    )

with open(bp_config_path, "rt") as f:
        bp_config = json.load(f)

ptblop.apply_bp_config_in_place(model, bp_config)

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

ptblop-0.3.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

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

ptblop-0.3.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file ptblop-0.3.0.tar.gz.

File metadata

  • Download URL: ptblop-0.3.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for ptblop-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8c13d0a13c2143a5d83b1db08655cce48d9b84b53b8a4124e177e1046081e563
MD5 6fb10c677ceb463d1e2ffe8faa3bdd4e
BLAKE2b-256 7aaf33064b11bcb1d1d28d83aedfab680ea7d531b3ef445b3e767c215a623413

See more details on using hashes here.

File details

Details for the file ptblop-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ptblop-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for ptblop-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d439cf74c3b8c4bb191e75244cf87e1b7657f4f997755dfdebe3638128614fb4
MD5 ca785c28979331fcf9bacb1b6c033768
BLAKE2b-256 71cb51bf434e28c4271869eb069db6d6ddac579deb6b9e344b8c6e5d6a14cc88

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