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.2.0.tar.gz (18.6 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.2.0-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ptblop-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b2fac9a21326f0a0d4363dc8585461cf30cfe28c55c4feceb951d2e07d41cb26
MD5 a3c2cd1cfc69ad99d0a6e3b60301923d
BLAKE2b-256 8dda29edf71c6a56a9aa8094e8ff78e5a6f3e5900893c6b0b56f7554f5b7c811

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptblop-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 23.2 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c04d1f96fe846e4367e272c465ffc9817dc3cea218b788c6a4687b1fa49d11d
MD5 8692f31812eed15868932c30b358c663
BLAKE2b-256 9228e19249be1efeac326b53f5cce57d95c6dadd83f1d421af7922b1dd1a1c95

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