Skip to main content

Neyra

Neyra edits the weights of local language models.

CI Apache 2.0 Python 3.10+ 312 conformance vectors

Install · Usage · Commands · Design · Results · Docs · Spec


Neyra writes facts and behaviour changes into safetensors checkpoints. An edit is a patch: about 170 KB for one fact on Qwen3-0.6B, tied to the digest of its base, and reversible bit for bit. neyra edit uses a MEMIT style closed form solve across several MLP layers. neyra fix finds the direction behind a reasoning loop and writes a patch that projects it out of the columns that write it.

It also reads changes made with other tools. diff recovers the form of an edit from two checkpoints, check recomputes a LoRA merge with the rounding PEFT and mlx-lm use, and hop walks base, adapter, merged model and GGUF to the first one that differs.

neyra diff on the Weight-Space Programming edit

neyra diff on the loop edit from Sparks of Weight-Space Programming, reading 4% of both checkpoints over HTTP range requests. The authors' notes give the same formula with a strength of 6.

Install

pip install neyra        # or: uv tool install neyra
neyra demo

Needs Python 3.10 or later. The base install handles patches, diffs and verification with numpy and cryptography. To run models, add neyra[mlx] on Apple Silicon or neyra[torch] elsewhere. neyra edit needs MLX. neyra doctor lists the backends you have.

neyra demo takes about 0.1 s and downloads nothing. It builds a toy model and a LoRA in memory, then runs check on a merge that dropped the adapter and on one that kept it.

Usage

Paths and Hugging Face repo names both work.

neyra probe MODEL                             # loops, runaway thinking, missing answers
neyra fix MODEL -o fix.neyra                  # candidate patch for a loop direction
neyra edit MODEL facts.json -o edit.neyra     # write facts, measure, sign
neyra apply MODEL edit.neyra -o edited-model  # rebuild, checking digests

neyra diff BASE OTHER --sample 4              # compare two checkpoints from a few percent of the bytes
neyra check BASE MERGED --adapter ADAPTER     # recompute a LoRA merge and compare bits
neyra hop BASE ADAPTER MERGED model.gguf      # first artifact that differs

Commands

Edit

Command
edit Write facts as a low rank patch. Exits 1 if it misses its gates
fix Find a loop direction and write a candidate patch
probe Run a fixed battery and report loops, runaway thinking and missing answers
patch, apply, show Write the difference between two checkpoints as a patch, rebuild from it, inspect it
merge Sum patches on one base with exact arithmetic. Order does not change the bytes
bisect Find the smallest part of a patch that keeps its effect
export Write a patch as a LoRA for PEFT or llama.cpp

Inspect

Command
diff Compare two checkpoints and name the form of the change
check Recompute a merge per tool and compare bits
hop Report the first artifact that differs across base, adapter, merged model and GGUF
identity Compare a model with its declared base: same weights, named transform, derivative, unrelated

Sign

Command
attest, render, supersede, withdraw, status Sign a statement of a change for OpenSSF model signing and CycloneDX tools
verify, log, keygen Check receipts and hash chained ledgers
index, prove Prove rows of a tensor against a root by reading only those rows
conformance Run the test vectors against your install

Automate

neyra mcp MCP server for agents, with a fixed budget, a sealed holdout and a hash chained ledger
action.yml GitHub Action that fails a job when a merge does not match its adapter
hf-neyra hf neyra diff and hf neyra check

Design

A patch is a safetensors file, so loading one runs no code. It records the digest of the tensors it expects and the digest it produces, and apply stops on a mismatch. The weights root hashes every tensor and ignores sharding, so a resharded model keeps its root.

merge sums deltas as integers and rounds once, because bf16 addition does not associate. At an entry with value 1 - 2^-8, three patches that each add 2^-8 give 1.0 in pairs and 1 + 2^-7 together.

neyra edit solves in float64 and measures the rounded weights the patch produces. Its gates cover efficacy, neighbouring facts, drift on neutral text and fluency. The limits ship in the code, not in your run, and the receipt keeps a FAIL as well as a PASS.

Output separates what you can recompute from what was measured. Sampled reads report their coverage. identity calls a model derived against distances measured on unrelated sibling models. A signature tells you who signed, so a receipt also lists what you need to rerun the claim.

hop takes artifacts in the order a fine-tune passed through them:

base, adapter, merged and GGUF, with merged marked as the first hop that differs

Results

Result Rerun
edit, Qwen3-0.6B, 200 unseen CounterFact cases Efficacy 1.00, paraphrase 0.95, neighbours 0.70 (0.745 before) bench/edit_counterfact.py
diff, planted edits, 50 trials each 100% form recovery on 12 of 14 conditions, 0 false alarms in 250 noise trials bench/forensics.py
check, real merges PEFT 0.21.2 and mlx-lm 0.32.2 in fp32, bf16 and fp16, matched bit for bit tests/test_check_real.py
merge Matches brute force rounding on all 24 orders of four patches tests/test_merge.py
Python and Go verifiers Agree on 312 vectors and on mutated inputs from a differential fuzzer fuzz/differential.py

So far these edits rewrite facts and remove loops. None has been shown to add ability. ROME led edit on the 20 development cases compared, and the full comparison is unfinished. Nothing has been tested above 1B parameters. The limits page has the rest.

Documentation

Guides: edit, merge, bisect, check, hop, identity, signing, lab.

Reference: specification, protocol notes, vectors, accuracy, limits, prior work, changelog.

Status

Early. Formats can change until v1.

See CONTRIBUTING.md to work on it and SECURITY.md to report a vulnerability. If you write a verifier from the spec and vectors, open an issue. The Go one here shares an author with the Python one.

License

Apache 2.0

Metadata

Release files for neyra 0.2.1

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

Source distribution (sdist)

Source distribution for neyra 0.2.1
File Size Uploaded Provenance Actions
neyra-0.2.1.tar.gz 506.7 kB Without provenance Details for neyra-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 1.2 MB

Release files / neyra-0.2.1.tar.gz

Download URL neyra-0.2.1.tar.gz
Size 506.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a13dbc0989d54c3d208211ca22c635376bd3992e293d2e5ab3309a522e597f82
BLAKE2b-256 checksum
How to use checksums
ef816fd17b3bbbe48baa3edceb01dae46b045df555f4e0530996b38d7c84464c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / neyra-0.2.1-py3-none-any.whl

Download URL neyra-0.2.1-py3-none-any.whl
Size 672.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7c1896dc55d78b04fb8c3208c02bf8c382b0d1c04f4dc604cd52dc0d72888d3
BLAKE2b-256 checksum
How to use checksums
47959e29938d3c6278ed00571aadac1c7a1e9cd42389f3da37d2718deef982cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for neyra 0.2.1

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.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

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