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.4.0.tar.gz (15.3 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.4.0-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ptblop-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c7207252a73ab2d1463b7fd84503e9f271efc1a0d434b2ce0902a41e2f0923b8
MD5 94f3ffc97d8956e5beeabd8af0ed42bc
BLAKE2b-256 226190d65ba5782af214dd668744396e563d27a27fb5cb0ad2bec078ae310481

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptblop-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 22.1 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 baeeb89ea4be444a7f5276ffb17909cb349c9a64c21d12e8d6b41e1eba9eb545
MD5 0810c3a2ee63792599b3f06b569180df
BLAKE2b-256 1f9548c9ab2b2f648d9b4b57c0da8a7936b1ac033f35334d132b343436c7c153

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