Skip to main content

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)

Metadata

Release files for ptblop 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ptblop 0.4.0
File Size Uploaded Provenance Actions
ptblop-0.4.0.tar.gz 15.3 kB Without provenance Details for ptblop-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ptblop 0.4.0
File Interpreter ABI Platform Actions
ptblop-0.4.0-py3-none-any.whl Python 3 none any Details for ptblop-0.4.0-py3-none-any.whl

Total release size: 37.4 kB

Release files / ptblop-0.4.0.tar.gz

Download URL ptblop-0.4.0.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c7207252a73ab2d1463b7fd84503e9f271efc1a0d434b2ce0902a41e2f0923b8
BLAKE2b-256 checksum
How to use checksums
226190d65ba5782af214dd668744396e563d27a27fb5cb0ad2bec078ae310481
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.10

Release files / ptblop-0.4.0-py3-none-any.whl

Download URL ptblop-0.4.0-py3-none-any.whl
Size 22.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
baeeb89ea4be444a7f5276ffb17909cb349c9a64c21d12e8d6b41e1eba9eb545
BLAKE2b-256 checksum
How to use checksums
1f9548c9ab2b2f648d9b4b57c0da8a7936b1ac033f35334d132b343436c7c153
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.10

Security for ptblop 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page