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.1.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.1-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ptblop-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 bb8738f601cc77c92f4f588e8392aaa46ed867619f0a518143ea35d41f685477
MD5 f56f0bb8c97a152afafaa2f3814c3dd4
BLAKE2b-256 fcab13a6aa347cabf48588e30f81f14bcfcc8d37325055b338c0f7bde5fa9620

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptblop-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80b3724ffbf2b44bc79625c4e9816c83cfad73b5952475427363e8448284c726
MD5 67d4d0054756dfdba8267b84f92cb3e9
BLAKE2b-256 667e84e12fc15c890f48438cdb2c70ca58c803d8922c5702a13623a8f16bbdc1

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