Skip to content

Commit 2aba50c

Browse files
committed
Remove obsolete release notes and release script for v0.2.2
1 parent 2682e09 commit 2aba50c

File tree

3 files changed

+94
-330
lines changed

3 files changed

+94
-330
lines changed

RELEASE_NOTES_v0.2.2.md

Lines changed: 0 additions & 163 deletions
This file was deleted.

optipfair.egg-info/PKG-INFO

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.4
22
Name: optipfair
3-
Version: 0.2.1
3+
Version: 0.2.2
44
Summary: A library for structured pruning & Bias visualization of large language models
55
Home-page: https://github.com/peremartra/optipfair
66
Author: Pere Martra
@@ -234,6 +234,48 @@ pruned_model.save_pretrained("./pruned-datadriven-model")
234234

235235
**Note:** Data-driven pruning is currently only available with `neuron_selection_method="MAW"`. Using a dataloader with "VOW" or "PON" will raise a `ValueError`.
236236

237+
### Selective Layer Width Pruning (NEW in v0.2.0)
238+
239+
Prune neurons only in specific layers while leaving others unchanged. Perfect for preserving critical layers or implementing layer-specific optimization strategies.
240+
241+
```python
242+
from transformers import AutoModelForCausalLM
243+
from optipfair import prune_model
244+
245+
# Load a pre-trained model
246+
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B")
247+
248+
# Prune neurons only in specific layers (e.g., middle layers)
249+
pruned_model, stats = prune_model(
250+
model=model,
251+
pruning_type="MLP_GLU",
252+
neuron_selection_method="MAW",
253+
pruning_percentage=30,
254+
layer_indices=[5, 10, 15, 20, 25], # Only prune these layers
255+
show_progress=True,
256+
return_stats=True
257+
)
258+
259+
# Print pruning statistics
260+
print(f"Pruned {stats['pruned_layers']} of {stats['total_layers']} layers")
261+
print(f"Total reduction: {stats['reduction']:,} parameters ({stats['percentage_reduction']:.2f}%)")
262+
263+
# Save the pruned model
264+
pruned_model.save_pretrained("./selective-pruned-llama")
265+
```
266+
267+
**Key Benefits:**
268+
- 🎯 **Precision Control**: Choose exactly which layers to optimize
269+
- 🛡️ **Preserve Critical Layers**: Keep first and last layers at full capacity
270+
- 🔬 **Data-Driven Selection**: Combine with layer importance analysis
271+
- ⚡ **Full Compatibility**: Works with all MLP_GLU features (expansion_rate, expansion_divisor, dataloader)
272+
273+
**Use Cases:**
274+
- Preserve embedding and output layers while pruning middle layers
275+
- Target specific layer ranges based on importance analysis
276+
- Implement asymmetric pruning strategies for domain adaptation
277+
- Experiment with different layer-wise pruning patterns
278+
237279
### Hardware-Optimized Pruning with expansion_divisor (NEW in v0.2.0)
238280

239281
The `expansion_divisor` parameter ensures that intermediate layer sizes are divisible by specific values (32, 64, 128, or 256), optimizing performance on modern GPUs and TPUs.
@@ -269,6 +311,48 @@ pruned_model.save_pretrained("./pruned-optimized-model")
269311

270312
**Note:** Cannot be used alone—requires either `pruning_percentage` or `expansion_rate`.
271313

314+
### Selective Layer Width Pruning (NEW in v0.2.0)
315+
316+
Prune neurons only in specific layers while leaving others unchanged. Perfect for preserving critical layers or implementing layer-specific optimization strategies.
317+
318+
```python
319+
from transformers import AutoModelForCausalLM
320+
from optipfair import prune_model
321+
322+
# Load a pre-trained model
323+
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B")
324+
325+
# Prune neurons only in specific layers (e.g., middle layers)
326+
pruned_model, stats = prune_model(
327+
model=model,
328+
pruning_type="MLP_GLU",
329+
neuron_selection_method="MAW",
330+
pruning_percentage=30,
331+
layer_indices=[5, 10, 15, 20, 25], # Only prune these layers
332+
show_progress=True,
333+
return_stats=True
334+
)
335+
336+
# Print pruning statistics
337+
print(f"Pruned {stats['pruned_layers']} of {stats['total_layers']} layers")
338+
print(f"Total reduction: {stats['reduction']:,} parameters ({stats['percentage_reduction']:.2f}%)
339+
340+
# Save the pruned model
341+
pruned_model.save_pretrained("./selective-pruned-llama")
342+
```
343+
344+
**Key Benefits:**
345+
- 🎯 **Precision Control**: Choose exactly which layers to optimize
346+
- 🛡️ **Preserve Critical Layers**: Keep first and last layers at full capacity
347+
- 🔬 **Data-Driven Selection**: Combine with layer importance analysis
348+
- ⚡ **Full Compatibility**: Works with all MLP_GLU features (expansion_rate, expansion_divisor, dataloader)
349+
350+
**Use Cases:**
351+
- Preserve embedding and output layers while pruning middle layers
352+
- Target specific layer ranges based on importance analysis
353+
- Implement asymmetric pruning strategies for domain adaptation
354+
- Experiment with different layer-wise pruning patterns
355+
272356
### Pruning Transformer Layers (Depth Pruning)
273357

274358
Remove entire layers from a model for significant efficiency gains. Here, we remove the last 4 layers.
@@ -415,6 +499,9 @@ The optipfair project is actively developed. Here's what's planned for the futur
415499
### Future Roadmap
416500
Our goal is to make optipfair the go-to toolkit for efficient and fair model optimization. Key upcoming features include:
417501

502+
* **Selective Layer Width Pruning**: Implemented in v0.2.0 ✓ - Prune neurons in specific layers using layer_indices
503+
* **Data-Driven Width Pruning**: Implemented in v0.2.0 ✓ - Hybrid importance with calibration data
504+
* **Hardware-Optimized Pruning**: Implemented in v0.2.0 ✓ - expansion_divisor for GPU optimization
418505
* **Attention Pruning**: Implementing Attention Bypass and Adaptive Attention Bypass(AAB).
419506
* **Advanced Benchmarks**: Integrating more comprehensive performance and evaluation benchmarks.
420507
* **GPU Optimizations**: Creating a v2.0 with significant GPU-specific optimizations for faster execution.
@@ -427,11 +514,13 @@ Contributions are welcome! Whether it's bug reports, feature requests, or code c
427514
If you use optipfair in your research or projects, please cite the library:
428515

429516
```bibtex
430-
@software{optipfair,
431-
author = {Pere Martra},
432-
title = {optipfair: A Library for Structured Pruning and Bias Visualization of Large Language Models},
517+
@misc{Martra2024optipfair,
518+
author = {Martra, Pere},
519+
title = {{optipfair: A Library for Structured Pruning and Bias Visualization of Large Language Models}},
433520
year = {2024},
434-
url = {https://github.com/peremartra/optipfair}
521+
howpublished = {GitHub Repository},
522+
url = {https://github.com/peremartra/optipfair},
523+
note = {Versión 0.2.0, accedido 14 Noviembre 2025}
435524
}
436525
```
437526
### License

0 commit comments

Comments
 (0)