φ-pruning keeps whole output channels of a layer and never keeps two adjacent ones, the (1,∞)-RLL constraint.
phi holds that pruner, the Fibonacci codes it writes quantized weights and model deltas in, and a Zeckendorf register modeled beside a binary register.
Beside them, phi_store, phi_rank and phi_model read the store the p4 plugins write in a project, and train and check its ranking models.
- Quick start: install, prune a model, check it, encode it and run the tests.
- Documentation: every page, published from
docs/.
phi_prune.prunegives each eligible Conv2d and Linear weight a φ mask, the heaviest set of output channels with no two adjacent, by their L1 norms.- The model's last weight layer, the classifier head in standard architectures, stays dense unless
prune_head=True. pattern="2:4"keeps instead the 2 heaviest of every 4 consecutive channels, the mask the φ mask is measured against.finetunetrains with the masks held fixed, so pruned weights stay zero.check, and thephi-prune checkcommand on a saved checkpoint, verify every mask against its pattern and that every pruned weight is zero.- Pages: Pruning a model, The masks and Measurements.
FibonacciEncoderquantizes kept weights onto the integers 0 to F(n+2) − 1, per tensor or per output channel, and writes each level as its Zeckendorf representation.phi_prune.export.export_bitstreamwrites a model's levels as Fibonacci codewords after one JSON header line, andload_bitstreamreads them back.cassini_checkruns the minimal-form check on each kept weight's digits, which catches a digit flipped from 0 to 1 beside a 1.phi_prune.gapswrites the positions of kept entries as Fibonacci-coded gaps, andgap_bitsprices them against Elias gamma, Elias delta, a fixed-length code and the entropy.phi_prune.deltawrites a model's delta between two checkpoints as a.phidfile: the top-k changes of each tensor, their positions as gaps and each value as a sign digit and a Fibonacci-coded level.- Pages: Quantization and the code and Fibonacci codes.
phi_prune.registerholds a Zeckendorf register and a binary register, each a list of digits that local rewrite rules bring to its normal form.- The rules can fire in any order and every order ends at the same normal form.
- The module runs phi-prune's own multiply–accumulate step in each register, so the two are measured on the same sums.
- Pages: The register model, with the Zeckendorf register, the binary register, computing F(n), the Fibonacci Q-matrix and related work beside it.
- A store is a repository's
.claude/p4directory, written by the p4 plugins of ezexe/p4: p4-phi keeps its entries underphi/storeand its training files underphi/models, and p4-temportal keeps memory notes undertemportal/memory. phi_storereads a store as training records, each a text with its session, its time and its weight, andsplitholds out every record timed at or after a cutoff.phi_ranktrains an asymmetric dual encoder that scores a store's documents against a session's query, by feature hashing of words, word bigrams and character trigrams, with one head for queries and one for documents.- It pretrains contrastively with in-batch negatives on the text files of the store that its
.gitignoredoes not exclude, then fine-tunes on the store's labelled query groups by Localized Contrastive Estimation. - The dual encoder learns in rounds: git LFS keeps a full checkpoint, and a later round is warm-started from the model the checkpoints rebuild and ships an incremental checkpoint, a
.phidfile that holds the largest 10% of the entries the round changed. - A round ships a full checkpoint again when the cut costs more than 0.02 of the training query groups' R-precision, when eight incremental checkpoints follow the full one, or when the pretrained base has changed.
phi_rank.treebuilds an ensemble of shard models, K small rankers at the first K store addresses, which answers by dynamic classifier selection or by the mean of every member's z-scored scores.phi_modelis model monitoring and on-demand retraining for a store:python -m phi_modeltakescheck,init,train,test,updateandmode, over the p4-phi plugin's logistic regression ranker and the dual encoder.modewrites therecallsection of the store'sp4.json:shadowtrains and logs retrieval's lines without adding them to a session's context,activeadds the rule and fact lines, andofftrains nothing and adds nothing.- The dual encoder is an experiment that retrieval does not serve:
check,init,trainandupdateleave it untrained and find nothing of it stale unlessVLDS_PT_RANKER=1is set, andtestevaluates it either way. - The p4-model skill gives the routine, and ezexe/p4-phi-experiments holds the measurements.
- Ask a question in the discussions of this repository, and report a problem in its issues.
- The wiki holds the readable documentation: how to install, how to contribute and how a release is cut.
- CONTRIBUTING.md, SECURITY.md and CODE_OF_CONDUCT.md.
- CITATION.cff, which GitHub shows as "Cite this repository".
- LICENSE: Apache-2.0.