Package containing builders for block-pruned transformer models in PyTorch
Project description
ptblop
Package containing builders for block-pruned transformer models in PyTorch.
Creating a block-pruned model
To create a block-pruned model, you need a bp_config usually serialized in a
JSON file. Code sample for language model from transformers library is presented
below:
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ptblop-0.1.0.tar.gz.
File metadata
- Download URL: ptblop-0.1.0.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9f461ebf51b51914cb22aa09c7c6795772deedc56357ad7be29b8b1a79a7e8d
|
|
| MD5 |
d9ecc4ada4e9bdfb70ef645fcb0381e7
|
|
| BLAKE2b-256 |
a4006c68dc15390623e870cad172146425e663096f9e1582b17b8d526d082262
|
File details
Details for the file ptblop-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ptblop-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72a54c3ea41f063596dc9ea0075cd175e46ceda7594ab908c4e7ca7eeeecc517
|
|
| MD5 |
c6f659a792e72d0570ca22411b5f6951
|
|
| BLAKE2b-256 |
3d24180db98f37d3f42e0d1fb8e6cd5f0697697d55de502324f0a78014507a8e
|