All projects

Integer & embedded · Research

int-llm coordinate permutation

Reversible checkpoint transformations across vocabulary rows, MLP neurons, attention heads, and the residual hidden basis.

At a glance

Evidence and scope

Repository measurements and recorded project results. Test and benchmark claims were inspected, not rerun during this catalog refresh. Physical line counts use the stated file scopes.

Tensor coverage
201 learned tensorsThe all-axis TinyLlama transformation covered the documented learned-tensor set.
Integer behavior
80/80 decisionsGreedy decisions remained aligned on the Q16.48 validation path.
Reversibility
Byte-for-byteThe BF16 inverse restored the pinned checkpoint exactly.
Input dtypes
BF16 / F16 / F32Unsharded SafeTensors within the documented Llama tensor-name scope.
Reviewed sources · 2026-10-15 · 0fd1a0f96d7f

217 tracked files · 49 documentation files · 1 workflow files. Inventory includes data and vendored or generated files; workflow presence does not establish a passing run.

Download inventory and line-count file scopes

Executive summary

int-llm-coordinate-permutation applies reversible coordinate changes to Llama-family checkpoints. The small scope reorders vocabulary rows and translates token IDs at the interface. The all-axis scope also reorders feed-forward neurons, whole grouped-query attention heads, and the global residual hidden basis with compensating row and column moves. Implementations work directly on BF16, F16, and F32 SafeTensors as well as the Q16.48 integer format. These are known model symmetries and layout experiments—not encryption, access control, or a method for making public weights private.

Problem and context

A neural network's stored coordinate order is not always part of its function. If every connected tensor is transformed consistently, many row and column orders can change while preserving the logical model. This repository turns that observation into strict tooling with explicit boundary maps and inverse operations.

What was built

  • Deterministic token-map creation from a private random key or explicit order.
  • Vocabulary-only SafeTensors and integer-model converters.
  • All-axis converters for vocabulary, MLP, attention-head, and residual-basis
  • coordinates.

  • Structural verifiers that check every prescribed destination coordinate.
  • Integer and floating-point inference comparison harnesses.
  • Explicit MLP layouts (original, smooth, spread, and seeded-random) and a
  • minimal residual-basis swap across all nine small-model matrices.

  • Format, provenance, security, and prior-art documentation.

How it works

Vocabulary rows move together in the input embedding and any separate output head. Token IDs are translated into the physical namespace on input and back to logical IDs on output. Internal coordinate maps require no runtime sidecar because their inverse relationships are baked into the affected matrix axes.

Attention transforms move whole heads and preserve grouped-query associations. Coordinates inside a head stay in place so rotary pairs remain canonical. The residual-basis permutation is global because every residual addition must use the same basis.

Evidence and validation

On the documented TinyLlama checkpoint, the all-axis composition classified and transformed all 201 learned tensors. The Q16.48 path passed prescribed-axis verification and the original 80/80 greedy-token gate. The direct BF16 path restored the original checkpoint byte-for-byte after the inverse transform; its floating-point control retained 48/48 top-1 decisions while showing small logit drift from a different reduction order.

The August follow-up adds explicit small-model layout experiments. Swapping residual coordinates 0 and 31 changes all nine learned matrices while preserving all 5,832 checked Q16.48 logits; the inverse restores the checkpoint exactly. Four MLP-neuron orders compare adjacency distances without claiming sparsity or a performance improvement. The sibling visualization project makes those verified changes inspectable.

Verifiers fail closed when the tensor layout, data type, or configuration falls outside the supported Llama shape.

Boundaries

Permutation is not encryption and does not hide the model function. A public base model makes a transformed checkpoint particularly easy to analyze. The floating-point path need not reproduce every logit bit because changing the reduction order changes rounding. Current full-checkpoint tools accept one unsharded SafeTensors file and a constrained set of Llama tensor names and types.

Repository map and first run

make test
python3 test_safetensors_coordinate_permutation.py

Start with the vocabulary-only fixture before using a full checkpoint. Read FORMAT.md for the map representation, RESULTS.md for measured gates, SECURITY.md for non-claims, and SOURCE_PROVENANCE.md for copied and derived components.