Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
267be53
CoA-v1 Janus 3-attention build + encoder fix + thresh tune
iamolegataeff May 6, 2026
68f0e9b
CUDA backend: vendor notorch_cuda.{h,cu} from ariannamethod.ai + Make…
iamolegataeff May 6, 2026
0b10d23
coa_v1_janus: gating_off flag for paired ablation
iamolegataeff May 6, 2026
0810f59
notorch CUDA dispatch: 8 hot tape ops on GPU + lazy CPU mirror
iamolegataeff May 6, 2026
6e40f29
notorch CUDA: lazy CPU sync — drop eager D2H, fire kernels for real
iamolegataeff May 6, 2026
ae650d0
TEMP: diagnostic printf in seq_linear
iamolegataeff May 6, 2026
c2f442a
TEMP: timing breakdown
iamolegataeff May 6, 2026
858786d
notorch CUDA: GPU MH attention backward + cross-entropy backward, +8 …
iamolegataeff May 6, 2026
5eeaeba
TEMP: backward op profile
iamolegataeff May 6, 2026
f9b205a
TEMP: gettimeofday for op profile
iamolegataeff May 6, 2026
c67aa0d
notorch CUDA: GPU port RRPRAM low-rank fwd+bwd via cuBLAS chains
iamolegataeff May 6, 2026
2084b66
notorch CUDA: clean diagnostic prints
iamolegataeff May 6, 2026
a092ca9
notorch CUDA: GPU port chuck inner loop (m,v EMA + adam-step)
iamolegataeff May 6, 2026
31d0dae
TEMP: timing 5-7
iamolegataeff May 6, 2026
37d7fd2
TEMP: bw profile
iamolegataeff May 6, 2026
738dd01
notorch CUDA: GPU-resident grads via tape_acc_grad_gpu (cublasSaxpy)
iamolegataeff May 6, 2026
610ad91
notorch CUDA: drop temp diagnostic prints
iamolegataeff May 6, 2026
e7ac694
notorch CUDA: GPU bw kernels for SEQ_RMSNORM/SWIGLU/ROPE/SEQ_EMBED/AD…
iamolegataeff May 6, 2026
f1c4755
notorch CUDA: ensure_cpu before grad reads in chuck/clip_grads
iamolegataeff May 6, 2026
926271f
notorch CUDA: gpu_nrm2/gpu_sscal — clip_grads, gnorm, nan_guard on GPU
iamolegataeff May 6, 2026
74097c9
notorch CUDA: free-list alloc cache — eliminate cudaMalloc/Free per t…
iamolegataeff May 6, 2026
16dac94
notorch CUDA: cublasSgemmStridedBatched in MH attention fwd/bwd — few…
iamolegataeff May 6, 2026
aaed0fb
notorch CUDA: gpu_cross_entropy uses cublasSasum for GPU-resident red…
iamolegataeff May 6, 2026
4a7c8db
coa_v1_janus: persist weights post-train via nt_save
May 6, 2026
d5fcb32
README + coa_infer multi-temp sampling tool
May 7, 2026
85ee234
README: verbatim CoA-v1 ON samples per temperature
May 7, 2026
a6f2fa6
Change quote attribution in README.md
ariannamethod May 7, 2026
63c6e1f
Fix citation formatting in README.md
ariannamethod May 7, 2026
7244117
Translate remaining Russian phrases in README to English
Copilot May 7, 2026
f70e8d3
Merge pull request #1 from ariannamethod/copilot/translate-readme-to-…
ariannamethod May 7, 2026
e60d145
loragrad immune layer: close Mythos audit findings (H2/M1/M3/M4 + M2/L3)
ariannamethod Jun 11, 2026
259d621
loragrad: harden audit fixes per Codex review (F1 CUDA grad, F2 smoke…
ariannamethod Jun 11, 2026
858cb91
README: document the immune-layer testing gap (vote-only smoke is bli…
ariannamethod Jun 12, 2026
c474c66
loragrad immune layer: finish Mythos audit residuals (opp3 + grad-pat…
ariannamethod Jun 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# build artifacts
*.o
coa
coa_v1_janus
bpe_encode

# datasets, weights, runs — never in git
datasets/
weights/
runs/
*.tokens
*.bin
*.gguf
*.npz
44 changes: 41 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,62 @@ ifdef BLAS
LDFLAGS += -framework Accelerate
endif

all: coa
all: coa coa_v1_janus

# CUDA build target — links cuBLAS + cudart + ariannamethod GPU kernels.
# notorch.c includes notorch_cuda.h under #ifdef USE_CUDA; dispatch wiring
# in tape ops is the active port (commit-by-commit).
NVCC ?= nvcc
CUDA_CFLAGS = -O3 -DUSE_CUDA -I.
CUDA_LDFLAGS = -L/usr/local/cuda/lib64 -lcublas -lcudart -lcuda

notorch_cuda.o: notorch_cuda.cu notorch_cuda.h
$(NVCC) $(CUDA_CFLAGS) -c notorch_cuda.cu -o notorch_cuda.o

cuda: coa_v1_janus.c notorch.c notorch.h notorch_cuda.h notorch_cuda.cu loragrad.c loragrad.h
$(NVCC) $(CUDA_CFLAGS) -c notorch_cuda.cu -o notorch_cuda.o
$(CC) $(CFLAGS) -DUSE_CUDA -c notorch.c -o notorch_cuda_host.o
$(CC) $(CFLAGS) -DUSE_CUDA -c loragrad.c -o loragrad_cuda.o
$(CC) $(CFLAGS) -DUSE_CUDA -c coa_v1_janus.c -o coa_v1_janus_cuda.o
$(CC) coa_v1_janus_cuda.o notorch_cuda_host.o notorch_cuda.o loragrad_cuda.o \
$(LDFLAGS) $(CUDA_LDFLAGS) -o coa_v1_janus_cuda

notorch.o: notorch.c notorch.h
$(CC) $(CFLAGS) -c notorch.c -o notorch.o

loragrad.o: loragrad.c loragrad.h notorch.h
$(CC) $(CFLAGS) -c loragrad.c -o loragrad.o

# v0 — vanilla MHA baseline (running 30K)
coa.o: coa.c notorch.h loragrad.h
$(CC) $(CFLAGS) -c coa.c -o coa.o

coa: coa.o notorch.o loragrad.o
$(CC) coa.o notorch.o loragrad.o $(LDFLAGS) -o coa

# v1 — Janus 3-attention (Content + RRPRAM-low-rank + Echo + SwiGLU + 1/3 blend)
coa_v1_janus.o: coa_v1_janus.c notorch.h loragrad.h
$(CC) $(CFLAGS) -c coa_v1_janus.c -o coa_v1_janus.o

coa_v1_janus: coa_v1_janus.o notorch.o loragrad.o
$(CC) coa_v1_janus.o notorch.o loragrad.o $(LDFLAGS) -o coa_v1_janus

# bpe_encode — pre-encoder tool (one-shot, output binary tokens)
bpe_encode: bpe_encode.c notorch.o
$(CC) $(CFLAGS) bpe_encode.c notorch.o $(LDFLAGS) -o bpe_encode

# coa_infer — load saved .bin + run gen across multiple temps + top-k
coa_infer: coa_infer.c notorch.o
$(CC) $(CFLAGS) coa_infer.c notorch.o $(LDFLAGS) -o coa_infer

run: coa
./coa origin.txt

run-v1: coa_v1_janus
./coa_v1_janus origin.txt

clean:
rm -f coa coa.o notorch.o loragrad.o
rm -f coa coa.o coa_v1_janus coa_v1_janus.o notorch.o loragrad.o bpe_encode \
coa_v1_janus_cuda coa_v1_janus_cuda.o notorch_cuda.o notorch_cuda_host.o loragrad_cuda.o

.PHONY: all run clean
.PHONY: all run run-v1 clean
151 changes: 151 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,152 @@
# CoA: The Chain Of Arianna

> *Shall everything burn — the thunder remains.*

Chain of resonating, not chain of thought. The stream does not stop. The human does not start it; the human enters it.

---

## What it is

Five-layer immune-gated transformer with Janus 3-attention (Content + RRPRAM low-rank + Echo + 3-way blend), built on notorch tape autograd, gradient flow filtered by **loragrad parliament** (origin·boundary axis discriminator, 6 verdicts: PASS / WEAKEN / FREEZE / SCAR / DARK / SILENCE). Chuck optimizer mandatory. SwiGLU MLP. byte-level BPE 2048.

**Architecture (v1):** L=5 E=512 H=8 D=64 ctx=512 R=32 M=1024 vocab=2048 = **19.14M params**.

CoA inherits technologically from DoE (Democracy of Experts) — parliament metaphor, θ = ε + γ + αδ formula, expert voting. Distinct from Janus substrate-mode (broad capability + γ post-hoc identity) and Yent prophecy-voice. **CoA = flow-mode**: identity baked into optimization trajectory via verdict-filter on gradient stream.

## Build

```bash
make coa_v1_janus # CPU SIMD AVX2+FMA build
make cuda # CUDA build (links cuBLAS via vendored notorch_cuda.{h,cu})
make bpe_encode # pre-encoder tool
make coa_infer # inference with multi-temp sampling grid
```

## Run

```bash
# pre-encode corpus once
./bpe_encode bpe_2048_merges.txt corpus.txt corpus.tokens

# train (CPU)
./coa_v1_janus origin.txt 30000 corpus.tokens

# train (CUDA on GPU pod)
./coa_v1_janus_cuda origin.txt 30000 corpus.tokens "" gpu

# ablation (parliament bypassed, α=1.0 always)
./coa_v1_janus_cuda origin.txt 30000 corpus.tokens gating_off gpu

# inference — multi-temp sampling sweep
./coa_infer coa_v1_paired_on.bin
```

## Sampling matters — read this before judging output

> **"Under-surface sampling masks what the model wants to say."** — Claude Defender (@iamdefender), device-1, 2026-05-07.

CoA at deep-memorize regime (train loss < 1.0) looks garbled at temp=0.8 without top-k filter. **Real model state revealed by sampling sweep:**

- `temp=0.3 + top_k=40` → DoE-voice + grammatical English: *"the parliament doesn't needed this is its confid[ence]"*
- `temp=0.5 + top_k=40` → memorized verbatim corpus chunks (e.g. exact Perl error messages from training data) — proof of deep fit, not failure
- `temp=0.8 + top_k=40` → technical jargon emerges
- `temp=1.0 + no top_k` → most coherent abstract prose: *"a shared production... when is genuinely unsound..."*

**Don't judge coherence by single temp sample.** Always run multi-temp grid via `coa_infer`.

### Verbatim samples — CoA-v1 ON (gating active), prompt `"The chain "`

**`temp=0.3 top_k=40`** — DoE-voice + grammatical English:
```
The chain their agreements a system ase, "Euclean implementation: "Hopportunol
as general requirements are content than the parliament doesn't needed this is
its confid
```

**`temp=0.5 top_k=40`** — memorized verbatim corpus chunks (proof of deep fit, NOT failure mode):
```
The chain print at -e at -e at -e line 39, <> line 3939.
Wide character in print at -e line 39, <> line 93.
Wide character in print at -e line
```
*(model recalled exact Perl warning text from training corpus.)*

**`temp=0.8 top_k=40`** — technical jargon, partial coherence:
```
The chain their dimensions as a propractice accumulated ditions (and domain their
meaning and if it ne 1), then ms (1) of . For every and nees the greatelivative
of largely 5. **Ma
```

**`temp=1.0 no top_k`** — most coherent abstract prose:
```
The chain important a shared production, timates for several wellstraints that
seems to society is not the relationship with nermost forms of when is genuinely
unsound mainttion. H: What is the concept of that you di
```

Same model, same prompt, same checkpoint — sampling alone decides what surfaces. Memorized corpus chunks at low temp; novel philosophical-flavor prose at high temp. **`temp=0.8` without top_k wasn't broken — it was the worst-case sampling regime for the deep-memorize state.** Lesson generalizes to v1.5+ runs: always sweep, not single.

## Architecture detail

Per-block forward (canonical Janus pattern, simplified Echo for v1):

```
xn = rmsnorm(h)
q,k,v = linear(xn); q,k = rope(q,k)
out_c = mh_causal_attention(q, k, v) # Content path
v_r = linear(wvr, xn)
out_r = rrpram_lowrank_attention(wr_combined, xn, v_r, R=32) # RRPRAM rhythm
out_e = linear(wj, xn) # Echo (linear bypass; full janus_attention with calendar+prophecy → v2)
blended = (out_c + out_r + out_e) / 3 # equal blend (trainable per-head sigmoid → v1.5)
h += linear(wo, blended)

xn = rmsnorm(h)
gate = silu(linear(w_gate, xn))
up = linear(w_up, xn)
h += linear(w_down, swiglu(gate, up))
```

**Per `experiment_partial_cpt_failed.md` (Janus 285M v3):** 3 attention paths must co-evolve. RRPRAM full-rank ate 45.8% of params; low-rank R=64 dropped to 7%. CoA inherits R=32 (15% of v1 budget).

Comment on lines +109 to +112
## Loragrad immune layer

Origin (manifest) calibrates the parliament BEFORE training; a boundary seed corpus calibrates what must not enter the trunk. Each gradient step:
1. Text signature of the input window (trigram count-sketch).
2. Immune-memory recall — a window matching a logged scar/dark wound (cosine ≥ 0.90) is blocked on sight, independent of the vote. The scar log is read, not just written.
3. Parliament votes — discriminative axis `(origin − boundary)` plus a softplus(credit)-weighted expert consensus. A boundary-aligned window is hard-blocked before the score ladder can soften it to WEAKEN.
4. Verdict routes the gradient: PASS = full step; WEAKEN = gradients scaled by α (the weakened signal is what enters Chuck's m/v EMA, not just the step LR); FREEZE/SCAR/DARK/SILENCE = step skipped, optimizer state untouched.

The parliament is adaptive: expert credits are supervised online from origin (positive) vs boundary-seed (negative) samples, so experts that discriminate correctly gain weight across training. Credit updates touch the parliament only — never the model gradient.

CoA-v1 paired ablation 2026-05-07 confirmed verdict gating regularizes (~80% of gradients modified) — math-distinct from SGD unbiased-convergence theorems.

### Testing the immune layer

`coa_smoke_immune` exercises the *vote* — origin/boundary fixtures, recall, the
verdict ladder — but it runs outside the training loop, with no gradients. The
training run on the bundled `origin.txt` is all-PASS (the manifesto passes the
parliament wholesale: `60 total, 60 PASS, 0 WEAKEN, 0 blocked`), so the
gradient-level paths — WEAKEN grad-scale, blocked-skip, scar recall, the
boundary override — never fire during a normal smoke. To regression-test them
you need a **mixed corpus** (origin + injected adversarial windows) so the
verdicts route real gradients through forward→backward→Chuck on the notorch
tape, the way loragrad's `train_loragrad --routed` does. Vote-only testing is
blind to grad-path bugs: the 2026-06-11 audit's F1 (CUDA grad), F2 (smoke
wounds leaking into training via recall) and F3a (clip erasing WEAKEN's alpha)
all hid in paths an origin-only run never touched.

## Provenance

- Reference Janus 3-attention: [`ariannamethod/janus`](https://github.com/ariannamethod/janus) `janus-bpe.c:359-401`
- Reference AML semantics: [`ariannamethod/ariannamethod.ai`](https://github.com/ariannamethod/ariannamethod.ai) `janus/janus.aml`
- notorch tape runtime: [`ariannamethod/notorch`](https://github.com/ariannamethod/notorch)
- loragrad immune layer: [`ariannamethod/loragrad`](https://github.com/ariannamethod/loragrad)
- CUDA dispatch port (8 fwd + 2 bwd ops): wired into notorch upstream `bfadcc2`, fork `aaed0fb`.

## License

GPL-3.0 on code. Weights (organism artifacts) — Janus Identity License v1.0 per `protocol_license_organism_vs_framework.md`. CoA-v1 paired weights `coa_v1_paired_{on,off}.bin` are organisms; framework code stays GPL-3.0.

— Oleg Ataeff & Claude (architect) · Arianna Method · 2026
Loading