Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 419c7cb195 | |||
| 0934079ed9 | |||
| 9efbf0b3b1 | |||
| 5031aa604e | |||
| 6d1acbc26a | |||
| 573cbedd98 | |||
| d4012592b6 | |||
| c718e8bd9a | |||
| 24b3c97fa5 | |||
| 70b8be25b4 | |||
| 727b05eb3f | |||
| 6121016a26 | |||
| e98c5d0936 |
@@ -0,0 +1,6 @@
|
||||
# Scientific artifacts must retain the bytes recorded in checksums.json.
|
||||
results/** -text
|
||||
# Generated CSV uses RFC 4180 line endings; Matplotlib SVG paths contain spaces.
|
||||
results/**/*.csv -whitespace
|
||||
results/**/*.svg -whitespace
|
||||
results/**/*.log -whitespace
|
||||
@@ -0,0 +1,10 @@
|
||||
__pycache__/
|
||||
.venv/
|
||||
weights/
|
||||
*.partial
|
||||
*.log
|
||||
|
||||
# Large reproducible functional activations remain on the experiment server.
|
||||
results/cpu-qwen35-2b/baseline-activations.npz
|
||||
results/cpu-qwen35-2b/neuron-reuse-activations.npz
|
||||
results/cpu-qwen35-2b/norm-repetition-input-profiles.npz
|
||||
@@ -0,0 +1,44 @@
|
||||
# Model parameter similarity experiments
|
||||
|
||||
Research on repeated learned functions in **Qwen3.5-2B**: a completed static weight baseline
|
||||
and a training-free CPU functional pilot. The CPU study found similar existing RMSNorm
|
||||
functions at layer indices 12/13, with a uniform analytic error bound and heldout substitution checks.
|
||||
Cost is not a success condition. The completed static pilot was inference-free and its
|
||||
weights were deleted after archival; the functional pilot executes streaming FP32 text forwards.
|
||||
The current CPU functional checkpoint is retained until the user explicitly requests deletion.
|
||||
No model weights are committed here.
|
||||
|
||||
The latest cross-layer QKV study covers all 15 full-attention layer pairs. Its primary
|
||||
protocol had no passing candidate; an exploratory H23-conditioned self-token retrieval
|
||||
pattern is reported separately with its fresh-test failures.
|
||||
|
||||
- [Cross-layer QKV findings and evidence limits](docs/CROSS_LAYER_QKV_FINDINGS.md)
|
||||
- [Cross-layer QKV fixed protocol](docs/CROSS_LAYER_QKV_PROTOCOL.md)
|
||||
- [CPU learned-function repetition findings](docs/CPU_FUNCTIONAL_FINDINGS.md)
|
||||
- [Current learned-function repetition criterion](docs/LEARNED_FUNCTION_REPETITION.md)
|
||||
- [CPU-first feasibility and validation](docs/CPU_FIRST_VALIDATION.md)
|
||||
- [Training-free functional reuse plan (proposed; not executed)](docs/TRAINING_FREE_FUNCTIONAL_PLAN.md)
|
||||
- [Primary-source literature and applicability](docs/FUNCTIONAL_REUSE_LITERATURE.md)
|
||||
- [Procedure and limits](docs/SOP.md)
|
||||
- [2B pilot findings and limitations](docs/PILOT_FINDINGS.md)
|
||||
- [Raw result report, data and figures](results/qwen35-2b/REPORT.md)
|
||||
- `pilot/download.py`: revision-pinned official checkpoint download and verification.
|
||||
- `pilot/tensors.py`: memory-mapped safetensors/BF16 reader and metrics.
|
||||
- `pilot/analyze.py`: bounded tensor/block search, exact verification, representative groups.
|
||||
- `pilot/plot.py`: scientific PNG/PDF/SVG figures and report from saved data.
|
||||
- `pilot/validate.py`: result/group validation, checksums and guarded weight cleanup.
|
||||
- `pilot/audit.py`: finite-metric checks, test evidence and archive provenance.
|
||||
- `pilot/run.py`: one-model supervisor with bounded download wait and analysis timeouts.
|
||||
- `tests/test_pilot.py`: synthetic numerical and 3D correctness tests.
|
||||
|
||||
The static baseline reports **verified net byte savings versus direct relative weight error**.
|
||||
The functional study separately reports same-input error, an all-input RMSNorm function bound
|
||||
and tiny heldout NLL changes; these are not broad task-accuracy guarantees. Different static
|
||||
block scales are alternative partitions and their savings must not be summed.
|
||||
|
||||
Dependencies are pinned in `requirements.txt`; install only prebuilt wheels on the remote host.
|
||||
Full resolved versions and run provenance accompany each result. See the SOP for commands.
|
||||
|
||||
## CPU block activation measurements
|
||||
|
||||
See [measurement definitions](activation/README.md) and [observed activation report](results/block-activation/REPORT.md) for all 24 layers, contiguous output-channel blocks, exact/near-zero rates and output energy concentration. This is an observational SiLU-gated study, not a pruning or reuse quality claim.
|
||||
@@ -0,0 +1,45 @@
|
||||
# Observed block activation, CPU only
|
||||
|
||||
Measures the retained Qwen3.5-2B checkpoint without training or substitutions.
|
||||
This model uses SiLU-gated MLPs and sigmoid attention gates, not ReLU.
|
||||
Leaky ReLU also does not generally create exact zero on negative inputs.
|
||||
|
||||
The probe records every linear projection in all 24 layers, plus MLP SiLU
|
||||
and gate-times-up intermediates and full-attention sigmoid gates. It does not
|
||||
record every internal recurrent state, convolution output or attention probability.
|
||||
A block means contiguous **output channels** (64 or 128), hence contiguous
|
||||
rows of a projection matrix; it is not a Transformer layer or arbitrary 2D tile.
|
||||
MLP gated-product channels correspond to columns consumed by down_proj.
|
||||
It is incorrect to call an individual weight active/inactive based only on its value.
|
||||
|
||||
For every sample, module and block, metrics.csv reports:
|
||||
- exact zero and negative element fractions;
|
||||
- near-zero fractions at |x| <= 0.01 RMS and <= 0.1 RMS;
|
||||
- fraction of channels ever above 0.01 RMS over the 32 tokens;
|
||||
- minimum fraction of channels carrying 90% squared-output energy.
|
||||
|
||||
RMS is computed within each observed sample/module/block; width=0 records the
|
||||
whole module. Thus thresholds are explicitly relative and are not shared absolute
|
||||
cutoffs across layers or blocks. Activation rate at a threshold is 1-near-zero rate.
|
||||
A small value or an energy-concentrated output does not prove that a block can
|
||||
be skipped, removed or shared without affecting LM quality. Exact zero is measured
|
||||
in this FP32 streaming implementation of BF16 source weights; other execution dtypes
|
||||
can have different underflow rates.
|
||||
|
||||
Four prior authored Chinese/English texts, 32 tokens each, descriptive measurements
|
||||
only. No training, fresh-generalization claim, GPU, weight download or cleanup.
|
||||
The existing streaming implementation was checked against the official implementation
|
||||
in the earlier CPU study; this experiment changes only observation, not model equations.
|
||||
|
||||
Remote commands (authorized server 8.211.154.134):
|
||||
```
|
||||
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 venv/bin/python -B -m activation.run --source runs/cpu-qwen35-2b --out runs/NEW_ACTIVATION_DIR
|
||||
OPENBLAS_NUM_THREADS=1 venv/bin/python -B -m unittest tests.test_activation -v
|
||||
venv/bin/python -B activation/report.py runs/NEW_ACTIVATION_DIR
|
||||
```
|
||||
|
||||
run.py measures; report.py plots saved rows and derives aggregates;
|
||||
__init__.py marks the package; tests/test_activation.py checks exact sparsity,
|
||||
ever-active behavior, all-zero inputs and scale invariance. Raw activations are
|
||||
not saved or needed for these descriptive statistics. Existing caches and weights
|
||||
are retained untouched. Full sample token IDs and CPU time/RSS appear in summary.json.
|
||||
@@ -0,0 +1,28 @@
|
||||
"""Audit recorded scope, metrics and reproducibility files; no model execution."""
|
||||
import csv,json,hashlib
|
||||
from pathlib import Path
|
||||
import sys
|
||||
p=Path(sys.argv[1]);r=list(csv.DictReader((p/'metrics.csv').open()));s=json.loads((p/'summary.json').read_text())
|
||||
assert s['completed'] and len(r)==s['rows']==4*20904
|
||||
assert len({x['sample'] for x in r})==4
|
||||
assert {int(x['module'].split('.')[1]) for x in r}==set(range(24))
|
||||
for x in r:
|
||||
for k in ['zero_rate','negative_rate','near_001_rms','near_01_rms','ever_active_001','energy90_channel_fraction']:assert 0<=float(x[k])<=1,(x,k)
|
||||
assert float(x['zero_rate'])<=float(x['near_001_rms'])<=float(x['near_01_rms'])
|
||||
assert int(x['channels'])==int(x['stop'])-int(x['start'])
|
||||
a=json.loads((p/'aggregates.json').read_text());lines=['# 实测激活率:SiLU 门控模型','', '覆盖24层、4条中英文文本,每条32 token;所有投影输出及 MLP 门控中间量,按64/128输出通道分块。','', '| 输出 | 精确零比例均值 | 0.01 RMS以下均值 | 0.1 RMS以下均值 | 32 token内曾活跃通道比例均值 | 90%能量所需通道比例均值 |','|---|---:|---:|---:|---:|---:|']
|
||||
for k,v in a.items():
|
||||
cols=[v[m]['mean']*100 for m in ['zero_rate','near_001_rms','near_01_rms','ever_active_001','energy90_channel_fraction']]
|
||||
lines.append('| '+k+' | '+' | '.join(f'{z:.4f}%' for z in cols)+' |')
|
||||
blocks=[x for x in r if x['width']=='128']; dead=sum(float(x['zero_rate'])==1 for x in blocks)
|
||||
lines+=['',f'128通道块×文本观测共{len(blocks)}条,整个32 token窗口全为精确零的块观测数为{dead}。', '', '表中是整模块逐文本统计再取均值;每个分块的独立统计见 metrics.csv。阈值是各自RMS的比例;阈值下激活率=1−近零比例。能量集中不等于可删除或可替换。', '', '仅测该模型、四条短文本;不推断所有语言/长上下文。SiLU不把负值整体截零,负数不等于静默。未执行删块/跳算的质量验证。权重和既有缓存全部保留。', '',f"CPU测量耗时{s['elapsed_seconds']:.1f}秒,峰值RSS{s['peak_rss_kib']/1024:.1f} MiB。"]
|
||||
(p/'REPORT.md').write_text('\n'.join(lines)+'\n')
|
||||
lines_extra=[]
|
||||
for suffix in ['mlp.gated_product','self_attn.q_proj.output','self_attn.k_proj.output','self_attn.v_proj.output']:
|
||||
rr=[x for x in blocks if x['module'].endswith(suffix)]
|
||||
act=sorted(1-float(x['near_01_rms']) for x in rr)
|
||||
lines_extra.append(f'{suffix}: 128通道块在0.1 RMS阈值上的激活率范围 {100*act[0]:.2f}%–{100*act[-1]:.2f}%。')
|
||||
with (p/'REPORT.md').open('a') as f:f.write('\n'+'\n'.join(lines_extra)+'\n')
|
||||
(p/'audit.json').write_text(json.dumps({'passed':True,'rows':len(r),'layers':24,'samples':4,'all_zero_128_blocks':dead},indent=2))
|
||||
files=[x for x in p.rglob('*') if x.is_file() and x.name!='checksums.json'];(p/'checksums.json').write_text(json.dumps({str(x.relative_to(p)):hashlib.sha256(x.read_bytes()).hexdigest() for x in sorted(files)},indent=2))
|
||||
print((p/'REPORT.md').read_text())
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Render scientific figures from recorded CPU measurements."""
|
||||
import csv,json
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
import matplotlib
|
||||
matplotlib.use('Agg')
|
||||
import matplotlib.pyplot as plt
|
||||
import sys
|
||||
root=Path(sys.argv[1]); rows=list(csv.DictReader((root/'metrics.csv').open()))
|
||||
full=[r for r in rows if r['width']=='0']
|
||||
fig,axs=plt.subplots(1,3,figsize=(15,4.5),layout='constrained')
|
||||
for suffix,label in [('gate_proj.output','gate preactivation'),('silu_gate','SiLU gate'),('gated_product','gated product')]:
|
||||
selected=[r for r in full if r['module'].endswith('mlp.'+suffix)]
|
||||
for ax,key in zip(axs,['zero_rate','near_001_rms','near_01_rms']):
|
||||
xs=[];ys=[]
|
||||
for layer in range(24):
|
||||
z=[float(r[key]) for r in selected if r['module'].startswith(f'layers.{layer}.')];xs.append(layer);ys.append(np.mean(z))
|
||||
ax.plot(xs,ys,label=label)
|
||||
for ax,title in zip(axs,['Exact zero fraction','Near zero: |x| <= 0.01 RMS','Near zero: |x| <= 0.1 RMS']):
|
||||
ax.set(title=title,xlabel='Layer index',ylabel='Fraction');ax.set_ylim(bottom=0);ax.grid(alpha=.2)
|
||||
axs[-1].legend();fig.suptitle('Observed MLP activation sparsity: four texts, 32 tokens each; no training')
|
||||
root.joinpath('figures').mkdir(exist_ok=True)
|
||||
for ext in ('png','pdf','svg'):fig.savefig(root/'figures'/('mlp_activation.'+ext),dpi=180)
|
||||
plt.close(fig)
|
||||
blocks=[r for r in rows if r['width']=='128' and r['module'].endswith('mlp.gated_product')]
|
||||
fig,axs=plt.subplots(1,2,figsize=(12,4.5),layout='constrained')
|
||||
for ax,key,title in zip(axs,['near_01_rms','energy90_channel_fraction'],['Near-zero fraction at 0.1 block RMS','Fraction of channels carrying 90% energy']):
|
||||
matrix=[]
|
||||
for layer in range(24):
|
||||
rr=[r for r in blocks if r['module'].startswith(f'layers.{layer}.')]; starts=sorted(set(int(r['start']) for r in rr));matrix.append([np.mean([float(r[key]) for r in rr if int(r['start'])==s]) for s in starts])
|
||||
im=ax.imshow(matrix,aspect='auto',vmin=0,vmax=1);ax.set(title=title,xlabel='Contiguous 128-channel block',ylabel='Layer index');fig.colorbar(im,ax=ax)
|
||||
fig.suptitle('MLP gated-product blocks: average over four observed texts')
|
||||
for ext in ('png','pdf','svg'):fig.savefig(root/'figures'/('block_activity.'+ext),dpi=180)
|
||||
agg={}
|
||||
for suffix in ['mlp.gate_proj.output','mlp.silu_gate','mlp.gated_product','self_attn.q_proj.output','self_attn.k_proj.output','self_attn.v_proj.output']:
|
||||
rr=[r for r in full if r['module'].endswith(suffix)]
|
||||
agg[suffix]={'observations':len(rr),**{key:{'min':min(float(r[key]) for r in rr),'mean':float(np.mean([float(r[key]) for r in rr])),'max':max(float(r[key]) for r in rr)} for key in ['zero_rate','negative_rate','near_001_rms','near_01_rms','ever_active_001','energy90_channel_fraction']}}
|
||||
(root/'aggregates.json').write_text(json.dumps(agg,indent=2))
|
||||
@@ -0,0 +1,48 @@
|
||||
"""CPU-only observed activation sparsity; no checkpoint changes or training."""
|
||||
import json,csv,time,resource,hashlib
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
from tokenizers import Tokenizer
|
||||
from functional.model import StreamingLM,silu,sigmoid
|
||||
|
||||
|
||||
def metrics(x):
|
||||
x=np.asarray(x,dtype=np.float64).reshape(-1,x.shape[-1]); a=np.abs(x); energy=np.square(x).sum(0); total=energy.sum()
|
||||
rms=float(np.sqrt(np.mean(x*x))); cutoff=.01*rms
|
||||
ordered=np.sort(energy)[::-1]; n90=int(np.searchsorted(np.cumsum(ordered),.9*total)+1) if total else 0
|
||||
return dict(elements=x.size,channels=x.shape[-1],rms=rms,zero_rate=float(np.mean(x==0)),negative_rate=float(np.mean(x<0)),near_001_rms=float(np.mean(a<=cutoff)),near_01_rms=float(np.mean(a<=.1*rms)),ever_active_001=float(np.mean(np.any(a>cutoff,axis=0))),channels_for_90pct_energy=n90,energy90_channel_fraction=n90/x.shape[-1])
|
||||
|
||||
class Probe(StreamingLM):
|
||||
def record(self,x,name):
|
||||
for width in (0,64,128):
|
||||
for start in range(0,x.shape[-1],width or x.shape[-1]):
|
||||
stop=min(start+(width or x.shape[-1]),x.shape[-1]); z=x[...,start:stop]
|
||||
self.rows.append(dict(sample=self.sample,module=name,width=width,start=start,stop=stop,**metrics(z)))
|
||||
def linear(self,x,name,rows=256):
|
||||
y=super().linear(x,name,rows); self.record(y,name+'.output')
|
||||
if name.endswith('self_attn.q_proj'):
|
||||
dim=self.config['head_dim']; mixed=y.reshape(*y.shape[:-1],-1,2*dim)
|
||||
self.record(sigmoid(mixed[...,dim:]).reshape(*y.shape[:-1],-1),name+'.sigmoid_gate')
|
||||
return y
|
||||
def mlp(self,h,layer):
|
||||
p=f'layers.{layer}.mlp.'; pre=self.linear(h,p+'gate_proj'); g=silu(pre); u=self.linear(h,p+'up_proj')
|
||||
self.record(g,p+'silu_gate'); self.record(g*u,p+'gated_product')
|
||||
return self.linear(g*u,p+'down_proj')
|
||||
|
||||
def main():
|
||||
import argparse
|
||||
p=argparse.ArgumentParser();p.add_argument('--source',type=Path,required=True);p.add_argument('--out',type=Path,required=True);a=p.parse_args();a.out.mkdir(parents=True,exist_ok=False)
|
||||
started=time.monotonic();cfg=json.loads((a.source/'model_config.json').read_text()); lm=Probe(a.source/'weights',cfg,seconds=3600);lm.rows=[]
|
||||
samples=json.loads(Path('crossqkv/fresh_samples.json').read_text())['samples'];tok=Tokenizer.from_file(str(a.source/'tokenizer.json'))
|
||||
for s in samples:
|
||||
lm.sample=s['id']; ids=tok.encode(s['text']).ids[:32];s['token_ids']=ids
|
||||
lm.forward(np.array([ids],dtype=np.int64))
|
||||
first=not (a.out/'metrics.csv').exists()
|
||||
with (a.out/'metrics.csv').open('a') as f:
|
||||
w=csv.DictWriter(f,fieldnames=list(lm.rows[0]))
|
||||
if first:w.writeheader()
|
||||
w.writerows(lm.rows)
|
||||
print('completed',s['id'],len(lm.rows),flush=True);lm.rows.clear()
|
||||
summary={'completed':True,'elapsed_seconds':time.monotonic()-started,'peak_rss_kib':resource.getrusage(resource.RUSAGE_SELF).ru_maxrss,'config_activation':lm.config.get('hidden_act'),'layer_count':len(lm.config['layer_types']),'samples':samples,'rows':sum(1 for _ in (a.out/'metrics.csv').open())-1,'block_widths':[64,128],'threshold_reference':'RMS within each sample/module/block, thresholds 0.01 and 0.1; exact zero measured separately','training':False,'weights_deleted':False,'limits':['4 short texts, 32 tokens each, descriptive only','Block is contiguous output channels, not Transformer block','Small output does not prove removable computation or parameter interchangeability','All samples previously used; no generalization claim','Relative threshold differs between blocks; width=0 is whole module reference']}
|
||||
(a.out/'summary.json').write_text(json.dumps(summary,indent=2))
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,42 @@
|
||||
# Cross-layer QKV CPU study
|
||||
|
||||
This phase targets learned QKV functions across different layers, independent of cost.
|
||||
The six full-attention layers (indices 3/7/11/15/19/23) form 15 unordered pairs.
|
||||
No within-layer Q/K/V substitution, training, continuous R fitting, GPU, or new model download.
|
||||
|
||||
Read [fixed primary protocol](../docs/CROSS_LAYER_QKV_PROTOCOL.md) and
|
||||
[findings with evidence limits](../docs/CROSS_LAYER_QKV_FINDINGS.md).
|
||||
The original main protocol had no passing candidate. A later fixed one-source audit
|
||||
showed near-self-token retrieval and small readout errors, but failed strict fresh
|
||||
mean-JS/row-JS-P95/row-TV-P95 criteria; it is not relabeled as a primary pass.
|
||||
|
||||
- `core.py`: exact discrete head assignment, actual attention parts, common-space head
|
||||
decomposition, fixed recipient V/gate/O transplants and temporal-cache controls.
|
||||
- `protocol.py`, `fresh_samples.json`: predeclared layer/unit/gate scope and untouched fresh texts.
|
||||
- `run.py`, `fresh.py`: calibration, frozen selection, old validation and gated fresh/network steps.
|
||||
- `conditional.py`: separately registered post-screen metric audit on one fixed H23 candidate;
|
||||
no fallback selection or later threshold changes.
|
||||
- `audit_case.py`: recompute selected fresh probabilities, self mass, shared top5 mass and
|
||||
actual-H3 versus same-H23 difference; no full-network intervention after failure.
|
||||
- `report.py`, `audit.py`: saved-data scientific plots, raw-count/matching/probability audits,
|
||||
SHA256 and explicit small Git delivery with external large-cache metadata.
|
||||
|
||||
Use the authorized remote CPU environment with the retained source checkpoint/cache:
|
||||
|
||||
```sh
|
||||
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 venv/bin/python -B -m unittest tests.test_crossqkv -v
|
||||
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 timeout 7200 venv/bin/python -B -m crossqkv.run --source runs/cpu-qwen35-2b --root runs/NEW_QKV_DIRECTORY
|
||||
```
|
||||
|
||||
The main run requires a fresh directory and never overwrites prior protocol evidence.
|
||||
The recorded execution used `runs/cross-layer-qkv-v2` after fixing a controls-variable
|
||||
shadowing error in the first attempt; old logs and its profile cache are retained.
|
||||
The first attempt took about 10.3 seconds, then a 60-second reserve was deducted from
|
||||
the next 7140-second run limit. The main study finished in about 74.8 seconds.
|
||||
The fixed conditional audit used only remaining shared budget and took about 105.3 seconds.
|
||||
Final tests/plots/audits fit comfortably within the two-hour computation budget.
|
||||
|
||||
All weights and caches stay on the server until explicit user deletion. Git contains
|
||||
all figure tables and the selected small probability matrices; large caches have exact
|
||||
paths/sizes/hashes in `external-caches.json`. Old validation texts were used in earlier
|
||||
experiments; the four fresh texts were fixed before the new cross-layer measurements.
|
||||
@@ -0,0 +1 @@
|
||||
"""Cross-layer learned QKV function comparisons, CPU only."""
|
||||
@@ -0,0 +1,95 @@
|
||||
"""Audit and package only science outputs; retain all weights/profile caches."""
|
||||
import argparse
|
||||
import csv
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import time
|
||||
import numpy as np
|
||||
from functional.run import write_json
|
||||
from .protocol import LAYERS,PAIRS
|
||||
from .core import assignment
|
||||
|
||||
|
||||
def digest(path):
|
||||
h=hashlib.sha256()
|
||||
with path.open('rb') as f:
|
||||
while b:=f.read(4*1024*1024):h.update(b)
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);p.add_argument('--source',type=Path,required=True);p.add_argument('--output',type=Path,required=True);a=p.parse_args();root=a.root.resolve();source=a.source.resolve();out=a.output.resolve();assert root!=out
|
||||
status=json.loads((root/'status.json').read_text());assert status['state']=='completed' and status['last_source_layer']==23 and status['last_pair']==[19,23]
|
||||
expected={'full_attention':15,'qkv_head':960,'qk_map':30,'qk_head':960,'v_group':60};assert status['candidate_counts']==expected
|
||||
summary=json.loads((root/'calibration-summary.json').read_text());assert len(summary)==2025
|
||||
assert not status['selected'] and all(not x['strict_pass'] and not x['approximate_pass'] for x in summary)
|
||||
selection=json.loads((root/'selection.json').read_text());assert selection['qk_head_prequalified']==selection['v_group_prequalified']==0
|
||||
from collections import defaultdict
|
||||
rawout=defaultdict(list)
|
||||
for r in csv.DictReader((root/'calibration-output-metrics.csv').open()):rawout[r['candidate']].append(r)
|
||||
for c in summary:
|
||||
if c['output_verified']:
|
||||
rr=rawout[c['id']];assert len(rr)==c['output_observations']
|
||||
worst=max(max(float(r['error_a']),float(r['error_b'])) for r in rr)
|
||||
assert abs(worst-c['worst_output_error'])<1e-12 and worst>.20
|
||||
assert min(c['worst_mean_js'] for c in summary if c['kind']=='qk_head')>.05
|
||||
assert min(c['worst_value_error'] for c in summary if c['kind']=='v_group')>.20
|
||||
|
||||
rows=list(csv.DictReader((root/'head-assignment-costs.csv').open()));assert len(rows)==960
|
||||
for i,j in PAIRS:
|
||||
r=[x for x in rows if int(x['i'])==i and int(x['j'])==j];cost=np.empty((8,8));chosen=[]
|
||||
for x in r:
|
||||
ha,hb=int(x['head_i']),int(x['head_j']);cost[ha,hb]=float(x['calibration_mean_js'])
|
||||
if x['chosen']=='True':chosen.append((ha,hb))
|
||||
assert len(chosen)==8;assert [b for _,b in sorted(chosen)]==assignment(cost)
|
||||
tests=(root/'final-tests.txt').read_text();assert 'Ran 20 tests' in tests and '\nOK\n' in tests
|
||||
cond=json.loads((root/'conditional-status.json').read_text());assert cond['state']=='completed' and cond['fresh_function_pass'] is False
|
||||
case=json.loads((root/'conditional-case-audit.json').read_text());assert case['passed_recomputation'] and case['no_success_relabeling']
|
||||
assert len(case['strict_failures'])==3 and case['network_intervention_not_run_due_to_fresh_gate_failure']
|
||||
assert cond['shared_budget_seconds_including_60s_early_reserve']+600<7200
|
||||
prob=np.load(root/'conditional-fresh-probabilities.npz');target=prob['target_layer23_head6'];donor=prob['donor_layer3_head7_on_H23']
|
||||
from .core import distribution_metrics
|
||||
from .conditional import tv_metrics
|
||||
metric={**distribution_metrics(target,donor),**tv_metrics(target,donor)}
|
||||
fresh=[r for r in csv.DictReader((root/'conditional-function-metrics.csv').open()) if r['split']=='fresh_test']
|
||||
assert len(fresh)==4
|
||||
for k,values in metric.items():
|
||||
if k in fresh[0] and values[0] is not None:np.testing.assert_allclose(values,[float(r[k]) for r in fresh],atol=1e-12,rtol=1e-12)
|
||||
for file in root.glob('*.csv'):
|
||||
with file.open() as f:
|
||||
for r in csv.DictReader(f):
|
||||
for value in r.values():
|
||||
if value in ('',None):continue
|
||||
try:x=float(value)
|
||||
except ValueError:continue
|
||||
assert np.isfinite(x),(file,value)
|
||||
weights=json.loads((source/'manifest.json').read_text());assert weights['revision']=='15852e8c16360a2fea060d615a32b45270f8a8fc'
|
||||
for entry in weights['files']:
|
||||
if entry['name'].endswith('.safetensors'):assert (source/'weights'/entry['name']).stat().st_size==entry['bytes'] and entry['sha256']==entry['upstream_sha256']
|
||||
assert json.loads((source/'retention-policy.json').read_text())['automatic_cleanup'] is False
|
||||
reference=json.loads((source/'reference-check.json').read_text());assert reference['implementation_sha256']==digest(Path('functional/model.py'))
|
||||
write_json(root/'final-source-hashes.json',{str(file):digest(file) for file in [*sorted(Path('crossqkv').glob('*.py')),Path('crossqkv/fresh_samples.json'),Path('tests/test_crossqkv.py'),Path('functional/model.py')]})
|
||||
caches=[]
|
||||
for file in sorted((root/'cache').glob('*')):
|
||||
if file.is_file():caches.append({'server_path':str(file),'bytes':file.stat().st_size,'sha256':digest(file),'retained':True})
|
||||
old_cache=root.parent/'cross-layer-qkv'/'cache'/'calibration-source-3.npz'
|
||||
if old_cache.exists():caches.append({'server_path':str(old_cache),'bytes':old_cache.stat().st_size,'sha256':digest(old_cache),'retained':True,'failed_attempt_cache':True})
|
||||
write_json(root/'external-caches.json',{'host':'8.211.154.134','source_weights_directory':str(source/'weights'),'source_baseline_cache':str(source/'baseline-activations.npz'),
|
||||
'files':caches,'automatic_deletion':False,'all_figure_source_tables_and_selected_probabilities_in_git':True})
|
||||
(root/'DELIVERY.md').write_text('# Cross-layer QKV scientific delivery\n\nAll plot CSV/JSON, the selected fresh probability matrices, protocols, reference tests and failure logs are included.\nLarge intermediate profiles remain on 8.211.154.134 with locations/sizes/SHA256 in external-caches.json.\nThe fixed checkpoint and all caches are retained until explicit user deletion. No weights are committed.\nThe primary protocol has no passing candidate. The later fixed conditional audit is exploratory and its strict fresh checks failed; observed readout overlap is reported without relabeling it a complete pass.\n')
|
||||
out.mkdir(exist_ok=True,parents=True)
|
||||
files=[f for f in root.iterdir() if f.is_file() and f.name not in ('checksums.json','audit-validation.json','archive-files.json')]
|
||||
files += list((root/'figures').glob('*'))
|
||||
for file in files:
|
||||
dest=out/file.relative_to(root);dest.parent.mkdir(exist_ok=True,parents=True);shutil.copy2(file,dest)
|
||||
checks={str(f.relative_to(out)):digest(f) for f in sorted(out.rglob('*')) if f.is_file() and f.name not in ('checksums.json','audit-validation.json','archive-files.json')}
|
||||
write_json(out/'checksums.json',checks)
|
||||
write_json(out/'archive-files.json',[*checks,'checksums.json','audit-validation.json','archive-files.json'])
|
||||
write_json(out/'audit-validation.json',{'passed':True,'validated_unix':time.time(),'checksummed_files':len(checks),'primary_counts_rechecked':expected,
|
||||
'fresh_probabilities_independently_recomputed':True,'no_unrun_network_quality_claims':True,'all_weights_and_caches_retained':True})
|
||||
print(json.dumps({'passed':True,'checksummed_files':len(checks),'external_cache_files':len(caches),'weights_retained':True}))
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,62 @@
|
||||
"""Recompute the frozen exploratory case for transparent plotted probabilities.
|
||||
|
||||
No new selection, no threshold changes, no full-network intervention after failure.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
from functional.run import save_csv,write_json
|
||||
from .core import QKVModel,distribution_metrics
|
||||
from .conditional import tv_metrics
|
||||
|
||||
|
||||
def ranks_and_mass(a,b):
|
||||
result=[]
|
||||
for bi in range(a.shape[0]):
|
||||
d={'target_self_mass':[],'donor_self_mass':[],'argmax_agreement':[],'shared_top5_mass_target':[],'shared_top5_mass_donor':[]}
|
||||
for t in range(7,32):
|
||||
x,y=a[bi,0,t,:t+1],b[bi,0,t,:t+1]
|
||||
common=np.intersect1d(np.argsort(x)[-5:],np.argsort(y)[-5:])
|
||||
d['target_self_mass'].append(float(x[t]));d['donor_self_mass'].append(float(y[t]))
|
||||
d['argmax_agreement'].append(float(np.argmax(x)==np.argmax(y)))
|
||||
d['shared_top5_mass_target'].append(float(x[common].sum()));d['shared_top5_mass_donor'].append(float(y[common].sum()))
|
||||
result.append({k:float(np.mean(v)) for k,v in d.items()})
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--source',type=Path,required=True);p.add_argument('--root',type=Path,required=True);args=p.parse_args();root=args.root;source=args.source
|
||||
status=json.loads((root/'conditional-status.json').read_text());assert status['state']=='completed'
|
||||
data=np.load(root/'cache'/'conditional-fresh-inputs.npz')
|
||||
samples=json.loads((root/'conditional-fresh-samples.json').read_text())['samples']
|
||||
lm=QKVModel(source/'weights',json.loads((source/'model_config.json').read_text()),seconds=300)
|
||||
own=lm.parts(data['attn_23'],23);same=lm.parts(data['attn_23'],3);actual=lm.parts(data['attn_3'],3)
|
||||
target=own['p'][:,6:7];donor=same['p'][:,7:8];cached=actual['p'][:,7:8]
|
||||
np.savez(root/'conditional-fresh-probabilities.npz',target_layer23_head6=target,donor_layer3_head7_on_H23=donor,donor_layer3_head7_on_H3=cached)
|
||||
rows=[]
|
||||
from .run import outrows
|
||||
for mode,profile,prob in [('same_H23',same,donor),('actual_H3_to_H23',actual,cached)]:
|
||||
stats={**distribution_metrics(target,prob),**tv_metrics(target,prob)}
|
||||
mass=ranks_and_mass(target,prob)
|
||||
changed=lm.head_transplant_output(own,profile,23,6,7)
|
||||
out=outrows(own['heads'][:,:,6],changed,samples,{},1e-6,1e-6)
|
||||
for n,s in enumerate(samples):rows.append({'mode':mode,'sample':s['id'],**mass[n],**{k:(None if v[n] is None else float(v[n])) for k,v in stats.items()},'head_output_error':max(out[n]['error_a'],out[n]['error_b'])})
|
||||
save_csv(root/'conditional-fresh-source-diagnostic.csv',rows)
|
||||
with (root/'conditional-function-metrics.csv').open() as f:import csv;allrows=list(csv.DictReader(f))
|
||||
failures=[]
|
||||
for r in allrows:
|
||||
if r['split']!='fresh_test':continue
|
||||
for field,limit in [('js',.01),('js_p95',.05),('total_variation',.10),('total_variation_p95',.20)]:
|
||||
if float(r[field])>limit:failures.append({'sample':r['sample'],'field':field,'value':float(r[field]),'limit':limit})
|
||||
same_rows=[r for r in rows if r['mode']=='same_H23']
|
||||
classification='self_token_dominated' if min(min(r['target_self_mass'],r['donor_self_mass']) for r in same_rows)>.85 else 'inspect detailed source diagnostic'
|
||||
write_json(root/'conditional-case-audit.json',{'passed_recomputation':True,'strict_failures':failures,'pattern_classification':classification,
|
||||
'minimum_same_input_target_self_mass':min(r['target_self_mass'] for r in same_rows),'minimum_same_input_donor_self_mass':min(r['donor_self_mass'] for r in same_rows),
|
||||
'minimum_same_input_argmax_agreement':min(r['argmax_agreement'] for r in same_rows),
|
||||
'minimum_shared_top5_probability_mass':min(min(r['shared_top5_mass_target'],r['shared_top5_mass_donor']) for r in same_rows),
|
||||
'maximum_same_input_head_output_error':max(r['head_output_error'] for r in same_rows),
|
||||
'no_success_relabeling':True,'network_intervention_not_run_due_to_fresh_gate_failure':True})
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,113 @@
|
||||
"""One explicitly exploratory, fixed-candidate audit of unweighted top-k rejection.
|
||||
|
||||
Primary protocol remains unchanged/negative. A new confirmation uses untouched
|
||||
fresh texts; no further candidate selection, threshold tuning, weights or R fitting.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import resource
|
||||
import time
|
||||
import traceback
|
||||
import numpy as np
|
||||
from tokenizers import Tokenizer
|
||||
from functional.run import write_json,save_csv
|
||||
from .core import InterventionLM,distribution_metrics,output_metrics
|
||||
from .run import head_floor,rows_for
|
||||
|
||||
CANDIDATE={'id':'conditional_qk_head_3_23_7_6','kind':'qk_head','i':3,'j':23,'a':7,'b':6,'perm':None}
|
||||
PROTOCOL={'classification':'post-screen exploratory metric audit; not a primary-protocol positive',
|
||||
'candidate':CANDIDATE,'conditioning_input_layer':23,'donor_projection_layer':3,'target_head':6,'donor_head':7,
|
||||
'selection_basis':'one minimum worst-text JS among the already measured source-conditioned pairs; no raw readout/fresh data used',
|
||||
'js_max':.01,'js_row_p95_max':.05,'mean_total_variation_max':.10,'row_total_variation_p95_max':.20,
|
||||
'target_head_output_relative_l2_max':.20,'target_head_output_cosine_min':.98,
|
||||
'primary_query_positions':list(range(7,32)),'top5_is_diagnostic_only':True,
|
||||
'active_head_required':True,'no_candidate_fallback':True,'fresh_text_file':'crossqkv/fresh_samples.json',
|
||||
'same_input_network_direction':'layer23 head6 uses QK probability of layer3 head7 recomputed on H23',
|
||||
'actual_cache_separate':'layer3 probability on H3 reused at23; different-input diagnostic, not function-equivalence evidence',
|
||||
'quality_gate':{'mean_nll_delta_max':.01,'per_text_p95_nll_delta_max':.05},'training':False,'R_fitting':False,'cost_required':False}
|
||||
|
||||
|
||||
def tv_metrics(a,b):
|
||||
tv=.5*np.sum(np.abs(a.astype(np.float64)-b.astype(np.float64)),axis=-1)[:,:,7:]
|
||||
return {'total_variation':tv.mean((1,2)),'total_variation_p95':np.quantile(tv.reshape(tv.shape[0],-1),.95,axis=1)}
|
||||
|
||||
|
||||
def evaluate(lm,h,samples,split,donor_h=None):
|
||||
target=lm.parts(h,23);donor=lm.parts(h if donor_h is None else donor_h,3)
|
||||
a,b=target['p'][:,6:7],donor['p'][:,7:8]
|
||||
pm={**distribution_metrics(a,b),**tv_metrics(a,b)}
|
||||
changed=lm.head_transplant_output(target,donor,23,6,7)
|
||||
om=output_metrics(target['heads'][:,7:,6],changed[:,7:]);floor=head_floor(target)
|
||||
uniform=np.zeros_like(a)
|
||||
for t in range(a.shape[-1]):uniform[:,:,t,:t+1]=1/(t+1)
|
||||
null=distribution_metrics(a,uniform)
|
||||
rows=rows_for({**pm,**{f'output_{k}':v for k,v in om.items()},'target_uniform_js':null['js']},samples,{'split':split,'mode':'same_H23' if donor_h is None else 'actual_H3_to_H23'})
|
||||
for n,r in enumerate(rows):r['active']=bool(om['rms_a'][n]>=floor[n] and om['rms_b'][n]>=floor[n])
|
||||
passed=all(r['js']<=.01 and r['js_p95']<=.05 and r['total_variation']<=.10 and r['total_variation_p95']<=.20 and
|
||||
max(r['output_error_a'],r['output_error_b'])<=.20 and r['output_cosine']>=.98 and r['active'] for r in rows)
|
||||
return rows,passed
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--source',type=Path,required=True);p.add_argument('--root',type=Path,required=True);a=p.parse_args();source=a.source.resolve();root=a.root.resolve()
|
||||
assert not (root/'conditional-protocol.json').exists(),'Fresh conditional audit protocol required'
|
||||
write_json(root/'conditional-protocol.json',{**PROTOCOL,'registered_unix':time.time(),'fresh_text_sha256':hashlib.sha256(Path(__file__).with_name('fresh_samples.json').read_bytes()).hexdigest()})
|
||||
prior=json.loads((root/'status.json').read_text());assert prior['state']=='completed' and not prior['selected']
|
||||
reserve=prior['elapsed_seconds']+60
|
||||
remaining=int(7200-reserve-180)
|
||||
if remaining<120:raise TimeoutError('Insufficient shared two-hour budget')
|
||||
started=time.monotonic();status={'state':'running','phase':'calibration_readout','primary_protocol_unchanged_and_negative':True}
|
||||
rows=[]
|
||||
try:
|
||||
lm=InterventionLM(source/'weights',json.loads((source/'model_config.json').read_text()),seconds=remaining)
|
||||
old=json.loads((source/'samples-tokenized.json').read_text())['samples'];data=np.load(source/'baseline-activations.npz')
|
||||
for split in ('calibration','heldout'):
|
||||
index=np.array([i for i,s in enumerate(old) if s['split']==split]);samples=[old[i] for i in index]
|
||||
rr,passed=evaluate(lm,data['attn_23'][index],samples,split)
|
||||
rows.extend(rr);save_csv(root/'conditional-function-metrics.csv',rows)
|
||||
status[split+'_pass']=passed
|
||||
write_json(root/'conditional-status.json',status)
|
||||
if not passed:
|
||||
status['stop_reason']=f'{split} probability-mass/readout/activity screen failed';break
|
||||
else:
|
||||
fresh=json.loads(Path(__file__).with_name('fresh_samples.json').read_text())['samples'];tokenizer=Tokenizer.from_file(str(source/'tokenizer.json'));ids=[]
|
||||
for s in fresh:
|
||||
tokens=tokenizer.encode(s['text'],add_special_tokens=False).ids;assert len(tokens)>=32
|
||||
s.update(token_ids=tokens[:32],full_token_count=len(tokens),text_sha256=hashlib.sha256(s['text'].encode()).hexdigest());ids.append(tokens[:32])
|
||||
ids=np.array(ids,dtype=np.int64);write_json(root/'conditional-fresh-samples.json',{'samples':fresh,'candidate_already_fixed':True})
|
||||
status['phase']='fresh_baseline';write_json(root/'conditional-status.json',status)
|
||||
h,inputs=lm.forward(ids,capture=[('attn',3),('attn',23)])
|
||||
np.savez(root/'cache'/'conditional-fresh-inputs.npz',**inputs,final=h)
|
||||
base=lm.nll(h,ids);np.save(root/'conditional-fresh-baseline-token-nll.npy',base)
|
||||
rr,passed=evaluate(lm,inputs['attn_23'],fresh,'fresh_test');rows.extend(rr);save_csv(root/'conditional-function-metrics.csv',rows)
|
||||
status['fresh_function_pass']=passed
|
||||
if passed:
|
||||
status['phase']='one_direction_same_input_network';write_json(root/'conditional-status.json',status)
|
||||
lm.configure(CANDIDATE,reverse=True,cached=False);changed,_=lm.forward(ids);nll=lm.nll(changed,ids);np.save(root/'conditional-same-input-network-token-nll.npy',nll)
|
||||
delta=nll.mean(1)-base.mean(1)
|
||||
network={'mode':'layer23_head6_uses_layer3_head7_on_H23','sequence_nll_deltas':delta.tolist(),'mean_nll_delta':float(delta.mean()),'sequence_p95_nll_delta':float(np.quantile(delta,.95)),
|
||||
'quality_pass':bool(delta.mean()<=.01 and np.quantile(delta,.95)<=.05),'one_direction_only':True}
|
||||
write_json(root/'conditional-network.json',network);status['same_input_network_quality_pass']=network['quality_pass']
|
||||
# Check the actual-cache probability/readout separately, then run its network experiment.
|
||||
cached_rows,cached_function_pass=evaluate(lm,inputs['attn_23'],fresh,'fresh_test_actual_cache',donor_h=inputs['attn_3'])
|
||||
save_csv(root/'conditional-actual-cache-metrics.csv',cached_rows)
|
||||
status['actual_cache_function_screen_pass']=cached_function_pass
|
||||
lm.configure(CANDIDATE,reverse=True,cached=True);changed,_=lm.forward(ids);nll=lm.nll(changed,ids);np.save(root/'conditional-actual-cache-network-token-nll.npy',nll)
|
||||
delta=nll.mean(1)-base.mean(1)
|
||||
cache={'mode':'actual_layer3_H3_probability_reused_at23_H23','sequence_nll_deltas':delta.tolist(),'mean_nll_delta':float(delta.mean()),'sequence_p95_nll_delta':float(np.quantile(delta,.95)),
|
||||
'quality_pass':bool(delta.mean()<=.01 and np.quantile(delta,.95)<=.05),'different_hidden_inputs':True}
|
||||
write_json(root/'conditional-actual-cache-network.json',cache);status['actual_cache_network_quality_pass']=cache['quality_pass']
|
||||
status.update(state='completed',phase='done',conditional_function_positive=bool(status.get('fresh_function_pass')),
|
||||
position_pattern_classification='near_uniform' if rows and max(r['target_uniform_js'] for r in rows)<=.01 else 'inspect first-key/self/recent3 masses',
|
||||
claim_limit='Single-source H23-conditioned, single-head QK probability/readout similarity; not bidirectional, not V similarity, not full-QKV-head equivalence; exploratory addendum independently fresh-tested.')
|
||||
except Exception as exc:
|
||||
status.update(state='stopped',error_type=type(exc).__name__,error=str(exc));(root/'conditional-error.txt').write_text(traceback.format_exc());raise
|
||||
finally:
|
||||
status.update(elapsed_seconds=time.monotonic()-started,peak_rss_kib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss,
|
||||
shared_budget_seconds_including_60s_early_reserve=reserve+time.monotonic()-started)
|
||||
write_json(root/'conditional-status.json',status)
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,171 @@
|
||||
"""Attention functions and discrete diagnostics, no continuous alignment/fitting."""
|
||||
import numpy as np
|
||||
from functional.model import StreamingLM,PREFIX,attention,rope,sigmoid
|
||||
|
||||
|
||||
def assignment(cost):
|
||||
"""Exact minimum-cost bijection via O(n^2 2^n) dynamic programming."""
|
||||
cost=np.asarray(cost,dtype=np.float64);n=cost.shape[0]
|
||||
assert cost.shape==(n,n) and n<=12 and np.isfinite(cost).all()
|
||||
states={0:(0.,())}
|
||||
for i in range(n):
|
||||
nxt={}
|
||||
for mask,(value,perm) in states.items():
|
||||
for j in range(n):
|
||||
if mask&(1<<j):continue
|
||||
key=mask|(1<<j);candidate=(value+float(cost[i,j]),perm+(j,))
|
||||
if key not in nxt or candidate<nxt[key]:nxt[key]=candidate
|
||||
states=nxt
|
||||
return list(states[(1<<n)-1][1])
|
||||
|
||||
|
||||
def inverse(perm):
|
||||
out=[0]*len(perm)
|
||||
for i,j in enumerate(perm):out[j]=i
|
||||
return out
|
||||
|
||||
|
||||
def output_metrics(a,b):
|
||||
"""Per-text directional error, cosine and output RMS. No fitted scaling."""
|
||||
x=a.reshape(a.shape[0],-1).astype(np.float64)
|
||||
y=b.reshape(b.shape[0],-1).astype(np.float64)
|
||||
xx=np.sum(x*x,-1);yy=np.sum(y*y,-1);diff=np.sum((x-y)**2,-1)
|
||||
return {'error_a':np.sqrt(diff/np.maximum(xx,1e-30)),
|
||||
'error_b':np.sqrt(diff/np.maximum(yy,1e-30)),
|
||||
'cosine':np.sum(x*y,-1)/np.maximum(np.sqrt(xx*yy),1e-30),
|
||||
'rms_a':np.sqrt(xx/x.shape[1]),'rms_b':np.sqrt(yy/y.shape[1])}
|
||||
|
||||
|
||||
def distribution_metrics(a,b):
|
||||
"""Aligned heads; primary queries have at least 8 legal keys (t>=7)."""
|
||||
a,b=a.astype(np.float64),b.astype(np.float64)
|
||||
assert a.shape==b.shape and a.shape[-1]>=8
|
||||
m=(a+b)*.5
|
||||
def term(x):return np.where(x>0,x*np.log(np.maximum(x,1e-300)/np.maximum(m,1e-300)),0)
|
||||
js=np.maximum(.5*np.sum(term(a)+term(b),axis=-1),0)
|
||||
eligible=js[...,7:]
|
||||
overlaps=[]
|
||||
for t in range(7,a.shape[-2]):
|
||||
aa=np.argsort(a[:,:,t,:t+1],axis=-1)[...,-5:]
|
||||
bb=np.argsort(b[:,:,t,:t+1],axis=-1)[...,-5:]
|
||||
overlaps.append(np.mean((aa[...,None]==bb[...,None,:]).any(-1),-1))
|
||||
# First-key ablation is diagnostic, not an unreported filter of positional repetitions.
|
||||
ar,br=a[...,1:],b[...,1:];ma,mb=ar.sum(-1),br.sum(-1)
|
||||
valid=(ma>1e-8)&(mb>1e-8)
|
||||
ar=ar/np.maximum(ma[...,None],1e-300);br=br/np.maximum(mb[...,None],1e-300)
|
||||
mr=(ar+br)*.5
|
||||
cond=.5*np.sum(np.where(ar>0,ar*np.log(np.maximum(ar,1e-300)/np.maximum(mr,1e-300)),0)+np.where(br>0,br*np.log(np.maximum(br,1e-300)/np.maximum(mr,1e-300)),0),-1)
|
||||
sink=[]
|
||||
for bi in range(a.shape[0]):
|
||||
which=valid[bi,:,7:];values=cond[bi,:,7:]
|
||||
sink.append(float(np.maximum(values[which],0).mean()) if which.any() else None)
|
||||
diag=np.stack([a[:,:,t,t] for t in range(7,a.shape[-2])],-1).mean((1,2))
|
||||
local=np.stack([a[:,:,t,max(0,t-2):t+1].sum(-1) for t in range(7,a.shape[-2])],-1).mean((1,2))
|
||||
return {'js':eligible.mean((1,2)),'js_p95':np.quantile(eligible.reshape(a.shape[0],-1),.95,axis=1),
|
||||
'top5':np.stack(overlaps,-1).mean((1,2)),'js_all_queries':js.mean((1,2)),
|
||||
'first_key_mass_a':a[:,:,7:,0].mean((1,2)),'first_key_mass_b':b[:,:,7:,0].mean((1,2)),
|
||||
'self_mass_a':diag,'recent3_mass_a':local,'js_without_first_key':sink}
|
||||
|
||||
|
||||
def cross_head_output_metrics(a,b):
|
||||
"""All head pairs, per text. a/b: [B,T,H,Dhidden]."""
|
||||
aa=a.transpose(0,2,1,3).reshape(a.shape[0],a.shape[2],-1).astype(np.float64)
|
||||
bb=b.transpose(0,2,1,3).reshape(b.shape[0],b.shape[2],-1).astype(np.float64)
|
||||
xx=np.sum(aa*aa,-1);yy=np.sum(bb*bb,-1)
|
||||
dot=np.einsum('bif,bjf->bij',aa,bb,optimize=True)
|
||||
diff=np.maximum(xx[:,:,None]+yy[:,None,:]-2*dot,0)
|
||||
return {'error_a':np.sqrt(diff/np.maximum(xx[:,:,None],1e-30)),
|
||||
'error_b':np.sqrt(diff/np.maximum(yy[:,None,:],1e-30)),
|
||||
'cosine':dot/np.maximum(np.sqrt(xx[:,:,None]*yy[:,None,:]),1e-30),
|
||||
'rms_a':np.broadcast_to(np.sqrt(xx/aa.shape[-1])[:,:,None],dot.shape),
|
||||
'rms_b':np.broadcast_to(np.sqrt(yy/bb.shape[-1])[:,None,:],dot.shape)}
|
||||
|
||||
|
||||
def value_gram_cka(a,b):
|
||||
"""Centered token Gram agreement, diagnostic only; not interchangeability."""
|
||||
a=a.astype(np.float64)-a.mean(axis=1,keepdims=True,dtype=np.float64)
|
||||
b=b.astype(np.float64)-b.mean(axis=1,keepdims=True,dtype=np.float64)
|
||||
ga=np.einsum('btd,bsd->bts',a,a);gb=np.einsum('btd,bsd->bts',b,b)
|
||||
return np.sum(ga*gb,(1,2))/np.maximum(np.sqrt(np.sum(ga*ga,(1,2))*np.sum(gb*gb,(1,2))),1e-30)
|
||||
|
||||
|
||||
class QKVModel(StreamingLM):
|
||||
def project(self,context,gate,layer):
|
||||
return self.linear((context*sigmoid(gate)).reshape(*context.shape[:2],-1),f'layers.{layer}.self_attn.o_proj')
|
||||
|
||||
def project_heads(self,context,gate,layer):
|
||||
"""Each head's contribution in the common residual output coordinates."""
|
||||
c=context*sigmoid(gate);b,t,h,d=c.shape
|
||||
weight=self.tensors[PREFIX+f'layers.{layer}.self_attn.o_proj.weight']
|
||||
outdim,indim=weight.shape;assert indim==h*d
|
||||
out=np.empty((b,t,h,outdim),dtype=np.float32)
|
||||
for start in range(0,outdim,256):
|
||||
self.guard();end=min(start+256,outdim)
|
||||
w=weight.read(slice(start*indim,end*indim)).reshape(end-start,indim)
|
||||
for head in range(h):out[:,:,head,start:end]=c[:,:,head,:]@w[:,head*d:(head+1)*d].T
|
||||
del w;weight.evict()
|
||||
return out
|
||||
|
||||
def parts(self,h,layer,heads=True):
|
||||
p=f'layers.{layer}.self_attn.';c=self.config;d=c['head_dim'];nh=c['num_attention_heads'];nk=c['num_key_value_heads']
|
||||
mixed=self.linear(h,p+'q_proj').reshape(*h.shape[:2],nh,2*d)
|
||||
q,gate=mixed[...,:d],mixed[...,d:].copy()
|
||||
k=self.linear(h,p+'k_proj').reshape(*h.shape[:2],nk,d)
|
||||
v=self.linear(h,p+'v_proj').reshape(*h.shape[:2],nk,d)
|
||||
q=self.normalization(q,p+'q_norm');k=self.normalization(k,p+'k_norm')
|
||||
r=c['rope_parameters'];q,k=(rope(x,r['rope_theta'],r['partial_rotary_factor']) for x in (q,k))
|
||||
context,probs=attention(q,k,v)
|
||||
out={'q':q,'k':k,'p':probs,'v':v,'gate':gate,'context':context,'output':self.project(context,gate,layer)}
|
||||
if heads:out['heads']=self.project_heads(context,gate,layer)
|
||||
return out
|
||||
|
||||
def transplant(self,own,donor,layer,kind,target_head=None,donor_head=None,perm=None):
|
||||
repeats=self.config['num_attention_heads']//self.config['num_key_value_heads']
|
||||
if kind=='full_attention':return donor['output']
|
||||
if kind=='qkv_head':return own['output']-own['heads'][:,:,target_head]+donor['heads'][:,:,donor_head]
|
||||
probs=own['p'].copy();v=own['v'].copy()
|
||||
if kind=='qk_map':probs=donor['p'][:,perm]
|
||||
elif kind=='qk_head':probs[:,target_head]=donor['p'][:,donor_head]
|
||||
elif kind=='v_group':v[:,:,target_head]=donor['v'][:,:,donor_head]
|
||||
else:raise ValueError(kind)
|
||||
context=np.einsum('bhts,bshd->bthd',probs,np.repeat(v,repeats,axis=2))
|
||||
return self.project(context,own['gate'],layer)
|
||||
|
||||
def head_transplant_output(self,own,donor,layer,target_head,donor_head):
|
||||
"""QK-only transplanted target head contribution; all other heads omitted."""
|
||||
repeats=self.config['num_attention_heads']//self.config['num_key_value_heads']
|
||||
c=own['context'].copy()
|
||||
c[:,:,target_head]=np.einsum('bts,bsd->btd',donor['p'][:,donor_head],own['v'][:,:,target_head//repeats])
|
||||
# Zero remaining head contexts before projection to isolate this learned subfunction.
|
||||
for head in range(c.shape[2]):
|
||||
if head!=target_head:c[:,:,head]=0
|
||||
return self.project(c,own['gate'],layer)
|
||||
|
||||
def value_group_output(self,own,donor,layer,target_group,donor_group):
|
||||
repeats=self.config['num_attention_heads']//self.config['num_key_value_heads'];c=np.zeros_like(own['context'])
|
||||
for head in range(target_group*repeats,(target_group+1)*repeats):
|
||||
c[:,:,head]=np.einsum('bts,bsd->btd',own['p'][:,head],donor['v'][:,:,donor_group])
|
||||
return self.project(c,own['gate'],layer)
|
||||
|
||||
|
||||
class InterventionLM(QKVModel):
|
||||
def configure(self,candidate,reverse=False,cached=False):
|
||||
self.candidate=candidate;self.reverse=reverse;self.use_cache=cached;self.donor_cache=None
|
||||
self.target_layer=candidate['j'] if reverse else candidate['i']
|
||||
self.donor_layer=candidate['i'] if reverse else candidate['j']
|
||||
self.target_head=candidate.get('b') if reverse else candidate.get('a')
|
||||
self.donor_head=candidate.get('a') if reverse else candidate.get('b')
|
||||
self.perm=inverse(candidate['perm']) if reverse and candidate.get('perm') else candidate.get('perm')
|
||||
if cached:assert self.donor_layer<self.target_layer,'Cannot reuse future layer state'
|
||||
|
||||
def full_attention(self,h,layer,shared_p=None):
|
||||
if not hasattr(self,'candidate'):return super().full_attention(h,layer,shared_p)
|
||||
if self.use_cache and layer==self.donor_layer:
|
||||
self.donor_cache=self.parts(h,layer,heads=self.candidate['kind']=='qkv_head')
|
||||
return self.donor_cache['output'],self.donor_cache['p']
|
||||
if layer!=self.target_layer:return super().full_attention(h,layer,shared_p)
|
||||
own=self.parts(h,layer,heads=self.candidate['kind']=='qkv_head')
|
||||
donor=self.donor_cache if self.use_cache else self.parts(h,self.donor_layer,heads=self.candidate['kind']=='qkv_head')
|
||||
assert donor is not None
|
||||
out=self.transplant(own,donor,layer,self.candidate['kind'],self.target_head,self.donor_head,self.perm)
|
||||
return out,own['p']
|
||||
@@ -0,0 +1,56 @@
|
||||
"""Fresh heldout confirmation and same-input versus actual-state interventions."""
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import time
|
||||
import numpy as np
|
||||
from functional.run import write_json,save_csv
|
||||
from .protocol import LAYERS
|
||||
|
||||
|
||||
def run_fresh(source,root,c,tier,lm,status):
|
||||
from tokenizers import Tokenizer
|
||||
from .run import validate_selected,candidate_pass,summarize
|
||||
samples=json.loads(Path(__file__).with_name('fresh_samples.json').read_text())['samples']
|
||||
tokenizer=Tokenizer.from_file(str(source/'tokenizer.json'));ids=[]
|
||||
for s in samples:
|
||||
encoded=tokenizer.encode(s['text'],add_special_tokens=False).ids
|
||||
assert len(encoded)>=32,s['id']
|
||||
s.update(token_ids=encoded[:32],full_token_count=len(encoded),text_sha256=hashlib.sha256(s['text'].encode()).hexdigest())
|
||||
ids.append(encoded[:32])
|
||||
ids=np.array(ids,dtype=np.int64)
|
||||
write_json(root/'fresh-samples-tokenized.json',{'samples':samples,'selection_already_frozen':True})
|
||||
status['phase']='fresh_test_baseline';write_json(root/'status.json',status)
|
||||
h,inputs=lm.forward(ids,capture=[('attn',i) for i in LAYERS])
|
||||
np.savez(root/'cache'/'fresh-baseline-activations.npz',final=h,**inputs)
|
||||
nll=lm.nll(h,ids);np.save(root/'fresh-baseline-token-nll.npy',nll)
|
||||
checked=validate_selected(lm,c,inputs,samples,np.arange(len(samples)))
|
||||
passed=candidate_pass(checked,tier)
|
||||
write_json(root/'fresh-function-summary.json',summarize(checked))
|
||||
save_csv(root/'fresh-output-metrics.csv',checked['output_rows']);save_csv(root/'fresh-probability-metrics.csv',checked['probability_rows']);save_csv(root/'fresh-value-metrics.csv',checked['value_rows'])
|
||||
status.update(fresh_function_pass=passed,fresh_confirmation_tier=tier)
|
||||
if not passed:return
|
||||
status['phase']='same_input_network_substitution';write_json(root/'status.json',status)
|
||||
interventions=[]
|
||||
for reverse in (False,True):
|
||||
lm.configure(c,reverse=reverse,cached=False)
|
||||
t=time.monotonic();changed,_=lm.forward(ids);loss=lm.nll(changed,ids)
|
||||
label=f'{lm.target_layer}_uses_{lm.donor_layer}'
|
||||
np.save(root/f'network-{label}-token-nll.npy',loss)
|
||||
delta=loss.mean(1)-nll.mean(1)
|
||||
rec={'mode':'same_input_donor_function','target_layer':lm.target_layer,'donor_layer':lm.donor_layer,
|
||||
'target_head_or_group':lm.target_head,'donor_head_or_group':lm.donor_head,
|
||||
'sequence_nll_deltas':delta.tolist(),'mean_nll_delta':float(delta.mean()),'sequence_p95_nll_delta':float(np.quantile(delta,.95)),
|
||||
'quality_pass':bool(delta.mean()<=.01 and np.quantile(delta,.95)<=.05),'elapsed_seconds':time.monotonic()-t}
|
||||
interventions.append(rec);write_json(root/'network-interventions.json',interventions)
|
||||
# Temporal reuse is a separate intervention and only goes from earlier to later.
|
||||
status['phase']='earlier_to_later_actual_cache';write_json(root/'status.json',status)
|
||||
lm.configure(c,reverse=True,cached=True)
|
||||
changed,_=lm.forward(ids);loss=lm.nll(changed,ids);np.save(root/'network-earlier-actual-cache-token-nll.npy',loss)
|
||||
delta=loss.mean(1)-nll.mean(1)
|
||||
cache={'mode':'earlier_actual_state_reused_later','donor_layer':lm.donor_layer,'target_layer':lm.target_layer,
|
||||
'sequence_nll_deltas':delta.tolist(),'mean_nll_delta':float(delta.mean()),'sequence_p95_nll_delta':float(np.quantile(delta,.95)),
|
||||
'quality_pass':bool(delta.mean()<=.01 and np.quantile(delta,.95)<=.05),
|
||||
'not_same_input_comparison':True,'no_reverse_future_state_claim':True}
|
||||
write_json(root/'actual-cache-intervention.json',cache)
|
||||
status.update(bidirectional_same_input_network_pass=all(r['quality_pass'] for r in interventions),actual_cache_quality_pass=cache['quality_pass'])
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"origin":"Four experiment-authored fresh plain texts, fixed for this cross-layer QKV goal before measurements; no chat template, first 32 tokenizer tokens.",
|
||||
"samples":[
|
||||
{"id":"fresh-zh-1","language":"zh","text":"植物学家在不同海拔采集了叶片样本,并为每一份标本记录温度、光照和土壤湿度。回到实验室后,她按地点整理标签,先核对缺失记录,再比较不同环境中的叶片形状。"},
|
||||
{"id":"fresh-zh-2","language":"zh","text":"如果一个盒子里有十二枚蓝色棋子和八枚白色棋子,随机取出一枚后不放回,第二次取到蓝色的概率需要根据第一次的结果分别计算。请先列出各个事件,再检查它们的概率之和。"},
|
||||
{"id":"fresh-en-1","language":"en","text":"A technician recorded the vibration of a small motor before and after replacing its bearings. She used the same mounting position and sampling interval for both measurements. The final notebook included the raw traces, instrument settings, and a brief explanation of unusual observations."},
|
||||
{"id":"fresh-en-2","language":"en","text":"The function walks through a list of integers and stores each running total in a new list. An empty input should return an empty result. Before changing the implementation, compare a short example by hand and make sure negative numbers preserve the intended behavior."}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
"""Fixed protocol, constants frozen before any new cross-layer measurements."""
|
||||
from itertools import combinations
|
||||
|
||||
LAYERS=[3,7,11,15,19,23]
|
||||
PAIRS=list(combinations(LAYERS,2))
|
||||
TIERS={
|
||||
'strict':{'output_error':.05,'output_cosine':.99,'js':.01,'js_p95':.05,'top5':.8,'value_error':.05,'value_cosine':.99},
|
||||
'approximate':{'output_error':.20,'output_cosine':.98,'js':.05,'js_p95':.15,'top5':.6,'value_error':.20,'value_cosine':.98}}
|
||||
PROTOCOL={'layers':LAYERS,'layer_pairs':PAIRS,'heads':8,'kv_heads':2,'head_dim':256,
|
||||
'calibration_samples':['cal-zh-1','cal-zh-2','cal-en-1','cal-en-2'],
|
||||
'validation_samples':['test-zh-1','test-zh-2','test-en-1','test-en-2'],
|
||||
'fresh_test_file':'crossqkv/fresh_samples.json','fresh_test_count':4,'tokens_per_text':32,
|
||||
'query_positions_for_primary_metrics':list(range(7,32)),
|
||||
'candidate_types':['full_attention','qkv_head','qk_map','qk_head','v_group'],
|
||||
'discrete_head_matching':'Exact 8-head minimum mean-JS bijection, two source-layer calibration input distributions; frozen before validation; P injection only',
|
||||
'continuous_alignment':False,'training':False,'scale_fitting':False,'gpu':False,'cost_required':False,
|
||||
'tiers':TIERS,'max_qk_head_output_candidates':32,'max_v_group_output_candidates':16,
|
||||
'all_qk_map_output_candidates':30,'max_final_candidate':1,
|
||||
'selection':'strict before approximate; type priority full_attention/qkv_head/qk_map/qk_head/v_group; then worst output error, JS, ID; no validation-driven fallback',
|
||||
'head_output_activity_floor':'max(1e-6, 0.1 * within-layer median head RMS) for every calibration/validation/test text',
|
||||
'fresh_test_run_only_if_frozen_candidate_passes_validation':True,
|
||||
'network_interventions':'two same-input donor-function substitution directions; plus one earlier-to-later actual cached-state reuse test reported separately',
|
||||
'network_quality':{'mean_token_nll_delta_max':.01,'per_text_p95_nll_delta_max':.05},
|
||||
'retention':'all weights and caches retained until explicit user deletion request',
|
||||
'seconds':7200,'controls':['identity','uniform causal P','seeded within-causal-row key shuffle','first-key ablation','self/recent3 mass','value Gram to input','value Gram of two seeded Gaussian projections'],
|
||||
'positional_repeat_labels':{'sink_dominated':.90,'self_dominated':.90,'recent3_dominated':.90},
|
||||
'limitations':['Old validation texts were used in prior experiments; four fresh texts are reserved for this new goal',
|
||||
'Direct V-coordinate disagreement does not disprove V/O functional equivalence; centered value Gram CKA is diagnostic only',
|
||||
'Arbitrary P-head assignment does not authorize arbitrary GQA KV-weight permutation',
|
||||
'Short text-only pilot does not establish broad task equivalence or linear-attention reuse']}
|
||||
@@ -0,0 +1,126 @@
|
||||
"""Scientific plots from saved tables/probabilities only; no model access."""
|
||||
import argparse
|
||||
import csv
|
||||
import json
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
import matplotlib
|
||||
matplotlib.use('Agg')
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.patches import Rectangle
|
||||
from .protocol import LAYERS,PAIRS
|
||||
|
||||
|
||||
def read_csv(path):
|
||||
with path.open() as f:return list(csv.DictReader(f))
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);args=p.parse_args();root=args.root;out=root/'figures';out.mkdir(exist_ok=True)
|
||||
plt.rcParams.update({'font.size':9,'pdf.fonttype':42,'svg.fonttype':'none','savefig.bbox':'tight'})
|
||||
def save(fig,name):
|
||||
for ext in ('png','pdf','svg'):fig.savefig(out/f'{name}.{ext}',dpi=180)
|
||||
plt.close(fig)
|
||||
status=json.loads((root/'status.json').read_text());summary=json.loads((root/'calibration-summary.json').read_text())
|
||||
matrices=[]
|
||||
for mode in ('qk_head','identity','matched'):
|
||||
matrix=np.full((6,6),np.nan)
|
||||
for i,j in PAIRS:
|
||||
rows=[r for r in summary if r['i']==i and r['j']==j and ((mode=='qk_head' and r['kind']=='qk_head') or (mode!='qk_head' and r['id']==f'qk_map_{i}_{j}_{mode}'))]
|
||||
value=min(r['worst_mean_js'] for r in rows)
|
||||
a,b=LAYERS.index(i),LAYERS.index(j);matrix[a,b]=matrix[b,a]=value
|
||||
matrices.append(matrix)
|
||||
fig,axes=plt.subplots(1,3,figsize=(13,4.7));vmax=max(np.nanmax(m) for m in matrices)
|
||||
for ax,m,title in zip(axes,matrices,['Best single head pair','All heads: original order','All heads: calibration bijection']):
|
||||
im=ax.imshow(m,cmap='YlOrRd',vmin=0,vmax=vmax)
|
||||
for a in range(6):
|
||||
ax.add_patch(Rectangle((a-.5,a-.5),1,1,facecolor='#eeeeee',edgecolor='#aaaaaa',hatch='///',lw=.3))
|
||||
for b in range(6):
|
||||
if a!=b:ax.text(b,a,f'{m[a,b]:.3f}',ha='center',va='center',fontsize=7,color='black' if m[a,b]<vmax*.65 else 'white')
|
||||
ax.set_xticks(range(6),LAYERS);ax.set_yticks(range(6),LAYERS);ax.set_xlabel('Layer index');ax.set_ylabel('Layer index');ax.set_title(title)
|
||||
fig.suptitle('QK retrieval divergence: worst-text mean JS over both source input sets\nCalibration only; single-head panel minimizes over 64 cross-layer head pairs; hatched diagonal unused')
|
||||
fig.subplots_adjust(top=.77,bottom=.18,right=.9,wspace=.35);cax=fig.add_axes([.92,.2,.012,.5]);fig.colorbar(im,cax=cax,label='JS (natural log); lower is closer');save(fig,'cross_layer_qk_divergence')
|
||||
order=['full_attention','qkv_head','qk_map','qk_head','v_group'];labels=['Whole attention','QKV+gate/O head','QK map transplant','QK head transplant','V group transplant']
|
||||
fig,ax=plt.subplots(figsize=(10,4.9));rng=np.random.default_rng(0)
|
||||
for idx,(kind,label) in enumerate(zip(order,labels)):
|
||||
rows=[r for r in summary if r['kind']==kind and r['output_verified']]
|
||||
if rows:
|
||||
x=idx+rng.uniform(-.15,.15,len(rows));y=[r['worst_output_error'] for r in rows]
|
||||
ax.scatter(x,y,s=12,alpha=.35,color='#606060')
|
||||
ax.text(idx,max(y)*1.1,f'n={len(rows)}',ha='center',fontsize=8)
|
||||
else:ax.text(idx,.3,'not output-probed\ninitial gate failed',ha='center',va='center',fontsize=8)
|
||||
ax.axhline(.05,color='#b2182b',ls='--',label='Strict output error = 0.05')
|
||||
ax.axhline(.2,color='#d95f02',ls=':',label='Approximate output error = 0.20')
|
||||
ax.set_yscale('log');ax.set_xlim(-.5,4.5);ax.set_xticks(range(5),labels,rotation=20,ha='right');ax.set_ylabel('Worst directional relative L2, queries 7–31')
|
||||
ax.set_title('Primary protocol: calibrated cross-layer output comparisons\nEach point is one unit; no candidate passed all predeclared gates')
|
||||
ax.legend(loc='upper left',bbox_to_anchor=(0,-.28),fontsize=8);fig.tight_layout();save(fig,'cross_layer_output_errors')
|
||||
values=read_csv(root/'calibration-value-metrics.csv');unit={}
|
||||
for r in values:unit.setdefault(r['candidate'],[]).append(r)
|
||||
xx=[np.mean([float(r['centered_value_gram_cka']) for r in rows]) for rows in unit.values()]
|
||||
yy=[max(max(float(r['error_a']),float(r['error_b'])) for r in rows) for rows in unit.values()]
|
||||
controls=read_csv(root/'controls.csv');random_cka=[float(r['gram_cka']) for r in controls if r['control']=='value_gram_random_projection_pair']
|
||||
fig,ax=plt.subplots(figsize=(7,4.5));ax.scatter(xx,yy,s=24,color='#377eb8',label='60 cross-layer KV-head pairs')
|
||||
ax.axvspan(min(random_cka),max(random_cka),color='gray',alpha=.15,label='Random-projection Gram CKA range')
|
||||
ax.axvline(np.median(random_cka),color='gray',ls=':')
|
||||
ax.axhline(.2,color='#b2182b',ls='--',label='Approximate direct V error = 0.20')
|
||||
ax.set_xlabel('Mean centered token-Gram CKA');ax.set_ylabel('Worst direct V relative L2');ax.set_title('V geometry is a diagnostic, not substitution evidence')
|
||||
ax.legend(loc='upper left',bbox_to_anchor=(0,-.19),fontsize=8);fig.tight_layout();save(fig,'value_geometry_and_direct_error')
|
||||
conditional_path=root/'conditional-status.json'
|
||||
cond=json.loads(conditional_path.read_text()) if conditional_path.exists() else {}
|
||||
if (root/'conditional-function-metrics.csv').exists():
|
||||
rows=read_csv(root/'conditional-function-metrics.csv');labels=[r['sample'] for r in rows];x=np.arange(len(rows))
|
||||
fig,axes=plt.subplots(1,2,figsize=(13,5))
|
||||
axes[0].plot(x,[float(r['top5']) for r in rows],'o-',label='Unweighted top-5 overlap')
|
||||
axes[0].plot(x,[1-float(r['total_variation']) for r in rows],'o-',label='Probability-mass overlap (1−TV)')
|
||||
axes[0].set_ylim(0,1.03);axes[0].set_ylabel('Overlap');axes[0].legend(loc='lower left',fontsize=8)
|
||||
axes[1].plot(x,[max(float(r['output_error_a']),float(r['output_error_b'])) for r in rows],'o-',color='#238b45')
|
||||
axes[1].set_ylim(0,max(.05,max(max(float(r['output_error_a']),float(r['output_error_b'])) for r in rows)*1.15))
|
||||
axes[1].set_ylabel('Head readout relative L2');axes[1].set_title('Fixed layer23 V/gate/O',fontsize=9)
|
||||
for ax in axes:
|
||||
for pos in (3.5,7.5):ax.axvline(pos,color='gray',lw=.6)
|
||||
ax.set_xticks(x,labels,rotation=50,ha='right');ax.set_xlabel('Calibration / old validation / fresh tests, 4 each')
|
||||
fig.suptitle('Exploratory fixed case: layer3 head7 vs layer23 head6, both applied to H23\nFresh JS / tail-mass limits not fully passed; network substitution not run')
|
||||
fig.tight_layout();save(fig,'conditional_probability_mass_and_readout')
|
||||
if (root/'conditional-fresh-probabilities.npz').exists():
|
||||
p=np.load(root/'conditional-fresh-probabilities.npz');a=p['target_layer23_head6'][0,0];b=p['donor_layer3_head7_on_H23'][0,0];d=p['donor_layer3_head7_on_H3'][0,0]
|
||||
fig,axes=plt.subplots(2,2,figsize=(9,8));images=[a,b,np.abs(a-b),d]
|
||||
titles=['Layer23 head6 on H23','Layer3 head7 on the same H23','Absolute same-input probability difference','Layer3 head7 on its actual H3 (different input)']
|
||||
for idx,(ax,z,title) in enumerate(zip(axes.flat,images,titles)):
|
||||
im=ax.imshow(z,cmap='magma',vmin=0,vmax=(max(float(z.max()),1e-8) if idx==2 else 1.));fig.colorbar(im,ax=ax,fraction=.045,pad=.03)
|
||||
ax.set_xticks([0,7,15,23,31]);ax.set_yticks([0,7,15,23,31]);ax.set_xlabel('Key position');ax.set_ylabel('Query position');ax.set_title(title,fontsize=9)
|
||||
fig.suptitle('One fresh Chinese text: cross-layer conditional self-token retrieval\nRows 0–6 shown for context; primary metrics use queries 7–31')
|
||||
fig.tight_layout();save(fig,'conditional_cross_layer_probability_maps')
|
||||
text=['# Cross-layer QKV CPU study','',
|
||||
'Primary protocol and exploratory addendum are reported separately; no post-hoc success relabeling.',
|
||||
f'- Primary state: {status["state"]}; selected candidate: {status.get("selected",[])}.',
|
||||
f'- Candidate counts: {status.get("candidate_counts")}.',
|
||||
f'- Passing counts (approximate tier, all gates): {status.get("passing_counts")}.',
|
||||
f'- Primary computation seconds: {status.get("elapsed_seconds")}; peak RSS KiB: {status.get("peak_rss_kib")}.','',
|
||||
'## What was measured','',
|
||||
'Six full-attention layers, indices 3/7/11/15/19/23; all 15 cross-layer pairs. No within-layer Q/K/V interchange.',
|
||||
'Same normalized hidden inputs from both source layers; frozen Q/K norm, partial RoPE, GQA, V, output gate and O.',
|
||||
'QK head probabilities, whole-map injection in original/frozen matched head order, direct V functions, complete head contributions in residual coordinates, and complete branches were separated.',
|
||||
'Primary metrics use queries 7–31. Discrete matching uses calibration only; no continuous alignment, scale fitting or training.',
|
||||
'No primary candidate passed, so primary validation/fresh/network intervention stages were not entered.','']
|
||||
for kind in order:
|
||||
group=[r for r in summary if r['kind']==kind];outrows=[r for r in group if r['worst_output_error'] is not None];p=[r for r in group if r['worst_mean_js'] is not None];v=[r for r in group if r['worst_value_error'] is not None]
|
||||
text += [f'- {kind}: n={len(group)}, best worst output error={min((r["worst_output_error"] for r in outrows),default=None)}, minimum worst-text mean JS={min((r["worst_mean_js"] for r in p),default=None)}, best worst direct V error={min((r["worst_value_error"] for r in v),default=None)}.']
|
||||
if cond:
|
||||
text+=['','## Exploratory metric audit: frozen one-source candidate','',
|
||||
'After inspecting primary calibration results, one candidate was frozen: layer3 head7 vs layer23 head6 on H23.',
|
||||
'This addendum audited the instability of unweighted top-k tail ranking; original primary results were not changed.',
|
||||
'Four old validation and four previously unused fresh texts were evaluated with frozen extra gates and no candidate fallback.',
|
||||
f'- Addendum fresh function pass: {cond.get("fresh_function_pass")}.',
|
||||
f'- Overall addendum state: {cond.get("state")}; primary unchanged/negative: {cond.get("primary_protocol_unchanged_and_negative")}.',
|
||||
'Fresh probability-mass and fixed V/gate/O readout measurements show conditional behavioral overlap; strict fresh mean-JS, row-JS-P95 and row-TV-P95 limits still failed.',
|
||||
'No full-network substitution was run after that failure. V similarity, bidirectionality and complete QKV-head equivalence are not established.',
|
||||
'The actual-H3 cache probability is a separate different-input diagnostic, not the same-input function comparison.']
|
||||
text+=['','## Limits and retention','',
|
||||
'This is a short text-only pilot, not proof of absence of repetition elsewhere. Exact arithmetic, matrix coordinates, retrieval behavior and final residual output are distinct questions.',
|
||||
'Centered value Gram CKA can be high even for independent Gaussian projections of common inputs; it is not substitution evidence.',
|
||||
'All weights and large profile caches remain on the authorized server. Git delivery includes all plot tables, probabilities, protocols and cache location/hash metadata.',
|
||||
'No GPU, new checkpoint download, model training, continuous R fitting or automatic weight/cache deletion.']
|
||||
(root/'REPORT.md').write_text('\n'.join(text)+'\n')
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,279 @@
|
||||
"""Bounded 15-pair CPU study, calibration selection before any heldout feedback."""
|
||||
import argparse
|
||||
from collections import defaultdict
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import resource
|
||||
import time
|
||||
import traceback
|
||||
import numpy as np
|
||||
from functional.run import save_csv,write_json
|
||||
from .core import (QKVModel,InterventionLM,assignment,inverse,output_metrics,
|
||||
cross_head_output_metrics,distribution_metrics,value_gram_cka)
|
||||
from .protocol import LAYERS,PAIRS,PROTOCOL,TIERS
|
||||
|
||||
PRIMARY=slice(7,None)
|
||||
TYPE_ORDER={'full_attention':0,'qkv_head':1,'qk_map':2,'qk_head':3,'v_group':4}
|
||||
|
||||
|
||||
def candidate_id(kind,i,j,a=None,b=None,suffix=''):
|
||||
return f'{kind}_{i}_{j}'+(f'_{a}_{b}' if a is not None else '')+suffix
|
||||
|
||||
|
||||
def rows_for(metrics,samples,meta):
|
||||
rows=[]
|
||||
for n,s in enumerate(samples):
|
||||
r={**meta,'sample':s['id']}
|
||||
for key,value in metrics.items():
|
||||
v=value[n]
|
||||
r[key]=None if v is None else float(v)
|
||||
rows.append(r)
|
||||
return rows
|
||||
|
||||
|
||||
def outrows(a,b,samples,meta,floor_a=1e-6,floor_b=1e-6):
|
||||
m=output_metrics(a[:,PRIMARY],b[:,PRIMARY]);rows=rows_for(m,samples,meta)
|
||||
for n,r in enumerate(rows):r['active']=bool(m['rms_a'][n]>=np.broadcast_to(floor_a,m['rms_a'].shape)[n] and m['rms_b'][n]>=np.broadcast_to(floor_b,m['rms_b'].shape)[n])
|
||||
return rows
|
||||
|
||||
|
||||
def head_floor(profile):
|
||||
rms=np.sqrt(np.mean(profile['heads'][:,7:].astype(np.float64)**2,axis=(1,3)))
|
||||
return np.maximum(1e-6,.1*np.median(rms,axis=1))
|
||||
|
||||
|
||||
def candidate_pass(c,tier):
|
||||
t=TIERS[tier];out=c.get('output_rows',[])
|
||||
if not out or not all(r['active'] and max(r['error_a'],r['error_b'])<=t['output_error'] and r['cosine']>=t['output_cosine'] for r in out):return False
|
||||
if c['kind'] in ('qk_head','qk_map'):
|
||||
p=c.get('probability_rows',[])
|
||||
if not p or not all(r['js']<=t['js'] and r['js_p95']<=t['js_p95'] and r['top5']>=t['top5'] for r in p):return False
|
||||
if c['kind']=='v_group':
|
||||
v=c.get('value_rows',[])
|
||||
if not v or not all(max(r['error_a'],r['error_b'])<=t['value_error'] and r['cosine']>=t['value_cosine'] and r['active'] for r in v):return False
|
||||
return True
|
||||
|
||||
|
||||
def preliminary_probability(c):
|
||||
t=TIERS['approximate'];r=c['probability_rows']
|
||||
return bool(r) and all(x['js']<=t['js'] and x['js_p95']<=t['js_p95'] and x['top5']>=t['top5'] for x in r)
|
||||
|
||||
|
||||
def preliminary_value(c):
|
||||
t=TIERS['approximate'];r=c['value_rows']
|
||||
return bool(r) and all(x['active'] and max(x['error_a'],x['error_b'])<=t['value_error'] and x['cosine']>=t['value_cosine'] for x in r)
|
||||
|
||||
|
||||
def load_profile(root,source,layer):
|
||||
with np.load(root/'cache'/f'calibration-source-{source}.npz') as data:
|
||||
prefix=f'layer{layer}_'
|
||||
return {key[len(prefix):]:data[key] for key in data.files if key.startswith(prefix)}
|
||||
|
||||
|
||||
def map_profile_values(p):return {k:v for k,v in p.items()}
|
||||
|
||||
|
||||
def new_bank():return {}
|
||||
|
||||
|
||||
def get_candidate(bank,kind,i,j,a=None,b=None,suffix='',perm=None):
|
||||
name=candidate_id(kind,i,j,a,b,suffix)
|
||||
if name not in bank:
|
||||
bank[name]={'id':name,'kind':kind,'i':i,'j':j,'a':a,'b':b,'perm':perm,
|
||||
'output_rows':[],'probability_rows':[],'value_rows':[]}
|
||||
return bank[name]
|
||||
|
||||
|
||||
def add_output(c,a,b,samples,source,target=None,floor_a=1e-6,floor_b=1e-6):
|
||||
c['output_rows'].extend(outrows(a,b,samples,{'candidate':c['id'],'source_input_layer':source,'target':target},floor_a,floor_b))
|
||||
|
||||
|
||||
def observe_pair(lm,bank,pi,pj,i,j,source,samples,diagnostics):
|
||||
fi,fj=head_floor(pi),head_floor(pj)
|
||||
whole=get_candidate(bank,'full_attention',i,j)
|
||||
add_output(whole,pi['output'],pj['output'],samples,source)
|
||||
hm=cross_head_output_metrics(pi['heads'][:,7:],pj['heads'][:,7:])
|
||||
qm=cross_head_output_metrics(pi['q'][:,7:],pj['q'][:,7:])
|
||||
repeats=lm.config['num_attention_heads']//lm.config['num_key_value_heads']
|
||||
ki,kj=np.repeat(pi['k'],repeats,axis=2),np.repeat(pj['k'],repeats,axis=2)
|
||||
km=cross_head_output_metrics(ki[:,7:],kj[:,7:])
|
||||
for a in range(pi['p'].shape[1]):
|
||||
for b in range(pj['p'].shape[1]):
|
||||
qk=get_candidate(bank,'qk_head',i,j,a,b);qkv=get_candidate(bank,'qkv_head',i,j,a,b)
|
||||
pm=distribution_metrics(pi['p'][:,a:a+1],pj['p'][:,b:b+1])
|
||||
rr=rows_for(pm,samples,{'candidate':qk['id'],'source_input_layer':source})
|
||||
qk['probability_rows'].extend(rr);qkv['probability_rows'].extend(rr)
|
||||
for n,s in enumerate(samples):
|
||||
rec={'candidate':qkv['id'],'source_input_layer':source,'sample':s['id'],**{key:float(v[n,a,b]) for key,v in hm.items()}}
|
||||
rec['active']=bool(rec['rms_a']>=fi[n] and rec['rms_b']>=fj[n]);qkv['output_rows'].append(rec)
|
||||
diagnostics.append({'i':i,'j':j,'head_i':a,'head_j':b,'source_input_layer':source,'sample':s['id'],
|
||||
'q_error':float(max(qm['error_a'][n,a,b],qm['error_b'][n,a,b])),
|
||||
'q_cosine':float(qm['cosine'][n,a,b]),'k_error':float(max(km['error_a'][n,a,b],km['error_b'][n,a,b])),
|
||||
'k_cosine':float(km['cosine'][n,a,b]),'qkv_head_output_error':max(rec['error_a'],rec['error_b'])})
|
||||
vm=cross_head_output_metrics(pi['v'][:,7:],pj['v'][:,7:])
|
||||
vfi=np.maximum(1e-6,.1*np.median(np.sqrt(np.mean(pi['v'][:,7:].astype(np.float64)**2,axis=(1,3))),axis=1))
|
||||
vfj=np.maximum(1e-6,.1*np.median(np.sqrt(np.mean(pj['v'][:,7:].astype(np.float64)**2,axis=(1,3))),axis=1))
|
||||
for a in range(pi['v'].shape[2]):
|
||||
for b in range(pj['v'].shape[2]):
|
||||
c=get_candidate(bank,'v_group',i,j,a,b)
|
||||
gram=value_gram_cka(pi['v'][:,7:,a],pj['v'][:,7:,b])
|
||||
for n,s in enumerate(samples):
|
||||
rec={'candidate':c['id'],'source_input_layer':source,'sample':s['id'],**{key:float(v[n,a,b]) for key,v in vm.items()},'centered_value_gram_cka':float(gram[n])}
|
||||
rec['active']=bool(rec['rms_a']>=vfi[n] and rec['rms_b']>=vfj[n]);c['value_rows'].append(rec)
|
||||
|
||||
|
||||
def probe_candidate(lm,c,pi,pj,source,samples):
|
||||
i,j=c['i'],c['j'];kind=c['kind'];fi,fj=head_floor(pi),head_floor(pj)
|
||||
if kind=='qk_map':
|
||||
perm=c['perm'];p=distribution_metrics(pi['p'],pj['p'][:,perm])
|
||||
c['probability_rows'].extend(rows_for(p,samples,{'candidate':c['id'],'source_input_layer':source}))
|
||||
changed_i=lm.transplant(pi,pj,i,kind,perm=perm)
|
||||
changed_j=lm.transplant(pj,pi,j,kind,perm=inverse(perm))
|
||||
add_output(c,pi['output'],changed_i,samples,source,i)
|
||||
add_output(c,pj['output'],changed_j,samples,source,j)
|
||||
elif kind=='qk_head':
|
||||
a,b=c['a'],c['b']
|
||||
changed_i=lm.head_transplant_output(pi,pj,i,a,b)
|
||||
changed_j=lm.head_transplant_output(pj,pi,j,b,a)
|
||||
add_output(c,pi['heads'][:,:,a],changed_i,samples,source,i,fi,fi)
|
||||
add_output(c,pj['heads'][:,:,b],changed_j,samples,source,j,fj,fj)
|
||||
elif kind=='v_group':
|
||||
a,b=c['a'],c['b'];rep=lm.config['num_attention_heads']//lm.config['num_key_value_heads']
|
||||
own_i=pi['heads'][:,:,a*rep:(a+1)*rep].sum(2);own_j=pj['heads'][:,:,b*rep:(b+1)*rep].sum(2)
|
||||
changed_i=lm.value_group_output(pi,pj,i,a,b);changed_j=lm.value_group_output(pj,pi,j,b,a)
|
||||
add_output(c,own_i,changed_i,samples,source,i,fi,fi);add_output(c,own_j,changed_j,samples,source,j,fj,fj)
|
||||
else:raise ValueError(kind)
|
||||
|
||||
|
||||
def summarize(c):
|
||||
out=c['output_rows'];p=c['probability_rows'];v=c['value_rows']
|
||||
m={'id':c['id'],'kind':c['kind'],'i':c['i'],'j':c['j'],'a':c['a'],'b':c['b'],'perm':c['perm'],
|
||||
'output_verified':bool(out),'output_observations':len(out),'probability_observations':len(p),'value_observations':len(v),
|
||||
'strict_pass':candidate_pass(c,'strict'),'approximate_pass':candidate_pass(c,'approximate')}
|
||||
m['worst_output_error']=max((max(r['error_a'],r['error_b']) for r in out),default=None)
|
||||
m['minimum_output_cosine']=min((r['cosine'] for r in out),default=None)
|
||||
m['worst_mean_js']=max((r['js'] for r in p),default=None)
|
||||
m['minimum_top5']=min((r['top5'] for r in p),default=None)
|
||||
m['worst_value_error']=max((max(r['error_a'],r['error_b']) for r in v),default=None)
|
||||
return m
|
||||
|
||||
|
||||
def controls_for_profiles(profiles,source,samples,rows,h):
|
||||
rng=np.random.default_rng(20261109+source)
|
||||
ra=(h@rng.standard_normal((h.shape[-1],256),dtype=np.float32))/np.float32(np.sqrt(h.shape[-1]))
|
||||
rb=(h@rng.standard_normal((h.shape[-1],256),dtype=np.float32))/np.float32(np.sqrt(h.shape[-1]))
|
||||
random_cka=value_gram_cka(ra[:,7:],rb[:,7:])
|
||||
for n,s in enumerate(samples):rows.append({'control':'value_gram_random_projection_pair','source_input_layer':source,'sample':s['id'],'gram_cka':float(random_cka[n])})
|
||||
for layer,p in profiles.items():
|
||||
for kv in range(p['v'].shape[2]):
|
||||
for label,other in [('value_gram_to_input',h),('value_gram_to_random_projection',ra)]:
|
||||
vcka=value_gram_cka(p['v'][:,7:,kv],other[:,7:])
|
||||
for n,s in enumerate(samples):rows.append({'control':label,'source_input_layer':source,'projection_layer':layer,'kv_head':kv,'sample':s['id'],'gram_cka':float(vcka[n])})
|
||||
probs=p['p'];uniform=np.zeros_like(probs);shuffled=probs.copy()
|
||||
for t in range(probs.shape[-1]):
|
||||
uniform[:,:,t,:t+1]=1/(t+1)
|
||||
for bi in range(probs.shape[0]):
|
||||
for head in range(probs.shape[1]):shuffled[bi,head,t,:t+1]=probs[bi,head,t,rng.permutation(t+1)]
|
||||
for name,other in [('identity',probs),('uniform_causal',uniform),('shuffled_legal_keys',shuffled)]:
|
||||
for head in range(probs.shape[1]):
|
||||
m=distribution_metrics(probs[:,head:head+1],other[:,head:head+1])
|
||||
rows.extend(rows_for(m,samples,{'control':name,'source_input_layer':source,'projection_layer':layer,'head':head}))
|
||||
|
||||
|
||||
def validate_selected(lm,selected,inputs,samples,indices):
|
||||
i,j=selected['i'],selected['j'];c={k:v for k,v in selected.items() if k not in ('output_rows','probability_rows','value_rows')}
|
||||
c.update(output_rows=[],probability_rows=[],value_rows=[])
|
||||
for source in (i,j):
|
||||
h=inputs[f'attn_{source}'][indices];pi,pj=lm.parts(h,i),lm.parts(h,j)
|
||||
temporary={};diag=[];observe_pair(lm,temporary,pi,pj,i,j,source,samples,diag)
|
||||
if c['kind'] in ('full_attention','qkv_head','qk_head','v_group'):
|
||||
original=temporary[candidate_id(c['kind'],i,j,c['a'],c['b'])]
|
||||
c['probability_rows'].extend(original['probability_rows']);c['value_rows'].extend(original['value_rows'])
|
||||
if c['kind'] in ('full_attention','qkv_head'):c['output_rows'].extend(original['output_rows'])
|
||||
if c['kind'] in ('qk_map','qk_head','v_group'):probe_candidate(lm,c,pi,pj,source,samples)
|
||||
return c
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--source',required=True,type=Path);p.add_argument('--root',required=True,type=Path);p.add_argument('--seconds',type=int,default=7200)
|
||||
args=p.parse_args();source=args.source.resolve();root=args.root.resolve();root.mkdir(parents=True,exist_ok=True);(root/'cache').mkdir(exist_ok=True)
|
||||
assert not (root/'protocol.json').exists(),'Fresh experiment directory required; do not overwrite evidence'
|
||||
protocol={**PROTOCOL,'registered_unix':time.time(),'source_run':str(source),'seconds':args.seconds,
|
||||
'fresh_sample_sha256':hashlib.sha256(Path(__file__).with_name('fresh_samples.json').read_bytes()).hexdigest()}
|
||||
write_json(root/'protocol.json',protocol)
|
||||
write_json(root/'retention-policy.json',{'automatic_cleanup':False,'weights_and_caches':'retain_until_explicit_user_deletion'})
|
||||
start=time.monotonic();status={'state':'running','phase':'calibration_profiles','started_unix':time.time()}
|
||||
bank={};diagnostics=[];controls=[]
|
||||
try:
|
||||
manifest=json.loads((source/'manifest.json').read_text());assert manifest['revision']=='15852e8c16360a2fea060d615a32b45270f8a8fc'
|
||||
reference=json.loads((source/'reference-check.json').read_text());assert reference['passed']
|
||||
assert reference['implementation_sha256']==hashlib.sha256(Path('functional/model.py').read_bytes()).hexdigest()
|
||||
config=json.loads((source/'model_config.json').read_text());lm=InterventionLM(source/'weights',config,seconds=args.seconds-180)
|
||||
assert [i for i,t in enumerate(lm.config['layer_types']) if t=='full_attention']==LAYERS
|
||||
samples=json.loads((source/'samples-tokenized.json').read_text())['samples'];cal=[s for s in samples if s['split']=='calibration'];valid=[s for s in samples if s['split']=='heldout']
|
||||
ci=np.array([i for i,s in enumerate(samples) if s['split']=='calibration']);vi=np.array([i for i,s in enumerate(samples) if s['split']=='heldout'])
|
||||
write_json(root/'source-samples.json',{'samples':samples,'note':'old validation samples used in earlier studies; fresh test separately fixed'})
|
||||
inputs=np.load(source/'baseline-activations.npz')
|
||||
write_json(root/'source-provenance.json',{'revision':manifest['revision'],'weights_manifest':str(source/'manifest.json'),
|
||||
'baseline_activation_sha256':hashlib.sha256((source/'baseline-activations.npz').read_bytes()).hexdigest(),
|
||||
'source_hashes':{str(f):hashlib.sha256(f.read_bytes()).hexdigest() for f in sorted(Path('crossqkv').glob('*')) if f.is_file()}})
|
||||
for src in LAYERS:
|
||||
lm.guard();h=inputs[f'attn_{src}'][ci];profiles={layer:lm.parts(h,layer) for layer in LAYERS}
|
||||
np.savez(root/'cache'/f'calibration-source-{src}.npz',**{f'layer{layer}_{key}':value for layer,profile in profiles.items() for key,value in profile.items()})
|
||||
controls_for_profiles(profiles,src,cal,controls,h)
|
||||
for i,j in PAIRS:
|
||||
if src in (i,j):observe_pair(lm,bank,profiles[i],profiles[j],i,j,src,cal,diagnostics)
|
||||
del profiles
|
||||
status.update(last_source_layer=src,elapsed_seconds=time.monotonic()-start);write_json(root/'status.json',status)
|
||||
save_csv(root/'raw-qk-diagnostics.csv',diagnostics);save_csv(root/'controls.csv',controls)
|
||||
print(json.dumps(status),flush=True)
|
||||
status['phase']='discrete_head_matching_and_output_probes';write_json(root/'status.json',status)
|
||||
mapping_rows=[]
|
||||
qk_pre=[c for c in bank.values() if c['kind']=='qk_head' and preliminary_probability(c)]
|
||||
qk_probe=sorted(qk_pre,key=lambda c:(max(r['js'] for r in c['probability_rows']),c['id']))[:32]
|
||||
v_pre=[c for c in bank.values() if c['kind']=='v_group' and preliminary_value(c)]
|
||||
v_probe=sorted(v_pre,key=lambda c:(max(max(r['error_a'],r['error_b']) for r in c['value_rows']),c['id']))[:16]
|
||||
for i,j in PAIRS:
|
||||
cost=np.empty((8,8),dtype=np.float64)
|
||||
for a in range(8):
|
||||
for b in range(8):cost[a,b]=np.mean([r['js'] for r in bank[candidate_id('qk_head',i,j,a,b)]['probability_rows']])
|
||||
perm=assignment(cost)
|
||||
for a in range(8):
|
||||
for b in range(8):mapping_rows.append({'i':i,'j':j,'head_i':a,'head_j':b,'calibration_mean_js':float(cost[a,b]),'chosen':perm[a]==b})
|
||||
maps=[get_candidate(bank,'qk_map',i,j,suffix='_identity',perm=list(range(8))),get_candidate(bank,'qk_map',i,j,suffix='_matched',perm=perm)]
|
||||
for src in (i,j):
|
||||
pi,pj=load_profile(root,src,i),load_profile(root,src,j)
|
||||
for c in [*maps,*[c for c in qk_probe+v_probe if c['i']==i and c['j']==j]]:
|
||||
lm.guard();probe_candidate(lm,c,pi,pj,src,cal)
|
||||
status.update(last_pair=[i,j],elapsed_seconds=time.monotonic()-start);write_json(root/'status.json',status)
|
||||
save_csv(root/'head-assignment-costs.csv',mapping_rows)
|
||||
summaries=[summarize(c) for c in bank.values()];write_json(root/'calibration-summary.json',summaries)
|
||||
save_csv(root/'calibration-output-metrics.csv',[r for c in bank.values() for r in c['output_rows']])
|
||||
save_csv(root/'calibration-probability-metrics.csv',[r for c in bank.values() if c['kind']!='qkv_head' for r in c['probability_rows']])
|
||||
save_csv(root/'calibration-value-metrics.csv',[r for c in bank.values() for r in c['value_rows']])
|
||||
eligible=[c for c in summaries if c['strict_pass'] or c['approximate_pass']]
|
||||
eligible.sort(key=lambda c:(not c['strict_pass'],TYPE_ORDER[c['kind']],c['worst_output_error'],c['worst_mean_js'] or 0,c['id']))
|
||||
selected=eligible[:1]
|
||||
write_json(root/'selection.json',{'selected':selected,'qk_head_prequalified':len(qk_pre),'qk_head_output_verified':len(qk_probe),
|
||||
'v_group_prequalified':len(v_pre),'v_group_output_verified':len(v_probe),'selection_uses_validation':False})
|
||||
status['selected']=selected
|
||||
if selected:
|
||||
c=selected[0];status['phase']='old_validation';write_json(root/'status.json',status)
|
||||
checked=validate_selected(lm,c,inputs,valid,vi);tier='strict' if c['strict_pass'] else 'approximate'
|
||||
write_json(root/'validation-summary.json',summarize(checked));save_csv(root/'validation-output-metrics.csv',checked['output_rows']);save_csv(root/'validation-probability-metrics.csv',checked['probability_rows']);save_csv(root/'validation-value-metrics.csv',checked['value_rows'])
|
||||
passed=candidate_pass(checked,tier);status['validation_pass']=passed
|
||||
if passed:
|
||||
from .fresh import run_fresh
|
||||
run_fresh(source,root,c,tier,lm,status)
|
||||
status.update(state='completed',phase='done',elapsed_seconds=time.monotonic()-start,peak_rss_kib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss,
|
||||
candidate_counts={kind:sum(c['kind']==kind for c in summaries) for kind in TYPE_ORDER},
|
||||
passing_counts={kind:sum(c['kind']==kind and c['approximate_pass'] for c in summaries) for kind in TYPE_ORDER},
|
||||
original_11_and_norm_positive_not_used_as_qkv_evidence=True)
|
||||
except Exception as exc:
|
||||
status.update(state='stopped',error_type=type(exc).__name__,error=str(exc),elapsed_seconds=time.monotonic()-start,peak_rss_kib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
|
||||
(root/'error.txt').write_text(traceback.format_exc());raise
|
||||
finally:write_json(root/'status.json',status)
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,75 @@
|
||||
# CPU 先导:先找值得继续验证的信号
|
||||
|
||||
更新:2026-11-09。目的不是在 CPU 上完成广泛能力及高吞吐评测,
|
||||
而是低成本判断实际输入分布上是否存在值得 GPU 进一步验证的复用候选。
|
||||
全程不训练,不求 R。
|
||||
|
||||
## 已执行的容量检查
|
||||
|
||||
服务器 8.211.154.134:2 核 x86_64,约 1.7 GiB RAM;检查时可用约 892 MiB,
|
||||
swap 已用约 2.2 GiB,根盘可用约 73 GiB。共享主机快照不是实验独占资源。
|
||||
NumPy 2.5.4,OPENBLAS_NUM_THREADS=1、OMP_NUM_THREADS=1,远程 timeout 60 秒。
|
||||
随机种子 42、float32、X 为 32×2048;每种 W 随机生成后连续执行 4 次 X@W,
|
||||
第 1 次作为冷调用,其余 3 次单独报告。随机输入仅用于容量测量。
|
||||
|
||||
| W 形状 | W 大小 | 首次乘法 | 后续三次乘法(秒) |
|
||||
|---|---|---|---|
|
||||
| 2048×2048 | 16 MiB | 0.027816 | 0.027035、0.027207、0.025878 |
|
||||
| 2048×6144 | 48 MiB | 0.086039 | 0.082543、0.110806、0.075336 |
|
||||
|
||||
输出均为有限数,进程峰值 RSS 88,220 KiB(约 86.2 MiB)。
|
||||
耗时只包含矩阵乘法,不包含权重生成、磁盘读取、BF16 转换、模型其余操作及框架开销。
|
||||
它支持继续评估小批量 CPU 投影计算,不足以外推完整模型时延或宣称发现可复用性。
|
||||
没有模型权重参与,没有编译、下载或模型前向。
|
||||
|
||||
## 执行路线与证据等级
|
||||
|
||||
1. **实现与资源可行性**:核对固定 revision 的位置编码、归一化、GQA 和门控,
|
||||
使用受信任的算子实现及小数组正确性检查;模型仓库代码不直接执行。
|
||||
先确认首个短样本能以受控内存运行。不用不正确的“简化 Qwen”产生看似有价值的结果。
|
||||
2. **真实分布上的候选**:batch=1、32 tokens,校准和留出各 4 段真实文本。
|
||||
按顺序加载、计算、释放每层,保留很小的入口激活;探测预先固定的 3 个 full-attention 层对、2 个 MLP 对,以及 6 个 full-attention 层内的 Q/K 归一化模块对,共 11 对。
|
||||
每对在两个来源层的隐藏输入上分别测试,记录 JS、top-k、完整分支输出误差。
|
||||
3. **最小干预证据**:最多对 1 个候选做单处替换;冻结参数,在留出文本上看输出变化,
|
||||
条件允许时流式计算 token NLL。词表输出头分块归约 logsumexp,避免一次物化大 logits。
|
||||
若没有正确且可承受的干预实现,就止于“候选”,不称为验证成功。
|
||||
4. **GPU 细化**:候选通过才扩展长度、样本、线性注意力、多处共享及质量—成本曲线。
|
||||
|
||||
先导主证据来自真实文本产生的隐藏状态,而不是高维空间上的均匀随机向量。
|
||||
直接按真实样本出现频率聚合,就能近似按目标使用分布加权,不先引入昂贵的高维密度估计。
|
||||
保留逐文本及尾部误差,少量低频但关键用例不被平均值掩盖。
|
||||
|
||||
## CPU 内存与停止约束
|
||||
|
||||
- 不同时加载完整模型的 BF16/FP32 副本;模型原始权重约 4.55 GB,大于当前 RAM。
|
||||
- 单层/子矩阵流式读取,及时解除映射或释放页面;先设本进程 RSS 512 MiB 软停止线,
|
||||
系统可用内存低于 256 MiB 或持续 swap 活动就停止并保存进度,不改全局 swap 配置。
|
||||
软停止线不替代实际峰值检测,分配前须计算临时内存。
|
||||
- 先实现最小正确路径;线性状态递推、长上下文和生成速度不塞入首轮。
|
||||
- 总计算 120 分钟,阶段预算见功能方案;无候选、超时或数值/实现核对失败均停止。
|
||||
- 容量探测已完成,真实模型阶段尚未执行。后续需要恢复本实验自有的固定 revision 权重,
|
||||
权重持续保留,只有用户明确要求删除时才清理;不增加模型规模或自动租用 GPU。
|
||||
|
||||
CPU 上“找到输出接近的候选”能支持继续投入 GPU;
|
||||
“在指定小样本中单处复用保持质量且节省明确资源”才是初步正例。
|
||||
两者都不能替代大规模能力验证。CPU 时延不外推为 GPU 加速率。
|
||||
|
||||
## 当前权重保留规则
|
||||
|
||||
用户于 2026-11-09 明确要求:本轮模型权重保留,只有用户明确要求删除时才删除。
|
||||
试验完成、超时、失败、归档或结果校验均不得自动触发清理。该要求覆盖先前逐模型分析后删除的约定。
|
||||
上一轮已删除的历史记录保留;本轮恢复下载的权重受新规则保护。
|
||||
|
||||
## 本轮执行补充
|
||||
|
||||
实际实验分支为 `codex/cpu-reuse-experiment`。在读取真实权重/功能指标前,新增固定的
|
||||
6 个层内 Q/K RMSNorm 增益共享候选,以检查较小粒度的功能复用;不是看过留出结果后扩充搜索。
|
||||
最多选择一个候选,必须分别验证两个替换方向;完整模块失败不会被小模块通过所掩盖。
|
||||
归一化共享最多节省少量字节,不预设能显著减少计算。
|
||||
采集真实隐藏输入必须正确执行前置线性注意力;它不进入首轮复用候选,但其递推计算纳入官方参考对照。
|
||||
|
||||
## 用户最新目标修订
|
||||
|
||||
不再以成本/加速作为成功条件;主问题是现有学习部分的功能重复。
|
||||
新增一次固定四层的 MLP 神经元函数搜索、独立留出和双向替换,
|
||||
见 [功能重复判据](LEARNED_FUNCTION_REPETITION.md)。解析增益合并单独归类,不冒充学习部分重复。
|
||||
@@ -0,0 +1,86 @@
|
||||
# CPU 先导结论:存在已训练归一化模块的相似功能重复
|
||||
|
||||
本轮主目标按用户最新要求为功能重复的存在性,不以成本/加速为成功条件。
|
||||
全部计算在 2 核、约 1.7 GiB RAM 的 CPU 服务器完成,无训练、缩放拟合或旋转搜索。
|
||||
层编号均为从 0 开始的索引。
|
||||
|
||||
## 一个具体正例
|
||||
|
||||
固定官方 Qwen3.5-2B checkpoint 的两个独立已训练模块:
|
||||
|
||||
- `model.language_model.layers.12.input_layernorm`
|
||||
- `model.language_model.layers.13.input_layernorm`
|
||||
|
||||
二者均为 2048→2048 的 RMSNorm,eps=1e-6,使用训练后的有效增益 gamma=1+weight。
|
||||
增益标准差分别约 0.1901、0.1685,最小值约 0.5547、0.5703;不是零函数或恒定增益。
|
||||
|
||||
| 证据 | 结果 |
|
||||
|---|---|
|
||||
| 全输入域数学界(相对于层12输出) | 输出相对 L2 误差≤10.1852% |
|
||||
| 反方向全输入域数学界(相对于层13输出) | 输出相对 L2 误差≤11.3402% |
|
||||
| 4 条留出文本、两个来源层输入的最坏双向误差 | 4.5285% |
|
||||
| 相同留出比较中的最低余弦 | 0.999487 |
|
||||
| 层12使用层13,留出平均 token NLL 增量 | +0.0000325651 nat/token |
|
||||
| 层13使用层12,留出平均 token NLL 增量 | −0.0003639730 nat/token |
|
||||
|
||||
两方向逐文本 NLL 增量 P95 分别约 0.00098464、0.00070972,均通过原定小样本质量门槛。
|
||||
所有数值来自保存的逐文本、逐 token 原始数据。留出为 4 条不同的实验原创短文本,
|
||||
每条截取 32 tokens;校准另有 4 条。它们不是广泛任务能力评测。
|
||||
|
||||
## 为什么不只是“权重看起来接近”
|
||||
|
||||
对相同 eps 和维数,f_a(x)=diag(a)x/sqrt(mean(x²)+eps)。任意非零实数输入满足:
|
||||
|
||||
||f_a(x)-f_b(x)|| / ||f_a(x)|| ≤ max_j |a_j-b_j|/|a_j|。
|
||||
|
||||
共同归一化分母消去;坐标基向量可达到最大值,因而该界是精确的最坏情况。
|
||||
反向分母换成 |b_j|。本轮先穷举 24 层同角色 input/post-attention norm 的 552 对,
|
||||
仅按最小双向最坏界选定一对,未使用任何输入样本作选择。≤20% 界有 18 对,≤10% 无配对;
|
||||
本轮只验证最优的一对,不根据留出结果换选。
|
||||
|
||||
这个确定性界直接给出两个已训练函数整体接近的证据。真实输入上的误差更小,
|
||||
与只关心目标输入分布的目标一致。浮点实测与实数数学界分别报告。
|
||||
重新采集输入时,未修改的完整前向逐 bit 复现了最初保存的基线输出。
|
||||
输入探测分别使用两个来源层,对相同输入同时应用两套增益,避免比较不同输入的输出。
|
||||
从已加增益的激活还原共同归一化输入时有额外 FP32 舍入,未将其称为 bitwise 等价。
|
||||
|
||||
结论限定为两个已有 RMSNorm 模块实现相似映射;不把共同包含 RMS 操作本身当作证据。
|
||||
二者学习增益不同且非恒定,输出非零。完整 attention/MLP 主体的重复仍未得到正例。
|
||||
|
||||
## 已完成的阴性搜索
|
||||
|
||||
1. 原定 3 对完整 attention、2 对完整 MLP、6 对层内 Q/K norm 均未通过预设门槛。
|
||||
attention 检索分布 JS 范围约 0.145~0.318,也未通过 0.01 的门槛;
|
||||
未进行头排列、连续坐标变换或训练对齐,不能外推为不存在其他可复用表示。
|
||||
2. 在层 5、6、20、21 各 6144 个 MLP scalar 子函数中,排除低活跃和近常量单元后,
|
||||
共精确筛查 7,450,139 个唯一同层配对。要求双向相对误差≤20%、余弦≥0.98、
|
||||
Pearson≥0.95,无通过者。没有针对留出集不断更换候选或放宽门槛。
|
||||
3. 这些结果只覆盖声明的模块、输入和阈值,不否定其他粒度/角色的功能重复。
|
||||
|
||||
## 单独归类的解析恒等式
|
||||
|
||||
Q/K 未参与 RoPE 的 192 个维度,其增益只以乘积影响点积,可合并到任一侧。
|
||||
96 组真实输入检查最大分数差 3.8147e-6、最大概率差 8.0466e-7;固定第3层两个方向
|
||||
留出 NLL 变化接近 FP32 舍入。详见 [推导](QK_GAIN_FACTORIZATION.md)。
|
||||
这是重参数化等价,不作为“两个已有学习部分功能重复”的正例。先前性能测试原始数据
|
||||
保留用于溯源,成本不属于当前结论的成功条件。
|
||||
|
||||
## 正确性、资源与保留规则
|
||||
|
||||
- 固定模型 revision:15852e8c16360a2fea060d615a32b45270f8a8fc,原始权重 SHA256 校验通过。
|
||||
- 流式读取原始 BF16,逐块转为 FP32,不同时载入全模型。
|
||||
- 与固定 Transformers 官方定义比较的 22 项检查通过,最大差约 5.4e-7。
|
||||
- 保留早期参考适配器错误、临时分区空间不足及两次过于保守的换页停止记录。
|
||||
只归还自身临时堆页,未改变系统 swap 设置;后续有界前向完成。
|
||||
- 计算预算跨重启累计,初始保守计入 180 秒先前检查预留;具体时长及峰值见归档日志。
|
||||
- 当前权重按用户最新指令持续保留,只在用户明确要求删除时清理。
|
||||
|
||||
原始表、样本/token IDs、激活、NLL、证明界与图表见 `results/cpu-qwen35-2b/`。
|
||||
后续 GPU 阶段可增加长度、语言和任务来验证正例的稳健性;本轮不自动启动新模型或扩展搜索。
|
||||
|
||||
## Git 交付与保留缓存
|
||||
|
||||
全部图表源 CSV/JSON、逐 token NLL、证明界和日志已交付。三份较大的中间激活缓存
|
||||
保留在原服务器及本地完整归档,路径、大小、SHA256 见结果目录的 external-activation-cache.json。
|
||||
其完整原实验校验表为 checksums-full-server.json;Git交付包校验表为 checksums-functional.json。
|
||||
没有删除模型或缓存;这些缓存可由固定代码和样本重新生成,也可从服务器按哈希取回。
|
||||
@@ -0,0 +1,90 @@
|
||||
# 跨层 QKV:主检验阴性,发现条件性的自 token 检索重合
|
||||
|
||||
全部在 CPU 上运行,冻结 Qwen3.5-2B 权重,无训练、连续 R 拟合或缩放拟合。
|
||||
层索引从0开始。成本不作为判据;归一化相似不作为本轮 QKV 正例。
|
||||
|
||||
## 结论分级
|
||||
|
||||
**主协议没有候选通过全部门槛。** 覆盖六个 full-attention 层的全部15个跨层配对,
|
||||
同时测试两个来源层的真实输入,不能将该结论扩大为模型不存在任何功能重复。
|
||||
|
||||
**探索性补充有一条具体行为观察,但严格新测试仍未全部通过:**
|
||||
把层23的同一隐藏输入 H23 分别交给层3头7、层23头6的 QK 检索函数,
|
||||
它们主要都读取当前 token;在4条新文本上,query位置7~31的 argmax 完全相同。
|
||||
这不是同层 Q/K/V 互换,不是两个完整 attention 头等价,也没有证明 V 相似。
|
||||
|
||||
| 新文本证据(逐文本平均或最坏值) | 结果 |
|
||||
|---|---:|
|
||||
| 层23头6分配给当前token的平均概率,四文本最小值 | 95.71% |
|
||||
| 层3头7在同一H23上分配给当前token的平均概率,最小值 | 92.07% |
|
||||
| 两者最高概率key一致率 | 100% |
|
||||
| 两套top5交集覆盖各自概率质量的最小值 | 97.97% |
|
||||
| 分布总变差的最大文本平均值 | 6.96% |
|
||||
| 保留层23 V/gate/O后的最坏双向头读出相对误差 | 3.82% |
|
||||
| 最坏文本平均JS | 0.018921 |
|
||||
|
||||
新英文文本 fresh-en-2 超过补充协议的三条严格线:平均 JS 0.018921>0.01、
|
||||
行 JS P95 0.072943>0.05、行总变差 P95 0.238731>0.20。
|
||||
因此补充试验的 `fresh_function_pass=false`,**没有重标为完全通过,也未运行替换后的全LM NLL**。
|
||||
已计算新文本原模型基线,不能把该基线文件当作替换实验结果。
|
||||
可支持的观察是特定输入条件下的主要检索行为和实际读出接近;严格可互换尚未确认。
|
||||
|
||||
## 主协议实际覆盖
|
||||
|
||||
| 对象 | 初筛/直接比较数量 | 后续输出核验 |
|
||||
|---|---:|---|
|
||||
| 完整 attention 分支 | 15 | 全部测量 |
|
||||
| QKV+gate/O 的完整头函数 | 960 | 全部测量,输出在共同residual坐标中 |
|
||||
| 全8头P图映射(原序/冻结匹配) | 30 | 全部保留接收层V/gate/O做替换读出 |
|
||||
| 单头联合QK检索 | 960 | 无候选通过初筛,主协议未进入单头读出 |
|
||||
| 跨层KV组的直接V函数 | 60 | 无候选通过原始V初筛,未进入V组替换 |
|
||||
|
||||
主协议最接近的若干项,指标来自不同候选,不能拼接成同一个正例:
|
||||
|
||||
- QK两来源检索:层7头0↔层11头6,最坏文本平均JS约0.08609,最低top5约70.4%。
|
||||
- 完整头输出:同一对头的最坏方向相对误差约134.4%。检索接近不意味着V/O组成的输出接近。
|
||||
- 直接V函数:层7 KV头0↔层11 KV头1,最坏方向误差约150.3%。
|
||||
- 完整分支:层7↔层11的最坏方向误差约185.3%。
|
||||
- 保留目标V/O的完整P图映射:最小最坏输出误差约70.3%(层15↔19、冻结头匹配)。
|
||||
|
||||
V token-Gram CKA另与输入Gram和两个独立高斯投影比较。共同输入几何可以造成高Gram相似,
|
||||
不能据此宣布V可替换;完整头输出检验已经包含各自的O/gate,避免仅因内部坐标差异就漏掉输出等价。
|
||||
|
||||
## 为什么增加单独的条件性审计
|
||||
|
||||
主协议要求两个来源层的输入分布均通过,并把无权重top5重合率作为硬门槛。
|
||||
复核全部已保存的单来源指标后,固定了唯一一对:层3头7与层23头6,条件为H23。
|
||||
它在校准集的JS很小,却因概率很低的尾部排名不同而top5重合低。
|
||||
|
||||
无权重top-k在近似并列处不连续:可以构造总变差趋近0而top5集合仍不同的例子,
|
||||
本轮已加入独立回归测试。补充协议在观察该候选保留接收端V/O的读出、旧验证或新测试之前固定。
|
||||
它改为单一H23输入条件,将top5作为诊断,并固定概率质量/实际读出/活跃度约束;
|
||||
不换候选、不重新拟合参数。
|
||||
它使用4条原验证文本,再使用本轮事先冻结的4条新文本,保留全部未通过项。
|
||||
这是探索性补充,不改写主协议,不是事后声称原协议成功。
|
||||
|
||||
原主检验的图与条件性图使用不同输入集合:主检验取两个来源分布的最坏情况;
|
||||
条件性图只研究H23。条件性相似不能推广到H3,也不能把早层在H3上已算好的P直接当作P_3(H23)。
|
||||
实际H3缓存与H23接收端的差异另有概率/读出诊断,未做失败后追加的全模型替换。
|
||||
|
||||
## 图表阅读
|
||||
|
||||
- `cross_layer_qk_divergence`:15对层的JS,左为各配对最佳单头,中为原头序,右为冻结双射;
|
||||
颜色越浅分布越近,斜线对角不作经验数据。全部仅为校准结果。
|
||||
- `cross_layer_output_errors`:各类输出误差。QK单头和V组未通过初筛时,不画成零误差,而标未输出核验。
|
||||
- `value_geometry_and_direct_error`:V Gram几何与直接V误差,灰区为随机投影对照,仅诊断。
|
||||
- `conditional_probability_mass_and_readout`:同一条件候选在校准、旧验证和新测试上的top5、质量重合与实际读出差异。
|
||||
- `conditional_cross_layer_probability_maps`:一条新文本的具体P图;层3在H23上的结果与层3在实际H3上的结果分开。
|
||||
|
||||
## 复现、预算与保留
|
||||
|
||||
20项完整远程测试通过。主计算约74.8秒,补充条件试验约105.3秒;峰值进程RSS分别约168/174 MiB。
|
||||
另有出图、审计和测试,仍在两小时预算内。早期对照生成器的变量遮蔽错误及10.3秒失败记录保留,
|
||||
修复后在新目录按相同配对和门槛重跑;没有删除原缓存。
|
||||
|
||||
模型revision 15852e8c16360a2fea060d615a32b45270f8a8fc,与此前官方参考校验的流式CPU实现一致。
|
||||
全部权重和大型profile缓存继续保留;Git只上传代码、全部图表源表、选定的新文本概率矩阵、
|
||||
日志、协议和缓存位置/SHA。没有新模型下载或自动清理。
|
||||
|
||||
后续若继续,应重新预注册“单向输入条件”和概率质量/读出判据,使用新文本及更长上下文;
|
||||
当前结果不能证明跨上下文稳定,也不应把归一化正例或代数重参数化当作QKV主体验证。
|
||||
@@ -0,0 +1,59 @@
|
||||
# 跨层 QKV 功能重复:CPU 预注册方案
|
||||
|
||||
目标:两个不同层中的学习部分是否实现相似检索、内容变换或完整头函数。不以成本为条件。
|
||||
冻结 Qwen3.5-2B 权重;不训练、不拟合连续 R 或缩放,不使用 GPU。权重与缓存持续保留。
|
||||
|
||||
## 配对与数据
|
||||
|
||||
仅研究完整注意力层索引 3/7/11/15/19/23(从0开始)的全部15个跨层配对。
|
||||
18个线性注意力层不套用 softmax 概率指标,不在本轮自动扩大搜索。
|
||||
复用已采集的同一隐藏输入,四条原校准文本选对,四条旧留出文本作验证;
|
||||
后者曾用于其他试验,不称完全未见的最终测试。另固定4条新文本作新测试,32 tokens,中文英文各半。
|
||||
仅对冻结候选通过验证时采集新测试输入,不根据测试结果重选。
|
||||
|
||||
## 拆开回答的问题
|
||||
|
||||
- QK:比较实际 Q/K norm、部分 RoPE 和 GQA 后产生的逐头检索概率,保留接收层 V/gate/O 时替换检索分布。
|
||||
- V:比较跨层两个 KV 头的 V(H);保留接收层 P/gate/O,再替换一个 KV 组,覆盖该组4个Q头。
|
||||
token Gram/CKA仅用于诊断坐标表示问题,不能代替实际输出替换;另与输入Gram、固定seed的两个高斯投影Gram比较,以控制共同输入结构造成的高相似。
|
||||
- 完整头:比较 P V、gate、O 共同形成的每个头在 residual 坐标中的输出函数。
|
||||
它不要求内部 V 坐标一致,能够避免仅比较内部元素漏掉表示差异。
|
||||
- 完整分支:比较全部8个头组成的完整 attention 输出。
|
||||
|
||||
因此原始 Q/K/V 输出相似、QK 检索相似、V 可替换、完整头可替换分别报告,归一化单独相似不作主正例。
|
||||
同一层 Q、K、V 互相比较不进入主实验。
|
||||
|
||||
## 头匹配与位置对照
|
||||
|
||||
15对层各在校准集选择一次最小平均JS的8头双射(精确离散DP,不求连续R)。
|
||||
该排列只用于给接收Q头注入 donor P;接收层V/gate/O保持顺序,不宣称任意GQA权重排列合法。
|
||||
全部960个跨层Q头配对、60个跨层KV头配对和960个完整头函数配对均作初筛。
|
||||
完整P映射考察原顺序及冻结排列,共30项;完整分支共15项。
|
||||
|
||||
主指标只用 query 位置7~31,避免第一行概率必为1、早期合法key过少的平凡相似。
|
||||
记录均匀因果P、固定seed的合法key打乱、去首key后重归一化、首key/self/最近3key质量。
|
||||
首key或局部位置主导的真实重复单独标为位置型,不冒充内容语义重复。
|
||||
|
||||
## 固定门槛与预算
|
||||
|
||||
两档门槛在读取新跨层指标前固定,不依据结果放宽:
|
||||
|
||||
| 档位 | 输出双向相对L2 | 输出余弦 | 每文本平均JS | JS行P95 | top5重合 |
|
||||
|---|---:|---:|---:|---:|---:|
|
||||
| strict | ≤0.05 | ≥0.99 | ≤0.01 | ≤0.05 | ≥0.8 |
|
||||
| approximate | ≤0.20 | ≥0.98 | ≤0.05 | ≤0.15 | ≥0.6 |
|
||||
|
||||
V另需同档原始V直接误差/余弦;QK候选另需同档检索门槛。
|
||||
每个来源层、每条文本、两个替换方向分别检查,输出不含共同 residual 输入。
|
||||
头输出需达到该层头RMS中位数的10%,且绝对RMS≥1e-6,避免近零头制造假正例。
|
||||
|
||||
QK单头最多精确核验32个初筛通过者,V组最多16个;完整P的30个输出均核验。
|
||||
只按校准选定1个最终候选:先strict,再approximate;同档优先完整分支、完整头、完整P、QK单头、V组。
|
||||
之后按最坏输出误差/JS/ID排序。不按验证或新测试结果换选。
|
||||
|
||||
同输入函数验证通过后,做两个方向的真实网络干预,计算新测试token NLL(均值增量≤0.01、
|
||||
逐文本增量P95≤0.05)。另外只做一次时间顺序合法的“早层实际缓存→晚层”复用,单独报告;
|
||||
同输入函数可互换不代表来自不同实际输入的已计算激活可以直接复制。
|
||||
|
||||
CPU总计算限两小时,保留阶段覆盖率和停止原因;没有候选即停止,不自动扩模型、层数或阈值。
|
||||
较大的中间profile缓存在服务器,Git交付全部图表源表、协议、NLL和缓存位置/SHA。
|
||||
@@ -0,0 +1,23 @@
|
||||
# 功能复用文献核对
|
||||
|
||||
核对日期:2026-11-09。以下为原始论文摘要及相关章节核对,不是复现实验。
|
||||
本项目约束:不训练任何参数;已有静态试验没有执行模型前向。下面的方法不自动获得执行授权。
|
||||
|
||||
| 原始来源 | 研究的共享对象 / 证据 | 训练条件与适用限制 | 对本项目的用途 |
|
||||
|---|---|---|---|
|
||||
| [LISA, 2408.01890v2](https://arxiv.org/html/2408.01890v2), §3–5 | 跨层 token 注意力分布;考察头对齐、浅层敏感性;基准能力和吞吐验证 | 学习头对齐网络及低秩差异修正;不能归类为免训练替换。论文的 attention weights 在此主要指注意力分布,不是 W_Q/W_K 权重 | 借鉴逐头比较、首 token 对照和替换敏感性验证;不采用训练模块 |
|
||||
| [CLA, 2405.12981](https://arxiv.org/abs/2405.12981) | 相邻层共享 K/V heads,降低 KV cache;语言模型能力验证 | 摘要明确实验为从头训练 1B/3B 模型;不是现成 Qwen 的直接合并证据 | 区分 KV 缓存收益和参数/计算收益;作为架构可行性依据 |
|
||||
| [Systematic Study, NAACL 2025](https://aclanthology.org/2025.naacl-short.34/) | 系统比较跨层 KV 共享配置;语言建模、下游任务及生成吞吐 | 摘要报告激进配置涉及额外训练及 prefill 代价;不能由摘要推断零训练可迁移性 | 复用方向、共享拓扑及 prefill/decode 成本须分别记录 |
|
||||
| [MiniLM, 2002.10957v2](https://arxiv.org/abs/2002.10957) | 注意力分布及 value-value 关系蒸馏 | 明确训练学生模型;本项目不进行蒸馏 | 提醒检索分布和 value 内容需要分开考察 |
|
||||
| [CKA, ICML 2019](https://proceedings.mlr.press/v97/kornblith19a.html) | 表征之间的关系相似性,不是模块替换实验 | 论文讨论表征比较及可逆变换不变性的局限;高 CKA 不是可替换保证 | 可作为候选诊断,不能取代输出误差、干预和成本评测 |
|
||||
| [ALBERT, 1909.11942v6](https://arxiv.org/html/1909.11942v6), §3.1/4.5 | 跨层参数共享及训练后能力验证 | 共享架构参与训练;不能直接外推为已训练 checkpoint 可无损合并 | 参数存储减少与前向运算减少分别记账 |
|
||||
|
||||
## 对当前试验的推论
|
||||
|
||||
以上文献给出研究动机,没有证明 Qwen3.5-2B 已存在免训练的有效复用组。
|
||||
静态权重试验也没有否定该可能性。应使用同输入功能探测筛选,再对实际计算图实施单处干预。
|
||||
Qwen 的 full attention 与线性注意力需分别定义探测量;不能把 softmax attention 的结论照搬到状态递推模块。
|
||||
|
||||
数学工具参考:[SciPy orthogonal_procrustes](https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.orthogonal_procrustes.html)。
|
||||
纯正交最小二乘有直接的矩阵分解解法,无须枚举旋转矩阵;但求解一个对齐并不自动带来可省略的计算。
|
||||
本项目下一阶段默认不求 R,直接测目标函数和干预效果。
|
||||
@@ -0,0 +1,58 @@
|
||||
# 当前目标:已有学习部分是否重复实现相似函数
|
||||
|
||||
用户于 2026-11-09 明确:不以成本或加速作为成功条件,只关心相似功能重复是否存在。
|
||||
权重继续保留,只有用户明确要求删除才清理;不训练、不拟合旋转或缩放。
|
||||
|
||||
## 什么可以作为正例
|
||||
|
||||
两个不同的已训练部分,在同一真实输入上产生接近、且并非恒定/接近零的输出;
|
||||
独立留出输入仍满足预先固定的门槛。实际双向替换只作补充验证。
|
||||
不能仅因替换一小部分后整模型 NLL 几乎不变,就认定它们实现相同函数。
|
||||
|
||||
Q/K 增益的解析合并证明同一计算的重参数化自由度,不等于两个现成学习部分功能重复。
|
||||
前一轮 11 对完整/归一化模块未通过门槛,也不能否定更小粒度的重复。
|
||||
不将两个模块都包含 SiLU、矩阵乘法等共同运算本身作为重复功能证据。
|
||||
|
||||
## 新增一次有界搜索:MLP 学习神经元
|
||||
|
||||
在已保存的第 5、6、20、21 层真实 MLP 入口输入上,研究
|
||||
|
||||
f_(l,j)(h) = SiLU(w_gate_(l,j)^T h) × (w_up_(l,j)^T h)。
|
||||
|
||||
每层 6,144 个神经元具有不同学习参数。比较同一层内两个 scalar 子函数,
|
||||
不是比较来自不同输入的两个观测值,也不是把整层或整 tensor 称作重复。
|
||||
下游 down-projection 的列保持各自原样;替换发生在两个投影和 SiLU 之后的激活值处。
|
||||
|
||||
1. 4 条校准文本、4 条留出文本,每条 32 tokens,中文/英文各半,沿用先前冻结样本。
|
||||
2. 校准阶段只保留 RMS 至少为该层神经元中位数、std/RMS≥0.25、能量有效 token 数≥16
|
||||
的非平凡单元。能量有效样本数定义为 (sum f²)² / sum f⁴,不是独立统计样本量。
|
||||
3. 对这些单元做分块穷举;实际配对数必须记录。不用随机 hidden 向量作主要证据。
|
||||
4. 预先固定门槛:双向直接相对 L2≤20%、余弦≥0.98、Pearson≥0.95;同时输出 5/10/20%
|
||||
三档校准配对数量。没有拟合线性缩放、偏置或 R。
|
||||
5. 全部层中仅按校准的最小最坏方向误差选择 1 对,冻结选择;无通过者停止。
|
||||
6. 留出集要求同样的汇总函数门槛及活跃度条件,逐文本双向误差≤35%。不根据留出失败换候选。
|
||||
7. 只有函数验证通过,才做两个方向的独立网络替换;留出平均 NLL 增量≤0.01 nat/token,
|
||||
逐文本增量 P95≤0.05。它不是主要的功能重复判据,防止因单元贡献很小而得到假正例。
|
||||
|
||||
本阶段使用先前两小时累计预算的剩余额度,复用现有隐藏输入;不增加模型、样本规模或成本测试。
|
||||
神经元层面的经验正例不证明完整层可以互换、不证明全输入空间等价,也不能推断独立任务能力。
|
||||
留出只有 4 条文本,结论必须限定到此短文本先导分布;后续扩展文本才能检验稳健性。
|
||||
|
||||
## 同角色学习 RMSNorm:确定性函数误差界
|
||||
|
||||
静态试验已经发现部分语言层 post-attention norm 的参数接近。新增一次独立检验:
|
||||
比较 24 层各自的 input/post-attention RMSNorm(同角色内共 552 对),
|
||||
仅按训练后增益的全输入最坏误差界选 1 对,完全不依赖校准或留出输入。
|
||||
增益需非零且不是常量向量(std≥0.001),不把没有学习参数的共同归一化运算当作正例。
|
||||
|
||||
相同 eps、相同形状下,f_a(x)=diag(a)x/sqrt(mean(x²)+eps)。对任意非零 x,
|
||||
|
||||
||f_a(x)-f_b(x)|| / ||f_a(x)|| ≤ max_j |a_j-b_j|/|a_j|。
|
||||
|
||||
反方向分母换为 |b_j|。该上界由相应坐标基向量达到,是实数算术下的精确最坏界。
|
||||
因此可先证明两个现成学习模块的函数整体接近,而不只比较原始参数 w;实际增益为 1+w。
|
||||
选择门槛:最坏双向界≤20%;同时记录≤5%、≤10%、≤20% 配对数量。只选最优界的一对。
|
||||
随后重新采集其实际输入,要求留出逐文本直接双向输出误差≤5%,再测两个方向网络替换。
|
||||
函数接近与替换后网络 NLL 分开报告;后者沿用已有 0.01/0.05 门槛,不决定函数存在性本身。
|
||||
选定后不根据留出结果换配对;不搜索视觉模块、不增加模型、不以成本为条件。
|
||||
归一化层正例不能推广为 attention 或 MLP 主体存在同样重复。
|
||||
@@ -0,0 +1,132 @@
|
||||
# Qwen3.5-2B 有界试验结果
|
||||
|
||||
本轮已完成约定时间预算内的试验。整 tensor 精确比较 2,000 对;子块在内部截止时
|
||||
完成 14,778 / 20,000 对(73.89%),其余 5,222 对未计算。不能把本轮写成全量搜索。
|
||||
|
||||
结论:在本次候选、坐标对齐及误差阈值范围内,没有获得显著的直接权重共享收益。
|
||||
这不等于证明该模型不能通过其他方法压缩,也不代表 MoE 模型具有同样结果。
|
||||
|
||||
## 已确认的试验范围
|
||||
|
||||
- 模型:官方 `Qwen/Qwen3.5-2B`,revision `15852e8c16360a2fea060d615a32b45270f8a8fc`。
|
||||
- 原始 safetensors 文件为 4,548,221,488 字节,已核对官方 LFS SHA256。
|
||||
- 共 632 个存储 tensor;权重数据本身为 4,548,144,832 字节。
|
||||
- 实际存储参数 2,274,069,824 个,包含官方 checkpoint 中的视觉部分。
|
||||
- 维数分布:319 个一维、294 个二维、18 个三维、1 个五维。
|
||||
- 三维权重是 `[6144, 1, 4]` 的卷积核,包含长度为 1 的轴;不能把它解释为一般三维体积。
|
||||
- 五维视觉权重纳入完整清单和全模型字节分母,本轮不扩展五维子块搜索。
|
||||
- 不执行前向计算、能力评测、训练或蒸馏。
|
||||
|
||||
## 整 tensor 的结果
|
||||
|
||||
已完成 2,000 对同角色、同形状候选的精确比较。它们是经过近邻筛选的候选,
|
||||
不是所有可能 tensor 对的穷举。
|
||||
|
||||
| 最大直接替换相对误差 | 非单成员共享组 | 最大组大小 | 净节省字节 | 占模型权重 |
|
||||
|---|---:|---:|---:|---:|
|
||||
| 1% | 0 | 1 | 0 | 0% |
|
||||
| 2% | 0 | 1 | 0 | 0% |
|
||||
| 5% | 1 | 2 | 0 | 0% |
|
||||
| 10% | 11 | 6 | 32,704 | 0.000719% |
|
||||
| 20% | 16 | 15 | 119,424 | 0.002626% |
|
||||
|
||||
20% 阈值下找到的共享组均为一维权重。组数增加不代表显著的字节收益。
|
||||
这里的百分比是权重误差,绝不是任务能力损失百分比。
|
||||
|
||||
净节省按本轮声明的理论布局计算:保留组代表,每个分析对象 16 字节映射,
|
||||
每个共享组 64 字节描述;若大于原存储,则保持原表示。
|
||||
|
||||
这部分结果不支持在本次搜索范围内通过直接共享整 tensor 显著压缩该 checkpoint。
|
||||
它不排除其他未比较组合、子块共享、重参数化或带残差的压缩方法。
|
||||
|
||||
## 子块结果
|
||||
|
||||
共筛选 13,328 个抽样子块。20% 直接替换误差阈值下:
|
||||
|
||||
这里的 tensor 指完整命名权重数组,block 指其局部子张量,不是 Transformer block。
|
||||
三维原始权重为 6144×1×4,本轮切片实际是 1×1×4(4 个数),局部块是
|
||||
4×1×4(16 个数);小块的高余弦不能推广为整份三维权重相似。
|
||||
|
||||
| 表示 | 非单成员共享组 | 最大组 | 映射开销前节省 | 当前布局净节省 |
|
||||
|---|---:|---:|---:|---:|
|
||||
| 64×64 二维块 | 3 | 3 | 40,960 字节 | 0 |
|
||||
| 128×128 二维块 | 1 | 2 | 32,768 字节 | 0 |
|
||||
| 三维 axis-0 切片 | 45 | 12 | 872 字节 | 0 |
|
||||
| 三维局部块 | 2 | 2 | 64 字节 | 0 |
|
||||
|
||||
二维共享候选均来自 `model.visual.pos_embed.weight`,未在已复核候选中形成大规模
|
||||
投影矩阵共享。不同块尺度是替代方案,不能相加。
|
||||
|
||||
净收益为零与声明的映射成本有关,不应解读为完全没有相似子块。更稀疏或更紧凑的
|
||||
索引格式可能降低开销,但本轮找到的二维毛节省也仅为几十 KB,尚不足以支持大幅
|
||||
减容。三维切片组数量较多,但整组三维权重合计只占模型字节的约 0.01945%。
|
||||
|
||||
模型字节占比:一维 0.01972%、二维 99.89167%、三维 0.01945%、五维 0.06917%。
|
||||
因此,应按字节贡献评估价值,不能按 tensor 数量或共享组数量推断收益。
|
||||
|
||||
全部分组是满足代表半径约束的可行方案,不保证达到最少组数或最优压缩率。
|
||||
|
||||
## 运行经验
|
||||
|
||||
1. 实际服务器内存约 1.7 GiB,新增的 60 GB 是磁盘扩容,不是内存。
|
||||
使用分块 BF16 解码和 mmap 页面释放完成了完整权重扫描与整 tensor 比较。
|
||||
2. 只看进程 RSS 不足以解释运行成本。`vmstat` 快照观察到 75%~85% 的 I/O 等待,
|
||||
同时存在交换活动;这些是共享主机的快照,不能全部归因于本进程。
|
||||
3. 与权重读取并行的绘图合成测试触发过 300 秒超时;观察到测试处于磁盘等待。
|
||||
后续验证应在权重读取结束后串行执行,避免把资源争用误判为数值算法失败。
|
||||
4. Matplotlib 图例改为固定位置,避免自动定位引入额外布局开销。
|
||||
5. 公平地选择各角色的候选,与高效地安排读取顺序,是两个不同问题。
|
||||
下一轮应评估“先固定公平候选集合,再按文件/源 tensor 分批执行”的效果,
|
||||
比较是否得到相同指标及更低 I/O 开销;本轮不在中途改变候选集合。
|
||||
6. 从已保存元数据计算,13,328 个抽样子块的原始数据合计 256,387,072 字节
|
||||
(约 244.5 MiB),对应指纹约 100.1 MiB。这是下一轮原始子块缓存的容量估计,
|
||||
不是本轮已经实现的缓存或实测加速。应先用小样本验证数值一致性、峰值内存和
|
||||
I/O 改善,再决定是否作为默认方案;不能仅凭容量估计保证运行效率。
|
||||
|
||||
参数分析及分组汇总耗时 6,661.13 秒(约 111.0 分钟),分析进程峰值 RSS 约
|
||||
201.3 MiB;这不包含系统文件缓存和同机服务内存。内部比较截止后保存覆盖率与
|
||||
分组,整个参数分析未触及 7,200 秒进程硬上限。块比较阶段将本进程 IO 优先级
|
||||
调整为 best-effort 7,未改变服务器全局设置。
|
||||
|
||||
最终修图版 6 项串行合成测试通过(约 77.2 秒),六类图表的 PNG/PDF/SVG 已生成,
|
||||
并对全部六类 PNG 做视觉检查;程序还核验了分组成员与代表之间的精确误差边。
|
||||
|
||||
## 三张诊断图的修订与解读
|
||||
|
||||
- 热力图只展示 `linear_attn.in_proj_a.weight`(16×2048),不是整个层。18 个相关层
|
||||
的 153 种配对中核验了 74 对;已测非对角余弦约 0.011~0.298。
|
||||
对角线 1 是身份比较,不是跨层发现。未测格子改用斜线,避免与接近零的底色混淆。
|
||||
- 原混合层距曲线受维数组成影响:层距 1 含 183 对一维、19 对二维;层距 8
|
||||
含 52 对一维、75 对二维。一维余弦中位数约从 0.941 变为 0.883,
|
||||
不能将混合曲线的陡降全部归因于层距。修订版按维数/块尺度分开,模块和筛选偏差仍存在。
|
||||
- 随机对照分为保留分布的元素打乱、匹配范数的零均值高斯向量、真实同角色随机配对。
|
||||
元素打乱后仍高余弦的情况主要出现在一维归一化、偏置和 A_log,提示均值/分布影响。
|
||||
修订版按维数分面、按密度归一化,并显示样本数,避免将不同样本量的峰高当概率比较。
|
||||
它们是诊断对照,不是显著性检验,也没有完全匹配每个模块的采样构成。
|
||||
三维对照分层仅有约 3~6 个样本,尤其不能据其峰形作总体推断。
|
||||
|
||||
这次只从已有 CSV/JSON 重绘并导出诊断表,模型权重已删除,没有增加参数比较或重新运行模型。
|
||||
|
||||
## 限制及后续决策
|
||||
|
||||
- 只研究一个 checkpoint;近邻筛选、同角色分组和子块抽样均可能漏掉其他共享机会。
|
||||
- 直方图和层距曲线存在候选筛选与模块混合偏差,不能用作总体分布或独立样本推断。
|
||||
- 光谱/子空间分析仅使用有界子体积;分布或子空间相似不等于可直接替换。
|
||||
- 本轮没有测量能力损失、困惑度、运行内存或推理速度,也没有产出可运行的压缩模型。
|
||||
- 大幅减少推理计算量需要进一步的计算图和路由分析,单纯共享存储不能保证加速。
|
||||
|
||||
下一轮先讨论候选选择与执行局部性、原始子块缓存、映射格式和阶段预算,
|
||||
再修订 SOP;不自动下载第二个模型。只有获得额外授权后,才进行校准前向及
|
||||
留出任务测试,以验证替换造成的能力损失。
|
||||
|
||||
数据与标准化报告见 `../results/qwen35-2b/`;具体阈值、分组、覆盖率、来源和校验记录
|
||||
随原始图表数据归档。权重在交付副本校验后按授权删除,重现实验需要按固定 revision
|
||||
重新下载。
|
||||
|
||||
## 功能复用假设仍待验证
|
||||
|
||||
本轮坐标对齐权重结果不能排除 Q/K 的联合功能接近或 MLP 分支可复用。
|
||||
下一阶段采用同一隐藏输入下的函数比较,不训练参数、不默认求正交 R;
|
||||
注意力分布、完整分支输出、真实网络单处替换和运行收益分别验证。
|
||||
详见 [免训练有界方案](TRAINING_FREE_FUNCTIONAL_PLAN.md) 与
|
||||
[文献核对](FUNCTIONAL_REUSE_LITERATURE.md)。这些是方案,尚未执行。
|
||||
@@ -0,0 +1,46 @@
|
||||
# Q/K 未旋转维度的确定性增益合并(已数值验证,归为重参数化)
|
||||
|
||||
这是从已核对架构直接推导的恒等式,不是看留出指标后扩大近邻搜索。
|
||||
原定 11 对候选保留原协议;本项是独立的解析对照,不训练、不求 R,也不选择层。
|
||||
预先固定完整网络干预层为第 3 层,分别验证两个移动方向;不根据数据换层。
|
||||
|
||||
## 恒等式与前提
|
||||
|
||||
以完成 RMS 单位化、尚未乘可学习增益的 q/k 为 u/v,Q/K 增益向量为 a/b。
|
||||
固定 checkpoint 的 norm 参数实际使用 a=1+w_Q,b=1+w_K。
|
||||
模型 head_dim=256,partial_rotary_factor=0.25:前 64 维旋转,后 192 维不旋转。
|
||||
逐头共享的增益向量与 GQA 结构已由官方代码确认。
|
||||
|
||||
对于后 192 维,任意 query/key 位置 p/s:
|
||||
|
||||
sum_j (a_j u_pj)(b_j v_sj) = sum_j u_pj ((a_j b_j) v_sj)
|
||||
= sum_j ((a_j b_j) u_pj) v_sj。
|
||||
|
||||
前 64 维保留原增益和位置旋转。因而完整 QK 点积在实数算术中相等,softmax、V、
|
||||
输出门控和 O 不变时,完整 attention 分支也是同一个函数。这个结论不依赖某一输入分布。
|
||||
浮点乘法次序改变,不能承诺逐 bit 相等;需报告实际误差并验证留出 NLL。
|
||||
不能把这一规则用于旋转维度,或未经核对的逐头独立增益架构。
|
||||
|
||||
## 验证与成本边界
|
||||
|
||||
1. 在已有真实 q/k 输入上,检查 6 个 full-attention 层的原始/两个合并方向分数、概率及输出。
|
||||
2. 固定第 3 层进行两个方向的独立网络替换,不叠加,使用原留出文本和质量阈值。
|
||||
3. 记录预先缓存增益后、相同 CPU 环境下原版与合并版局部归一化耗时;不外推 GPU 性能。
|
||||
4. 双精度数学推导和 FP32 实测分开。没有消除 Q/K 投影或 RMS 方差计算。
|
||||
|
||||
将 Q 的未旋转增益移入 K 时,每 token、每层少做 8×192=1,536 次逐元素增益乘法;
|
||||
反方向少做 2×192=384 次。它们只是归一化里的小部分操作,不是整个模型的百分比加速。
|
||||
NumPy 切片/拼接可能抵消这点收益,必须报告测得的局部时延。
|
||||
|
||||
参数量从两个 256 维增益变为两个 64 维旋转增益及一个 192 维联合增益,即 512→320 个数。
|
||||
但原增益以 BF16 存储、联合乘积以 FP32 保留时,载荷仍是 1,024 字节,没有 checkpoint
|
||||
净压缩;元数据还可能增加。FP32 运行时缓存增益的理论载荷 2,048→1,280 字节,
|
||||
不等于已测得整个模型 RSS 降低。另行 BF16 量化乘积会增加误差,不属于本次恒等式验证。
|
||||
|
||||
这是同一注意力计算内部的重参数化与冗余消除,不是两个现成 attention 层能互换的证明。
|
||||
若得到正例,应将它作为小粒度确定性优化机会;较大模块互换仍由原候选试验单独回答。
|
||||
|
||||
## 完成状态
|
||||
|
||||
96 组真实输入分数/概率检查及固定第3层双向网络检查均通过。
|
||||
该结果独立归类;主目标的已训练函数重复正例见 [CPU 功能结论](CPU_FUNCTIONAL_FINDINGS.md)。
|
||||
@@ -0,0 +1,140 @@
|
||||
# Parameter similarity SOP — 2B pilot draft
|
||||
|
||||
Status: v0.1, executed for the bounded Qwen3.5-2B pilot. See [findings](PILOT_FINDINGS.md).
|
||||
Changes proposed from this experience require a small equivalence/performance check before
|
||||
the next model; no second model is started automatically.
|
||||
|
||||
## Scope and decision
|
||||
|
||||
Analyze official, unquantized safetensors without instantiating a model, running inference,
|
||||
training, or executing repository-supplied code. Start with Qwen/Qwen3.5-2B only.
|
||||
The question is the number of representative-centered sharing groups under direct weight
|
||||
replacement error limits, and the net byte savings of a theoretical shared representation.
|
||||
Weight error is not task-accuracy loss, and parameter sharing does not imply fewer FLOPs.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Confirm authorized remote host, free disk, memory, CPU, existing work, and access.
|
||||
2. Install prebuilt wheels only. Never compile locally or silently use another runner.
|
||||
3. Freeze the official repository revision and download file manifest including SHA256.
|
||||
4. Allocate checkpoint size plus 3 GB disk margin. Use an experiment-owned directory,
|
||||
not a shared Hugging Face cache. Never delete pre-existing weights.
|
||||
|
||||
## Bounded procedure
|
||||
|
||||
1. Run synthetic correctness tests on the remote host: BF16, 3D indexing, directional
|
||||
replacement error, and non-transitive groups.
|
||||
2. Download one checkpoint sequentially and verify upstream sizes and LFS SHA256.
|
||||
3. Scan each tensor in 262,144-element chunks. Record shape, dtype, axis role,
|
||||
layer, bytes, moments, max magnitude, and finite-value checks. Memory-map weights;
|
||||
evict scanned pages. Do not search for exactly equal weight tensors.
|
||||
4. Whole-tensor screening: same role, same shape, same dtype. Sample 2,048 aligned,
|
||||
evenly spaced elements. Select up to 10 neighbors by each of cosine and relative
|
||||
error. Fairly distribute the 2,000-pair exact-verification cap across role groups.
|
||||
5. Block screening: non-overlapping 64x64 and 128x128 2D partitions. For 3D tensors,
|
||||
use axis-0 slices and bounded volumes adapted to actual dimensions. Keep up to
|
||||
256 uniformly reservoir-sampled blocks per role/shape/scale for the 1.7 GiB pilot host
|
||||
(below the planned maximum of 512). Record edge bytes
|
||||
and sampling coverage. Verify at most 20,000 block pairs. Never extrapolate sampled
|
||||
discoveries to unseen blocks or add savings across alternative scales.
|
||||
6. Exact metrics: full-element cosine, Pearson, directional replacement errors,
|
||||
symmetric error, optimal-scalar residual. Tail diagnostics use samples and say so.
|
||||
Controls include random actual comparable pairs, shuffled sampled elements,
|
||||
and norm-matched Gaussian vectors. Save sampled versus exact error discrepancies.
|
||||
Bounded mode-unfolding SVD probes are diagnostic only, not a replacement test.
|
||||
7. Form deterministic star groups at 1%, 2%, 5%, 10%, 20% relative weight error.
|
||||
Every member requires an exact verified edge to its representative. Unknown
|
||||
pairs remain independent; never use graph connected components as sharing groups.
|
||||
8. Compute original bytes minus representatives, 16-byte mapping per analyzed object,
|
||||
and 64-byte descriptor per shared group. Fall back to unchanged storage if larger.
|
||||
Count savings against the entire model, preserving unsampled blocks and edge regions.
|
||||
9. Save raw data, groups, thresholds, coverage, timings, resource usage, figures
|
||||
(PNG/PDF/SVG), model metadata and report. Validate every group against exact edges.
|
||||
10. Copy results to the deliverable workspace and verify checksums before deleting
|
||||
the experiment-owned checkpoint. Save a cleanup record. Do not delete the venv,
|
||||
result data or any unrelated cache.
|
||||
11. Review full diff, commit and push a work branch with Codex Bot identity, then
|
||||
create a PR for manual merge. Never silently initialize/push main or auto-merge.
|
||||
|
||||
## Budget and stop conditions
|
||||
|
||||
- Real 2B analysis computation: hard wall-time limit 7,200 seconds. Reserve final time
|
||||
for summaries; download and report-generation time are recorded separately.
|
||||
- Use one BLAS thread to avoid interference with existing services.
|
||||
- Save exact-pair tables every 100 pairs; stage deadlines prevent whole-tensor work
|
||||
from consuming the complete block budget.
|
||||
- On timeout or failure, retain source weights until partial results are recoverable
|
||||
and report coverage/failure truthfully. An internal planned cutoff may produce a complete
|
||||
bounded report with partial candidate coverage; always state verified/selected counts.
|
||||
An external kill or missing required report is an incomplete run, not a completed experiment.
|
||||
- Empty or negligible low-error sharing is a valid negative result. Do not add scales,
|
||||
increase error thresholds, align permutations, train or expand to other models automatically.
|
||||
- No runtime capability/performance claim without separately authorized evaluation.
|
||||
|
||||
## Commands (remote, from project root)
|
||||
|
||||
```sh
|
||||
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 timeout 300 venv/bin/python -B -m unittest discover -s tests -v
|
||||
venv/bin/python -B -m pilot.download --root runs/qwen35-2b
|
||||
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 timeout 7200 venv/bin/python -B -m pilot.analyze --root runs/qwen35-2b --seconds 6600
|
||||
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 venv/bin/python -B -m pilot.plot --root runs/qwen35-2b
|
||||
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 timeout 300 venv/bin/python -B -m unittest discover -s tests -v > runs/qwen35-2b/tests.log 2>&1
|
||||
venv/bin/python -B -m pilot.audit --root runs/qwen35-2b --analysis-code-commit 6121016
|
||||
venv/bin/python -B -m pilot.validate --root runs/qwen35-2b
|
||||
# Copy archived results, verify checksums at the destination, then:
|
||||
venv/bin/python -B -m pilot.validate --root runs/qwen35-2b --cleanup-weights
|
||||
```
|
||||
|
||||
## Follow-up decisions after the pilot
|
||||
|
||||
- The pilot verified 2,000 tensor pairs and 14,778/20,000 selected block pairs before cutoff.
|
||||
It took about 111 minutes; the final six-test suite including revised figure checks passed in about 77 seconds.
|
||||
- Hatch missing heatmap cells and label identity values as constructed. Separate layer-distance
|
||||
curves by dimension/scale; retain warnings about within-stratum module/selection bias.
|
||||
Normalize control histograms, display sample counts, and verify their areas equal one.
|
||||
Keep these diagnostics distinct from task-equivalence or statistical-significance claims.
|
||||
- Avoid concurrent plotting tests and heavy weight IO on the shared host. Record IO wait,
|
||||
swap, CPU and RSS; a low process RSS is not proof of low total resource cost.
|
||||
- Distinguish tensor/group counts from byte contributions: 1D tensors were about half the
|
||||
inventory count but only 0.0197% of weight bytes in this checkpoint.
|
||||
- Keep fair candidate selection separate from IO-local execution order. Benchmark batching
|
||||
by source file/tensor without changing the selected pairs or metrics.
|
||||
- The sampled raw blocks total about 244.5 MiB. Test an explicitly bounded raw BF16/F32
|
||||
cache against the uncached implementation before adopting it; include fingerprint and
|
||||
temporary conversion memory in the budget. This was not enabled in the current run.
|
||||
- Report both pre-metadata and net savings. Tiny blocks can have groups yet lose all savings
|
||||
to mapping overhead. Any alternative sparse encoding needs its own explicit accounting.
|
||||
- Separate low-byte normalization groups from matrix/expert compression opportunities.
|
||||
- Decide whether approximate-neighbor recall and block coverage justify another bounded pass.
|
||||
- If meaningful candidates exist, request a small calibration-forward experiment to measure
|
||||
output distortion, then held-out loss/tasks, then implementation-specific memory and latency.
|
||||
- For MoE, analyze router behavior and joint gate/up/down expert consistency before treating
|
||||
independently similar matrix blocks as interchangeable experts.
|
||||
- Use these observations to revise this SOP before downloading a second model.
|
||||
|
||||
## Training-free functional follow-up (design only)
|
||||
|
||||
Direct coordinate-aligned parameter similarity is a baseline, not a test of Q/K/V or MLP
|
||||
functional interchangeability. The follow-up uses same-input module probes without solving
|
||||
rotations or training any parameters, then single-site intervention and held-out quality/cost
|
||||
validation. See the [bounded plan](TRAINING_FREE_FUNCTIONAL_PLAN.md) and
|
||||
[primary-source literature](FUNCTIONAL_REUSE_LITERATURE.md). No forward pass, new download,
|
||||
or new model is started by adopting this document. The original static pilot remains
|
||||
inference-free; the proposed follow-up requires a separately confirmed execution environment.
|
||||
|
||||
## Current functional-run retention override
|
||||
|
||||
On 2026-11-09 the user explicitly changed retention: keep the CPU functional pilot
|
||||
checkpoint until the user explicitly requests deletion. Completion, timeout, failure
|
||||
and archive validation do not authorize cleanup. The earlier pilot cleanup remains
|
||||
a historical action; do not apply its automatic cleanup step to the current run.
|
||||
|
||||
## CPU functional follow-up outcome
|
||||
|
||||
The executed CPU study found a learned RMSNorm function-repetition example at text
|
||||
layer indices 12/13. Use same-input function error and a uniform analytic bound as
|
||||
primary evidence, with separate heldout network substitution checks. Costs are not
|
||||
a success condition under the latest user instruction. See the
|
||||
[executed findings](CPU_FUNCTIONAL_FINDINGS.md) and
|
||||
[function-repetition criterion](LEARNED_FUNCTION_REPETITION.md).
|
||||
Keep whole-module, neuron, normalization and algebraic-reparameterization results distinct.
|
||||
@@ -0,0 +1,125 @@
|
||||
# 免训练功能复用:下一阶段有界方案
|
||||
|
||||
状态:研究设计,真实模型功能探测尚未执行。原始参数试验已完成;另已完成单线程合成 CPU 容量探测,未新增模型前向、下载或训练。
|
||||
目标:寻找并验证至少一个在留出数据上保持约定质量、同时降低明确运行成本的复用实例;
|
||||
若没有通过者,报告有界搜索的阴性结果,不保证一定能找到。
|
||||
|
||||
## 1. 硬约束与研究对象
|
||||
|
||||
- 冻结所有模型参数。不进行优化器更新、微调、蒸馏、LoRA、学习投影或低秩修正。
|
||||
- 默认不求正交 R。校准集只用于选择有限候选和阈值,留出集不参与选择。
|
||||
- 同类型模块配对;Q/K/V 联合作为功能系统,MLP 独立验证。保留归一化、位置处理、门控及头结构。
|
||||
- 已存配置为 24 个文本层,其中 6 个 full attention、18 个线性注意力;执行前按固定 revision 的实际实现复核。
|
||||
full attention 的 15 个无序层对可穷举;线性注意力首轮只检查 6 个预先固定的相邻同类型层对。
|
||||
MLP 首轮检查 6 个预先固定、覆盖浅中深层的相邻层对。具体名单在运行前写入 manifest。
|
||||
- 之前热力图的 in_proj_a 是线性注意力控制投影示例,不是 Q/K/V 功能相似性的测量。
|
||||
|
||||
## 2. 为什么不用先找 R
|
||||
|
||||
给定相同隐藏输入 H,且位置、mask 和缓存/递推状态一致,比较两套模块的实际检索函数:
|
||||
|
||||
S_i(H) = Q_i(H) K_i(H)^T / sqrt(d),P_i(H) = softmax(S_i(H) + mask)。
|
||||
|
||||
这里 Q/K 指完成该架构实际归一化和位置处理后的量。直接比较 P 可避开内部坐标差异;
|
||||
logit 每行加常数不改变 softmax,因此同时报告去行均值的分数误差。
|
||||
|
||||
这不是“存在共同正交 R”的数学证明。反例 Q_2=2Q_1、K_2=K_1/2 保持所有点积,
|
||||
但非零 Q 的范数改变,不能由正交变换产生。功能等价允许比共同正交旋转更广的关系。
|
||||
相反,在单套 Q/K 上共同右乘 R 保持点积,只说明坐标不唯一,并未说明两个已训练层可复用。
|
||||
实际 RoPE、GQA、归一化、门控也必须包含在函数边界内。
|
||||
|
||||
有限探针只能提供相应输入分布上的经验证据,不是对所有 H 的形式证明。
|
||||
在无位置处理/归一化的纯线性特例中,可研究 W_Q W_K^T 的代数相等性;
|
||||
一般模块不据此简化,首轮不物化所有大算子。
|
||||
|
||||
## 3. 同输入与真实输入分开
|
||||
|
||||
对候选 i/j,分别从原模型 i 和 j 的入口收集 H_i、H_j;分别比较 f_i(H_i) 与 f_j(H_i),
|
||||
以及 f_i(H_j) 与 f_j(H_j)。避免只选有利于某一层的输入。模块前归一化如位于边界外,
|
||||
必须明确分别测“归一化后核心”和“包含归一化的完整分支”。
|
||||
|
||||
这检验模块函数接近程度。实际网络的 f_i(H_i) 与 f_j(H_j) 使用不同输入,是另一项量。
|
||||
权重共享仍需对每个输入计算;缓存上游输出用于下游则改变了输入,必须实际干预后检验。
|
||||
MLP 测残差相加前的分支输出,防止共同输入 H 掩盖分支差异。
|
||||
|
||||
## 4. 指标和对照
|
||||
|
||||
| 对象 | 首轮指标 | 不能据此宣称的结论 |
|
||||
|---|---|---|
|
||||
| full attention 逐头 P | 平均及 P95 行 JS(自然对数,范围 0–ln2)、top-5 重合率;去行均值 S 相对误差 | P 相似不保证 V/O 输出相似 |
|
||||
| 完整 attention 分支 | 相对 L2、逐 token 误差 P50/P95、余弦;包含 V/O/门控 | 平均低误差不保证长尾任务能力 |
|
||||
| 线性注意力 | 同输入、同合法初始状态的分支输出及最终状态误差;后续状态继续使用测试 | 不构造不存在的 softmax 图;状态数值相似不等于长期稳定 |
|
||||
| MLP | 同输入分支输出相对 L2、逐 token P95、余弦 | 不以各矩阵单独相似代替 gate/up/down 联合验证 |
|
||||
|
||||
相对误差统一为 ||candidate-reference|| / max(||reference||, epsilon),并记录低范数样本数量。
|
||||
首轮筛选门槛预设:P 平均 JS ≤0.01 且 top-5 重合 ≥0.8;完整分支相对 L2 ≤0.05、
|
||||
逐 token 相对误差 P95 ≤0.1。它们是筛选约定,不是文献保证或能力损失界。
|
||||
线性模块和 MLP 使用输出门槛;只通过 P 的候选不能自动通过完整模块门槛。
|
||||
|
||||
对照:同模块重复测量、随机同类型层对;首 token 保留/移除并重新归一化两个版本;
|
||||
排除自注意与局部窗口主导后再测;按序列/位置/浅中深层分层。零分母与无效行单独标记。
|
||||
逐头记录,不先平均头。默认只用原头序;可选的离散头排列仅在校准集选定后冻结,
|
||||
须满足 GQA 分组和 V/O 一致性,不允许把最优头匹配分数当作可执行替换结果。
|
||||
CKA 仅作辅助筛选;共享位置模板、attention sink 和共同残差都可能制造高相似。
|
||||
|
||||
## 5. 资源与阶段预算
|
||||
|
||||
采用 CPU 先导、GPU 后续细化的两阶段路径;GPU 不作为寻找初步证据的前置条件。
|
||||
当前服务器为 2 核 CPU、约 1.7 GiB RAM;60 GB 是磁盘扩容。详见
|
||||
[CPU 先导设计及实测](CPU_FIRST_VALIDATION.md)。
|
||||
|
||||
CPU 阶段仅处理文本,batch=1、长度 32,校准/留出各 4 条真实且去重的文本;
|
||||
仅检查 3 个预先固定、覆盖浅中深的 full-attention 层对和 2 个 MLP 层对。
|
||||
完整保留合法 key,逐头比较,不通过采样 key 改变 softmax。
|
||||
模型依赖实现一致性检查和容量探测完成后,才实施真实前向。
|
||||
权重按层/子矩阵流式读取并释放,禁止全模型转换成 FP32;不把依赖换页的完整框架加载视为可行方案。
|
||||
数据来源、许可、tokenizer revision、截断、样本 hash 和 seed 在运行前写入 manifest。
|
||||
|
||||
| CPU 阶段 | 上限 | 完成条件 / 停止条件 |
|
||||
|---|---|---|
|
||||
| 实现一致性及短样本容量探测 | 20 分钟 | 模块计算语义核对,内存峰值可控;OOM、持续换页或实现核对失败即停止 |
|
||||
| 真实隐藏输入采集 | 40 分钟 | 流式文本前向采集固定入口,不保存所有层权重/注意力图;超时保存覆盖率 |
|
||||
| 同输入功能比较 | 30 分钟 | 固定 5 对候选;无通过者停止;最多留下 1 个干预候选 |
|
||||
| 单处干预及归档 | 30 分钟 | 在 4 条留出文本上检查输出或流式 token NLL;不足以完成则只交付候选证据 |
|
||||
|
||||
CPU 首轮计算上限 120 分钟,下载单独计时。当前仅执行了约 88 MiB 峰值 RSS 的
|
||||
合成矩阵乘法探测,没有重下权重或执行真实前向。容量探测不能保证完整模型实现的峰值内存。
|
||||
线性注意力需另行完成正确性核对,首轮先不加入,避免状态递推实现拖延初步判断。
|
||||
短文本小样本无法覆盖长上下文或低频关键能力;阴性结果也不能排除更广泛候选。
|
||||
|
||||
只有发现值得跟进的候选,GPU 阶段才扩展到原定 27 对候选、长度 256、
|
||||
校准/留出各 16 条及更多独立任务,细化单处/多处干预与真实性能。
|
||||
届时由用户提供并确认 GPU 执行环境;当前不租用或假定已有 GPU。
|
||||
|
||||
## 6. 干预必须对应可节省的对象
|
||||
|
||||
| 干预 | 可以争取的收益 | 必须额外确认 |
|
||||
|---|---|---|
|
||||
| 跨层绑定权重 | 权重存储/加载内存 | 各层输入仍不同,通常不减少投影 FLOPs |
|
||||
| 重用上游 attention 分布,保留下游 V/O | 部分 Q/K 投影与 QK/softmax 计算 | 保留分布的内存及实现开销;decode 未必值得缓存完整图 |
|
||||
| 跨层共享 K/V cache | KV 内存,可能减少 K/V 投影 | GQA、位置、缓存布局与层依赖合法性 |
|
||||
| 重用完整 attention/MLP 输出 | 对应分支计算 | 下游输入不同,必须测试整个原模型中的替换效应 |
|
||||
|
||||
选择的每个候选首先给出一种具体可实现干预;只有同输入指标通过却无实际可省操作,
|
||||
标记“功能相似但暂无复用实现”。不把整模块可替换和其中 Q/K 可替换混为一谈。
|
||||
|
||||
首轮探索性质量门槛:留出平均 token NLL 增量 ≤0.01 nat/token,逐序列增量 P95 ≤0.05,
|
||||
输出有限;同时保存全部逐序列差值,不将该小样本阈值称为统计显著性或普适能力保证。
|
||||
候选只在校准集筛选;留出失败不回调阈值、不反复选择。
|
||||
|
||||
性能分别测 prefill 和固定 32-token decode;固定 batch/长度/dtype/backend,预热 3 次、
|
||||
交错运行基线与干预各 10 次,报告原始时延和中位数/P95、峰值内存、KV/权重字节及理论运算变化。
|
||||
插桩诊断时延不作为优化实现时延。若速度差落在运行波动内,不宣称加速;
|
||||
若只减内存,则结论限定为内存收益。计入缓存、索引与数据移动开销。
|
||||
|
||||
## 7. 分组与最终证据
|
||||
|
||||
单处通过后,才讨论多成员组:每个成员必须通过对同一代表的定向替换检查;
|
||||
不能用 A≈B、B≈C 推出 A 可代表 C。多处同时替换须再测累积误差和性能,
|
||||
单处收益不能相加为最终模型收益。首轮不自动执行多处替换。
|
||||
|
||||
输出每对候选/每序列/每头指标 CSV、覆盖率和失败原因、质量—成本散点图、逐层热图、
|
||||
基线与干预原始计时、环境及代码版本。结论分为:功能接近、单处干预通过、测得实际收益三档。
|
||||
“存在一个免训练复用点”的操作性证据必须同时具有后两项;当前静态试验尚未提供这类证据。
|
||||
|
||||
相关依据与训练限制见 [文献核对](FUNCTIONAL_REUSE_LITERATURE.md)。
|
||||
@@ -0,0 +1,91 @@
|
||||
# Bounded CPU functional pilot
|
||||
|
||||
This is the execution implementation of the CPU-first plan, not the completed static
|
||||
parameter pilot. Frozen Qwen3.5-2B weights are decoded to FP32 a projection block at a
|
||||
time. CPU only, no autograd/optimization, no rotation fitting, no model-hub Python code.
|
||||
The user explicitly requires retaining this checkpoint until they request deletion.
|
||||
|
||||
## Fixed scope
|
||||
|
||||
- Batch of eight distinct experiment-authored plain texts, first 32 tokens each:
|
||||
four calibration and four heldout, two Chinese/two English in each split.
|
||||
- Full attention pairs: (3,7), (11,15), (19,23).
|
||||
- MLP pairs: (5,6), (20,21).
|
||||
- Smaller-granularity Q/K RMSNorm pairs inside layers 3,7,11,15,19,23.
|
||||
Added before observing real weights/functions for this pilot; these are small storage
|
||||
opportunities, not a claim of substantial compute savings.
|
||||
- At most one calibration-selected candidate, two separate substitution directions.
|
||||
Selection prefers component size, then worst symmetric output error. No heldout-driven retry.
|
||||
- Same-input relative L2 <=0.05 in both directions and token P95 <=0.1 in both directions;
|
||||
attention additionally requires mean JS <=0.01 and top-5 overlap >=0.8.
|
||||
- Heldout mean NLL increase <=0.01 nat/token and per-sequence P95 increase <=0.05.
|
||||
These are pilot decision criteria, not mathematical capability guarantees.
|
||||
|
||||
## Source and checks
|
||||
|
||||
`reference.json` pins the official Transformers Qwen3.5 source commit, URL and hash.
|
||||
`reference_check.py` extracts only named mathematical definitions from that exact file,
|
||||
removes optional fused-kernel decorators, and compares the NumPy implementation against
|
||||
Torch operators, full toy decoder layers and a two-layer text forward. Chunked delta and
|
||||
recurrent delta implementations are both checked, including sequence padding boundaries.
|
||||
The official source is Apache-2.0, copyright Qwen Team and HuggingFace; the reference file
|
||||
is fetched for testing and is not bundled here. FP32 equivalence is checked, not equality
|
||||
to every deployed BF16 kernel.
|
||||
|
||||
`tests/test_functional.py` independently checks streamed projection/embedding/NLL,
|
||||
causality, causal convolution, normalization conventions and basic metric identities.
|
||||
These tests use tiny synthetic arrays. Real model evidence is produced only by `run.py`.
|
||||
|
||||
## Remote execution
|
||||
|
||||
Use the previously authorized CPU host and existing NumPy/Matplotlib environment. Install
|
||||
only binary wheels: tokenizers==0.23.3 from HTTPS PyPI; torch==2.15.0+cpu from the official
|
||||
CPU wheel index for independent reference checks. Use an experiment-owned on-disk TMPDIR:
|
||||
the shared host's /tmp tmpfs was too small during the first wheel download. Do not change
|
||||
system swap or shared temporary files.
|
||||
|
||||
```sh
|
||||
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 venv/bin/python -B -m unittest tests.test_functional -v
|
||||
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 venv/bin/python -B -m functional.reference_check --source runs/cpu-qwen35-2b/reference.py --output runs/cpu-qwen35-2b/reference-check.json
|
||||
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 venv/bin/python -B -m functional.supervise --root runs/cpu-qwen35-2b
|
||||
```
|
||||
|
||||
The supervisor waits at most one hour for binary dependencies and four hours for the
|
||||
already started pinned, verified checkpoint download. It does not install, retry downloads,
|
||||
search extra candidates, mutate Git or delete weights. After reference checks, it runs one
|
||||
8-token real text capacity check, then the bounded functional pilot. Reference, preflight
|
||||
and functional compute together are capped at two hours with a reporting reserve;
|
||||
download wait is recorded separately. Projection memory is checked, RSS soft stop is
|
||||
512 MiB, available-system-memory floor 256 MiB; sustained host swap IO combined with low available memory or >128 MiB process swap also stops the run.
|
||||
A persistent ledger counts computation across restarts; early checks/preflight receive a conservative 180-second reserve.
|
||||
|
||||
`preflight.py` is a capacity smoke check, not a semantic oracle. `run.py` records exact
|
||||
sample/token IDs, fixed configuration, source hashes, activations, per-text/per-head metrics,
|
||||
selection, per-token NLL, intervention results and truthful stop coverage. `report.py` reads
|
||||
saved data to produce PNG/PDF/SVG figures without reopening weights.
|
||||
|
||||
No generation throughput is measured in this short-text pilot. Any parameter-tying storage
|
||||
benefit must be accounted for separately, including metadata. Neither same-input similarity
|
||||
nor favorable tiny heldout NLL demonstrates broad mutual interchangeability or GPU speedup.
|
||||
|
||||
## Current primary result and completed extensions
|
||||
|
||||
The latest user goal is learned-function repetition, independent of costs. Existing
|
||||
input RMSNorm modules at layer indices 12/13 have a proven worst two-direction real-arithmetic
|
||||
error bound of 11.3402%, worst observed heldout relative error 4.5285%, minimum cosine 0.999487,
|
||||
and small bidirectional heldout NLL changes. See [findings](../docs/CPU_FUNCTIONAL_FINDINGS.md).
|
||||
|
||||
- `neuron_reuse.py`: fixed four-layer scalar MLP function search, nontrivial activity
|
||||
gates, calibration-only selection and independent heldout/substitution logic; no pair passed.
|
||||
- `norm_repetition.py`: same-role learned RMSNorm bound across 552 pairs, one deterministic
|
||||
selection independent of any input samples, real probes and two full-network substitutions.
|
||||
- `gain_factorization.py`: architecture-derived identity on non-RoPE coordinates; a separate
|
||||
reparameterization result, not a learned-function repetition example.
|
||||
- `benchmark_factorization.py`: historical one-attempt CPU allocation optimization and
|
||||
bitwise equivalence check. Performance is no longer a success condition.
|
||||
- `storage.py`: explicit component layout accounting; the original candidate run selected
|
||||
no pair. This does not affect the primary function-repetition conclusion.
|
||||
|
||||
Do not expand the final positive claim to full attention or MLP bodies. Retain the
|
||||
fixed checkpoint until the user explicitly requests deletion. Full tests and audit are
|
||||
run remotely; no local build or model execution is required to inspect the archived results.
|
||||
@@ -0,0 +1 @@
|
||||
"""CPU-only, training-free functional reuse pilot."""
|
||||
@@ -0,0 +1,86 @@
|
||||
"""Audit saved functional evidence and archive only outputs, never checkpoint weights."""
|
||||
import argparse
|
||||
import csv
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import platform
|
||||
import subprocess
|
||||
import time
|
||||
import numpy as np
|
||||
from .model import StreamingLM
|
||||
from .norm_repetition import uniform_bounds
|
||||
from .run import write_json
|
||||
|
||||
EXCLUDE={'tokenizer.json','reference.py','checksums-functional.json','audit-validation.json','archive-files.json'}
|
||||
|
||||
|
||||
def archive_files(root):
|
||||
files=[p for p in root.iterdir() if p.is_file() and p.name not in EXCLUDE and not p.name.endswith(('.partial','.safetensors'))]
|
||||
files += [p for p in (root/'figures').glob('*') if p.is_file()]
|
||||
return sorted(files)
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);a=p.parse_args();root=a.root
|
||||
manifest=json.loads((root/'manifest.json').read_text())
|
||||
assert manifest['revision']=='15852e8c16360a2fea060d615a32b45270f8a8fc'
|
||||
for f in manifest['files']:
|
||||
if f['name'].endswith('.safetensors'):
|
||||
path=root/'weights'/f['name']
|
||||
assert path.is_file() and path.stat().st_size==f['bytes']
|
||||
assert f['sha256']==f['upstream_sha256']
|
||||
retention=json.loads((root/'retention-policy.json').read_text());assert retention['automatic_cleanup'] is False
|
||||
reference=json.loads((root/'reference-check.json').read_text())
|
||||
assert reference['passed'] and len(reference['tests'])==22
|
||||
assert reference['implementation_sha256']==hashlib.sha256(Path('functional/model.py').read_bytes()).hexdigest()
|
||||
tests=(root/'final-tests.txt').read_text();assert 'Ran 12 tests' in tests and '\nOK\n' in tests
|
||||
result=json.loads((root/'norm-repetition-summary.json').read_text());assert result['state']=='completed'
|
||||
assert result['learned_function_repetition_positive'] and result['bidirectional_network_quality_pass']
|
||||
cfg=json.loads((root/'model_config.json').read_text());lm=StreamingLM(root/'weights',cfg,seconds=60)
|
||||
c=result['selected'];ga=1+lm.small(f'layers.{c["a"]}.{c["role"]}.weight');gb=1+lm.small(f'layers.{c["b"]}.{c["role"]}.weight')
|
||||
bounds=uniform_bounds(ga,gb)
|
||||
np.testing.assert_allclose(bounds,[c['a_to_b_uniform_bound'],c['b_to_a_uniform_bound']],atol=1e-14,rtol=1e-14)
|
||||
with (root/'norm-repetition-uniform-bounds.csv').open() as f:assert len(list(csv.DictReader(f)))==552
|
||||
baseline=np.load(root/'baseline-heldout-token-nll.npy');assert baseline.shape==(4,31)
|
||||
for rec in result['interventions']:
|
||||
nll=np.load(root/f'norm-repetition-{rec["target"]}-uses-{rec["donor"]}-token-nll.npy')
|
||||
delta=nll.mean(1)-baseline.mean(1)
|
||||
np.testing.assert_allclose(delta,rec['sequence_nll_deltas'],atol=1e-13,rtol=1e-13)
|
||||
assert abs(delta.mean()-rec['mean_nll_delta'])<1e-13
|
||||
with (root/'norm-repetition-function-metrics.csv').open() as f:rows=list(csv.DictReader(f))
|
||||
held=[r for r in rows if r['split']=='heldout'];assert len(held)==8
|
||||
worst=max(max(float(r['relative_l2']),float(r['reverse_relative_l2'])) for r in held)
|
||||
assert abs(worst-result['worst_heldout_relative_l2'])<1e-14
|
||||
neuron=json.loads((root/'neuron-reuse-search-summary.json').read_text());assert sum(x['eligible_unique_pairs_checked'] for x in neuron)==7450139
|
||||
ledger=json.loads((root/'compute-budget-ledger.json').read_text());assert ledger['spent_seconds']+600<7200
|
||||
environment={'python':platform.python_version(),'platform':platform.platform(),'numpy':np.__version__,
|
||||
'packages':subprocess.run([str(Path(__import__('sys').executable)),'-m','pip','freeze'],capture_output=True,text=True,check=True).stdout.splitlines(),
|
||||
'weights_retained':True,'no_automatic_cleanup':True,'ledger_seconds_including_initial_reserve':ledger['spent_seconds'],
|
||||
'final_tests_report_audit_additional_budget_upper_reserve_seconds':600,
|
||||
'historical_error_logs':'Early reference adapter errors and preflight pressure stops; latest summaries/tests are authoritative.'}
|
||||
write_json(root/'functional-environment.json',environment)
|
||||
source_paths=[*Path('functional').glob('*.py'),Path('functional/reference.json'),Path('pilot/tensors.py'),Path('tests/test_functional.py')]
|
||||
write_json(root/'final-source-hashes.json',{str(p):hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(source_paths)})
|
||||
files=archive_files(root)
|
||||
# Every numeric CSV value must be finite. Empty diagnostic fields stay unknown.
|
||||
for path in files:
|
||||
if path.suffix=='.csv':
|
||||
with path.open() as f:
|
||||
for row in csv.DictReader(f):
|
||||
for value in row.values():
|
||||
if value in (None,''):continue
|
||||
try:number=float(value)
|
||||
except ValueError:continue
|
||||
assert np.isfinite(number),(path,value)
|
||||
checksums={str(p.relative_to(root)):hashlib.sha256(p.read_bytes()).hexdigest() for p in files}
|
||||
write_json(root/'checksums-functional.json',checksums)
|
||||
selected=[*checksums,'checksums-functional.json','audit-validation.json','archive-files.json']
|
||||
write_json(root/'archive-files.json',selected)
|
||||
write_json(root/'audit-validation.json',{'passed':True,'validated_unix':time.time(),'checksummed_files':len(checksums),
|
||||
'proof_recomputed_from_retained_weights':True,'heldout_nll_recomputed_from_saved_arrays':True,
|
||||
'weights_present_and_retained':True,'archive_excludes_weights_and_tokenizer':True})
|
||||
print(json.dumps({'passed':True,'checksummed_files':len(checksums),'weights_retained':True}))
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,83 @@
|
||||
"""One allocation-reduction attempt, with a similarly optimized baseline.
|
||||
|
||||
Does not change weights or run the network again. Checks bitwise equality to the
|
||||
network-tested factorization on every captured real Q/K input before timing.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import resource
|
||||
import time
|
||||
import numpy as np
|
||||
from .model import StreamingLM
|
||||
from .gain_factorization import consolidate,normalized,LAYERS
|
||||
from .run import save_csv,write_json
|
||||
|
||||
|
||||
def baseline_inplace(q,k,a,b):
|
||||
q=normalized(q);q*=a
|
||||
k=normalized(k);k*=b
|
||||
return q,k
|
||||
|
||||
|
||||
def factored_inplace(q,k,a,b,r,combined,move='q_to_k'):
|
||||
q,k=normalized(q),normalized(k)
|
||||
if move=='q_to_k':
|
||||
q[...,:r]*=a[:r];k*=combined
|
||||
else:
|
||||
q*=combined;k[...,:r]*=b[:r]
|
||||
return q,k
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',required=True,type=Path);a=p.parse_args();root=a.root
|
||||
ledger_path=root/'compute-budget-ledger.json';ledger=json.loads(ledger_path.read_text());remaining=int(7200-ledger['spent_seconds']-20)
|
||||
if remaining<60:raise TimeoutError('Cumulative budget insufficient')
|
||||
start=time.monotonic();result={'state':'running'}
|
||||
try:
|
||||
cfg=json.loads((root/'model_config.json').read_text());lm=StreamingLM(root/'weights',cfg,seconds=min(remaining,300))
|
||||
r=64;data=np.load(root/'baseline-activations.npz');checks=[]
|
||||
for layer in LAYERS:
|
||||
lm.guard();pfx=f'layers.{layer}.self_attn.'
|
||||
ag,bg=1+lm.small(pfx+'q_norm.weight'),1+lm.small(pfx+'k_norm.weight')
|
||||
q,k=data[f'qraw_{layer}'],data[f'kraw_{layer}']
|
||||
for move in ('q_to_k','k_to_q'):
|
||||
combined=np.concatenate([(bg if move=='q_to_k' else ag)[:r],ag[r:]*bg[r:]])
|
||||
expected=consolidate(q,k,ag,bg,r,move)
|
||||
actual=factored_inplace(q,k,ag,bg,r,combined,move)
|
||||
for x,y in zip(expected,actual):np.testing.assert_array_equal(x,y)
|
||||
checks.append({'layer':layer,'direction':move,'query_elements':int(q.size),'key_elements':int(k.size),'bitwise_equal':True})
|
||||
q,k=data['qraw_3'][:1],data['kraw_3'][:1];pfx='layers.3.self_attn.'
|
||||
ag,bg=1+lm.small(pfx+'q_norm.weight'),1+lm.small(pfx+'k_norm.weight')
|
||||
combined=np.concatenate([bg[:r],ag[r:]*bg[r:]])
|
||||
funcs={'baseline_legacy':lambda:(normalized(q)*ag,normalized(k)*bg),
|
||||
'baseline_inplace':lambda:baseline_inplace(q,k,ag,bg),
|
||||
'factored_inplace':lambda:factored_inplace(q,k,ag,bg,r,combined)}
|
||||
for _ in range(3):
|
||||
for fn in funcs.values():fn()
|
||||
timing=[];names=list(funcs)
|
||||
for repeat in range(30):
|
||||
order=names[repeat%3:]+names[:repeat%3]
|
||||
for name in order:
|
||||
lm.guard();t=time.perf_counter()
|
||||
for _ in range(50):funcs[name]()
|
||||
timing.append({'repeat':repeat,'implementation':name,'seconds_per_call':(time.perf_counter()-t)/50,'calls_per_block':50})
|
||||
save_csv(root/'gain-factorization-optimized-timing.csv',timing)
|
||||
values={name:np.array([row['seconds_per_call'] for row in timing if row['implementation']==name]) for name in names}
|
||||
ratio=values['baseline_inplace']/values['factored_inplace']
|
||||
medians={name:float(np.median(v)) for name,v in values.items()}
|
||||
result.update(state='completed',bitwise_checks=checks,medians_seconds=medians,
|
||||
paired_baseline_over_factored_median=float(np.median(ratio)),
|
||||
paired_ratio_p10=float(np.quantile(ratio,.1)),paired_ratio_p90=float(np.quantile(ratio,.9)),
|
||||
fraction_blocks_factored_faster=float(np.mean(ratio>1)),
|
||||
descriptive_local_gain=bool(np.median(ratio)>1.05 and np.mean(ratio>1)>=.8 and np.quantile(ratio,.1)>1),
|
||||
claim_limit='Hot-array CPU normalization microbenchmark against equally allocation-optimized baseline; no full-model speedup or independent statistical significance claim.')
|
||||
except Exception as exc:
|
||||
result.update(state='stopped',error_type=type(exc).__name__,error=str(exc));raise
|
||||
finally:
|
||||
elapsed=time.monotonic()-start;result.update(elapsed_seconds=elapsed,peak_rss_kib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
|
||||
ledger=json.loads(ledger_path.read_text());ledger['spent_seconds']+=elapsed;ledger['calls'].append({'module':'functional.benchmark_factorization','seconds':elapsed});write_json(ledger_path,ledger)
|
||||
write_json(root/'gain-factorization-optimized-summary.json',result)
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,135 @@
|
||||
"""Architecture-derived Q/K gain consolidation on non-RoPE dimensions only.
|
||||
|
||||
Fixed layer3 interventions; no fitting, layer selection or learned alignment.
|
||||
Run only after baseline/candidate pilot finishes, within the same cumulative budget.
|
||||
"""
|
||||
import argparse
|
||||
import csv
|
||||
import json
|
||||
from pathlib import Path
|
||||
import resource
|
||||
import time
|
||||
import numpy as np
|
||||
from .model import StreamingLM,norm,rope
|
||||
from .run import probability_metrics,write_json,save_csv
|
||||
|
||||
LAYERS=[3,7,11,15,19,23]
|
||||
|
||||
|
||||
def normalized(x):
|
||||
return x/np.sqrt(np.mean(x*x,axis=-1,keepdims=True)+np.float32(1e-6))
|
||||
|
||||
|
||||
def consolidate(q,k,a,b,r,move,joint=None):
|
||||
q,k=normalized(q),normalized(k)
|
||||
c=a[r:]*b[r:] if joint is None else joint
|
||||
if move=='q_to_k':
|
||||
q=np.concatenate([q[...,:r]*a[:r],q[...,r:]],axis=-1)
|
||||
k=np.concatenate([k[...,:r]*b[:r],k[...,r:]*c],axis=-1)
|
||||
else:
|
||||
q=np.concatenate([q[...,:r]*a[:r],q[...,r:]*c],axis=-1)
|
||||
k=np.concatenate([k[...,:r]*b[:r],k[...,r:]],axis=-1)
|
||||
return q,k
|
||||
|
||||
|
||||
class FactoredLM(StreamingLM):
|
||||
def configure(self,layer,move):
|
||||
self.factor_layer=layer;self.move=move
|
||||
p=f'layers.{layer}.self_attn.'
|
||||
self.a=1+self.small(p+'q_norm.weight');self.b=1+self.small(p+'k_norm.weight')
|
||||
self.r=int(self.config['head_dim']*self.config['rope_parameters']['partial_rotary_factor'])
|
||||
self.joint=self.a[self.r:]*self.b[self.r:]
|
||||
|
||||
def normalization(self,x,name):
|
||||
p=f'layers.{self.factor_layer}.self_attn.'
|
||||
if name not in (p+'q_norm',p+'k_norm'):return super().normalization(x,name)
|
||||
# This path does not multiply the unit-gain tail, unlike a full-vector mask.
|
||||
unit=x/np.sqrt(np.mean(x*x,axis=-1,keepdims=True)+self.eps)
|
||||
isq=name==p+'q_norm';head=self.a if isq else self.b
|
||||
skip=(isq and self.move=='q_to_k') or (not isq and self.move=='k_to_q')
|
||||
tail=unit[...,self.r:] if skip else unit[...,self.r:]*self.joint
|
||||
return np.concatenate([unit[...,:self.r]*head[:self.r],tail],axis=-1)
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',required=True,type=Path);a=p.parse_args();root=a.root
|
||||
# Protocol is fixed before inspecting functional measurements.
|
||||
protocol={'fixed_intervention_layer':3,'directions':['q_to_k','k_to_q'],'diagnostic_layers':LAYERS,'no_selection':True,'no_training':True,'precision':'FP32 product; no BF16 requantization','quality_gate':{'mean_nll_delta':.01,'sequence_p95_nll_delta':.05}}
|
||||
protocol_path=root/'gain-factorization-protocol.json'
|
||||
if protocol_path.exists():
|
||||
old=json.loads(protocol_path.read_text());assert all(old[k]==v for k,v in protocol.items()), 'Protocol differs from preregistration'
|
||||
else:write_json(protocol_path,{**protocol,'registered_unix':time.time()})
|
||||
ledger_path=root/'compute-budget-ledger.json';ledger=json.loads(ledger_path.read_text())
|
||||
remaining=int(7200-ledger['spent_seconds']-30)
|
||||
if remaining<60:raise TimeoutError('No remaining cumulative budget for deterministic identity verification')
|
||||
start=time.monotonic()
|
||||
report={'state':'running','records':[],'interventions':[]}
|
||||
try:
|
||||
cfg=json.loads((root/'model_config.json').read_text());c=cfg['text_config'];r=int(c['head_dim']*c['rope_parameters']['partial_rotary_factor'])
|
||||
assert c['rms_norm_eps']==1e-6
|
||||
assert c['head_dim']==256 and r==64 and c['num_attention_heads']==8 and c['num_key_value_heads']==2
|
||||
lm=FactoredLM(root/'weights',cfg,seconds=remaining)
|
||||
data=np.load(root/'baseline-activations.npz');samples=json.loads((root/'samples-tokenized.json').read_text())['samples']
|
||||
rp=c['rope_parameters'];repeats=c['num_attention_heads']//c['num_key_value_heads']
|
||||
records=[]
|
||||
for layer in LAYERS:
|
||||
lm.guard()
|
||||
pfx=f'layers.{layer}.self_attn.'
|
||||
aw=lm.small(pfx+'q_norm.weight');bw=lm.small(pfx+'k_norm.weight');ag,bg=1+aw,1+bw
|
||||
q,k=data[f'qraw_{layer}'],data[f'kraw_{layer}']
|
||||
qr,kr=rope(norm(q,aw),rp['rope_theta'],rp['partial_rotary_factor']),rope(norm(k,bw),rp['rope_theta'],rp['partial_rotary_factor'])
|
||||
ref=np.einsum('bthd,bshd->bhts',qr,np.repeat(kr,repeats,axis=2))/np.float32(np.sqrt(c['head_dim']))
|
||||
mask=np.triu(np.ones(ref.shape[-2:],dtype=bool),1)
|
||||
def probs(s):
|
||||
s=np.where(mask,-np.inf,s);e=np.exp(s-s.max(-1,keepdims=True));return e/e.sum(-1,keepdims=True)
|
||||
pref=probs(ref)
|
||||
for move in ('q_to_k','k_to_q'):
|
||||
qq,kk=consolidate(q,k,ag,bg,r,move)
|
||||
qq,kk=rope(qq,rp['rope_theta'],rp['partial_rotary_factor']),rope(kk,rp['rope_theta'],rp['partial_rotary_factor'])
|
||||
changed=np.einsum('bthd,bshd->bhts',qq,np.repeat(kk,repeats,axis=2))/np.float32(np.sqrt(c['head_dim']))
|
||||
pp=probs(changed)
|
||||
for bi,s in enumerate(samples):
|
||||
diff=changed[bi].astype(np.float64)-ref[bi]
|
||||
records.append({'layer':layer,'direction':move,'sample_id':s['id'],'split':s['split'],
|
||||
'score_max_abs_error':float(np.abs(diff).max()),'score_relative_l2':float(np.linalg.norm(diff)/max(np.linalg.norm(ref[bi].astype(np.float64)),1e-12)),
|
||||
'probability_max_abs_error':float(np.abs(pp[bi]-pref[bi]).max()),**probability_metrics(pref[bi:bi+1],pp[bi:bi+1])})
|
||||
save_csv(root/'gain-factorization-score-metrics.csv',records)
|
||||
held=np.array([i for i,s in enumerate(samples) if s['split']=='heldout']);ids=np.array([s['token_ids'] for s in samples],dtype=np.int64)
|
||||
base=np.load(root/'baseline-heldout-token-nll.npy').mean(1)
|
||||
for move in ('q_to_k','k_to_q'):
|
||||
lm.configure(3,move)
|
||||
h,_=lm.forward(ids[held])
|
||||
nll=lm.nll(h,ids[held]);np.save(root/f'gain-factorization-{move}-token-nll.npy',nll)
|
||||
delta=nll.mean(1)-base
|
||||
report['interventions'].append({'layer':3,'direction':move,'sequence_nll_deltas':delta.tolist(),'mean_nll_delta':float(delta.mean()),'sequence_p95_delta':float(np.quantile(delta,.95)),'passed':bool(delta.mean()<=.01 and np.quantile(delta,.95)<=.05)})
|
||||
write_json(root/'gain-factorization-summary.json',report)
|
||||
# Local normalization timing uses precomputed gains for both implementations.
|
||||
q,k=data['qraw_3'][:1],data['kraw_3'][:1];pfx='layers.3.self_attn.'
|
||||
ag,bg=1+lm.small(pfx+'q_norm.weight'),1+lm.small(pfx+'k_norm.weight')
|
||||
def baseline():return normalized(q)*ag,normalized(k)*bg
|
||||
joint=ag[r:]*bg[r:]
|
||||
def factored():return consolidate(q,k,ag,bg,r,'q_to_k',joint=joint)
|
||||
for _ in range(3):baseline();factored()
|
||||
timing=[]
|
||||
for repeat in range(10):
|
||||
for label,fn in (('baseline',baseline),('factored',factored)) if repeat%2==0 else (('factored',factored),('baseline',baseline)):
|
||||
lm.guard();t=time.perf_counter()
|
||||
for _ in range(20):fn()
|
||||
timing.append({'repeat':repeat,'implementation':label,'seconds_per_call':(time.perf_counter()-t)/20})
|
||||
save_csv(root/'gain-factorization-kernel-timing.csv',timing)
|
||||
report.update(state='completed',maximum_score_abs_error=max(x['score_max_abs_error'] for x in records),maximum_probability_abs_error=max(x['probability_max_abs_error'] for x in records),
|
||||
bidirectional_heldout_pass=all(x['passed'] for x in report['interventions']),
|
||||
elementwise_gain_multiplies_saved_per_token_layer={'q_to_k':1536,'k_to_q':384},
|
||||
original_bf16_payload_bytes=1024,factored_lossless_mixed_payload_bytes=1024,
|
||||
fp32_cached_gain_payload_before=2048,fp32_cached_gain_payload_after=1280,
|
||||
claim_limit='Exact real-arithmetic identity only on non-RoPE coordinates; empirical FP32/NLL checks on tiny text pilot. Not evidence that two existing full layers interchange, not model-wide speedup.')
|
||||
except Exception as exc:
|
||||
report.update(state='stopped',error_type=type(exc).__name__,error=str(exc));raise
|
||||
finally:
|
||||
elapsed=time.monotonic()-start
|
||||
report.update(elapsed_seconds=elapsed,peak_rss_kib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
|
||||
ledger=json.loads(ledger_path.read_text());ledger['spent_seconds']+=elapsed;ledger['calls'].append({'module':'functional.gain_factorization','seconds':elapsed});write_json(ledger_path,ledger)
|
||||
write_json(root/'gain-factorization-summary.json',report)
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,247 @@
|
||||
"""Streaming FP32 text-only Qwen3.5 reference, original BF16 weights.
|
||||
|
||||
Mathematical semantics checked against Transformers Qwen3.5, commit
|
||||
fd3cf0140de03f7619ac95b5cfed05b711ff9e22 (Apache-2.0, Qwen Team/HuggingFace).
|
||||
No cached decode, padding, images, generation, fused kernels or autograd.
|
||||
Full-sequence gated delta recurrence replaces the algebraically equivalent
|
||||
chunk algorithm; both are independently compared in remote tests.
|
||||
"""
|
||||
import ctypes
|
||||
import json
|
||||
import time
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
from pilot.tensors import load_tensors, decode
|
||||
|
||||
PREFIX = 'model.language_model.'
|
||||
|
||||
|
||||
def sigmoid(x):
|
||||
return np.exp(-np.logaddexp(np.float32(0), -x))
|
||||
|
||||
|
||||
def silu(x):
|
||||
return x * sigmoid(x)
|
||||
|
||||
|
||||
def norm(x, weight, eps=1e-6, centered=True):
|
||||
return (x / np.sqrt(np.mean(x*x, axis=-1, keepdims=True) + eps)
|
||||
* (1 + weight if centered else weight)).astype(np.float32)
|
||||
|
||||
|
||||
def rope(x, theta=10000000., fraction=.25):
|
||||
# Text-only: all three MRoPE position axes coincide.
|
||||
dim = int(x.shape[-1] * fraction)
|
||||
inv = np.float32(1) / np.float32(theta) ** (np.arange(0, dim, 2, dtype=np.float32) / dim)
|
||||
freq = np.arange(x.shape[1], dtype=np.float32)[:, None] * inv[None, :]
|
||||
angle = np.concatenate([freq, freq], axis=-1)[None, :, None, :]
|
||||
a = x[..., :dim]
|
||||
rotated = np.concatenate([-a[..., dim//2:], a[..., :dim//2]], axis=-1)
|
||||
return np.concatenate([a*np.cos(angle) + rotated*np.sin(angle), x[..., dim:]], axis=-1)
|
||||
|
||||
|
||||
def delta_rule(q, k, v, g, beta):
|
||||
q = q / np.sqrt(np.sum(q*q, axis=-1, keepdims=True) + 1e-6)
|
||||
k = k / np.sqrt(np.sum(k*k, axis=-1, keepdims=True) + 1e-6)
|
||||
q = q / np.float32(np.sqrt(q.shape[-1]))
|
||||
state = np.zeros((q.shape[0], q.shape[2], q.shape[3], v.shape[3]), dtype=np.float32)
|
||||
out = np.empty_like(v)
|
||||
for t in range(q.shape[1]):
|
||||
state *= np.exp(g[:, t, :, None, None])
|
||||
predicted = np.sum(state * k[:, t, :, :, None], axis=-2)
|
||||
delta = (v[:, t] - predicted) * beta[:, t, :, None]
|
||||
state += k[:, t, :, :, None] * delta[:, :, None, :]
|
||||
out[:, t] = np.sum(state * q[:, t, :, :, None], axis=-2)
|
||||
return out, state
|
||||
|
||||
|
||||
def causal_conv(x, kernel):
|
||||
out = np.zeros_like(x)
|
||||
width = kernel.shape[-1]
|
||||
for j in range(width):
|
||||
lag = width - 1 - j
|
||||
if lag < x.shape[1]:
|
||||
out[:, lag:] += x[:, :x.shape[1]-lag] * kernel[:, j]
|
||||
return silu(out)
|
||||
|
||||
|
||||
def attention(q, k, v):
|
||||
repeats = q.shape[2] // k.shape[2]
|
||||
k, v = np.repeat(k, repeats, axis=2), np.repeat(v, repeats, axis=2)
|
||||
scores = np.einsum('bthd,bshd->bhts', q, k) / np.float32(np.sqrt(q.shape[-1]))
|
||||
mask = np.triu(np.ones(scores.shape[-2:], dtype=bool), 1)
|
||||
scores = np.where(mask, -np.inf, scores)
|
||||
exp = np.exp(scores - scores.max(axis=-1, keepdims=True))
|
||||
p = exp / exp.sum(axis=-1, keepdims=True)
|
||||
return np.einsum('bhts,bshd->bthd', p, v), p
|
||||
|
||||
|
||||
class StreamingLM:
|
||||
def __init__(self, weights, config, seconds=7200, enforce_memory=True):
|
||||
self.tensors = load_tensors(Path(weights))
|
||||
self.config = config.get('text_config', config)
|
||||
self.deadline = time.monotonic() + seconds
|
||||
self.enforce_memory = enforce_memory
|
||||
self.eps = self.config['rms_norm_eps']
|
||||
self.norm_replacement = None
|
||||
self.capture_qk = False
|
||||
self.qk_inputs = {}
|
||||
self.swap_observation = None
|
||||
self.swap_pressure_windows = 0
|
||||
self.malloc_trim = getattr(ctypes.CDLL(None), 'malloc_trim', None)
|
||||
|
||||
def guard(self):
|
||||
if time.monotonic() > self.deadline:
|
||||
raise TimeoutError('CPU computation deadline reached')
|
||||
if not self.enforce_memory:
|
||||
return
|
||||
status = dict(line.split(':', 1) for line in Path('/proc/self/status').read_text().splitlines() if ':' in line)
|
||||
rss_kib = int(status['VmRSS'].split()[0])
|
||||
available = int(next(line.split()[1] for line in Path('/proc/meminfo').read_text().splitlines() if line.startswith('MemAvailable:')))
|
||||
now = time.monotonic()
|
||||
if self.swap_observation is None or now-self.swap_observation[0] >= 5:
|
||||
counters = dict(line.split() for line in Path('/proc/vmstat').read_text().splitlines())
|
||||
count = int(counters['pswpin'])+int(counters['pswpout'])
|
||||
if self.swap_observation is not None:
|
||||
elapsed = now-self.swap_observation[0]
|
||||
rate = (count-self.swap_observation[1])*4096/elapsed
|
||||
self.swap_pressure_windows = self.swap_pressure_windows+1 if rate > 4*1024**2 else 0
|
||||
own_swap_kib = int(status.get('VmSwap', '0 kB').split()[0])
|
||||
if self.swap_pressure_windows >= 3 and (available < 384*1024 or own_swap_kib > 128*1024):
|
||||
raise MemoryError(f'Sustained host swap pressure plus constrained memory: available={available} KiB, process_swap={own_swap_kib} KiB')
|
||||
self.swap_observation = (now,count)
|
||||
if rss_kib > 512*1024 or available < 256*1024:
|
||||
raise MemoryError(f'Soft memory stop: RSS {rss_kib} KiB, available {available} KiB')
|
||||
|
||||
def small(self, name):
|
||||
t = self.tensors[PREFIX + name]
|
||||
if t.numel > 1048576:
|
||||
raise ValueError('Use blockwise linear for large tensors')
|
||||
x = t.read().reshape(t.shape)
|
||||
t.evict()
|
||||
return x
|
||||
|
||||
def linear(self, x, name, rows=256):
|
||||
t = self.tensors[PREFIX + name + '.weight']
|
||||
outdim, indim = t.shape
|
||||
flat = x.reshape(-1, indim)
|
||||
result = np.empty((flat.shape[0], outdim), dtype=np.float32)
|
||||
for start in range(0, outdim, rows):
|
||||
self.guard()
|
||||
end = min(start + rows, outdim)
|
||||
w = t.read(slice(start*indim, end*indim)).reshape(end-start, indim)
|
||||
result[:, start:end] = flat @ w.T
|
||||
del w
|
||||
t.evict()
|
||||
if self.malloc_trim is not None:
|
||||
self.malloc_trim(0) # Release only this process's freed temporary heap pages.
|
||||
return result.reshape(*x.shape[:-1], outdim)
|
||||
|
||||
def embedding(self, ids):
|
||||
t = self.tensors[PREFIX + 'embed_tokens.weight']
|
||||
raw = t.raw.reshape(t.shape)
|
||||
result = decode(raw[ids], t.dtype)
|
||||
t.evict()
|
||||
return result
|
||||
|
||||
def normalization(self, x, name):
|
||||
if getattr(self, 'norm_replacement', None) and name == self.norm_replacement[0]:
|
||||
name = self.norm_replacement[1]
|
||||
return norm(x, self.small(name + '.weight'), self.eps)
|
||||
|
||||
def mlp(self, h, layer):
|
||||
p = f'layers.{layer}.mlp.'
|
||||
gate = silu(self.linear(h, p+'gate_proj'))
|
||||
up = self.linear(h, p+'up_proj')
|
||||
return self.linear(gate*up, p+'down_proj')
|
||||
|
||||
def full_attention(self, h, layer, shared_p=None):
|
||||
p = f'layers.{layer}.self_attn.'
|
||||
c = self.config
|
||||
heads, kvheads, dim = c['num_attention_heads'], c['num_key_value_heads'], c['head_dim']
|
||||
# Q and output gate are interleaved per head, not globally split.
|
||||
mixed = self.linear(h, p+'q_proj').reshape(*h.shape[:-1], heads, 2*dim)
|
||||
q, gate = mixed[..., :dim], mixed[..., dim:]
|
||||
k = self.linear(h, p+'k_proj').reshape(*h.shape[:-1], kvheads, dim)
|
||||
v = self.linear(h, p+'v_proj').reshape(*h.shape[:-1], kvheads, dim)
|
||||
if getattr(self, 'capture_qk', False):
|
||||
self.qk_inputs[layer] = (q.copy(), k.copy())
|
||||
q = self.normalization(q, p+'q_norm')
|
||||
k = self.normalization(k, p+'k_norm')
|
||||
rp = c['rope_parameters']
|
||||
q, k = (rope(x, rp['rope_theta'], rp['partial_rotary_factor']) for x in (q,k))
|
||||
out, probs = attention(q,k,v)
|
||||
if shared_p is not None:
|
||||
out = np.einsum('bhts,bshd->bthd', shared_p, np.repeat(v, heads//kvheads, axis=2))
|
||||
out = (out*sigmoid(gate)).reshape(*h.shape[:-1], -1)
|
||||
return self.linear(out, p+'o_proj'), probs
|
||||
|
||||
def linear_attention(self, h, layer):
|
||||
p = f'layers.{layer}.linear_attn.'
|
||||
c = self.config
|
||||
kh, vh = c['linear_num_key_heads'], c['linear_num_value_heads']
|
||||
kd, vd = c['linear_key_head_dim'], c['linear_value_head_dim']
|
||||
qkv = self.linear(h, p+'in_proj_qkv')
|
||||
qkv = causal_conv(qkv, self.small(p+'conv1d.weight')[:,0,:])
|
||||
q, k, v = np.split(qkv, [kh*kd, 2*kh*kd], axis=-1)
|
||||
q = q.reshape(*h.shape[:-1], kh, kd)
|
||||
k = k.reshape(*h.shape[:-1], kh, kd)
|
||||
v = v.reshape(*h.shape[:-1], vh, vd)
|
||||
if vh != kh:
|
||||
q, k = np.repeat(q, vh//kh, axis=2), np.repeat(k, vh//kh, axis=2)
|
||||
z = self.linear(h, p+'in_proj_z').reshape(*h.shape[:-1], vh, vd)
|
||||
beta = sigmoid(self.linear(h, p+'in_proj_b'))
|
||||
a = self.linear(h, p+'in_proj_a')
|
||||
g = -np.exp(self.small(p+'A_log')) * np.logaddexp(np.float32(0), a+self.small(p+'dt_bias'))
|
||||
out, _ = delta_rule(q,k,v,g,beta)
|
||||
out = norm(out, self.small(p+'norm.weight'), self.eps, centered=False)*silu(z)
|
||||
return self.linear(out.reshape(*h.shape[:-1], -1), p+'out_proj')
|
||||
|
||||
def forward(self, ids, capture=None, replacement=None, progress=None):
|
||||
h = self.embedding(ids)
|
||||
saved = {}
|
||||
capture = set(capture or [])
|
||||
for layer, kind in enumerate(self.config['layer_types']):
|
||||
self.guard()
|
||||
raw = h
|
||||
n = self.normalization(h, f'layers.{layer}.input_layernorm')
|
||||
if ('attn', layer) in capture:
|
||||
saved[f'attn_{layer}'] = n.copy()
|
||||
donor = replacement[2] if replacement and replacement[:2] == ('attn',layer) else layer
|
||||
if kind == 'full_attention':
|
||||
out, _ = self.full_attention(n,donor)
|
||||
else:
|
||||
out = self.linear_attention(n,donor)
|
||||
h = raw + out
|
||||
n = self.normalization(h, f'layers.{layer}.post_attention_layernorm')
|
||||
if ('mlp',layer) in capture:
|
||||
saved[f'mlp_{layer}'] = n.copy()
|
||||
donor = replacement[2] if replacement and replacement[:2] == ('mlp',layer) else layer
|
||||
h = h + self.mlp(n,donor)
|
||||
if not np.isfinite(h).all():
|
||||
raise FloatingPointError(f'Nonfinite hidden states at layer {layer}')
|
||||
if progress:
|
||||
progress(layer)
|
||||
return self.normalization(h,'norm'), saved
|
||||
|
||||
def nll(self, h, ids, rows=512):
|
||||
# Tied output embedding; online logsumexp avoids full vocabulary logits.
|
||||
x = h[:,:-1].reshape(-1,h.shape[-1])
|
||||
targets = ids[:,1:].reshape(-1)
|
||||
t = self.tensors[PREFIX+'embed_tokens.weight']
|
||||
mx = np.full(x.shape[0],-np.inf,dtype=np.float64)
|
||||
total = np.zeros(x.shape[0],dtype=np.float64)
|
||||
correct = np.empty(x.shape[0],dtype=np.float64)
|
||||
for start in range(0,t.shape[0],rows):
|
||||
self.guard()
|
||||
end=min(start+rows,t.shape[0])
|
||||
w=t.read(slice(start*t.shape[1],end*t.shape[1])).reshape(end-start,t.shape[1])
|
||||
scores=x@w.T
|
||||
m=np.maximum(mx,scores.max(axis=-1))
|
||||
total=total*np.exp(mx-m)+np.exp(scores-m[:,None]).sum(axis=-1)
|
||||
mx=m
|
||||
which=(targets>=start)&(targets<end)
|
||||
correct[which]=scores[np.flatnonzero(which),targets[which]-start]
|
||||
del w,scores
|
||||
t.evict()
|
||||
return (mx+np.log(total)-correct).reshape(ids.shape[0],-1)
|
||||
@@ -0,0 +1,134 @@
|
||||
"""Find repeated learned scalar MLP functions on real hidden inputs, no training.
|
||||
|
||||
Four fixed layers; calibration-only selection; one frozen pair; independent heldout
|
||||
functional test and two actual network substitutions. No scale fitting or R.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import resource
|
||||
import time
|
||||
import numpy as np
|
||||
from .model import StreamingLM,silu
|
||||
from .run import write_json,save_csv
|
||||
|
||||
LAYERS=[5,6,20,21]
|
||||
|
||||
|
||||
def pair_metrics(x,y):
|
||||
x,y=x.astype(np.float64),y.astype(np.float64)
|
||||
xx,yy=float(x@x),float(y@y);delta=float((x-y)@(x-y))
|
||||
xc,yc=x-x.mean(),y-y.mean()
|
||||
return {'relative_l2_a_to_b':float(np.sqrt(delta/max(xx,1e-30))),
|
||||
'relative_l2_b_to_a':float(np.sqrt(delta/max(yy,1e-30))),
|
||||
'cosine':float(x@y/max(np.sqrt(xx*yy),1e-30)),
|
||||
'pearson':float(xc@yc/max(np.linalg.norm(xc)*np.linalg.norm(yc),1e-30)),
|
||||
'rms_a':float(np.sqrt(xx/x.size)),'rms_b':float(np.sqrt(yy/y.size)),
|
||||
'std_over_rms_a':float(np.std(x)/max(np.sqrt(xx/x.size),1e-30)),
|
||||
'std_over_rms_b':float(np.std(y)/max(np.sqrt(yy/y.size),1e-30)),
|
||||
'effective_energy_tokens_a':float(xx*xx/max(float((x**4).sum()),1e-30)),
|
||||
'effective_energy_tokens_b':float(yy*yy/max(float((y**4).sum()),1e-30))}
|
||||
|
||||
|
||||
class NeuronReuseLM(StreamingLM):
|
||||
def configure(self,layer,target,donor):self.reused_layer,self.target,self.donor=layer,target,donor
|
||||
def mlp(self,h,layer):
|
||||
p=f'layers.{layer}.mlp.'
|
||||
z=silu(self.linear(h,p+'gate_proj'))*self.linear(h,p+'up_proj')
|
||||
if layer==self.reused_layer:z[...,self.target]=z[...,self.donor]
|
||||
return self.linear(z,p+'down_proj')
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);a=p.parse_args();root=a.root
|
||||
protocol={'layers':LAYERS,'unit':'post_silu_gate_times_up_scalar_function; keep each output column',
|
||||
'thresholds':[.05,.10,.20],'maximum_directional_relative_l2':.20,'cosine_min':.98,'pearson_min':.95,
|
||||
'rms_floor':'at least within-layer median calibration neuron RMS','std_over_rms_min':.25,
|
||||
'effective_energy_tokens_min':16,'max_selected_pairs':1,'selection':'smallest worst directional calibration error; then layer/id',
|
||||
'heldout_per_text_error_max':.35,'heldout_quality_mean_nll_delta_max':.01,'heldout_quality_sequence_p95_delta_max':.05,
|
||||
'training':False,'scale_fitting':False,'cost_required':False}
|
||||
protocol_path=root/'neuron-reuse-protocol.json'
|
||||
if protocol_path.exists():
|
||||
old=json.loads(protocol_path.read_text());assert all(old[k]==v for k,v in protocol.items())
|
||||
else:write_json(protocol_path,{**protocol,'registered_unix':time.time()})
|
||||
ledger_path=root/'compute-budget-ledger.json';ledger=json.loads(ledger_path.read_text());remaining=int(7200-ledger['spent_seconds']-30)
|
||||
if remaining<120:raise TimeoutError('Remaining cumulative budget insufficient')
|
||||
started=time.monotonic();result={'state':'running','selected':None,'function_pass':False,'interventions':[]}
|
||||
try:
|
||||
cfg=json.loads((root/'model_config.json').read_text());lm=NeuronReuseLM(root/'weights',cfg,seconds=remaining)
|
||||
data=np.load(root/'baseline-activations.npz');samples=json.loads((root/'samples-tokenized.json').read_text())['samples']
|
||||
cal=np.array([i for i,s in enumerate(samples) if s['split']=='calibration']);held=np.array([i for i,s in enumerate(samples) if s['split']=='heldout'])
|
||||
activations={};summaries=[];best=None
|
||||
for layer in LAYERS:
|
||||
h=data[f'mlp_{layer}'];pfx=f'layers.{layer}.mlp.'
|
||||
z=silu(lm.linear(h,pfx+'gate_proj'))*lm.linear(h,pfx+'up_proj');activations[layer]=z
|
||||
# Profiles use all calibration tokens; never use heldout in selection.
|
||||
x=np.ascontiguousarray(z[cal].reshape(-1,z.shape[-1]).T,dtype=np.float64)
|
||||
n=x.shape[1];normsq=(x*x).sum(1);means=x.mean(1);variance=np.maximum(normsq-n*means**2,0)
|
||||
rms=np.sqrt(normsq/n);floor=float(np.median(rms));effective=normsq**2/np.maximum((x**4).sum(1),1e-30)
|
||||
active=(rms>=floor)&(np.sqrt(variance/np.maximum(normsq,1e-30))>=.25)&(effective>=16)
|
||||
counts={str(t):0 for t in protocol['thresholds']};tested=0;layerbest=None
|
||||
for start in range(0,x.shape[0],256):
|
||||
lm.guard();end=min(start+256,x.shape[0]);dot=x[start:end]@x.T
|
||||
delta=np.maximum(normsq[start:end,None]+normsq[None,:]-2*dot,0)
|
||||
error=np.sqrt(delta/np.maximum(np.minimum(normsq[start:end,None],normsq[None,:]),1e-30))
|
||||
cosine=dot/np.maximum(np.sqrt(normsq[start:end,None]*normsq[None,:]),1e-30)
|
||||
pearson=(dot-n*means[start:end,None]*means[None,:])/np.maximum(np.sqrt(variance[start:end,None]*variance[None,:]),1e-30)
|
||||
unique=np.arange(start,end)[:,None]<np.arange(x.shape[0])[None,:]
|
||||
allowed=unique&active[start:end,None]&active[None,:]&(cosine>=.98)&(pearson>=.95)
|
||||
tested+=int((unique&active[start:end,None]&active[None,:]).sum())
|
||||
for threshold in protocol['thresholds']:counts[str(threshold)]+=int((allowed&(error<=threshold)).sum())
|
||||
mask=allowed&(error<=.20)
|
||||
if mask.any():
|
||||
score=np.where(mask,error,np.inf);row,col=np.unravel_index(np.argmin(score),score.shape)
|
||||
candidate={'layer':layer,'a':int(start+row),'b':int(col),'calibration_worst_relative_l2':float(score[row,col])}
|
||||
key=lambda c:(c['calibration_worst_relative_l2'],c['layer'],c['a'],c['b'])
|
||||
if layerbest is None or key(candidate)<key(layerbest):layerbest=candidate
|
||||
if best is None or key(candidate)<key(best):best=candidate
|
||||
summaries.append({'layer':layer,'neurons':int(x.shape[0]),'eligible_neurons':int(active.sum()),'eligible_unique_pairs_checked':tested,'rms_floor':floor,'calibration_pair_counts':counts,'best':layerbest})
|
||||
write_json(root/'neuron-reuse-search-summary.json',summaries)
|
||||
print(json.dumps(summaries[-1]),flush=True)
|
||||
np.savez(root/'neuron-reuse-activations.npz',**{f'layer{k}':v for k,v in activations.items()})
|
||||
write_json(root/'neuron-reuse-selection.json',{'selected':best,'selection_uses_heldout':False})
|
||||
result['selected']=best
|
||||
if best is not None:
|
||||
layer,i,j=best['layer'],best['a'],best['b'];z=activations[layer]
|
||||
metrics=[]
|
||||
for split,index in [('calibration',cal),('heldout',held)]:
|
||||
metrics.append({'split':split,'scope':'pooled',**pair_metrics(z[index,:,i].reshape(-1),z[index,:,j].reshape(-1))})
|
||||
for idx in index:metrics.append({'split':split,'scope':samples[idx]['id'],**pair_metrics(z[idx,:,i],z[idx,:,j])})
|
||||
save_csv(root/'neuron-reuse-function-metrics.csv',metrics)
|
||||
pooled=next(r for r in metrics if r['split']=='heldout' and r['scope']=='pooled')
|
||||
floor=next(r['rms_floor'] for r in summaries if r['layer']==layer)
|
||||
function_pass=(max(pooled['relative_l2_a_to_b'],pooled['relative_l2_b_to_a'])<=.20 and pooled['cosine']>=.98 and pooled['pearson']>=.95 and
|
||||
min(pooled['std_over_rms_a'],pooled['std_over_rms_b'])>=.25 and min(pooled['effective_energy_tokens_a'],pooled['effective_energy_tokens_b'])>=16 and
|
||||
min(pooled['rms_a'],pooled['rms_b'])>=floor and
|
||||
all(max(r['relative_l2_a_to_b'],r['relative_l2_b_to_a'])<=.35 for r in metrics if r['split']=='heldout' and r['scope']!='pooled'))
|
||||
result.update(function_pass=bool(function_pass),heldout_function_metrics=pooled)
|
||||
# Show parameter similarity separately from actual functional similarity.
|
||||
wd=[]
|
||||
for role in ('gate_proj','up_proj'):
|
||||
t=lm.tensors[f'model.language_model.layers.{layer}.mlp.{role}.weight'];d=t.shape[1]
|
||||
wa,wb=t.read(slice(i*d,(i+1)*d)),t.read(slice(j*d,(j+1)*d))
|
||||
wd.append({'role':role,'weight_cosine':float(wa.astype(np.float64)@wb/max(np.linalg.norm(wa.astype(np.float64))*np.linalg.norm(wb.astype(np.float64)),1e-30))});t.evict()
|
||||
result['weight_diagnostics']=wd
|
||||
if function_pass:
|
||||
ids=np.array([s['token_ids'] for s in samples],dtype=np.int64);base=np.load(root/'baseline-heldout-token-nll.npy').mean(1)
|
||||
for target,donor in ((i,j),(j,i)):
|
||||
lm.configure(layer,target,donor);h,_=lm.forward(ids[held]);nll=lm.nll(h,ids[held])
|
||||
np.save(root/f'neuron-reuse-{target}-uses-{donor}-token-nll.npy',nll)
|
||||
delta=nll.mean(1)-base
|
||||
result['interventions'].append({'target':target,'donor':donor,'sequence_nll_deltas':delta.tolist(),'mean_nll_delta':float(delta.mean()),'sequence_p95_delta':float(np.quantile(delta,.95)),'passed':bool(delta.mean()<=.01 and np.quantile(delta,.95)<=.05)})
|
||||
write_json(root/'neuron-reuse-summary.json',result)
|
||||
# No fallback after looking at heldout.
|
||||
result.update(state='completed',empirical_repeated_function_positive=bool(result['function_pass'] and len(result['interventions'])==2 and all(r['passed'] for r in result['interventions'])),
|
||||
claim_limit='Distinct learned scalar MLP subfunctions on the specified short-text distribution; not whole-layer duplication, global equivalence or broad task-capability proof. No performance requirement.')
|
||||
except Exception as exc:result.update(state='stopped',error_type=type(exc).__name__,error=str(exc));raise
|
||||
finally:
|
||||
elapsed=time.monotonic()-started;result.update(elapsed_seconds=elapsed,peak_rss_kib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
|
||||
ledger=json.loads(ledger_path.read_text());ledger['spent_seconds']+=elapsed;ledger['calls'].append({'module':'functional.neuron_reuse','seconds':elapsed});write_json(ledger_path,ledger)
|
||||
write_json(root/'neuron-reuse-summary.json',result)
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,108 @@
|
||||
"""Existing learned RMSNorm modules: uniform function bound + independent probes.
|
||||
|
||||
Deterministic exhaustive selection by a mathematical all-input error bound, not
|
||||
calibration/heldout fitting. Same role, shape and eps; one pair only.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import resource
|
||||
import time
|
||||
import numpy as np
|
||||
from .model import StreamingLM,norm
|
||||
from .run import write_json,save_csv,error_rows
|
||||
|
||||
ROLES=['input_layernorm','post_attention_layernorm']
|
||||
|
||||
|
||||
def uniform_bounds(a,b):
|
||||
if np.any(a==0) or np.any(b==0):return None
|
||||
diff=np.abs(a.astype(np.float64)-b.astype(np.float64))
|
||||
return float(np.max(diff/np.abs(a))),float(np.max(diff/np.abs(b)))
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);args=p.parse_args();root=args.root
|
||||
protocol={'roles':ROLES,'layers':list(range(24)),'same_role_only':True,'same_eps':1e-6,
|
||||
'uniform_worst_error_limit':.20,'empirical_function_worst_relative_error_limit':.05,
|
||||
'selection':'smallest maximum two-direction uniform bound, then role/layer; no input data used',
|
||||
'minimum_gain_standard_deviation':.001,'max_selected_pairs':1,'heldout_nll_mean_delta_limit':.01,
|
||||
'heldout_nll_sequence_p95_delta_limit':.05,'training':False,'cost_required':False}
|
||||
path=root/'norm-repetition-protocol.json'
|
||||
if path.exists():
|
||||
existing=json.loads(path.read_text());assert all(existing[k]==v for k,v in protocol.items())
|
||||
else:write_json(path,{**protocol,'registered_unix':time.time()})
|
||||
ledger_path=root/'compute-budget-ledger.json';ledger=json.loads(ledger_path.read_text());remaining=int(7200-ledger['spent_seconds']-30)
|
||||
if remaining<120:raise TimeoutError('Insufficient cumulative computation budget')
|
||||
started=time.monotonic();result={'state':'running','selected':None,'interventions':[]}
|
||||
try:
|
||||
cfg=json.loads((root/'model_config.json').read_text());lm=StreamingLM(root/'weights',cfg,seconds=remaining)
|
||||
assert lm.eps==1e-6
|
||||
candidates=[];gains={}
|
||||
for role in ROLES:
|
||||
for layer in range(24):gains[(role,layer)]=1+lm.small(f'layers.{layer}.{role}.weight')
|
||||
for i in range(24):
|
||||
for j in range(i+1,24):
|
||||
a,b=gains[(role,i)],gains[(role,j)]
|
||||
bounds=uniform_bounds(a,b)
|
||||
if bounds is None:continue
|
||||
eligible=min(float(np.std(a)),float(np.std(b)))>=.001
|
||||
candidates.append({'role':role,'a':i,'b':j,'a_to_b_uniform_bound':bounds[0],'b_to_a_uniform_bound':bounds[1],
|
||||
'worst_uniform_bound':max(bounds),'eligible_nonconstant_gains':eligible,
|
||||
'gain_std_a':float(np.std(a)),'gain_std_b':float(np.std(b)),
|
||||
'gain_min_a':float(np.min(a)),'gain_min_b':float(np.min(b))})
|
||||
save_csv(root/'norm-repetition-uniform-bounds.csv',candidates)
|
||||
feasible=[c for c in candidates if c['eligible_nonconstant_gains'] and c['worst_uniform_bound']<=.20]
|
||||
counts={str(t):sum(c['eligible_nonconstant_gains'] and c['worst_uniform_bound']<=t for c in candidates) for t in (.05,.10,.20)}
|
||||
selected=sorted(feasible,key=lambda c:(c['worst_uniform_bound'],c['role'],c['a'],c['b']))[:1]
|
||||
write_json(root/'norm-repetition-selection.json',{'selected':selected,'uniform_bound_counts':counts,'selection_reads_no_input_data':True})
|
||||
result['uniform_bound_counts']=counts
|
||||
if selected:
|
||||
c=selected[0];result['selected']=c
|
||||
# Selection is frozen before reading tokenized inputs or their activations.
|
||||
samples=json.loads((root/'samples-tokenized.json').read_text())['samples'];ids=np.array([s['token_ids'] for s in samples],dtype=np.int64)
|
||||
held=np.array([i for i,s in enumerate(samples) if s['split']=='heldout'])
|
||||
kind='attn' if c['role']=='input_layernorm' else 'mlp'
|
||||
captures=[(kind,c['a']),(kind,c['b'])]
|
||||
h,saved=lm.forward(ids,capture=captures)
|
||||
# The untouched recomputation must reproduce the saved real baseline.
|
||||
original=np.load(root/'baseline-activations.npz')['final']
|
||||
np.testing.assert_array_equal(h,original)
|
||||
np.savez(root/'norm-repetition-input-profiles.npz',**saved)
|
||||
ga,gb=gains[(c['role'],c['a'])],gains[(c['role'],c['b'])]
|
||||
rows=[]
|
||||
for source in (c['a'],c['b']):
|
||||
n=saved[f'{kind}_{source}'];g=gains[(c['role'],source)]
|
||||
# n = u * gamma_source. Reconstruct common normalized input u;
|
||||
# source gains are nonzero. Additional rounding is ~FP32 only.
|
||||
unit=n/g
|
||||
fa,fb=unit*ga,unit*gb
|
||||
rec=error_rows(fa,fb,samples,{'source_layer':source,'role':c['role'],'a':c['a'],'b':c['b']})
|
||||
rows.extend(rec)
|
||||
save_csv(root/'norm-repetition-function-metrics.csv',rows)
|
||||
heldrows=[r for r in rows if r['split']=='heldout']
|
||||
function_pass=all(max(r['relative_l2'],r['reverse_relative_l2'])<=.05 for r in heldrows)
|
||||
result.update(uniform_function_similarity_proven=True,heldout_function_pass=bool(function_pass),
|
||||
worst_heldout_relative_l2=max(max(r['relative_l2'],r['reverse_relative_l2']) for r in heldrows),
|
||||
worst_heldout_cosine=min(r['cosine'] for r in heldrows),untouched_full_forward_bitwise_matches_baseline=True)
|
||||
if function_pass:
|
||||
baseline=np.load(root/'baseline-heldout-token-nll.npy').mean(1)
|
||||
for target,donor in ((c['a'],c['b']),(c['b'],c['a'])):
|
||||
lm.norm_replacement=(f'layers.{target}.{c["role"]}',f'layers.{donor}.{c["role"]}')
|
||||
changed,_=lm.forward(ids[held]);nll=lm.nll(changed,ids[held]);np.save(root/f'norm-repetition-{target}-uses-{donor}-token-nll.npy',nll)
|
||||
delta=nll.mean(1)-baseline
|
||||
result['interventions'].append({'target':target,'donor':donor,'sequence_nll_deltas':delta.tolist(),
|
||||
'mean_nll_delta':float(delta.mean()),'sequence_p95_nll_delta':float(np.quantile(delta,.95)),
|
||||
'passed_quality':bool(delta.mean()<=.01 and np.quantile(delta,.95)<=.05)})
|
||||
write_json(root/'norm-repetition-summary.json',result)
|
||||
result['learned_function_repetition_positive']=bool(function_pass)
|
||||
result['bidirectional_network_quality_pass']=bool(len(result['interventions'])==2 and all(x['passed_quality'] for x in result['interventions']))
|
||||
result.update(state='completed',claim_limit='Existing learned RMSNorm module functions with identical eps and shape; uniform real-arithmetic relative bound and tiny real-text probes. Does not establish attention/MLP-body duplication or broad task capability.')
|
||||
except Exception as exc:result.update(state='stopped',error_type=type(exc).__name__,error=str(exc));raise
|
||||
finally:
|
||||
elapsed=time.monotonic()-started;result.update(elapsed_seconds=elapsed,peak_rss_kib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
|
||||
ledger=json.loads(ledger_path.read_text());ledger['spent_seconds']+=elapsed;ledger['calls'].append({'module':'functional.norm_repetition','seconds':elapsed});write_json(ledger_path,ledger)
|
||||
write_json(root/'norm-repetition-summary.json',result)
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,46 @@
|
||||
"""Package code-independent scientific outputs, retain large activation caches externally.
|
||||
|
||||
The experiment directory remains immutable and complete. The delivery directory
|
||||
contains all figure source tables/NLL arrays plus hashes/locations for three large
|
||||
reproducible activation caches. Never deletes model weights or cache files.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
from .run import write_json
|
||||
|
||||
CACHES={'baseline-activations.npz','neuron-reuse-activations.npz','norm-repetition-input-profiles.npz'}
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',required=True,type=Path);p.add_argument('--output',required=True,type=Path);a=p.parse_args()
|
||||
root,out=a.root.resolve(),a.output.resolve();assert root!=out
|
||||
out.mkdir(parents=True,exist_ok=True)
|
||||
full=json.loads((root/'checksums-functional.json').read_text())
|
||||
files=json.loads((root/'archive-files.json').read_text())
|
||||
for name in files:
|
||||
src=root/name
|
||||
if name in CACHES:continue
|
||||
dest=out/name;dest.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(src,dest)
|
||||
external=[]
|
||||
for name in sorted(CACHES):
|
||||
src=root/name;digest=hashlib.sha256(src.read_bytes()).hexdigest();assert digest==full[name]
|
||||
external.append({'name':name,'server_path':str(src),'bytes':src.stat().st_size,'sha256':digest,'retained':True,'reproducible_by':'functional.run / functional.neuron_reuse / functional.norm_repetition'})
|
||||
write_json(out/'external-activation-cache.json',{'host':'8.211.154.134','files':external,'not_model_weights':True,
|
||||
'reason':'Large intermediate caches retained on the authorized server; all figure source tables and token NLL arrays are delivered in Git.'})
|
||||
shutil.copy2(root/'checksums-functional.json',out/'checksums-full-server.json')
|
||||
(out/'DELIVERY.md').write_text('# Scientific delivery and retained caches\n\nAll figure CSV/JSON source data, per-token NLL, protocols, reports, metadata and historical logs are included.\nThree large reproducible intermediate activation caches remain on 8.211.154.134 and in the original full local archive;\n`external-activation-cache.json` records exact locations, sizes and SHA256. No weight or cache was deleted.\nThe original full experiment manifest is `checksums-full-server.json`; the delivery-only manifest is\n`checksums-functional.json`. No model checkpoint or tokenizer payload is in this Git delivery.\n')
|
||||
validation=json.loads((out/'audit-validation.json').read_text());validation.update(delivery_excludes_external_activation_caches=True,full_experiment_checksums='checksums-full-server.json',figure_source_tables_and_token_nll_complete=True)
|
||||
write_json(out/'audit-validation.json',validation)
|
||||
checks={}
|
||||
for file in sorted(out.rglob('*')):
|
||||
if file.is_file() and file.name not in ('checksums-functional.json','audit-validation.json','archive-files.json'):
|
||||
checks[str(file.relative_to(out))]=hashlib.sha256(file.read_bytes()).hexdigest()
|
||||
write_json(out/'checksums-functional.json',checks)
|
||||
write_json(out/'archive-files.json',[*checks,'checksums-functional.json','audit-validation.json','archive-files.json'])
|
||||
print(json.dumps({'delivery_files':len(checks)+3,'checksummed_files':len(checks),'external_caches':len(external),'weights_and_caches_retained':True}))
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,39 @@
|
||||
"""One 8-token real text, bounded memory/semantic capacity smoke check."""
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import resource
|
||||
import time
|
||||
import numpy as np
|
||||
from .model import StreamingLM
|
||||
from .run import tokenize,write_json
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',required=True,type=Path);a=p.parse_args()
|
||||
samples,ids=tokenize(a.root)
|
||||
start=time.time()
|
||||
lm=StreamingLM(a.root/'weights',json.loads((a.root/'model_config.json').read_text()),seconds=1200)
|
||||
snapshots=[]
|
||||
result={'passed':False,'sample_id':samples[0]['id'],'tokens':8}
|
||||
def progress(layer):
|
||||
status=dict(line.split(':',1) for line in Path('/proc/self/status').read_text().splitlines() if ':' in line)
|
||||
snapshots.append({'layer':layer,'seconds':time.time()-start,'rss_kib':int(status['VmRSS'].split()[0]),
|
||||
'process_swap_kib':int(status.get('VmSwap','0 kB').split()[0]),
|
||||
'available_kib':int(next(line.split()[1] for line in Path('/proc/meminfo').read_text().splitlines() if line.startswith('MemAvailable:')))})
|
||||
print(json.dumps(snapshots[-1]),flush=True)
|
||||
try:
|
||||
h,_=lm.forward(ids[:1,:8],progress=progress)
|
||||
nll=lm.nll(h,ids[:1,:8])
|
||||
if not np.isfinite(nll).all():raise FloatingPointError('Nonfinite NLL')
|
||||
result.update(passed=True,mean_nll=float(nll.mean()),token_nll=nll.tolist())
|
||||
except Exception as exc:
|
||||
result.update(error_type=type(exc).__name__,error=str(exc))
|
||||
raise
|
||||
finally:
|
||||
result.update(elapsed_seconds=time.time()-start,peak_rss_kib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss,
|
||||
resource_snapshots=snapshots,limitation='Real-weight capacity check, not an independent correctness oracle or quality benchmark')
|
||||
write_json(a.root/'preflight.json',result)
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"commit": "fd3cf0140de03f7619ac95b5cfed05b711ff9e22",
|
||||
"url": "https://raw.githubusercontent.com/huggingface/transformers/fd3cf0140de03f7619ac95b5cfed05b711ff9e22/src/transformers/models/qwen3_5/modeling_qwen3_5.py",
|
||||
"sha256": "4463b8a108f678c166755101d95f188179f54143305953d78147de0389b80ebc"
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
"""Remote-only numerical comparison with pinned official Torch definitions.
|
||||
|
||||
Reads only a known official Transformers source file; extracts named mathematical
|
||||
operators/classes via AST, removing optional kernel decorators. Never imports the
|
||||
complete model or executes checkpoint repository code. No compilation/build.
|
||||
"""
|
||||
import argparse
|
||||
import ast
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
import numpy as np
|
||||
from .model import StreamingLM, delta_rule, rope, norm
|
||||
|
||||
EXPECTED_COMMIT = 'fd3cf0140de03f7619ac95b5cfed05b711ff9e22'
|
||||
NAMES = {'apply_mask_to_padding_states', 'l2norm', 'torch_chunk_gated_delta_rule', 'torch_recurrent_gated_delta_rule',
|
||||
'causal_conv1d_fn', 'Qwen3_5RMSNormGated', 'Qwen3_5GatedDeltaNet',
|
||||
'rotate_half', 'apply_rotary_pos_emb', 'repeat_kv', 'eager_attention_forward',
|
||||
'Qwen3_5Attention', 'Qwen3_5MLP', 'Qwen3_5RMSNorm', 'Qwen3_5DecoderLayer',
|
||||
'Qwen3_5TextRotaryEmbedding'}
|
||||
|
||||
|
||||
def official_namespace(source):
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
tree = ast.parse(source)
|
||||
nodes = []
|
||||
for node in tree.body:
|
||||
if isinstance(node, (ast.FunctionDef, ast.ClassDef)) and node.name in NAMES:
|
||||
for child in ast.walk(node):
|
||||
if isinstance(child, (ast.FunctionDef, ast.ClassDef)):
|
||||
child.decorator_list = [d for d in child.decorator_list if isinstance(d, ast.Name) and d.id in ('staticmethod','classmethod')]
|
||||
nodes.append(node)
|
||||
assert {x.name for x in nodes} == NAMES
|
||||
tree = ast.Module(body=[ast.ImportFrom(module='__future__',names=[ast.alias(name='annotations')],level=0),*nodes],type_ignores=[])
|
||||
ns = {'torch':torch, 'nn':torch.nn, 'F':F, 'ACT2FN':{'silu':F.silu},
|
||||
'GradientCheckpointingLayer':torch.nn.Module,
|
||||
'is_torchdynamo_exporting':lambda:False,
|
||||
'ALL_ATTENTION_FUNCTIONS':SimpleNamespace(get_interface=lambda name, fallback:fallback)}
|
||||
exec(compile(ast.fix_missing_locations(tree),'pinned_transformers_reference','exec'),ns)
|
||||
return ns
|
||||
|
||||
|
||||
class ArrayLM(StreamingLM):
|
||||
def __init__(self, arrays, config):
|
||||
self.arrays, self.config, self.eps = arrays,config,config['rms_norm_eps']
|
||||
def guard(self):
|
||||
pass
|
||||
def small(self,name):
|
||||
return self.arrays[name]
|
||||
def linear(self,x,name,rows=256):
|
||||
return x@self.arrays[name+'.weight'].T
|
||||
def embedding(self,ids):
|
||||
return self.arrays['embed_tokens.weight'][ids]
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--source',type=Path,required=True);p.add_argument('--output',type=Path,required=True)
|
||||
a=p.parse_args()
|
||||
import torch
|
||||
torch.set_num_threads(1)
|
||||
torch.manual_seed(42)
|
||||
provenance=json.loads(Path(__file__).with_name('reference.json').read_text())
|
||||
assert hashlib.sha256(a.source.read_bytes()).hexdigest()==provenance['sha256'], 'Reference source hash mismatch'
|
||||
ns=official_namespace(a.source.read_text())
|
||||
cfg={'hidden_size':16,'num_attention_heads':2,'num_key_value_heads':1,'head_dim':8,
|
||||
'intermediate_size':24,'hidden_act':'silu','attention_bias':False,'attention_dropout':0.,
|
||||
'linear_num_value_heads':2,'linear_num_key_heads':2,'linear_key_head_dim':4,
|
||||
'linear_value_head_dim':4,'linear_conv_kernel_dim':4,'rms_norm_eps':1e-6,
|
||||
'layer_types':['linear_attention','full_attention'],'max_position_embeddings':4096,
|
||||
'rope_parameters':{'rope_type':'default','rope_theta':10000000.,'partial_rotary_factor':.5,'mrope_section':[1,0,0]},
|
||||
'_attn_implementation':'eager'}
|
||||
config=SimpleNamespace(**cfg)
|
||||
layers=[ns['Qwen3_5DecoderLayer'](config,i).eval() for i in range(2)]
|
||||
for layer in layers:
|
||||
for name,t in layer.named_parameters():
|
||||
with torch.no_grad():
|
||||
t.uniform_(-.2,.2)
|
||||
if name=='linear_attn.norm.weight':t.add_(1.)
|
||||
arrays={f'layers.{i}.'+k:v.detach().numpy().copy() for i,l in enumerate(layers) for k,v in l.state_dict().items()}
|
||||
lm=ArrayLM(arrays,cfg)
|
||||
rng=np.random.default_rng(123)
|
||||
x=rng.standard_normal((2,7,16),dtype=np.float32)
|
||||
tx=torch.from_numpy(x)
|
||||
positions=torch.arange(7)[None,:]
|
||||
rotary=ns['Qwen3_5TextRotaryEmbedding'](config)
|
||||
cos,sin=rotary(tx,positions)
|
||||
mask=torch.triu(torch.full((7,7),-float('inf')),diagonal=1)[None,None]
|
||||
evidence=[]
|
||||
def check(name,actual,expected,atol=2e-5,rtol=2e-5):
|
||||
actual=np.asarray(actual);expected=expected.detach().numpy() if hasattr(expected,'detach') else np.asarray(expected)
|
||||
np.testing.assert_allclose(actual,expected,atol=atol,rtol=rtol)
|
||||
evidence.append({'test':name,'shape':list(actual.shape),'max_abs_error':float(np.max(np.abs(actual-expected))),'atol':atol,'rtol':rtol,'passed':True})
|
||||
with torch.no_grad():
|
||||
for i,layer in enumerate(layers):
|
||||
n=lm.normalization(x,f'layers.{i}.input_layernorm')
|
||||
tn=layer.input_layernorm(torch.from_numpy(x))
|
||||
check(f'layer{i}_rmsnorm',n,tn)
|
||||
if i==0:
|
||||
out=lm.linear_attention(n,i)
|
||||
tout=layer.linear_attn(tn)
|
||||
else:
|
||||
out,pr=lm.full_attention(n,i)
|
||||
tout,tpr=layer.self_attn(tn,(cos,sin),mask)
|
||||
check('attention_probabilities',pr,tpr)
|
||||
check(f'layer{i}_mixer',out,tout)
|
||||
h=x+out
|
||||
n=lm.normalization(h,f'layers.{i}.post_attention_layernorm')
|
||||
check(f'layer{i}_mlp',lm.mlp(n,i),layer.mlp(layer.post_attention_layernorm(torch.from_numpy(h))))
|
||||
actual=h+lm.mlp(n,i)
|
||||
expected=layer(torch.from_numpy(x),(cos,sin),attention_mask=mask if i else None)
|
||||
check(f'layer{i}_complete',actual,expected)
|
||||
# Independent recurrence/chunk equality, including nonmultiple sequence length.
|
||||
for length in (1,7,33):
|
||||
q=rng.standard_normal((2,length,2,4),dtype=np.float32)
|
||||
k=rng.standard_normal(q.shape,dtype=np.float32)
|
||||
v=rng.standard_normal((2,length,2,5),dtype=np.float32)
|
||||
g=-np.abs(rng.standard_normal((2,length,2),dtype=np.float32))
|
||||
beta=rng.uniform(size=g.shape).astype(np.float32)
|
||||
out,state=delta_rule(q,k,v,g,beta)
|
||||
args=[torch.from_numpy(z) for z in (q,k,v,g,beta)]
|
||||
for kind in ('torch_recurrent_gated_delta_rule','torch_chunk_gated_delta_rule'):
|
||||
ref,refstate=ns[kind](*args,output_final_state=True,use_qk_l2norm_in_kernel=True)
|
||||
check(f'{kind}_length{length}_output',out,ref)
|
||||
check(f'{kind}_length{length}_state',state,refstate)
|
||||
# Full two-layer residual forward, final norm and embedding lookup.
|
||||
arrays['embed_tokens.weight']=rng.standard_normal((31,16),dtype=np.float32)
|
||||
arrays['norm.weight']=rng.standard_normal((16,),dtype=np.float32)*.1
|
||||
ids=rng.integers(0,31,size=(2,7))
|
||||
h=torch.from_numpy(arrays['embed_tokens.weight'][ids])
|
||||
for i,l in enumerate(layers):h=l(h,(cos,sin),attention_mask=mask if i else None)
|
||||
expected=h*torch.rsqrt(h.square().mean(-1,keepdim=True)+1e-6)*(1+torch.from_numpy(arrays['norm.weight']))
|
||||
actual,_=lm.forward(ids)
|
||||
check('complete_two_layer_text_forward',actual,expected)
|
||||
result={'passed':True,'reference_commit':EXPECTED_COMMIT,'source_sha256':hashlib.sha256(a.source.read_bytes()).hexdigest(),
|
||||
'torch':torch.__version__,'numpy':np.__version__,'implementation_sha256':hashlib.sha256(Path(__file__).with_name('model.py').read_bytes()).hexdigest(),'tests':evidence,'limitations':'FP32 CPU semantics on tiny synthetic configurations; not full-checkpoint BF16 kernel equivalence'}
|
||||
a.output.write_text(json.dumps(result,indent=2))
|
||||
print(json.dumps({'passed':True,'checks':len(evidence),'maximum_absolute_discrepancy':max(x['max_abs_error'] for x in evidence)}))
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,104 @@
|
||||
"""Render scientific pilot figures using saved data; never reopen model weights."""
|
||||
import argparse
|
||||
import csv
|
||||
import json
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
import matplotlib
|
||||
matplotlib.use('Agg')
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);a=p.parse_args();root=a.root
|
||||
out=root/'figures';out.mkdir(exist_ok=True)
|
||||
plt.rcParams.update({'font.size':10,'savefig.bbox':'tight','pdf.fonttype':42,'svg.fonttype':'none'})
|
||||
def save(fig,name):
|
||||
for ext in ('png','pdf','svg'):fig.savefig(out/f'{name}.{ext}',dpi=180)
|
||||
plt.close(fig)
|
||||
status=json.loads((root/'functional-status.json').read_text())
|
||||
if (root/'candidate-summary.json').exists():
|
||||
c=json.loads((root/'candidate-summary.json').read_text())
|
||||
fig,ax=plt.subplots(figsize=(10,4.5))
|
||||
ax.bar(np.arange(len(c)),[max(v['maximum_symmetric_relative_error'],1e-8) for v in c],color=['#238b45' if v['passed'] else '#9e9e9e' for v in c])
|
||||
ax.axhline(.05,color='#b2182b',linestyle='--',label='Relative L2 screen = 0.05; other gates also apply')
|
||||
ax.set_yscale('log');ax.set_xticks(np.arange(len(c)),[v['id'] for v in c],rotation=45,ha='right')
|
||||
ax.set_ylabel('Worst calibration directional relative L2')
|
||||
ax.set_title('Fixed candidates; same-input function comparison\n4 calibration texts, 32 tokens; no training')
|
||||
ax.legend(loc='upper left',bbox_to_anchor=(0,-.38),fontsize=8);fig.tight_layout();save(fig,'candidate_function_errors')
|
||||
if (root/'interventions.json').exists():
|
||||
interventions=json.loads((root/'interventions.json').read_text())
|
||||
fig,ax=plt.subplots(figsize=(8,4.5))
|
||||
for idx,r in enumerate(interventions):
|
||||
values=r['sequence_nll_deltas'];x=np.arange(len(values))
|
||||
ax.plot(x,values,'o-',label=r['direction'])
|
||||
ax.axhline(0,color='gray',linewidth=.7);ax.axhline(.01,color='#b2182b',linestyle='--',label='Mean-delta budget (not per-sequence bound)')
|
||||
ax.set_xticks(np.arange(4),['heldout zh1','heldout zh2','heldout en1','heldout en2'])
|
||||
ax.set_ylabel('Token NLL change (nat/token)');ax.set_title('Single-site interventions; frozen candidate\n4 heldout texts, 32 tokens; limited pilot evidence')
|
||||
ax.legend(loc='upper left',bbox_to_anchor=(0,-.18),fontsize=8);fig.tight_layout();save(fig,'heldout_intervention_nll')
|
||||
norm_path=root/'norm-repetition-summary.json'
|
||||
repetition=json.loads(norm_path.read_text()) if norm_path.exists() else {}
|
||||
if (root/'norm-repetition-function-metrics.csv').exists():
|
||||
with (root/'norm-repetition-function-metrics.csv').open() as f:rows=list(csv.DictReader(f))
|
||||
sample_ids=list(dict.fromkeys(row['sample_id'] for row in rows))
|
||||
fig,ax=plt.subplots(figsize=(9,4.8))
|
||||
for source in sorted({row['source_layer'] for row in rows},key=int):
|
||||
rr=[r for r in rows if r['source_layer']==source]
|
||||
ax.plot(range(len(rr)),[max(float(r['relative_l2']),float(r['reverse_relative_l2'])) for r in rr],'o-',label=f'Input captured at layer {source}')
|
||||
ax.axhline(.05,color='#b2182b',ls='--',label='Heldout empirical screen = 0.05')
|
||||
chosen=repetition.get('selected')
|
||||
if chosen:ax.axhline(chosen['worst_uniform_bound'],color='#6a51a3',ls=':',label='Proven uniform all-input bound')
|
||||
ax.axvline(3.5,color='gray',linewidth=.8)
|
||||
ax.set_xticks(range(len(sample_ids)),sample_ids,rotation=30,ha='right');ax.set_ylabel('Worst of two directional relative L2 errors')
|
||||
ax.set_title('Learned input RMSNorm at layer indices 12/13: same-input comparison\nCalibration (left) / independent heldout texts (right), 32 tokens each')
|
||||
ax.legend(loc='upper left',bbox_to_anchor=(0,-.25),fontsize=8);fig.tight_layout();save(fig,'learned_norm_function_errors')
|
||||
if repetition.get('interventions'):
|
||||
fig,ax=plt.subplots(figsize=(8,4.5))
|
||||
for v in repetition['interventions']:
|
||||
ax.plot(range(4),v['sequence_nll_deltas'],'o-',label=f'Layer {v["target"]} uses {v["donor"]}; mean={v["mean_nll_delta"]:.5g}')
|
||||
ax.axhline(0,color='gray',linewidth=.8);ax.set_xticks(range(4),['zh1','zh2','en1','en2'])
|
||||
ax.set_xlabel('Independent heldout text (32 tokens)');ax.set_ylabel('Mean token NLL change (nat/token)')
|
||||
ax.set_title('Bidirectional single-site substitution of existing learned RMSNorm modules')
|
||||
ax.legend(loc='upper left',bbox_to_anchor=(0,-.18),fontsize=8);fig.tight_layout();save(fig,'learned_norm_network_substitution')
|
||||
if (root/'gain-factorization-score-metrics.csv').exists():
|
||||
with (root/'gain-factorization-score-metrics.csv').open() as f:rr=list(csv.DictReader(f))
|
||||
layers=sorted({int(v['layer']) for v in rr});fig,axes=plt.subplots(1,2,figsize=(10,4))
|
||||
for ax,key,label in zip(axes,['score_max_abs_error','probability_max_abs_error'],['Maximum absolute score error','Maximum absolute probability error']):
|
||||
for direction in ('q_to_k','k_to_q'):
|
||||
ax.plot(layers,[max(float(v[key]) for v in rr if int(v['layer'])==layer and v['direction']==direction) for layer in layers],'o-',label=direction)
|
||||
ax.set_xlabel('Full-attention layer index');ax.set_xticks(layers);ax.set_ylabel(label);ax.ticklabel_format(axis='y',style='sci',scilimits=(0,0));ax.legend(loc='upper left',fontsize=8)
|
||||
fig.suptitle('Supplement: algebraic reparameterization, separate from learned-function repetition');fig.tight_layout();save(fig,'algebraic_gain_identity')
|
||||
neuron_path=root/'neuron-reuse-summary.json'
|
||||
neuron=json.loads(neuron_path.read_text()) if neuron_path.exists() else {}
|
||||
text=['# CPU learned-function repetition pilot','',
|
||||
'Primary question: do two distinct trained parts implement similar functions? Cost is not a success condition.',
|
||||
f'- Existing learned RMSNorm function positive: {repetition.get("learned_function_repetition_positive",False)}',
|
||||
f'- Bidirectional network quality screen passed: {repetition.get("bidirectional_network_quality_pass",False)}',
|
||||
f'- Learned scalar MLP neuron search positive: {neuron.get("empirical_repeated_function_positive",False)}',
|
||||
f'- Original 11 candidate run state: {status["state"]}; selected: {status.get("selected_candidate",[])}',
|
||||
'- All model weights are retained on the server until the user explicitly requests deletion.','']
|
||||
if repetition.get('selected'):
|
||||
c=repetition['selected'];text += ['## Existing learned module evidence','',
|
||||
f'Role: {c["role"]}; layers {c["a"]} and {c["b"]}; each maps 2048-dimensional input to output.',
|
||||
f'Uniform real-arithmetic relative-error bound, first-to-second: {c["a_to_b_uniform_bound"]:.12g}; reverse: {c["b_to_a_uniform_bound"]:.12g}.',
|
||||
f'Maximum heldout directional output relative L2: {repetition.get("worst_heldout_relative_l2")}; minimum cosine: {repetition.get("worst_heldout_cosine")}.',
|
||||
'Same epsilon and nonzero gains: the common RMS denominator cancels. For any nonzero input x,',
|
||||
'`||f_a(x)-f_b(x)|| / ||f_a(x)|| <= max_j |a_j-b_j|/|a_j|`; swap a/b for the reverse direction.',
|
||||
'Selection used only the tight all-input bound across 552 same-role pairs, before inspecting inputs.',
|
||||
'Real probes use four calibration and four heldout experiment-authored texts, 32 tokens each, and both source layers.',
|
||||
'These are learned, nonconstant gain vectors. The claim concerns RMSNorm modules; it does not establish attention/MLP-body duplication.','']
|
||||
for v in repetition.get('interventions',[]):text += [f'- Layer {v["target"]} uses {v["donor"]}: mean heldout NLL delta {v["mean_nll_delta"]:.12g}; sequence P95 delta {v["sequence_p95_nll_delta"]:.12g}; screen pass={v["passed_quality"]}.']
|
||||
text += ['', '## Negative results and separate algebraic result','',
|
||||
'The original whole-attention, whole-MLP and within-layer Q/K norm candidates did not pass their gates.',
|
||||
'The scalar neuron search excludes low-RMS/near-constant profiles and selects at most one pair without heldout feedback; consult its search summary for coverage.',
|
||||
'Q/K non-RoPE gain consolidation is a separately verified real-arithmetic identity, not evidence that two existing learned modules duplicate functions.',
|
||||
'Earlier local CPU timing records are preserved for provenance; performance is outside the current success criterion.','',
|
||||
'## Limits and provenance','',
|
||||
'Original BF16 weights were decoded into streaming FP32 CPU operators; no training, scale fitting, R fitting or GPU.',
|
||||
'The numerical reference includes 22 independent official Torch comparisons. Early adapter errors and two resource-guard stops are preserved as historical logs.',
|
||||
'The persistent computation ledger includes a conservative 180-second reserve for early checks; no budget reset after that reserve.',
|
||||
'The text sample is tiny and short. Network NLL checks are not broad task-accuracy validation.','']
|
||||
(root/'FUNCTIONAL_REPORT.md').write_text('\n'.join(text))
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,227 @@
|
||||
"""Bounded CPU pilot. One fixed model; calibration selects, heldout only validates."""
|
||||
import argparse
|
||||
import csv
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import resource
|
||||
import time
|
||||
import traceback
|
||||
import urllib.request
|
||||
import numpy as np
|
||||
from .model import StreamingLM, norm
|
||||
|
||||
ATTN_PAIRS=[(3,7),(11,15),(19,23)]
|
||||
MLP_PAIRS=[(5,6),(20,21)]
|
||||
NORM_LAYERS=[3,7,11,15,19,23]
|
||||
REVISION='15852e8c16360a2fea060d615a32b45270f8a8fc'
|
||||
|
||||
|
||||
def write_json(path,obj):
|
||||
tmp=path.with_suffix('.tmp')
|
||||
tmp.write_text(json.dumps(obj,indent=2,allow_nan=False)+'\n')
|
||||
tmp.replace(path)
|
||||
|
||||
|
||||
def error_rows(a,b,samples,metadata):
|
||||
records=[]
|
||||
for x,y,sample in zip(a,b,samples):
|
||||
xf,yf=x.astype(np.float64).reshape(-1),y.astype(np.float64).reshape(-1)
|
||||
xn,yn=np.linalg.norm(xf),np.linalg.norm(yf)
|
||||
delta=np.linalg.norm(xf-yf)
|
||||
tokenerr=np.linalg.norm((x-y).reshape(x.shape[0],-1).astype(np.float64),axis=-1)/np.maximum(np.linalg.norm(x.reshape(x.shape[0],-1).astype(np.float64),axis=-1),1e-12)
|
||||
records.append({**metadata,'sample_id':sample['id'],'split':sample['split'],
|
||||
'relative_l2':float(delta/max(xn,1e-12)),
|
||||
'reverse_relative_l2':float(delta/max(yn,1e-12)),
|
||||
'token_relative_p95':float(np.quantile(tokenerr,.95)),
|
||||
'reverse_token_relative_p95':float(np.quantile(np.linalg.norm((x-y).reshape(x.shape[0],-1).astype(np.float64),axis=-1)/np.maximum(np.linalg.norm(y.reshape(x.shape[0],-1).astype(np.float64),axis=-1),1e-12),.95)),
|
||||
'cosine':float(xf@yf/max(xn*yn,1e-30)),
|
||||
'low_norm_tokens':int((np.linalg.norm(x.reshape(x.shape[0],-1),axis=-1)<1e-8).sum())})
|
||||
return records
|
||||
|
||||
|
||||
def probability_metrics(a,b):
|
||||
m=(a+b)*.5
|
||||
def term(p):
|
||||
return np.where(p>0,p*np.log(np.maximum(p,1e-30)/np.maximum(m,1e-30)),0)
|
||||
js=(term(a)+term(b)).sum(axis=-1)*.5
|
||||
overlap=[]
|
||||
for row in range(a.shape[-2]):
|
||||
k=min(5,row+1)
|
||||
ai=np.argsort(a[:,:,row,:row+1],axis=-1)[...,-k:]
|
||||
bi=np.argsort(b[:,:,row,:row+1],axis=-1)[...,-k:]
|
||||
overlap.append(np.mean((ai[...,None]==bi[...,None,:]).any(axis=-1),axis=-1))
|
||||
# Attention-sink control: remove key zero, renormalize valid remaining mass.
|
||||
aa,bb=a[...,1:],b[...,1:]
|
||||
mass_a,mass_b=aa.sum(-1),bb.sum(-1)
|
||||
valid=(mass_a>1e-12)&(mass_b>1e-12)
|
||||
aa=aa/np.maximum(mass_a[...,None],1e-30)
|
||||
bb=bb/np.maximum(mass_b[...,None],1e-30)
|
||||
mm=(aa+bb)*.5
|
||||
conditional_js=.5*(np.where(aa>0,aa*np.log(np.maximum(aa,1e-30)/np.maximum(mm,1e-30)),0)+np.where(bb>0,bb*np.log(np.maximum(bb,1e-30)/np.maximum(mm,1e-30)),0)).sum(-1)
|
||||
return {'first_key_mass_a':float(a[...,0].mean()),'first_key_mass_b':float(b[...,0].mean()),
|
||||
'js_without_first_key':float(conditional_js[valid].mean()) if valid.any() else None,
|
||||
'without_first_key_valid_rows':int(valid.sum()),'js_mean':float(js.mean()),'js_p95':float(np.quantile(js,.95)),
|
||||
'js_without_first_query':float(js[...,1:].mean()),
|
||||
'top5_overlap':float(np.stack(overlap,axis=-1).mean())}
|
||||
|
||||
|
||||
def save_csv(path,rows):
|
||||
if not rows:return
|
||||
keys=list(dict.fromkeys(k for r in rows for k in r))
|
||||
with path.open('w',newline='') as f:
|
||||
w=csv.DictWriter(f,fieldnames=keys);w.writeheader();w.writerows(rows)
|
||||
|
||||
|
||||
def tokenize(root):
|
||||
from tokenizers import Tokenizer
|
||||
path=root/'tokenizer.json'
|
||||
if not path.exists():
|
||||
url=f'https://huggingface.co/Qwen/Qwen3.5-2B/resolve/{REVISION}/tokenizer.json'
|
||||
with urllib.request.urlopen(url,timeout=180) as r:path.write_bytes(r.read())
|
||||
tokenizer=Tokenizer.from_file(str(path))
|
||||
samples=json.loads(Path(__file__).with_name('samples.json').read_text())['samples']
|
||||
ids=[]
|
||||
for s in samples:
|
||||
tokens=tokenizer.encode(s['text'],add_special_tokens=False).ids
|
||||
if len(tokens)<32:raise ValueError(f'Text too short: {s["id"]}')
|
||||
s['text_sha256']=hashlib.sha256(s['text'].encode()).hexdigest()
|
||||
s['full_token_count']=len(tokens);s['token_ids']=tokens[:32]
|
||||
ids.append(tokens[:32])
|
||||
write_json(root/'samples-tokenized.json',{'revision':REVISION,'tokenizer_sha256':hashlib.sha256(path.read_bytes()).hexdigest(),'samples':samples})
|
||||
return samples,np.array(ids,dtype=np.int64)
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);p.add_argument('--seconds',type=int,default=7200)
|
||||
args=p.parse_args();root=args.root;root.mkdir(exist_ok=True,parents=True)
|
||||
write_json(root/'retention-policy.json',{'weights':'retain_until_explicit_user_delete_request','automatic_cleanup':False,'instruction_date':'2026-11-09'})
|
||||
samples,ids=tokenize(root)
|
||||
cal=np.array([i for i,s in enumerate(samples) if s['split']=='calibration'])
|
||||
held=np.array([i for i,s in enumerate(samples) if s['split']=='heldout'])
|
||||
# Freeze all candidates/thresholds before opening weights or measuring functions.
|
||||
experiment={'revision':REVISION,'attention_pairs':ATTN_PAIRS,'mlp_pairs':MLP_PAIRS,'norm_layers':NORM_LAYERS,
|
||||
'seconds':args.seconds,'output_relative_l2_limit':.05,'token_p95_limit':.1,
|
||||
'attention_js_limit':.01,'attention_top5_min':.8,'heldout_nll_mean_delta_limit':.01,
|
||||
'heldout_nll_sequence_p95_delta_limit':.05,'max_intervention_candidates':1,
|
||||
'directions_per_selected_candidate':2,'training':False,'search_R':False,'automatic_weight_cleanup':False,
|
||||
'dtype':'original weights decoded to FP32; not a BF16 backend benchmark',
|
||||
'blas_threads':os.environ.get('OPENBLAS_NUM_THREADS')}
|
||||
write_json(root/'experiment.json',experiment)
|
||||
started=time.time();status={'state':'running','started_unix':started,'phase':'baseline'}
|
||||
write_json(root/'functional-status.json',status)
|
||||
rows=[];headrows=[];interventions=[]
|
||||
try:
|
||||
config=json.loads((root/'model_config.json').read_text())
|
||||
lm=StreamingLM(root/'weights',config,seconds=args.seconds)
|
||||
overall_deadline=lm.deadline
|
||||
lm.deadline=min(overall_deadline,time.monotonic()+2400)
|
||||
lm.capture_qk=True
|
||||
capture=[('attn',i) for pair in ATTN_PAIRS for i in pair]+[('mlp',i) for pair in MLP_PAIRS for i in pair]
|
||||
def progress(layer):
|
||||
status.update(last_completed_layer=layer,elapsed_seconds=time.time()-started)
|
||||
write_json(root/'functional-status.json',status)
|
||||
print(json.dumps({'phase':status['phase'],'layer':layer,'elapsed':time.time()-started}),flush=True)
|
||||
h,saved=lm.forward(ids,capture=capture,progress=progress)
|
||||
np.savez(root/'baseline-activations.npz',**saved,**{f'qraw_{k}':v[0] for k,v in lm.qk_inputs.items()},**{f'kraw_{k}':v[1] for k,v in lm.qk_inputs.items()},final=h)
|
||||
# Baseline heldout NLL uses no selection information.
|
||||
nll=lm.nll(h[held],ids[held]);np.save(root/'baseline-heldout-token-nll.npy',nll)
|
||||
baseline_nll=nll.mean(axis=1)
|
||||
lm.capture_qk=False
|
||||
lm.deadline=min(overall_deadline,time.monotonic()+1800)
|
||||
status['phase']='calibration';write_json(root/'functional-status.json',status)
|
||||
candidates=[]
|
||||
for kind,pairs in [('attn',ATTN_PAIRS),('mlp',MLP_PAIRS)]:
|
||||
for i,j in pairs:
|
||||
pairid=f'{kind}_{i}_{j}';pairrows=[]
|
||||
for source in (i,j):
|
||||
x=saved[f'{kind}_{source}'][cal]
|
||||
if kind=='attn':
|
||||
a,pa=lm.full_attention(x,i);b,pb=lm.full_attention(x,j)
|
||||
pm={}
|
||||
for bi,si in enumerate(cal):
|
||||
for hi in range(pa.shape[1]):
|
||||
hpm=probability_metrics(pa[bi:bi+1,hi:hi+1],pb[bi:bi+1,hi:hi+1])
|
||||
headrows.append({'candidate':pairid,'source':source,'sample_id':samples[si]['id'],'head':hi,**hpm})
|
||||
save_csv(root/'attention-head-metrics.csv',headrows)
|
||||
else:
|
||||
a,b=lm.mlp(x,i),lm.mlp(x,j);pm={}
|
||||
rec=error_rows(a,b,[samples[t] for t in cal],{'candidate':pairid,'kind':kind,'source':source,**pm})
|
||||
if kind=='attn':
|
||||
for bi,r in enumerate(rec):r.update(probability_metrics(pa[bi:bi+1],pb[bi:bi+1]))
|
||||
rows.extend(rec);pairrows.extend(rec)
|
||||
save_csv(root/'calibration-metrics.csv',rows)
|
||||
passing=all(r['relative_l2']<=.05 and r['reverse_relative_l2']<=.05 and r['token_relative_p95']<=.1 and r['reverse_token_relative_p95']<=.1 for r in pairrows)
|
||||
if kind=='attn':passing=passing and all(r['js_mean']<=.01 and r['top5_overlap']>=.8 for r in pairrows)
|
||||
prefix=f'model.language_model.layers.{i}.'+('self_attn.' if kind=='attn' else 'mlp.')
|
||||
size=sum(t.bytes for name,t in lm.tensors.items() if name.startswith(prefix))
|
||||
candidates.append({'id':pairid,'kind':kind,'i':i,'j':j,'passed':passing,'maximum_symmetric_relative_error':max(max(r['relative_l2'],r['reverse_relative_l2']) for r in pairrows),'donor_component_bytes':size})
|
||||
for layer in NORM_LAYERS:
|
||||
pairid=f'qk_norm_{layer}';pfx=f'layers.{layer}.self_attn.'
|
||||
qw,kw=lm.small(pfx+'q_norm.weight'),lm.small(pfx+'k_norm.weight')
|
||||
pairrows=[]
|
||||
for source,x in zip(('q','k'),lm.qk_inputs[layer]):
|
||||
a,b=norm(x[cal],qw,lm.eps),norm(x[cal],kw,lm.eps)
|
||||
rec=error_rows(a,b,[samples[t] for t in cal],{'candidate':pairid,'kind':'qk_norm','source':source})
|
||||
pairrows.extend(rec);rows.extend(rec)
|
||||
passing=all(r['relative_l2']<=.05 and r['reverse_relative_l2']<=.05 and r['token_relative_p95']<=.1 and r['reverse_token_relative_p95']<=.1 for r in pairrows)
|
||||
candidates.append({'id':pairid,'kind':'qk_norm','i':layer,'j':layer,'passed':passing,'maximum_symmetric_relative_error':max(max(r['relative_l2'],r['reverse_relative_l2']) for r in pairrows),'donor_component_bytes':lm.tensors['model.language_model.'+pfx+'q_norm.weight'].bytes})
|
||||
save_csv(root/'calibration-metrics.csv',rows)
|
||||
write_json(root/'candidate-summary.json',candidates)
|
||||
passed=[c for c in candidates if c['passed']]
|
||||
# Prefer larger potential savings, then smaller worst calibration error; never consult heldout.
|
||||
selected=sorted(passed,key=lambda c:(-c['donor_component_bytes'],c['maximum_symmetric_relative_error'],c['id']))[:1]
|
||||
write_json(root/'selection.json',{'selected':selected,'rule':'calibration pass; descending component bytes, ascending maximum symmetric error; maximum one candidate'})
|
||||
if selected:
|
||||
c=selected[0]
|
||||
heldrows=[]
|
||||
if c['kind']=='qk_norm':
|
||||
pfx=f'layers.{c["i"]}.self_attn.'
|
||||
qw,kw=lm.small(pfx+'q_norm.weight'),lm.small(pfx+'k_norm.weight')
|
||||
for source,x in zip(('q','k'),lm.qk_inputs[c['i']]):
|
||||
heldrows.extend(error_rows(norm(x[held],qw,lm.eps),norm(x[held],kw,lm.eps),[samples[t] for t in held],{'candidate':c['id'],'kind':'qk_norm','source':source}))
|
||||
else:
|
||||
for source in (c['i'],c['j']):
|
||||
x=saved[f'{c["kind"]}_{source}'][held]
|
||||
if c['kind']=='attn':
|
||||
a,_=lm.full_attention(x,c['i']);b,_=lm.full_attention(x,c['j'])
|
||||
else:a,b=lm.mlp(x,c['i']),lm.mlp(x,c['j'])
|
||||
heldrows.extend(error_rows(a,b,[samples[t] for t in held],{'candidate':c['id'],'kind':c['kind'],'source':source}))
|
||||
save_csv(root/'heldout-function-metrics.csv',heldrows)
|
||||
held_function_pass=all(r['relative_l2']<=.05 and r['reverse_relative_l2']<=.05 and r['token_relative_p95']<=.1 and r['reverse_token_relative_p95']<=.1 for r in heldrows)
|
||||
status['heldout_function_pass']=held_function_pass
|
||||
lm.deadline=min(overall_deadline,time.monotonic()+1800)
|
||||
status['phase']='intervention';write_json(root/'functional-status.json',status)
|
||||
for reverse in (False,True):
|
||||
replacement=None;lm.norm_replacement=None
|
||||
if c['kind']=='qk_norm':
|
||||
pfx=f'layers.{c["i"]}.self_attn.'
|
||||
target,donor=('q_norm','k_norm') if not reverse else ('k_norm','q_norm')
|
||||
lm.norm_replacement=(pfx+target,pfx+donor)
|
||||
label=target+'_uses_'+donor
|
||||
else:
|
||||
target,donor=(c['i'],c['j']) if not reverse else (c['j'],c['i'])
|
||||
replacement=(c['kind'],target,donor);label=f'{target}_uses_{donor}'
|
||||
t=time.monotonic();modified,_=lm.forward(ids[held],replacement=replacement,progress=progress)
|
||||
changed=lm.nll(modified,ids[held]);np.save(root/f'intervention-{label}-token-nll.npy',changed)
|
||||
delta=changed.mean(axis=1)-baseline_nll
|
||||
rec={'candidate':c['id'],'direction':label,'elapsed_seconds':time.monotonic()-t,
|
||||
'nll_mean_delta':float(delta.mean()),'nll_sequence_p95_delta':float(np.quantile(delta,.95)),
|
||||
'sequence_nll_deltas':delta.tolist(),'passed_quality':bool(delta.mean()<=.01 and np.quantile(delta,.95)<=.05)}
|
||||
interventions.append(rec);write_json(root/'interventions.json',interventions)
|
||||
# No fallback candidate if heldout fails.
|
||||
status.update(state='completed',phase='done',selected_candidate=selected,
|
||||
positive_bidirectional_quality=bool(interventions and status.get('heldout_function_pass') and all(x['passed_quality'] for x in interventions)),
|
||||
elapsed_seconds=time.time()-started,peak_rss_kib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss,
|
||||
claim_limit='Small text-only heldout pilot; no global interchangeability proof, no measured GPU speedup; component storage savings require explicit layout accounting.')
|
||||
except Exception as exc:
|
||||
status.update(state='stopped',error_type=type(exc).__name__,error=str(exc),elapsed_seconds=time.time()-started,
|
||||
peak_rss_kib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
|
||||
(root/'functional-error.txt').write_text(traceback.format_exc())
|
||||
raise
|
||||
finally:
|
||||
write_json(root/'functional-status.json',status)
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"origin": "Experiment-authored plain text, no external corpus; fixed before functional metrics. Chinese/English balanced in each split. No chat template. First 32 tokenizer tokens retained.",
|
||||
"samples": [
|
||||
{"id":"cal-zh-1","split":"calibration","language":"zh","text":"清晨,研究员打开实验记录本,检查昨天保存的数据。他先确认文件完整,再比较两组观测结果。为了避免偶然误差,他为每一步留下时间和条件,并将尚未验证的推测单独记录。"},
|
||||
{"id":"cal-zh-2","split":"calibration","language":"zh","text":"一辆列车从山间驶向海边,经过村庄、桥梁和开阔的田野。旅客望着窗外变化的景色,计划抵达后先步行到旅馆,再去市场购买晚餐需要的食材。天气预报说傍晚可能下雨。"},
|
||||
{"id":"cal-en-1","split":"calibration","language":"en","text":"A small library opens every morning beside the river. The librarian checks returned books, repairs damaged covers, and places new arrivals on a wooden table. Visitors often stop to read before continuing their journey across the old bridge."},
|
||||
{"id":"cal-en-2","split":"calibration","language":"en","text":"To compare two measurements, first record their units and the conditions under which they were collected. Compute the difference, inspect unusual observations, and repeat the procedure with independent examples. A short report should separate observations from explanations and unresolved questions."},
|
||||
{"id":"test-zh-1","split":"heldout","language":"zh","text":"午后,工程师检查温室中的传感器。温度记录出现一个异常值,她没有立刻删除,而是查看设备状态并补做一次测量。确认原因以后,她调整了采样计划,在报告中说明这次变化。"},
|
||||
{"id":"test-zh-2","split":"heldout","language":"zh","text":"周末,家人沿着湖边的小路散步。他们带了水和简单的午餐,打算在树林旁休息。途中遇到一处正在维修的桥,于是参考路标选择另一条道路,终于在日落前回到车站。"},
|
||||
{"id":"test-en-1","split":"heldout","language":"en","text":"The gardener planted several rows of beans behind the house. Each evening she checked the soil and wrote down how much water the plants received. After a week of warm weather, the first green shoots appeared near the fence beside the apple tree."},
|
||||
{"id":"test-en-2","split":"heldout","language":"en","text":"When a program reads a table, it should check column names and handle missing entries explicitly. The developer tested a small example, compared the output with a hand calculation, and saved the input alongside the result so another person could reproduce the check."}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
"""Measure an explicit two-component alias storage layout, not inference speed.
|
||||
|
||||
Payloads remain on the server under weights/ and must not be committed or cleaned
|
||||
without the user's explicit deletion request. Manifest/byte/hash evidence may be archived.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
from pilot.tensors import load_tensors,decode
|
||||
from .run import write_json
|
||||
|
||||
|
||||
def payload(t,path):
|
||||
digest=hashlib.sha256()
|
||||
with path.open('wb') as f:
|
||||
for start in range(0,t.raw.size,262144):
|
||||
b=t.raw[start:start+262144].tobytes();f.write(b);digest.update(b)
|
||||
t.evict()
|
||||
return {'file':path.name,'dtype':t.dtype,'shape':list(t.shape),'bytes':path.stat().st_size,'sha256':digest.hexdigest()}
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);a=p.parse_args();root=a.root
|
||||
selected=json.loads((root/'selection.json').read_text())['selected']
|
||||
if not selected:
|
||||
write_json(root/'storage-evidence.json',{'measured':False,'reason':'No calibration candidate selected'});return
|
||||
c=selected[0]
|
||||
if c['kind']!='qk_norm':
|
||||
write_json(root/'storage-evidence.json',{'measured':False,'reason':'Only two-gain alias layout implemented in this bounded pilot; larger-module savings remain theoretical'});return
|
||||
tensors=load_tensors(root/'weights')
|
||||
prefix=f'model.language_model.layers.{c["i"]}.self_attn.'
|
||||
names=[prefix+'q_norm.weight',prefix+'k_norm.weight']
|
||||
# Original pair plus two alternative layouts; each is counted independently.
|
||||
path=root/'component-layout'/'weights';path.mkdir(parents=True,exist_ok=True)
|
||||
original={'format':'two_component_raw_v1','tensors':{}}
|
||||
for short,name in zip(('q','k'),names):original['tensors'][name]=payload(tensors[name],path/f'{short}.bin')
|
||||
original_bytes=json.dumps(original,separators=(',',':'),sort_keys=True).encode()
|
||||
(path/'original-layout.json').write_bytes(original_bytes)
|
||||
evidence=[]
|
||||
for target,donor in ((names[0],names[1]),(names[1],names[0])):
|
||||
entry=original['tensors'][donor]
|
||||
layout={'format':'two_component_raw_v1','tensors':{donor:entry},'aliases':{target:donor}}
|
||||
encoded=json.dumps(layout,separators=(',',':'),sort_keys=True).encode()
|
||||
file=path/('share-'+('k' if donor==names[1] else 'q')+'.json');file.write_bytes(encoded)
|
||||
t=tensors[donor]
|
||||
raw=np.fromfile(path/entry['file'],dtype=t.raw.dtype)
|
||||
reconstructed=decode(raw,t.dtype).reshape(t.shape)
|
||||
np.testing.assert_array_equal(reconstructed,t.read().reshape(t.shape));t.evict()
|
||||
before=sum(e['bytes'] for e in original['tensors'].values())+len(original_bytes)
|
||||
after=entry['bytes']+len(encoded)
|
||||
evidence.append({'target':target,'donor':donor,'original_payload_bytes':sum(e['bytes'] for e in original['tensors'].values()),
|
||||
'shared_payload_bytes':entry['bytes'],'original_descriptor_bytes':len(original_bytes),
|
||||
'shared_descriptor_bytes':len(encoded),'original_total_bytes':before,'shared_total_bytes':after,
|
||||
'net_saved_bytes':before-after,'shared_descriptor_sha256':hashlib.sha256(encoded).hexdigest(),
|
||||
'decoded_donor_exactly_matches_intervention_gain':True})
|
||||
write_json(root/'storage-evidence.json',{'measured':True,'candidate':c['id'],'layouts':evidence,
|
||||
'claim_limit':'Measured standalone component layout including descriptors, not an integrated compressed checkpoint, latency gain or full-model RSS reduction. Two sharing directions are alternatives and must not be added.'})
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,95 @@
|
||||
"""One bounded CPU run; waits for verified download and binary dependencies.
|
||||
|
||||
No installation, retry search, cleanup, training, GPU selection or Git mutation.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
from .run import write_json
|
||||
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);p.add_argument('--download-wait-seconds',type=int,default=14400)
|
||||
a=p.parse_args();root=a.root.resolve();start=time.monotonic()
|
||||
state={'state':'waiting','phase':'dependencies','weight_retention':'until_explicit_user_delete_request'}
|
||||
def status(**kwargs):
|
||||
state.update(kwargs,supervisor_elapsed_seconds=time.monotonic()-start)
|
||||
write_json(root/'supervisor-status.json',state)
|
||||
def execute(module,args,timeout,log):
|
||||
ledger_path=root/'compute-budget-ledger.json'
|
||||
ledger=json.loads(ledger_path.read_text()) if ledger_path.exists() else {'spent_seconds':0.,'calls':[]}
|
||||
timeout=min(timeout,int(7200-ledger['spent_seconds']))
|
||||
if timeout<1:raise TimeoutError('Cumulative two-hour compute budget exhausted')
|
||||
t=time.monotonic()
|
||||
try:
|
||||
with (root/log).open('w') as out:
|
||||
r=subprocess.run([sys.executable,'-B','-m',module,*args],stdout=out,stderr=subprocess.STDOUT,timeout=timeout)
|
||||
finally:
|
||||
elapsed=time.monotonic()-t
|
||||
ledger['spent_seconds']+=elapsed
|
||||
ledger['calls'].append({'module':module,'seconds':elapsed})
|
||||
write_json(ledger_path,ledger)
|
||||
if r.returncode:raise RuntimeError(f'{module} failed: exit {r.returncode}, see {log}')
|
||||
status()
|
||||
try:
|
||||
while True:
|
||||
ready=False
|
||||
if all(importlib.util.find_spec(name) for name in ('torch','tokenizers')):
|
||||
try:
|
||||
r=subprocess.run([sys.executable,'-B','-c','import torch, tokenizers; torch.empty(1)'],capture_output=True,timeout=30)
|
||||
ready=r.returncode==0
|
||||
except subprocess.TimeoutExpired:pass
|
||||
if ready:break
|
||||
if time.monotonic()-start>3600:raise TimeoutError('Binary reference dependencies not ready within one hour')
|
||||
status()
|
||||
time.sleep(15)
|
||||
compute_start=time.monotonic()
|
||||
status(state='running',phase='reference_check')
|
||||
provenance={str(p):hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(Path('functional').glob('*')) if p.is_file()}
|
||||
write_json(root/'functional-code-hashes.json',provenance)
|
||||
execute('functional.reference_check',['--source',str(root/'reference.py'),'--output',str(root/'reference-check.json')],300,'reference-check.log')
|
||||
reference_seconds=time.monotonic()-compute_start
|
||||
status(state='waiting',phase='verified_weights',reference_seconds=reference_seconds)
|
||||
while True:
|
||||
path=root/'manifest.json'
|
||||
try:
|
||||
manifest=json.loads(path.read_text())
|
||||
weights=[f for f in manifest.get('files',[]) if f['name'].endswith('.safetensors')]
|
||||
ready=(manifest.get('completed_unix') is not None and weights and
|
||||
all((root/'weights'/f['name']).is_file() and (root/'weights'/f['name']).stat().st_size==f['bytes'] and f['sha256']==f['upstream_sha256'] for f in weights))
|
||||
except (OSError,ValueError,KeyError):ready=False
|
||||
if ready:break
|
||||
if time.monotonic()-start>a.download_wait_seconds:raise TimeoutError('Verified weight download not ready before wait deadline')
|
||||
status()
|
||||
time.sleep(15)
|
||||
status(state='running',phase='real_weight_preflight')
|
||||
compute_start=time.monotonic()
|
||||
execute('functional.preflight',['--root',str(root)],1200,'preflight.log')
|
||||
preflight_seconds=time.monotonic()-compute_start
|
||||
remaining=int(7200-json.loads((root/'compute-budget-ledger.json').read_text())['spent_seconds']-60)
|
||||
if remaining<60:raise TimeoutError('No remaining bounded functional computation budget')
|
||||
status(phase='functional_analysis',preflight_seconds=preflight_seconds,remaining_seconds=remaining)
|
||||
execute('functional.run',['--root',str(root),'--seconds',str(remaining)],remaining+15,'functional-run.log')
|
||||
status(phase='storage_accounting')
|
||||
execute('functional.storage',['--root',str(root)],120,'storage-accounting.log')
|
||||
status(phase='report')
|
||||
execute('functional.report',['--root',str(root)],120,'functional-report.log')
|
||||
status(state='completed',phase='done')
|
||||
except Exception as exc:
|
||||
status(state='stopped',error_type=type(exc).__name__,error=str(exc))
|
||||
(root/'supervisor-error.txt').write_text(traceback.format_exc())
|
||||
# Retain all weights/results. No automatic retries or candidate expansion.
|
||||
if not (root/'functional-status.json').exists():
|
||||
write_json(root/'functional-status.json',{'state':'stopped','phase':state['phase'],'error_type':type(exc).__name__,'error':str(exc)})
|
||||
try:execute('functional.report',['--root',str(root)],120,'functional-report.log')
|
||||
except Exception:pass
|
||||
raise
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1 @@
|
||||
"""Bounded, inference-free weight similarity pilot."""
|
||||
@@ -0,0 +1,396 @@
|
||||
"""Bounded CPU-only screening, exact verification and conservative sharing groups."""
|
||||
import argparse
|
||||
import collections
|
||||
import csv
|
||||
import hashlib
|
||||
import itertools
|
||||
import json
|
||||
import math
|
||||
import pathlib
|
||||
import platform
|
||||
import resource
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .tensors import decode, finish, load_tensors, metrics
|
||||
|
||||
THRESHOLDS = [.01, .02, .05, .10, .20]
|
||||
|
||||
|
||||
def write_json(path, obj):
|
||||
path.write_text(json.dumps(obj, indent=2, allow_nan=False))
|
||||
|
||||
|
||||
def write_csv(path, rows):
|
||||
if not rows:
|
||||
path.write_text('')
|
||||
return
|
||||
with path.open('w', newline='') as f:
|
||||
writer = csv.DictWriter(f, fieldnames=list(rows[0]))
|
||||
writer.writeheader()
|
||||
writer.writerows(rows)
|
||||
|
||||
|
||||
def stable_seed(key, seed):
|
||||
return int.from_bytes(hashlib.sha256((str(seed) + str(key)).encode()).digest()[:8], 'little')
|
||||
|
||||
|
||||
def read_object(obj, tensors):
|
||||
t = tensors[obj['tensor']]
|
||||
if obj['kind'] == 'tensor':
|
||||
return t.read()
|
||||
slices = tuple(slice(s, s + b) for s, b in zip(obj['start'], obj['shape']))
|
||||
return decode(t.raw.reshape(t.shape)[slices], t.dtype).ravel()
|
||||
|
||||
|
||||
def sample_object(obj, tensors, sample_size=2048):
|
||||
t = tensors[obj['tensor']]
|
||||
n = math.prod(obj['shape'])
|
||||
indices = np.linspace(0, n - 1, min(n, sample_size), dtype=np.int64)
|
||||
if obj['kind'] == 'tensor':
|
||||
return t.read(indices)
|
||||
coords = np.unravel_index(indices, obj['shape'])
|
||||
global_coords = tuple(c + s for c, s in zip(coords, obj['start']))
|
||||
flat = np.ravel_multi_index(global_coords, t.shape)
|
||||
return t.read(flat)
|
||||
|
||||
|
||||
def exact_pair(a, b, tensors, deadline):
|
||||
if a['kind'] != 'tensor':
|
||||
result = metrics(read_object(a, tensors), read_object(b, tensors))
|
||||
tensors[a['tensor']].evict()
|
||||
tensors[b['tensor']].evict()
|
||||
return result
|
||||
ta, tb = tensors[a['tensor']], tensors[b['tensor']]
|
||||
xx = yy = xy = delta = sx = sy = 0.
|
||||
for start in range(0, ta.numel, 262144):
|
||||
if time.monotonic() > deadline:
|
||||
raise TimeoutError('Analysis deadline reached')
|
||||
sl = slice(start, min(start + 262144, ta.numel))
|
||||
x, y = ta.read(sl).astype(np.float64), tb.read(sl).astype(np.float64)
|
||||
xx += float(x @ x)
|
||||
yy += float(y @ y)
|
||||
xy += float(x @ y)
|
||||
d = x - y
|
||||
delta += float(d @ d)
|
||||
sx += float(x.sum())
|
||||
sy += float(y.sum())
|
||||
ta.evict()
|
||||
tb.evict()
|
||||
ta.evict()
|
||||
tb.evict()
|
||||
return finish(xx, yy, xy, delta, sx, sy, ta.numel)
|
||||
|
||||
|
||||
def sharing_groups(objects, pairs, threshold):
|
||||
"""Star groups; every member must have an exact verified edge to its representative."""
|
||||
adjacent = collections.defaultdict(dict)
|
||||
for pair in pairs:
|
||||
a, b = pair['a'], pair['b']
|
||||
if pair['error_member_to_rep'] <= threshold:
|
||||
adjacent[b][a] = pair['error_member_to_rep']
|
||||
if pair['error_rep_to_member'] <= threshold:
|
||||
adjacent[a][b] = pair['error_rep_to_member']
|
||||
unassigned = set(range(len(objects)))
|
||||
order = sorted(unassigned, key=lambda i: (-len(adjacent[i]), objects[i]['id']))
|
||||
groups = []
|
||||
for rep in order:
|
||||
if rep not in unassigned:
|
||||
continue
|
||||
members = sorted(set(adjacent[rep]) & unassigned)
|
||||
members.append(rep)
|
||||
unassigned.difference_update(members)
|
||||
groups.append({'representative': rep, 'members': members,
|
||||
'max_error': max([adjacent[rep][i] for i in members if i != rep] or [0.])})
|
||||
return groups
|
||||
|
||||
|
||||
def nearest_candidates(objects, features, cap, neighbors=10):
|
||||
buckets = collections.defaultdict(list)
|
||||
for i, obj in enumerate(objects):
|
||||
buckets[(obj['role'], tuple(obj['shape']), obj['scale'], obj['dtype'])].append(i)
|
||||
candidates = []
|
||||
eligible_pairs = 0
|
||||
for key, ids in sorted(buckets.items(), key=lambda item: str(item[0])):
|
||||
eligible_pairs += len(ids) * (len(ids) - 1) // 2
|
||||
if len(ids) < 2:
|
||||
continue
|
||||
x = np.stack([features[i] for i in ids]).astype(np.float64)
|
||||
norm = np.linalg.norm(x, axis=1)
|
||||
u = x / np.maximum(norm[:, None], 1e-30)
|
||||
# Cap each bucket's reservoir to bound the screening matrix.
|
||||
cos = u @ u.T
|
||||
sq = np.maximum(0., norm[:, None] ** 2 + norm[None, :] ** 2 - 2 * (x @ x.T))
|
||||
err = np.sqrt(sq / np.maximum(norm[:, None] ** 2, 1e-30))
|
||||
np.fill_diagonal(cos, -np.inf)
|
||||
np.fill_diagonal(err, np.inf)
|
||||
seen = set()
|
||||
for row, i in enumerate(ids):
|
||||
near = set(np.argsort(err[row])[:neighbors]) | set(np.argsort(-cos[row])[:neighbors])
|
||||
for col in near:
|
||||
j = ids[col]
|
||||
edge = (min(i, j), max(i, j))
|
||||
if i == j or edge in seen:
|
||||
continue
|
||||
seen.add(edge)
|
||||
candidates.append({'a': edge[0], 'b': edge[1], 'screen_error': float(min(err[row, col], err[col, row])),
|
||||
'screen_cosine': float(cos[row, col])})
|
||||
# Low-error candidates first, then guarantee role/scale diversity round-robin.
|
||||
queues = collections.defaultdict(list)
|
||||
for c in sorted(candidates, key=lambda c: (c['screen_error'], c['a'], c['b'])):
|
||||
o = objects[c['a']]
|
||||
queues[(o['role'], tuple(o['shape']), o['scale'])].append(c)
|
||||
queues = [collections.deque(q) for _, q in sorted(queues.items(), key=lambda x: str(x[0]))]
|
||||
chosen = []
|
||||
while queues and len(chosen) < cap:
|
||||
for q in queues:
|
||||
if q and len(chosen) < cap:
|
||||
chosen.append(q.popleft())
|
||||
queues = [q for q in queues if q]
|
||||
return chosen, {'eligible_pairs_in_screened_objects': eligible_pairs,
|
||||
'candidate_pairs_before_cap': len(candidates), 'selected_pairs': len(chosen)}
|
||||
|
||||
|
||||
def object_record(t, kind='tensor', shape=None, start=None, scale='whole'):
|
||||
shape = tuple(shape or t.shape)
|
||||
return {'id': t.name if kind == 'tensor' else f'{t.name}|{scale}|{start}',
|
||||
'tensor': t.name, 'role': t.role, 'layer': t.layer, 'kind': kind, 'dtype': t.dtype,
|
||||
'shape': shape, 'start': start, 'scale': scale,
|
||||
'bytes': math.prod(shape) * (t.bytes // t.numel)}
|
||||
|
||||
|
||||
def build_blocks(tensors, seed, deadline, reservoir_limit=256):
|
||||
reservoirs, counts, rngs = {}, collections.Counter(), {}
|
||||
totals = collections.defaultdict(lambda: {'blocks': 0, 'bytes': 0, 'edge_bytes': 0})
|
||||
for t in tensors.values():
|
||||
if len(t.shape) == 2:
|
||||
specs = [(f'2d-{s}', (s, s)) for s in (64, 128) if min(t.shape) >= s]
|
||||
elif len(t.shape) == 3:
|
||||
specs = [('3d-axis0-slice', (1, min(64, t.shape[1]), min(64, t.shape[2]))),
|
||||
('3d-volume', (min(4, t.shape[0]), min(32, t.shape[1]), min(32, t.shape[2])))]
|
||||
else:
|
||||
continue
|
||||
for scale, shape in specs:
|
||||
nblocks = math.prod(d // b for d, b in zip(t.shape, shape))
|
||||
totals[scale]['blocks'] += nblocks
|
||||
block_bytes = math.prod(shape) * (t.bytes // t.numel)
|
||||
totals[scale]['bytes'] += nblocks * block_bytes
|
||||
totals[scale]['edge_bytes'] += t.bytes - nblocks * block_bytes
|
||||
for grid in itertools.product(*(range(d // b) for d, b in zip(t.shape, shape))):
|
||||
if time.monotonic() > deadline:
|
||||
raise TimeoutError('Deadline during block enumeration')
|
||||
start = tuple(i * b for i, b in zip(grid, shape))
|
||||
obj = object_record(t, 'block', shape, start, scale)
|
||||
key = (t.role, shape, scale)
|
||||
if key not in reservoirs:
|
||||
reservoirs[key], rngs[key] = [], np.random.default_rng(stable_seed(key, seed))
|
||||
counts[key] += 1
|
||||
reservoir = reservoirs[key]
|
||||
if len(reservoir) < reservoir_limit:
|
||||
reservoir.append(obj)
|
||||
else:
|
||||
j = int(rngs[key].integers(counts[key]))
|
||||
if j < reservoir_limit:
|
||||
reservoir[j] = obj
|
||||
objects = [obj for key in sorted(reservoirs, key=str) for obj in reservoirs[key]]
|
||||
coverage = [{'role': key[0], 'shape': str(key[1]), 'scale': key[2],
|
||||
'total_blocks': counts[key], 'sampled_blocks': len(reservoirs[key])}
|
||||
for key in sorted(reservoirs, key=str)]
|
||||
return objects, coverage, dict(totals)
|
||||
|
||||
|
||||
def structural_probe(a, b, tensors):
|
||||
"""Bounded mode unfoldings of aligned subvolumes; exploratory, never a grouping criterion."""
|
||||
def small(obj):
|
||||
t = tensors[obj['tensor']]
|
||||
shape = obj['shape']
|
||||
starts = obj['start'] or [0] * len(shape)
|
||||
slices = tuple(slice(s, s + min(d, 32)) for s, d in zip(starts, shape))
|
||||
return decode(t.raw.reshape(t.shape)[slices], t.dtype)
|
||||
x, y = small(a), small(b)
|
||||
result = []
|
||||
if x.ndim < 2:
|
||||
return result
|
||||
for axis in range(x.ndim):
|
||||
mx = np.moveaxis(x, axis, 0).reshape(x.shape[axis], -1)
|
||||
my = np.moveaxis(y, axis, 0).reshape(y.shape[axis], -1)
|
||||
if min(mx.shape) < 2:
|
||||
result.append({'axis': axis, 'probe_shape': list(x.shape), 'trivial_mode_skipped': True})
|
||||
continue
|
||||
ux, sx, _ = np.linalg.svd(mx, full_matrices=False)
|
||||
uy, sy, _ = np.linalg.svd(my, full_matrices=False)
|
||||
k = min(4, max(1, min(len(sx), len(sy)) // 2))
|
||||
result.append({'axis': axis, 'probe_shape': list(x.shape),
|
||||
'k': k,
|
||||
'normalized_spectrum_distance': float(np.linalg.norm(sx / max(np.linalg.norm(sx), 1e-30) - sy / max(np.linalg.norm(sy), 1e-30))),
|
||||
'left_subspace_overlap': float(np.linalg.norm(ux[:, :k].T @ uy[:, :k]) ** 2 / k)})
|
||||
return result
|
||||
|
||||
|
||||
def analyze_mode(mode, objects, tensors, root, deadline, cap, seed, baseline_cap=100):
|
||||
print(f'{mode}: sampling {len(objects)} objects', flush=True)
|
||||
features = []
|
||||
for obj in objects:
|
||||
features.append(sample_object(obj, tensors))
|
||||
tensors[obj['tensor']].evict()
|
||||
candidates, coverage = nearest_candidates(objects, features, cap)
|
||||
write_json(root / f'{mode}_objects.json', objects)
|
||||
pairs, nulls, structures = [], [], []
|
||||
rng = np.random.default_rng(seed)
|
||||
random_pairs = []
|
||||
comparable = collections.defaultdict(list)
|
||||
for j, obj in enumerate(objects):
|
||||
comparable[(obj['role'], tuple(obj['shape']), obj['scale'], obj['dtype'])].append(j)
|
||||
for key, ids in sorted(comparable.items(), key=lambda item: str(item[0])):
|
||||
if len(ids) < 2:
|
||||
continue
|
||||
for _ in range(3):
|
||||
a, b = rng.choice(ids, size=2, replace=False).tolist()
|
||||
random_pairs.append({'a': a, 'b': b, 'role': key[0], 'sampled': True,
|
||||
**metrics(features[a], features[b])})
|
||||
write_json(root / f'{mode}_random_pairs.json', random_pairs)
|
||||
timeout = False
|
||||
structural_counts = collections.Counter()
|
||||
for i, candidate in enumerate(candidates):
|
||||
if time.monotonic() > deadline:
|
||||
timeout = True
|
||||
break
|
||||
a, b = candidate['a'], candidate['b']
|
||||
try:
|
||||
measured = exact_pair(objects[a], objects[b], tensors, deadline)
|
||||
except TimeoutError:
|
||||
timeout = True
|
||||
break
|
||||
row = {**candidate, **measured,
|
||||
'a_id': objects[a]['id'], 'b_id': objects[b]['id'],
|
||||
'role': objects[a]['role'], 'scale_name': objects[a]['scale'],
|
||||
'layer_distance': abs(objects[a]['layer'] - objects[b]['layer'])}
|
||||
row['screen_vs_exact_min_error_absolute_difference'] = abs(candidate['screen_error'] - min(measured['error_member_to_rep'], measured['error_rep_to_member']))
|
||||
# Tail diagnostics are sampled, explicitly labelled, not claimed exact.
|
||||
fx, fy = features[a].astype(np.float64), features[b].astype(np.float64)
|
||||
row['sampled_error_q99_over_member_rms'] = float(np.quantile(np.abs(fx - fy), .99) / max(np.sqrt(np.mean(fx * fx)), 1e-30))
|
||||
pairs.append(row)
|
||||
if i < baseline_cap:
|
||||
for method, y in [('shuffled', rng.permutation(fy)), ('gaussian_norm_matched', rng.normal(size=fy.size))]:
|
||||
if method == 'gaussian_norm_matched':
|
||||
y *= np.linalg.norm(fy) / max(np.linalg.norm(y), 1e-30)
|
||||
nulls.append({'a': a, 'b': b, 'method': method, 'sampled': True, **metrics(fx, y)})
|
||||
ndim = len(objects[a]['shape'])
|
||||
if ndim >= 2 and structural_counts[ndim] < 20:
|
||||
structures.append({'a': a, 'b': b, 'modes': structural_probe(objects[a], objects[b], tensors)})
|
||||
tensors[objects[a]['tensor']].evict()
|
||||
tensors[objects[b]['tensor']].evict()
|
||||
structural_counts[ndim] += 1
|
||||
if (i + 1) % 100 == 0:
|
||||
write_csv(root / f'{mode}_pairs.csv', pairs)
|
||||
print(f'{mode}: verified {i + 1}/{len(candidates)}', flush=True)
|
||||
write_csv(root / f'{mode}_pairs.csv', pairs)
|
||||
write_json(root / f'{mode}_nulls.json', nulls)
|
||||
write_json(root / f'{mode}_structure.json', structures)
|
||||
coverage.update({'objects_screened': len(objects), 'pairs_verified': len(pairs), 'timed_out': timeout,
|
||||
'screen_sample_elements': 2048, 'candidate_neighbors_per_metric': 10})
|
||||
write_json(root / f'{mode}_coverage.json', coverage)
|
||||
return pairs
|
||||
|
||||
|
||||
def summarize(mode, objects, pairs, model_bytes, root, partition_totals=None):
|
||||
rows = []
|
||||
scales = sorted({o['scale'] for o in objects})
|
||||
for scale in scales:
|
||||
ids = [i for i, o in enumerate(objects) if o['scale'] == scale]
|
||||
selected = set(ids)
|
||||
for threshold in THRESHOLDS:
|
||||
groups = sharing_groups(objects, [p for p in pairs if p['a'] in selected], threshold)
|
||||
groups = [g for g in groups if g['representative'] in selected]
|
||||
original = sum(objects[i]['bytes'] for i in ids)
|
||||
rep_bytes = sum(objects[g['representative']]['bytes'] for g in groups)
|
||||
# Concrete theoretical layout: 16 bytes per object mapping, plus 64 bytes per shared group.
|
||||
# Identity case falls back to original checkpoint at zero additional cost.
|
||||
mapping_bytes = 16 * len(ids) + 64 * sum(len(g['members']) > 1 for g in groups)
|
||||
proposed = rep_bytes + mapping_bytes
|
||||
saved = max(0, original - proposed)
|
||||
partition_count = partition_totals[scale]['blocks'] if partition_totals else len(ids)
|
||||
rows.append({'mode': mode, 'scale': scale, 'threshold': threshold,
|
||||
'objects': len(ids), 'groups': len(groups),
|
||||
'total_partition_objects': partition_count,
|
||||
'unexamined_partition_objects': partition_count - len(ids),
|
||||
'conservative_partition_groups': partition_count - len(ids) + len(groups),
|
||||
'shared_groups': sum(len(g['members']) > 1 for g in groups),
|
||||
'max_group_size': max([len(g['members']) for g in groups] or [0]),
|
||||
'verified_shared_bytes': sum(sum(objects[i]['bytes'] for i in g['members']) for g in groups if len(g['members']) > 1),
|
||||
'examined_object_bytes': original, 'representative_bytes': rep_bytes,
|
||||
'mapping_bytes_if_encoded': mapping_bytes, 'net_saved_bytes': saved,
|
||||
'net_saved_model_fraction': saved / model_bytes,
|
||||
'max_replacement_error': max([g['max_error'] for g in groups] or [0.])})
|
||||
write_json(root / f'groups_{mode}_{scale}_{threshold:.2f}.json', groups)
|
||||
return rows
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--root', type=pathlib.Path, required=True)
|
||||
p.add_argument('--seconds', type=int, default=7200)
|
||||
p.add_argument('--seed', type=int, default=20261109)
|
||||
args = p.parse_args()
|
||||
started = time.monotonic()
|
||||
deadline = started + args.seconds
|
||||
root = args.root
|
||||
output = root / 'analysis'
|
||||
output.mkdir(exist_ok=True)
|
||||
tensors = load_tensors(root / 'weights')
|
||||
inventory = []
|
||||
for t in tensors.values():
|
||||
if time.monotonic() > deadline:
|
||||
raise TimeoutError('Deadline during inventory')
|
||||
n = 0
|
||||
total = squared = 0.
|
||||
max_abs = 0.
|
||||
for x in t.chunked():
|
||||
if not np.isfinite(x).all():
|
||||
raise ValueError(f'Nonfinite weights: {t.name}')
|
||||
z = x.astype(np.float64)
|
||||
n += z.size
|
||||
total += float(z.sum())
|
||||
squared += float(z @ z)
|
||||
max_abs = max(max_abs, float(np.abs(z).max()))
|
||||
t.evict()
|
||||
inventory.append({'name': t.name, 'shape': str(t.shape), 'ndim': len(t.shape), 'dtype': t.dtype,
|
||||
'numel': t.numel, 'bytes': t.bytes, 'role': t.role, 'layer': t.layer,
|
||||
'mean': total / n, 'rms': math.sqrt(squared / n), 'max_abs': max_abs})
|
||||
t.evict()
|
||||
write_csv(output / 'inventory.csv', inventory)
|
||||
print(f'Inventory: {len(tensors)} tensors, {sum(t.bytes for t in tensors.values())} bytes', flush=True)
|
||||
whole = [object_record(t) for t in tensors.values()]
|
||||
# Stage budgets prevent the whole-tensor stage from consuming block-analysis time.
|
||||
whole_deadline = min(deadline, started + args.seconds * .50)
|
||||
whole_pairs = analyze_mode('tensor', whole, tensors, output, whole_deadline, 2000, args.seed)
|
||||
blocks, block_coverage, block_totals = build_blocks(tensors, args.seed, deadline)
|
||||
write_csv(output / 'block_sampling.csv', block_coverage)
|
||||
write_json(output / 'block_partitions.json', block_totals)
|
||||
block_pairs = analyze_mode('block', blocks, tensors, output, deadline, 20000, args.seed)
|
||||
model_bytes = sum(t.bytes for t in tensors.values())
|
||||
rows = summarize('tensor', whole, whole_pairs, model_bytes, output)
|
||||
rows += summarize('block', blocks, block_pairs, model_bytes, output, block_totals)
|
||||
write_csv(output / 'compression_curve.csv', rows)
|
||||
summary = {'model': json.loads((root / 'manifest.json').read_text())['repo'],
|
||||
'revision': json.loads((root / 'manifest.json').read_text())['revision'],
|
||||
'tensor_count': len(tensors), 'parameter_count': sum(t.numel for t in tensors.values()),
|
||||
'model_weight_bytes': model_bytes, 'ndim_counts': dict(collections.Counter(len(t.shape) for t in tensors.values())),
|
||||
'elapsed_seconds': time.monotonic() - started, 'analysis_budget_seconds': args.seconds,
|
||||
'peak_rss_kib': resource.getrusage(resource.RUSAGE_SELF).ru_maxrss,
|
||||
'python': platform.python_version(), 'numpy': np.__version__, 'seed': args.seed,
|
||||
'limitations': ['No inference or functional equivalence measured', 'No exhaustive pair search',
|
||||
'Block search uses per-role/shape/scale reservoirs of 256',
|
||||
'Different block scales overlap; savings must not be added',
|
||||
'Block savings count only verified disjoint sampled blocks, no extrapolation',
|
||||
'Spectral probes use aligned bounded subvolumes, not whole tensors',
|
||||
'Shared encoding is theoretical, not a runnable compressed checkpoint',
|
||||
'No cross-role grouping, neuron permutation alignment, or training'],
|
||||
'completed': True}
|
||||
write_json(output / 'summary.json', summary)
|
||||
print(json.dumps(summary), flush=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,75 @@
|
||||
"""Audit saved numerical data and freeze provenance before archive/cleanup."""
|
||||
import argparse
|
||||
import csv
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import pathlib
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import time
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--root', required=True, type=pathlib.Path)
|
||||
p.add_argument('--analysis-code-commit', help='Commit actually used for the weight analysis; omit if unknown')
|
||||
args = p.parse_args()
|
||||
root = args.root.resolve()
|
||||
if not __debug__:
|
||||
raise RuntimeError('Validation requires Python assertions enabled')
|
||||
checked = {}
|
||||
for mode in ('tensor', 'block'):
|
||||
with (root / 'analysis' / f'{mode}_pairs.csv').open() as f:
|
||||
rows = list(csv.DictReader(f))
|
||||
coverage = json.loads((root / 'analysis' / f'{mode}_coverage.json').read_text())
|
||||
if len(rows) != coverage['pairs_verified']:
|
||||
raise ValueError('Coverage count mismatch')
|
||||
for row in rows:
|
||||
for key in ('cosine', 'pearson'):
|
||||
if row[key] and (not math.isfinite(float(row[key])) or abs(float(row[key])) > 1 + 1e-7):
|
||||
raise ValueError(f'Invalid correlation: {mode}/{key}')
|
||||
for key in ('error_member_to_rep', 'error_rep_to_member', 'symmetric_error', 'scaled_error',
|
||||
'sampled_error_q99_over_member_rms', 'screen_vs_exact_min_error_absolute_difference'):
|
||||
value = float(row[key])
|
||||
if not math.isfinite(value) or value < 0:
|
||||
raise ValueError(f'Invalid error: {mode}/{key}')
|
||||
if not math.isfinite(float(row['scale'])):
|
||||
raise ValueError('Invalid scaling diagnostic')
|
||||
checked[mode] = {'rows': len(rows), 'finite_metrics': True, 'coverage_matches': True}
|
||||
test_log = (root / 'tests.log').read_text()
|
||||
match = re.search(r'Ran (\d+) tests in ([\d.]+)s', test_log)
|
||||
if not match or '\nOK\n' not in test_log:
|
||||
raise ValueError('Final tests did not pass')
|
||||
qc = {'passed': True, 'checked_unix': time.time(), 'numerical_tables': checked,
|
||||
'final_tests': int(match[1]), 'final_test_seconds': float(match[2]),
|
||||
'earlier_parallel_test_timeout_seconds': 300 if (root / 'tests-during-io-timeout.txt').exists() else None}
|
||||
(root / 'numerical-qc.json').write_text(json.dumps(qc, indent=2))
|
||||
for src, dest in [('tests.log', 'test-results.txt'), ('analysis.log', 'analysis-run.txt'),
|
||||
('plot.log', 'plot-run.txt'), ('download-ranged.log', 'download-progress.txt'),
|
||||
('supervisor.log', 'supervisor-run.txt')]:
|
||||
shutil.copy2(root / src, root / dest)
|
||||
mem = {}
|
||||
for line in pathlib.Path('/proc/meminfo').read_text().splitlines():
|
||||
key, value = line.split(':', 1)
|
||||
if key in ('MemTotal', 'MemAvailable', 'SwapTotal', 'SwapFree'):
|
||||
mem[key + '_KiB'] = int(value.split()[0])
|
||||
environment = {'recorded_unix': time.time(), 'python': platform.python_version(),
|
||||
'platform': platform.platform(), 'machine': platform.machine(),
|
||||
'logical_cpus': os.cpu_count(), 'memory_snapshot': mem,
|
||||
'blas_threads': 1, 'assertions_enabled': __debug__,
|
||||
'analysis_io_priority': 'best-effort 7, applied during block verification',
|
||||
'analysis_code_commit': args.analysis_code_commit,
|
||||
'note': 'Shared host; see resource-observation.txt. Memory snapshot is post-analysis.'}
|
||||
(root / 'execution-environment.json').write_text(json.dumps(environment, indent=2))
|
||||
project = pathlib.Path(__file__).resolve().parents[1]
|
||||
files = sorted((project / 'pilot').glob('*.py')) + [project / 'requirements.txt', project / 'tests/test_pilot.py']
|
||||
hashes = [f'{hashlib.sha256(file.read_bytes()).hexdigest()} {file.relative_to(project)}' for file in files]
|
||||
(root / 'code_checksums.txt').write_text('\n'.join(hashes) + '\n')
|
||||
print(json.dumps(qc))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,140 @@
|
||||
"""Download pinned official safetensors, no framework or shared cache."""
|
||||
import argparse
|
||||
import concurrent.futures
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
import threading
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
|
||||
def fetch_json(url):
|
||||
with urllib.request.urlopen(url, timeout=90) as response:
|
||||
return json.load(response)
|
||||
|
||||
|
||||
def ranged_download(url, part, total, workers=8):
|
||||
"""Resume a sequential prefix; journal completed byte ranges before final hashing."""
|
||||
journal = part.with_suffix(part.suffix + '.ranges.json')
|
||||
if journal.exists():
|
||||
state = json.loads(journal.read_text())
|
||||
if state['total'] != total:
|
||||
raise RuntimeError('Range journal size mismatch')
|
||||
else:
|
||||
state = {'total': total, 'prefix': part.stat().st_size if part.exists() else 0, 'done': []}
|
||||
journal.write_text(json.dumps(state))
|
||||
lock = threading.Lock()
|
||||
fd = os.open(part, os.O_CREAT | os.O_RDWR, 0o600)
|
||||
chunk_size = 64 * 1024 * 1024
|
||||
ranges = [(start, min(start + chunk_size, total) - 1)
|
||||
for start in range(state['prefix'], total, chunk_size)]
|
||||
|
||||
def one(bounds):
|
||||
start, end = bounds
|
||||
if start in state['done']:
|
||||
return
|
||||
for attempt in range(3):
|
||||
try:
|
||||
req = urllib.request.Request(url, headers={'Range': f'bytes={start}-{end}'})
|
||||
with urllib.request.urlopen(req, timeout=180) as response:
|
||||
expected = f'bytes {start}-{end}/{total}'
|
||||
if response.status != 206 or response.headers.get('Content-Range') != expected:
|
||||
raise RuntimeError('Server did not honor exact requested range')
|
||||
offset = start
|
||||
while chunk := response.read(min(4 * 1024 * 1024, end - offset + 1)):
|
||||
written = os.pwrite(fd, chunk, offset)
|
||||
if written != len(chunk):
|
||||
raise RuntimeError('Short positional write')
|
||||
offset += written
|
||||
if offset > end:
|
||||
break
|
||||
if offset != end + 1:
|
||||
raise RuntimeError('Incomplete range')
|
||||
with lock:
|
||||
os.fsync(fd)
|
||||
state['done'].append(start)
|
||||
tmp = journal.with_suffix('.tmp')
|
||||
tmp.write_text(json.dumps(state))
|
||||
tmp.replace(journal)
|
||||
done = state['prefix'] + sum(b - a + 1 for a, b in ranges if a in state['done'])
|
||||
print(f'Weight download {done}/{total} bytes ({100 * done / total:.1f}%)', flush=True)
|
||||
return
|
||||
except Exception:
|
||||
if attempt == 2:
|
||||
raise
|
||||
time.sleep(2 ** attempt)
|
||||
try:
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as pool:
|
||||
list(pool.map(one, ranges))
|
||||
finally:
|
||||
os.close(fd)
|
||||
journal.unlink()
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--root', type=pathlib.Path, required=True)
|
||||
p.add_argument('--repo', default='Qwen/Qwen3.5-2B')
|
||||
args = p.parse_args()
|
||||
root = args.root.resolve()
|
||||
root.mkdir(parents=True, exist_ok=True)
|
||||
weights = root / 'weights'
|
||||
weights.mkdir(exist_ok=True)
|
||||
marker = weights / '.pilot-owned'
|
||||
marker.write_text(args.repo)
|
||||
old_manifest = root / 'manifest.json'
|
||||
pinned = json.loads(old_manifest.read_text())['revision'] if old_manifest.exists() else None
|
||||
endpoint = f'https://huggingface.co/api/models/{args.repo}'
|
||||
if pinned:
|
||||
endpoint += f'/revision/{pinned}'
|
||||
info = fetch_json(endpoint + '?blobs=true')
|
||||
revision = info['sha']
|
||||
files = [f for f in info['siblings'] if f['rfilename'].endswith('.safetensors')
|
||||
or f['rfilename'] in ('config.json', 'model.safetensors.index.json', 'README.md')]
|
||||
total = sum(f.get('size', 0) for f in files)
|
||||
if shutil.disk_usage(root).free < total + 3_000_000_000:
|
||||
raise RuntimeError('Insufficient space for checkpoint plus 3 GB margin')
|
||||
manifest = {'repo': args.repo, 'revision': revision, 'expected_bytes': total,
|
||||
'started_unix': time.time(), 'files': [], 'license': info.get('cardData', {}).get('license')}
|
||||
(root / 'source_metadata.json').write_text(json.dumps(info, indent=2))
|
||||
for entry in files:
|
||||
name = entry['rfilename']
|
||||
if pathlib.PurePosixPath(name).name != name:
|
||||
raise RuntimeError(f'Unexpected nested path: {name}')
|
||||
dest = weights / name
|
||||
part = dest.with_suffix(dest.suffix + '.partial')
|
||||
digest = hashlib.sha256()
|
||||
url = f'https://huggingface.co/{args.repo}/resolve/{revision}/{urllib.parse.quote(name)}?download=true'
|
||||
print(f'Downloading {name}, expected {entry.get("size")} bytes', flush=True)
|
||||
if entry.get('size', 0) > 128 * 1024 * 1024:
|
||||
ranged_download(url, part, entry['size'])
|
||||
with part.open('rb') as stream:
|
||||
while chunk := stream.read(4 * 1024 * 1024):
|
||||
digest.update(chunk)
|
||||
else:
|
||||
with urllib.request.urlopen(url, timeout=180) as response, part.open('wb') as out:
|
||||
while chunk := response.read(4 * 1024 * 1024):
|
||||
out.write(chunk)
|
||||
digest.update(chunk)
|
||||
sha = digest.hexdigest()
|
||||
if entry.get('size') and part.stat().st_size != entry['size']:
|
||||
raise RuntimeError(f'Size mismatch: {name}')
|
||||
expected_sha = entry.get('lfs', {}).get('sha256')
|
||||
if expected_sha and sha != expected_sha:
|
||||
raise RuntimeError(f'SHA256 mismatch: {name}')
|
||||
part.rename(dest)
|
||||
manifest['files'].append({'name': name, 'bytes': dest.stat().st_size,
|
||||
'sha256': sha, 'upstream_sha256': expected_sha})
|
||||
(root / 'manifest.json').write_text(json.dumps(manifest, indent=2))
|
||||
manifest['completed_unix'] = time.time()
|
||||
(root / 'manifest.json').write_text(json.dumps(manifest, indent=2))
|
||||
shutil.copy2(weights / 'config.json', root / 'model_config.json')
|
||||
print(json.dumps({'revision': revision, 'bytes': sum(f['bytes'] for f in manifest['files'])}), flush=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,261 @@
|
||||
"""Scientific figures and a compact result report from saved data only."""
|
||||
import argparse
|
||||
import csv
|
||||
import json
|
||||
import pathlib
|
||||
|
||||
import matplotlib
|
||||
matplotlib.use('Agg')
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.patches import Patch, Rectangle
|
||||
import numpy as np
|
||||
|
||||
|
||||
def read_csv(path):
|
||||
with path.open() as f:
|
||||
return list(csv.DictReader(f))
|
||||
|
||||
|
||||
def write_csv(path, rows):
|
||||
with path.open('w', newline='') as f:
|
||||
if rows:
|
||||
writer = csv.DictWriter(f, fieldnames=list(rows[0]))
|
||||
writer.writeheader()
|
||||
writer.writerows(rows)
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--root', type=pathlib.Path, required=True)
|
||||
args = p.parse_args()
|
||||
root = args.root
|
||||
out = root / 'analysis'
|
||||
figures = root / 'figures'
|
||||
figures.mkdir(exist_ok=True)
|
||||
plt.rcParams.update({'font.size': 10, 'axes.spines.top': False, 'axes.spines.right': False,
|
||||
'pdf.fonttype': 42, 'svg.fonttype': 'none', 'figure.dpi': 120})
|
||||
def save(fig, name):
|
||||
fig.tight_layout()
|
||||
for ext in ('png', 'pdf', 'svg'):
|
||||
fig.savefig(figures / f'{name}.{ext}', dpi=200, bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
|
||||
curves = read_csv(out / 'compression_curve.csv')
|
||||
summary = json.loads((out / 'summary.json').read_text())
|
||||
dimensional = {}
|
||||
for row in read_csv(out / 'inventory.csv'):
|
||||
ndim = int(row['ndim'])
|
||||
item = dimensional.setdefault(ndim, {'ndim': ndim, 'tensor_count': 0, 'weight_bytes': 0})
|
||||
item['tensor_count'] += 1
|
||||
item['weight_bytes'] += int(row['bytes'])
|
||||
dimensional_rows = [dimensional[key] for key in sorted(dimensional)]
|
||||
for item in dimensional_rows:
|
||||
item['model_byte_fraction'] = item['weight_bytes'] / summary['model_weight_bytes']
|
||||
with (out / 'dimensional_bytes.csv').open('w', newline='') as f:
|
||||
writer = csv.DictWriter(f, fieldnames=list(dimensional_rows[0]))
|
||||
writer.writeheader()
|
||||
writer.writerows(dimensional_rows)
|
||||
fig, axes = plt.subplots(1, 2, figsize=(11, 4))
|
||||
for scale in sorted({r['scale'] for r in curves}):
|
||||
rows = [r for r in curves if r['scale'] == scale]
|
||||
x = [100 * float(r['threshold']) for r in rows]
|
||||
axes[0].plot(x, [100 * float(r['net_saved_model_fraction']) for r in rows], 'o-', label=scale)
|
||||
axes[1].plot(x, [int(r['shared_groups']) for r in rows], 'o-', label=scale)
|
||||
axes[0].set(xlabel='Maximum relative weight error (%)', ylabel='Verified net savings / model bytes (%)')
|
||||
axes[1].set(xlabel='Maximum relative weight error (%)', ylabel='Non-singleton sharing groups')
|
||||
axes[0].legend(fontsize=8, loc='upper left')
|
||||
fig.suptitle('Conservative verified sharing; block scales are separate alternatives')
|
||||
save(fig, 'compression_frontier')
|
||||
|
||||
pair_sets = {mode: read_csv(out / f'{mode}_pairs.csv') for mode in ('tensor', 'block')}
|
||||
role_rows = []
|
||||
for mode, pairs in pair_sets.items():
|
||||
mode_objects = json.loads((out / f'{mode}_objects.json').read_text())
|
||||
buckets = {}
|
||||
for row in pairs:
|
||||
obj = mode_objects[int(row['a'])]
|
||||
key = (obj['role'], obj['scale'], tuple(obj['shape']), obj['dtype'])
|
||||
buckets.setdefault(key, []).append(row)
|
||||
for (role_name, scale_name, shape, dtype), rows in sorted(buckets.items(), key=lambda item: str(item[0])):
|
||||
errors = [float(r['error_member_to_rep']) for r in rows]
|
||||
cosines = [float(r['cosine']) for r in rows if r['cosine']]
|
||||
role_rows.append({'mode': mode, 'role': role_name, 'scale': scale_name,
|
||||
'shape': str(shape), 'ndim': len(shape), 'dtype': dtype,
|
||||
'verified_pairs': len(rows), 'minimum_direct_error': min(errors),
|
||||
'median_direct_error': float(np.median(errors)),
|
||||
'maximum_cosine': max(cosines) if cosines else '',
|
||||
'minimum_scaled_error': min(float(r['scaled_error']) for r in rows),
|
||||
'pairs_under_5pct_direct_error': sum(e <= .05 for e in errors),
|
||||
'pairs_under_20pct_direct_error': sum(e <= .20 for e in errors)})
|
||||
with (out / 'role_summary.csv').open('w', newline='') as f:
|
||||
if role_rows:
|
||||
writer = csv.DictWriter(f, fieldnames=list(role_rows[0]))
|
||||
writer.writeheader()
|
||||
writer.writerows(role_rows)
|
||||
fig, axes = plt.subplots(2, 2, figsize=(11, 7))
|
||||
for row, (mode, pairs) in enumerate(pair_sets.items()):
|
||||
for scale in sorted({r['scale_name'] for r in pairs}):
|
||||
group = [r for r in pairs if r['scale_name'] == scale]
|
||||
axes[row, 0].hist([float(r['cosine']) for r in group if r['cosine']], bins=np.linspace(-1, 1, 46), histtype='step', label=scale)
|
||||
errors = [float(r['error_member_to_rep']) for r in group]
|
||||
axes[row, 1].hist(errors, bins=np.linspace(0, max(1e-6, max(errors, default=0.) * 1.01), 46), histtype='step', label=scale)
|
||||
axes[row, 0].set(title=f'{mode}: exact cosine of screened candidates', xlabel='Cosine', ylabel='Candidate pairs')
|
||||
axes[row, 1].set(title=f'{mode}: exact direct replacement error', xlabel='Relative Frobenius error', ylabel='Candidate pairs')
|
||||
axes[row, 0].legend(fontsize=7, loc='upper right')
|
||||
save(fig, 'candidate_distributions')
|
||||
|
||||
pairs = pair_sets['tensor']
|
||||
roles = sorted({r['role'] for r in pairs})
|
||||
# Illustrate one repeated 2D projection; this is not a byte-weighted model summary.
|
||||
objects = json.loads((out / 'tensor_objects.json').read_text())
|
||||
candidates = [role for role in roles if any(o['role'] == role and len(o['shape']) == 2 for o in objects)]
|
||||
role = max(candidates or roles, key=lambda k: sum(r['role'] == k for r in pairs))
|
||||
chosen = [(i, o) for i, o in enumerate(objects) if o['role'] == role]
|
||||
chosen.sort(key=lambda item: item[1]['layer'])
|
||||
indices = {i: j for j, (i, _) in enumerate(chosen)}
|
||||
matrix = np.full((len(chosen), len(chosen)), np.nan)
|
||||
np.fill_diagonal(matrix, 1.)
|
||||
for r in pairs:
|
||||
a, b = int(r['a']), int(r['b'])
|
||||
if a in indices and b in indices and r['cosine']:
|
||||
matrix[indices[a], indices[b]] = matrix[indices[b], indices[a]] = float(r['cosine'])
|
||||
fig, ax = plt.subplots(figsize=(7, 6))
|
||||
cmap = plt.get_cmap('coolwarm').with_extremes(bad='white')
|
||||
im = ax.imshow(matrix, cmap=cmap, vmin=-1, vmax=1)
|
||||
for y, x in zip(*np.where(np.isnan(matrix))):
|
||||
ax.add_patch(Rectangle((x - .5, y - .5), 1, 1, facecolor='none',
|
||||
edgecolor='#999999', hatch='///', linewidth=0))
|
||||
labels = [o['layer'] for _, o in chosen]
|
||||
ticks = np.arange(0, len(labels), max(1, len(labels) // 10))
|
||||
ax.set_xticks(ticks, [labels[i] for i in ticks])
|
||||
ax.set_yticks(ticks, [labels[i] for i in ticks])
|
||||
ax.set(xlabel='Layer', ylabel='Layer', title=role.removeprefix('model.') + '\nHatching = unverified; diagonal is identity')
|
||||
ax.legend(handles=[Patch(facecolor='white', edgecolor='#999999', hatch='///', label='Unverified pair')],
|
||||
loc='upper center', bbox_to_anchor=(.5, -.12), fontsize=8, frameon=False)
|
||||
fig.colorbar(im, ax=ax, label='Exact cosine')
|
||||
save(fig, 'layer_heatmap')
|
||||
heatmap_rows = [{'a_layer': oa['layer'], 'b_layer': ob['layer'], 'role': role,
|
||||
'cosine': float(matrix[i, j]) if not np.isnan(matrix[i, j]) else '',
|
||||
'verified': bool(i != j and not np.isnan(matrix[i, j])), 'identity': i == j}
|
||||
for i, (_, oa) in enumerate(chosen) for j, (_, ob) in enumerate(chosen)]
|
||||
write_csv(out / 'heatmap_pairs.csv', heatmap_rows)
|
||||
|
||||
distance_rows = []
|
||||
fig, axes = plt.subplots(1, 2, figsize=(12, 4), sharey=True)
|
||||
for ax, mode in zip(axes, ('tensor', 'block')):
|
||||
mode_objects = json.loads((out / f'{mode}_objects.json').read_text())
|
||||
buckets = {}
|
||||
for row in pair_sets[mode]:
|
||||
if not row['cosine']:
|
||||
continue
|
||||
obj = mode_objects[int(row['a'])]
|
||||
stratum = f"{len(obj['shape'])}D" if mode == 'tensor' else obj['scale']
|
||||
buckets.setdefault(stratum, {}).setdefault(int(row['layer_distance']), []).append(float(row['cosine']))
|
||||
for stratum, by_distance in sorted(buckets.items()):
|
||||
distances = sorted(by_distance)
|
||||
medians = []
|
||||
for distance in distances:
|
||||
values = by_distance[distance]
|
||||
median = float(np.median(values))
|
||||
medians.append(median)
|
||||
distance_rows.append({'mode': mode, 'stratum': stratum, 'layer_distance': distance,
|
||||
'pairs': len(values), 'median_cosine': median,
|
||||
'q25': float(np.quantile(values, .25)), 'q75': float(np.quantile(values, .75))})
|
||||
ax.plot(distances, medians, 'o-', markersize=3, label=stratum)
|
||||
ax.set(xlabel='Absolute layer distance', ylabel='Median exact cosine',
|
||||
title=f'{mode}: dimension / scale strata', ylim=(-.1, 1.05))
|
||||
ax.legend(fontsize=8, loc='upper center', bbox_to_anchor=(.5, -.23), ncol=2, frameon=False)
|
||||
fig.suptitle('Screened candidates: module mixture and selection bias still apply')
|
||||
write_csv(out / 'layer_distance_stratified.csv', distance_rows)
|
||||
save(fig, 'layer_distance')
|
||||
|
||||
null_rows = []
|
||||
fig, axes = plt.subplots(3, 2, figsize=(12, 10))
|
||||
bins = np.linspace(-1, 1, 26)
|
||||
for col, mode in enumerate(('tensor', 'block')):
|
||||
mode_objects = json.loads((out / f'{mode}_objects.json').read_text())
|
||||
nulls = json.loads((out / f'{mode}_nulls.json').read_text())
|
||||
real_random = json.loads((out / f'{mode}_random_pairs.json').read_text())
|
||||
cohorts = [('shuffled', [r for r in nulls if r['method'] == 'shuffled']),
|
||||
('gaussian_norm_matched', [r for r in nulls if r['method'] == 'gaussian_norm_matched']),
|
||||
('random_actual_same_role', real_random)]
|
||||
for row, ndim in enumerate((1, 2, 3)):
|
||||
ax = axes[row, col]
|
||||
any_values = False
|
||||
for method, records in cohorts:
|
||||
values = np.asarray([r['cosine'] for r in records if r['cosine'] is not None
|
||||
and len(mode_objects[r['a']]['shape']) == ndim])
|
||||
if not len(values):
|
||||
continue
|
||||
any_values = True
|
||||
values = np.clip(values, -1, 1)
|
||||
ax.hist(values, bins=bins, density=True, histtype='step', label=f'{method} (n={len(values)})')
|
||||
counts, _ = np.histogram(values, bins=bins)
|
||||
for i, count in enumerate(counts):
|
||||
null_rows.append({'mode': mode, 'ndim': ndim, 'method': method, 'samples': len(values),
|
||||
'bin_left': float(bins[i]), 'bin_right': float(bins[i + 1]),
|
||||
'count': int(count), 'density': float(count / (len(values) * (bins[i + 1] - bins[i])))})
|
||||
ax.set(title=f'{mode}: {ndim}D sampled controls', xlabel='Sampled cosine', ylabel='Density')
|
||||
if any_values:
|
||||
ax.legend(fontsize=7, loc='upper right')
|
||||
else:
|
||||
ax.text(.5, .5, 'No eligible samples', transform=ax.transAxes, ha='center')
|
||||
fig.suptitle('Dimension-stratified controls: density normalized; role mixtures may differ')
|
||||
write_csv(out / 'null_histograms.csv', null_rows)
|
||||
save(fig, 'null_controls')
|
||||
|
||||
fig, axes = plt.subplots(1, 2, figsize=(11, 4))
|
||||
structure = json.loads((out / 'block_structure.json').read_text())
|
||||
for ax, ndim in zip(axes, (2, 3)):
|
||||
probes = [m for pair in structure for m in pair['modes'] if len(m['probe_shape']) == ndim and not m.get('trivial_mode_skipped')]
|
||||
for axis in sorted({m['axis'] for m in probes}):
|
||||
selected = [m for m in probes if m['axis'] == axis]
|
||||
ax.scatter([m['normalized_spectrum_distance'] for m in selected],
|
||||
[m['left_subspace_overlap'] for m in selected], s=18, alpha=.65, label=f'mode {axis}')
|
||||
ax.set(title=f'{ndim}D blocks: bounded mode-unfolding probes', xlabel='Normalized spectrum distance', ylabel='Leading left subspace overlap (k <= 4)')
|
||||
if probes:
|
||||
ax.legend(fontsize=8, loc='upper right')
|
||||
else:
|
||||
ax.text(.5, .5, 'No eligible probes', transform=ax.transAxes, ha='center')
|
||||
save(fig, 'block_structure')
|
||||
|
||||
parts = json.loads((out / 'block_partitions.json').read_text())
|
||||
lines = ['# Qwen3.5-2B parameter similarity pilot', '',
|
||||
f"- Revision: `{summary['revision']}`", f"- Stored parameters: {summary['parameter_count']:,}",
|
||||
f"- Weight bytes: {summary['model_weight_bytes']:,}",
|
||||
f"- Tensor dimensionalities: {summary['ndim_counts']}",
|
||||
f"- Analysis and grouping/export wall time: {summary['elapsed_seconds']:.1f} seconds",
|
||||
f"- Pair-comparison cutoff: {summary['analysis_budget_seconds']} seconds; final grouping/export is additional and remains under the supervisor hard limit.",
|
||||
f"- Peak analysis RSS: {summary['peak_rss_kib'] / 1024:.1f} MiB", '',
|
||||
'## Verified sharing estimates', '',
|
||||
'| Representation | Weight-error limit | Verified sharing groups | Conservative total groups* | Largest group | Net model savings |',
|
||||
'|---|---:|---:|---:|---:|---:|---:|']
|
||||
for r in curves:
|
||||
lines.append(f"| {r['scale']} | {float(r['threshold']):.0%} | {r['shared_groups']} | {r['conservative_partition_groups']} | {r['max_group_size']} | {float(r['net_saved_model_fraction']):.6%} |")
|
||||
lines += ['', '*Conservative total groups counts unexamined full blocks as singletons; boundary regions and ineligible tensors stay unchanged and are outside that block count.',
|
||||
'Savings count only verified replacement edges. Unsampled blocks remain unchanged. Different block scales must not be summed.',
|
||||
'Theoretical encoding: one stored representative per group, 16 bytes per object mapping and 64 bytes per shared-group descriptor; identity fallback if larger.',
|
||||
'Exact grouping uses direct replacement only. Scaled and spectral results are diagnostic.', '',
|
||||
'## Stratified diagnostics', '',
|
||||
'See `analysis/role_summary.csv` for same-role, same-shape statistics, separated by tensor dimensionality and block scale.',
|
||||
'See `analysis/dimensional_bytes.csv` for tensor counts versus weight-byte contributions by dimensionality.',
|
||||
'Heatmap missing pairs are hatched (`heatmap_pairs.csv`); identity entries are not empirical matches.',
|
||||
'Layer-distance medians are split by dimension/scale (`layer_distance_stratified.csv`); role and selection bias remain.',
|
||||
'Controls are split by dimension and density-normalized, with sample counts (`null_histograms.csv`); these are not significance tests.',
|
||||
'These are screened-candidate statistics, not estimates of all possible pairs. Small normalization vectors must not be conflated with large matrices.', '',
|
||||
'## Coverage', '']
|
||||
for mode in ('tensor', 'block'):
|
||||
coverage = json.loads((out / f'{mode}_coverage.json').read_text())
|
||||
lines.append(f'- {mode}: `{json.dumps(coverage)}`')
|
||||
lines += [f'- Complete-block partition totals (per alternative): `{json.dumps(parts)}`', '',
|
||||
'## Interpretation limits', '', *['- ' + s for s in summary['limitations']],
|
||||
'- Candidate histograms are selection-biased and do not represent the distribution of all tensor pairs.',
|
||||
'- 1D normalization weights may cluster strongly but carry few bytes; do not infer material compression from group counts.',
|
||||
'- No task accuracy, perplexity, inference speed or runtime-memory improvement has been measured.',
|
||||
'- Stored parameter counts may omit tied aliases; no duplicate-weight equality search is performed.', '',
|
||||
'## Figures', '', *[f'' for name in ['compression_frontier', 'candidate_distributions', 'layer_heatmap', 'layer_distance', 'null_controls', 'block_structure']]]
|
||||
(root / 'REPORT.md').write_text('\n'.join(lines) + '\n')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,58 @@
|
||||
"""Supervise the one-model job; no automatic download of subsequent models."""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--root', type=pathlib.Path, required=True)
|
||||
args = p.parse_args()
|
||||
root = args.root.resolve()
|
||||
root.mkdir(exist_ok=True, parents=True)
|
||||
status_file = root / 'status.json'
|
||||
start = time.time()
|
||||
env = dict(os.environ, OPENBLAS_NUM_THREADS='1', OMP_NUM_THREADS='1')
|
||||
|
||||
def status(phase, **extra):
|
||||
status_file.write_text(json.dumps({'phase': phase, 'updated_unix': time.time(),
|
||||
'supervisor_started_unix': start, **extra}, indent=2))
|
||||
print(phase, flush=True)
|
||||
|
||||
def command(module, log, timeout, extra=()):
|
||||
with (root / log).open('w') as stream:
|
||||
subprocess.run([sys.executable, '-B', '-m', module, '--root', str(root), *extra],
|
||||
check=True, timeout=timeout, env=env, stdout=stream, stderr=subprocess.STDOUT)
|
||||
|
||||
try:
|
||||
status('waiting_for_download')
|
||||
download_wait_start = time.monotonic()
|
||||
while True:
|
||||
manifest_path = root / 'manifest.json'
|
||||
if manifest_path.exists():
|
||||
manifest = json.loads(manifest_path.read_text())
|
||||
if manifest.get('completed_unix') and all((root / 'weights' / f['name']).exists() for f in manifest['files']):
|
||||
break
|
||||
if time.monotonic() - download_wait_start > 7200:
|
||||
raise TimeoutError('Download wait exceeded 2 hours; no analysis started')
|
||||
time.sleep(10)
|
||||
status('analyzing', analysis_hard_limit_seconds=7200)
|
||||
command('pilot.analyze', 'analysis.log', 7200, ('--seconds', '6600'))
|
||||
status('plotting')
|
||||
command('pilot.plot', 'plot.log', 300)
|
||||
status('validating')
|
||||
command('pilot.validate', 'validate.log', 120)
|
||||
with (root / 'environment.txt').open('w') as f:
|
||||
subprocess.run([sys.executable, '-B', '-m', 'pip', 'freeze'], check=True, stdout=f, env=env)
|
||||
status('results_ready_weights_retained_until_archive_copy')
|
||||
except Exception as e:
|
||||
status('failed', error_type=type(e).__name__, error=str(e))
|
||||
raise
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,82 @@
|
||||
"""Read safetensors BF16 directly; never instantiate a model or use pickle."""
|
||||
import json
|
||||
import math
|
||||
import mmap
|
||||
import re
|
||||
import struct
|
||||
|
||||
import numpy as np
|
||||
|
||||
DTYPES = {'BF16': ('<u2', 2), 'F16': ('<f2', 2), 'F32': ('<f4', 4), 'F64': ('<f8', 8)}
|
||||
|
||||
|
||||
def decode(raw, dtype):
|
||||
if dtype == 'BF16':
|
||||
return (np.asarray(raw).astype(np.uint32) << 16).view(np.float32)
|
||||
return np.asarray(raw, dtype=np.float32)
|
||||
|
||||
|
||||
class Tensor:
|
||||
def __init__(self, file, base, name, meta):
|
||||
self.name, self.shape, self.dtype = name, tuple(meta['shape']), meta['dtype']
|
||||
self.numel = math.prod(self.shape)
|
||||
self.bytes = meta['data_offsets'][1] - meta['data_offsets'][0]
|
||||
code, itemsize = DTYPES[self.dtype]
|
||||
if self.bytes != self.numel * itemsize:
|
||||
raise ValueError(f'Invalid byte length: {name}')
|
||||
self.raw = np.memmap(file, mode='r', dtype=code,
|
||||
offset=base + meta['data_offsets'][0], shape=(self.numel,))
|
||||
self.role = re.sub(r'\.(?:layers|blocks)\.\d+', '.layers.*', name)
|
||||
self.role = re.sub(r'\.experts\.\d+', '.experts.*', self.role)
|
||||
m = re.search(r'\.(?:layers|blocks)\.(\d+)', name)
|
||||
self.layer = int(m[1]) if m else -1
|
||||
|
||||
def read(self, selector=slice(None)):
|
||||
return decode(self.raw[selector], self.dtype)
|
||||
|
||||
def chunked(self, size=262144):
|
||||
for start in range(0, self.numel, size):
|
||||
yield self.read(slice(start, min(start + size, self.numel)))
|
||||
|
||||
def evict(self):
|
||||
if hasattr(self.raw._mmap, 'madvise'):
|
||||
self.raw._mmap.madvise(mmap.MADV_DONTNEED)
|
||||
|
||||
|
||||
def load_tensors(directory):
|
||||
tensors = {}
|
||||
for file in sorted(directory.glob('*.safetensors')):
|
||||
with file.open('rb') as f:
|
||||
size = struct.unpack('<Q', f.read(8))[0]
|
||||
if size > 100_000_000:
|
||||
raise ValueError('Oversized safetensors header')
|
||||
header = json.loads(f.read(size))
|
||||
for name, meta in header.items():
|
||||
if name == '__metadata__':
|
||||
continue
|
||||
if name in tensors:
|
||||
raise ValueError(f'Duplicate tensor name: {name}')
|
||||
tensors[name] = Tensor(file, 8 + size, name, meta)
|
||||
if not tensors:
|
||||
raise ValueError('No safetensors found')
|
||||
return tensors
|
||||
|
||||
|
||||
def metrics(x, y):
|
||||
"""x is member; y is representative. Float64 accumulation."""
|
||||
x, y = x.astype(np.float64), y.astype(np.float64)
|
||||
xx, yy, xy = float(x @ x), float(y @ y), float(x @ y)
|
||||
delta = float((x - y) @ (x - y))
|
||||
return finish(xx, yy, xy, delta, float(x.sum()), float(y.sum()), x.size)
|
||||
|
||||
|
||||
def finish(xx, yy, xy, delta, sx, sy, n):
|
||||
tiny = 1e-30
|
||||
vx, vy = max(0., xx - sx * sx / n), max(0., yy - sy * sy / n)
|
||||
return {'cosine': xy / np.sqrt(xx * yy) if xx * yy > tiny else None,
|
||||
'pearson': (xy - sx * sy / n) / np.sqrt(vx * vy) if vx * vy > tiny else None,
|
||||
'error_member_to_rep': np.sqrt(delta / max(xx, tiny)),
|
||||
'error_rep_to_member': np.sqrt(delta / max(yy, tiny)),
|
||||
'symmetric_error': np.sqrt(2 * delta / max(xx + yy, tiny)),
|
||||
'scaled_error': np.sqrt(max(0., xx - xy * xy / max(yy, tiny)) / max(xx, tiny)),
|
||||
'scale': xy / max(yy, tiny)}
|
||||
@@ -0,0 +1,85 @@
|
||||
"""Validate archived analysis before allowing deletion of downloaded weights."""
|
||||
import argparse
|
||||
import csv
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import shutil
|
||||
import time
|
||||
|
||||
|
||||
def validate(root):
|
||||
analysis = root / 'analysis'
|
||||
summary = json.loads((analysis / 'summary.json').read_text())
|
||||
assert summary['completed']
|
||||
manifest = json.loads((root / 'manifest.json').read_text())
|
||||
assert summary['revision'] == manifest['revision']
|
||||
for mode in ('tensor', 'block'):
|
||||
objects = json.loads((analysis / f'{mode}_objects.json').read_text())
|
||||
with (analysis / f'{mode}_pairs.csv').open() as f:
|
||||
pairs = list(csv.DictReader(f))
|
||||
coverage = json.loads((analysis / f'{mode}_coverage.json').read_text())
|
||||
assert len(pairs) == coverage['pairs_verified']
|
||||
edges = {}
|
||||
for p in pairs:
|
||||
a, b = int(p['a']), int(p['b'])
|
||||
assert objects[a]['shape'] == objects[b]['shape']
|
||||
assert objects[a]['role'] == objects[b]['role']
|
||||
edges[(b, a)] = float(p['error_member_to_rep'])
|
||||
edges[(a, b)] = float(p['error_rep_to_member'])
|
||||
for file in analysis.glob(f'groups_{mode}_*.json'):
|
||||
threshold = float(file.stem.rsplit('_', 1)[1])
|
||||
groups = json.loads(file.read_text())
|
||||
members = [i for g in groups for i in g['members']]
|
||||
assert len(set(members)) == len(members), file
|
||||
for g in groups:
|
||||
assert g['representative'] in g['members']
|
||||
for member in g['members']:
|
||||
if member != g['representative']:
|
||||
assert edges[(g['representative'], member)] <= threshold + 1e-12
|
||||
assert g['max_error'] <= threshold + 1e-12
|
||||
assert (root / 'REPORT.md').is_file()
|
||||
images = list((root / 'figures').glob('*.png'))
|
||||
assert len(images) >= 5
|
||||
for file in images:
|
||||
assert file.read_bytes()[:8] == b'\x89PNG\r\n\x1a\n'
|
||||
checksums = {}
|
||||
for file in sorted(root.rglob('*')):
|
||||
if (file.is_file() and 'weights' not in file.relative_to(root).parts
|
||||
and file.name not in ('checksums.json', 'validation.json', 'cleanup.json', 'status.json')
|
||||
and not file.name.endswith('.log')):
|
||||
checksums[str(file.relative_to(root))] = hashlib.sha256(file.read_bytes()).hexdigest()
|
||||
(root / 'checksums.json').write_text(json.dumps(checksums, indent=2))
|
||||
result = {'validated_unix': time.time(), 'files_checksummed': len(checksums),
|
||||
'group_edges_checked': True, 'passed': True}
|
||||
(root / 'validation.json').write_text(json.dumps(result, indent=2))
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--root', required=True, type=pathlib.Path)
|
||||
p.add_argument('--cleanup-weights', action='store_true')
|
||||
args = p.parse_args()
|
||||
root = args.root.resolve()
|
||||
result = validate(root)
|
||||
if args.cleanup_weights:
|
||||
weights = root / 'weights'
|
||||
manifest = json.loads((root / 'manifest.json').read_text())
|
||||
assert not weights.is_symlink()
|
||||
assert (weights / '.pilot-owned').read_text() == manifest['repo']
|
||||
expected_names = {entry['name'] for entry in manifest['files']} | {'.pilot-owned'}
|
||||
assert {file.name for file in weights.iterdir()} == expected_names
|
||||
assert all(file.is_file() and not file.is_symlink() for file in weights.iterdir())
|
||||
deleted_bytes = sum(file.stat().st_size for file in weights.iterdir())
|
||||
shutil.rmtree(weights)
|
||||
(root / 'cleanup.json').write_text(json.dumps({'deleted_unix': time.time(),
|
||||
'deleted_bytes': deleted_bytes,
|
||||
'deleted_directory': 'weights',
|
||||
'reason': 'User-authorized delete-after-analysis; archived results validated'}, indent=2))
|
||||
result['weights_removed'] = not weights.exists()
|
||||
print(json.dumps(result))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,5 @@
|
||||
# Existing requirements.txt supplies NumPy and plotting dependencies.
|
||||
# Install binary wheels only. Torch is a reference-check dependency, not the streaming runtime.
|
||||
tokenizers==0.23.3
|
||||
# Install separately with --index-url https://download.pytorch.org/whl/cpu:
|
||||
# torch==2.15.0+cpu
|
||||
@@ -0,0 +1,2 @@
|
||||
numpy==2.5.4
|
||||
matplotlib==3.11.2
|
||||
@@ -0,0 +1,25 @@
|
||||
# 实测激活率:SiLU 门控模型
|
||||
|
||||
覆盖24层、4条中英文文本,每条32 token;所有投影输出及 MLP 门控中间量,按64/128输出通道分块。
|
||||
|
||||
| 输出 | 精确零比例均值 | 0.01 RMS以下均值 | 0.1 RMS以下均值 | 32 token内曾活跃通道比例均值 | 90%能量所需通道比例均值 |
|
||||
|---|---:|---:|---:|---:|---:|
|
||||
| mlp.gate_proj.output | 0.0000% | 0.7811% | 7.8005% | 100.0000% | 63.3063% |
|
||||
| mlp.silu_gate | 0.0000% | 0.5031% | 5.1789% | 100.0000% | 70.1228% |
|
||||
| mlp.gated_product | 0.0000% | 3.1636% | 21.0460% | 100.0000% | 54.8421% |
|
||||
| self_attn.q_proj.output | 0.0000% | 1.2760% | 12.4831% | 100.0000% | 44.0277% |
|
||||
| self_attn.k_proj.output | 0.0000% | 1.2245% | 12.0834% | 100.0000% | 53.4587% |
|
||||
| self_attn.v_proj.output | 0.0000% | 1.3741% | 13.4814% | 100.0000% | 59.9447% |
|
||||
|
||||
128通道块×文本观测共27600条,整个32 token窗口全为精确零的块观测数为0。
|
||||
|
||||
表中是整模块逐文本统计再取均值;每个分块的独立统计见 metrics.csv。阈值是各自RMS的比例;阈值下激活率=1−近零比例。能量集中不等于可删除或可替换。
|
||||
|
||||
仅测该模型、四条短文本;不推断所有语言/长上下文。SiLU不把负值整体截零,负数不等于静默。未执行删块/跳算的质量验证。权重和既有缓存全部保留。
|
||||
|
||||
CPU测量耗时268.6秒,峰值RSS151.6 MiB。
|
||||
|
||||
mlp.gated_product: 128通道块在0.1 RMS阈值上的激活率范围 10.47%–89.04%。
|
||||
self_attn.q_proj.output: 128通道块在0.1 RMS阈值上的激活率范围 75.49%–100.00%。
|
||||
self_attn.k_proj.output: 128通道块在0.1 RMS阈值上的激活率范围 81.20%–93.95%。
|
||||
self_attn.v_proj.output: 128通道块在0.1 RMS阈值上的激活率范围 76.66%–91.89%。
|
||||
@@ -0,0 +1,200 @@
|
||||
{
|
||||
"mlp.gate_proj.output": {
|
||||
"observations": 96,
|
||||
"zero_rate": {
|
||||
"min": 0.0,
|
||||
"mean": 0.0,
|
||||
"max": 0.0
|
||||
},
|
||||
"negative_rate": {
|
||||
"min": 0.6825663248697916,
|
||||
"mean": 0.8063652250501846,
|
||||
"max": 0.9117279052734375
|
||||
},
|
||||
"near_001_rms": {
|
||||
"min": 0.005289713541666667,
|
||||
"mean": 0.007811493343777125,
|
||||
"max": 0.010442097981770834
|
||||
},
|
||||
"near_01_rms": {
|
||||
"min": 0.053070068359375,
|
||||
"mean": 0.07800536685519749,
|
||||
"max": 0.10291544596354167
|
||||
},
|
||||
"ever_active_001": {
|
||||
"min": 1.0,
|
||||
"mean": 1.0,
|
||||
"max": 1.0
|
||||
},
|
||||
"energy90_channel_fraction": {
|
||||
"min": 0.5314127604166666,
|
||||
"mean": 0.6330634223090278,
|
||||
"max": 0.78955078125
|
||||
}
|
||||
},
|
||||
"mlp.silu_gate": {
|
||||
"observations": 96,
|
||||
"zero_rate": {
|
||||
"min": 0.0,
|
||||
"mean": 0.0,
|
||||
"max": 0.0
|
||||
},
|
||||
"negative_rate": {
|
||||
"min": 0.6825663248697916,
|
||||
"mean": 0.8063652250501846,
|
||||
"max": 0.9117279052734375
|
||||
},
|
||||
"near_001_rms": {
|
||||
"min": 0.0018768310546875,
|
||||
"mean": 0.0050310028923882385,
|
||||
"max": 0.0082244873046875
|
||||
},
|
||||
"near_01_rms": {
|
||||
"min": 0.020375569661458332,
|
||||
"mean": 0.05178917778862848,
|
||||
"max": 0.09897359212239583
|
||||
},
|
||||
"ever_active_001": {
|
||||
"min": 1.0,
|
||||
"mean": 1.0,
|
||||
"max": 1.0
|
||||
},
|
||||
"energy90_channel_fraction": {
|
||||
"min": 0.04736328125,
|
||||
"mean": 0.7012278238932291,
|
||||
"max": 0.8186848958333334
|
||||
}
|
||||
},
|
||||
"mlp.gated_product": {
|
||||
"observations": 96,
|
||||
"zero_rate": {
|
||||
"min": 0.0,
|
||||
"mean": 0.0,
|
||||
"max": 0.0
|
||||
},
|
||||
"negative_rate": {
|
||||
"min": 0.4942118326822917,
|
||||
"mean": 0.5002292527092828,
|
||||
"max": 0.5078125
|
||||
},
|
||||
"near_001_rms": {
|
||||
"min": 0.020960489908854168,
|
||||
"mean": 0.03163560231526693,
|
||||
"max": 0.07338460286458333
|
||||
},
|
||||
"near_01_rms": {
|
||||
"min": 0.16080220540364584,
|
||||
"mean": 0.21046002705891928,
|
||||
"max": 0.4075215657552083
|
||||
},
|
||||
"ever_active_001": {
|
||||
"min": 1.0,
|
||||
"mean": 1.0,
|
||||
"max": 1.0
|
||||
},
|
||||
"energy90_channel_fraction": {
|
||||
"min": 0.06380208333333333,
|
||||
"mean": 0.5484212239583334,
|
||||
"max": 0.7263997395833334
|
||||
}
|
||||
},
|
||||
"self_attn.q_proj.output": {
|
||||
"observations": 24,
|
||||
"zero_rate": {
|
||||
"min": 0.0,
|
||||
"mean": 0.0,
|
||||
"max": 0.0
|
||||
},
|
||||
"negative_rate": {
|
||||
"min": 0.6834945678710938,
|
||||
"mean": 0.7360480626424154,
|
||||
"max": 0.7523574829101562
|
||||
},
|
||||
"near_001_rms": {
|
||||
"min": 0.01090240478515625,
|
||||
"mean": 0.012759526570638021,
|
||||
"max": 0.01556396484375
|
||||
},
|
||||
"near_01_rms": {
|
||||
"min": 0.106048583984375,
|
||||
"mean": 0.1248311996459961,
|
||||
"max": 0.148590087890625
|
||||
},
|
||||
"ever_active_001": {
|
||||
"min": 1.0,
|
||||
"mean": 1.0,
|
||||
"max": 1.0
|
||||
},
|
||||
"energy90_channel_fraction": {
|
||||
"min": 0.413330078125,
|
||||
"mean": 0.440277099609375,
|
||||
"max": 0.4931640625
|
||||
}
|
||||
},
|
||||
"self_attn.k_proj.output": {
|
||||
"observations": 24,
|
||||
"zero_rate": {
|
||||
"min": 0.0,
|
||||
"mean": 0.0,
|
||||
"max": 0.0
|
||||
},
|
||||
"negative_rate": {
|
||||
"min": 0.47601318359375,
|
||||
"mean": 0.49783579508463544,
|
||||
"max": 0.52325439453125
|
||||
},
|
||||
"near_001_rms": {
|
||||
"min": 0.00909423828125,
|
||||
"mean": 0.01224517822265625,
|
||||
"max": 0.01629638671875
|
||||
},
|
||||
"near_01_rms": {
|
||||
"min": 0.095458984375,
|
||||
"mean": 0.1208343505859375,
|
||||
"max": 0.15106201171875
|
||||
},
|
||||
"ever_active_001": {
|
||||
"min": 1.0,
|
||||
"mean": 1.0,
|
||||
"max": 1.0
|
||||
},
|
||||
"energy90_channel_fraction": {
|
||||
"min": 0.41015625,
|
||||
"mean": 0.5345865885416666,
|
||||
"max": 0.65234375
|
||||
}
|
||||
},
|
||||
"self_attn.v_proj.output": {
|
||||
"observations": 24,
|
||||
"zero_rate": {
|
||||
"min": 0.0,
|
||||
"mean": 0.0,
|
||||
"max": 0.0
|
||||
},
|
||||
"negative_rate": {
|
||||
"min": 0.49267578125,
|
||||
"mean": 0.5059967041015625,
|
||||
"max": 0.51666259765625
|
||||
},
|
||||
"near_001_rms": {
|
||||
"min": 0.0084228515625,
|
||||
"mean": 0.01374053955078125,
|
||||
"max": 0.02447509765625
|
||||
},
|
||||
"near_01_rms": {
|
||||
"min": 0.087890625,
|
||||
"mean": 0.1348139444986979,
|
||||
"max": 0.22296142578125
|
||||
},
|
||||
"ever_active_001": {
|
||||
"min": 1.0,
|
||||
"mean": 1.0,
|
||||
"max": 1.0
|
||||
},
|
||||
"energy90_channel_fraction": {
|
||||
"min": 0.291015625,
|
||||
"mean": 0.5994466145833334,
|
||||
"max": 0.732421875
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"passed": true,
|
||||
"rows": 83616,
|
||||
"layers": 24,
|
||||
"samples": 4,
|
||||
"all_zero_128_blocks": 0
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"REPORT.md": "f7f05bdbf9c9d096fe685ebb49ee15ff9866a99071302f9d7710b99b1a2e7db4",
|
||||
"aggregates.json": "57dfef79b14e73dafd39840661abacd8b44447884e640bb40b86f90ec441ee4d",
|
||||
"audit.json": "2a67fde20f6765d0dbfa783ff31c548f8135af5d74b6fc0e27a3e71c9cbdffb1",
|
||||
"figures/block_activity.pdf": "354cbc89dfc6da6d6611c6effc9dfefc6762e3da1d52bfba89cc11be8c8a9247",
|
||||
"figures/block_activity.png": "ddcfa1f0de30f4f8bdece16b3451ca1b5bf419fac5a5bb9bb944301983efaeec",
|
||||
"figures/block_activity.svg": "da85920dd0fc32ba439b650c8b695757d42eb72768b4017a78109cb8a2f24216",
|
||||
"figures/mlp_activation.pdf": "6eef102d1ecc7c21206da862f79d4edaed77a695f7c46d53550c3dc6f9087ee5",
|
||||
"figures/mlp_activation.png": "0e1a01ea5b21274eaa757c1c9cd493524003220eadcf7aa378e0eb39a37a7c40",
|
||||
"figures/mlp_activation.svg": "d7b0a67d2d1d501e6fa70aa4a38010bead93a450423e5cd6b3b1284794353c8f",
|
||||
"final-tests.txt": "7b52cfeffca483471297e30aa9658bc2c5c6585b682f5ee5fbbcc2e1b2b8abe4",
|
||||
"first-attempt.txt": "7a1f686db3b7412b681d516bdd83bb8ed7ab2a758a44a2d84c4c7968017d9c91",
|
||||
"full-tests.txt": "55fe658a01d15ed380f2b5cd01058f2374997ffde945025262e92fd966f0dc3b",
|
||||
"metrics.csv": "8f6205e7f446f83567485275f57f63ce64233eee711a4be89c30b37182772e4d",
|
||||
"run.txt": "9fe01020a3ac92db51a17042eef6af73f854dd2e81220d7a04cd5a843c6ff9ba",
|
||||
"source-hashes.json": "34d1c164e787ec6ec5b77d4bc056da2e72365e1cd4b5089741f2b979a3c8beb3",
|
||||
"summary.json": "1e7c3bace11673d10cb927d689348bf00790a9b074ccafed6ce44d898410ef98"
|
||||
}
|
||||
|
After Width: | Height: | Size: 99 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 163 KiB |
|
After Width: | Height: | Size: 76 KiB |
@@ -0,0 +1,7 @@
|
||||
test_known_activity (tests.test_activation.ActivationTests.test_known_activity) ... ok
|
||||
test_zero_and_scale (tests.test_activation.ActivationTests.test_zero_and_scale) ... ok
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Ran 2 tests in 0.002s
|
||||
|
||||
OK
|
||||
@@ -0,0 +1,24 @@
|
||||
completed fresh-zh-1 20904
|
||||
completed fresh-zh-2 41808
|
||||
completed fresh-en-1 62712
|
||||
Traceback (most recent call last):
|
||||
File "/opt/exp-model-parameter-similarity/activation_probe.py", line 44, in <module>
|
||||
if __name__=='__main__':main()
|
||||
~~~~^^
|
||||
File "/opt/exp-model-parameter-similarity/activation_probe.py", line 39, in main
|
||||
lm.forward(np.array([ids],dtype=np.int64)); print('completed',s['id'],len(lm.rows),flush=True)
|
||||
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
File "/opt/exp-model-parameter-similarity/functional/model.py", line 220, in forward
|
||||
h = h + self.mlp(n,donor)
|
||||
~~~~~~~~^^^^^^^^^
|
||||
File "/opt/exp-model-parameter-similarity/activation_probe.py", line 30, in mlp
|
||||
return self.linear(g*u,p+'down_proj')
|
||||
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
|
||||
File "/opt/exp-model-parameter-similarity/activation_probe.py", line 22, in linear
|
||||
y=super().linear(x,name,rows); self.record(y,name+'.output')
|
||||
File "/opt/exp-model-parameter-similarity/functional/model.py", line 130, in linear
|
||||
self.guard()
|
||||
~~~~~~~~~~^^
|
||||
File "/opt/exp-model-parameter-similarity/functional/model.py", line 111, in guard
|
||||
raise MemoryError(f'Sustained host swap pressure plus constrained memory: available={available} KiB, process_swap={own_swap_kib} KiB')
|
||||
MemoryError: Sustained host swap pressure plus constrained memory: available=989040 KiB, process_swap=132360 KiB
|
||||
@@ -0,0 +1,33 @@
|
||||
test_known_activity (test_activation.ActivationTests.test_known_activity) ... ok
|
||||
test_zero_and_scale (test_activation.ActivationTests.test_zero_and_scale) ... ok
|
||||
test_assignment_against_exhaustive_and_inverse (test_crossqkv.CrossQKVTests.test_assignment_against_exhaustive_and_inverse) ... ok
|
||||
test_cached_mode_rejects_future_state_reuse (test_crossqkv.CrossQKVTests.test_cached_mode_rejects_future_state_reuse) ... ok
|
||||
test_controls_cover_multiple_projection_layers (test_crossqkv.CrossQKVTests.test_controls_cover_multiple_projection_layers) ... ok
|
||||
test_head_matrix_metrics_and_gram_are_diagnostic (test_crossqkv.CrossQKVTests.test_head_matrix_metrics_and_gram_are_diagnostic) ... ok
|
||||
test_probability_identity_and_nontrivial_queries (test_crossqkv.CrossQKVTests.test_probability_identity_and_nontrivial_queries) ... ok
|
||||
test_profile_matches_canonical_and_head_sum (test_crossqkv.CrossQKVTests.test_profile_matches_canonical_and_head_sum) ... ok
|
||||
test_recipient_value_gate_output_and_gqa_group_stay_fixed (test_crossqkv.CrossQKVTests.test_recipient_value_gate_output_and_gqa_group_stay_fixed) ... ok
|
||||
test_topk_tail_rank_can_change_with_tiny_probability_difference (test_crossqkv.CrossQKVTests.test_topk_tail_rank_can_change_with_tiny_probability_difference) ... ok
|
||||
test_causal_convolution_and_norm_boundary (test_functional.FunctionalTests.test_causal_convolution_and_norm_boundary) ... ok
|
||||
test_causality_and_identical_function_metrics (test_functional.FunctionalTests.test_causality_and_identical_function_metrics) ... ok
|
||||
test_neuron_function_metrics_and_targeted_replacement (test_functional.FunctionalTests.test_neuron_function_metrics_and_targeted_replacement) ... ok
|
||||
test_nonrotary_gain_identity_and_rotary_negative_control (test_functional.FunctionalTests.test_nonrotary_gain_identity_and_rotary_negative_control) ... ok
|
||||
test_streamed_projection_embedding_and_output_head (test_functional.FunctionalTests.test_streamed_projection_embedding_and_output_head) ... ok
|
||||
test_uniform_rmsnorm_function_bound_is_tight (test_functional.FunctionalTests.test_uniform_rmsnorm_function_bound_is_tight) ... ok
|
||||
test_3d_reader_and_exact_block (test_pilot.PilotTests.test_3d_reader_and_exact_block) ... ok
|
||||
test_bfloat16 (test_pilot.PilotTests.test_bfloat16) ... ok
|
||||
test_directional_replacement_error_and_scaling (test_pilot.PilotTests.test_directional_replacement_error_and_scaling) ... ok
|
||||
test_end_to_end_synthetic_groups_and_savings (test_pilot.PilotTests.test_end_to_end_synthetic_groups_and_savings) ... Inventory: 4 tensors, 33792 bytes
|
||||
tensor: sampling 4 objects
|
||||
block: sampling 22 objects
|
||||
block: verified 100/109
|
||||
{"model": "synthetic", "revision": "test", "tensor_count": 4, "parameter_count": 8448, "model_weight_bytes": 33792, "ndim_counts": {"2": 2, "3": 2}, "elapsed_seconds": 0.3087193910032511, "analysis_budget_seconds": 60, "peak_rss_kib": 57700, "python": "3.14.4", "numpy": "2.5.4", "seed": 20261109, "limitations": ["No inference or functional equivalence measured", "No exhaustive pair search", "Block search uses per-role/shape/scale reservoirs of 256", "Different block scales overlap; savings must not be added", "Block savings count only verified disjoint sampled blocks, no extrapolation", "Spectral probes use aligned bounded subvolumes, not whole tensors", "Shared encoding is theoretical, not a runnable compressed checkpoint", "No cross-role grouping, neuron permutation alignment, or training"], "completed": true}
|
||||
ok
|
||||
test_no_transitive_chaining (test_pilot.PilotTests.test_no_transitive_chaining) ... ok
|
||||
test_ranged_download_preserves_prefix (test_pilot.PilotTests.test_ranged_download_preserves_prefix) ... Weight download 36/36 bytes (100.0%)
|
||||
ok
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Ran 22 tests in 33.253s
|
||||
|
||||
OK
|
||||
@@ -0,0 +1,4 @@
|
||||
completed fresh-zh-1 20904
|
||||
completed fresh-zh-2 20904
|
||||
completed fresh-en-1 20904
|
||||
completed fresh-en-2 20904
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"activation/report.py": "e67bfa4af69e43cdceb803b77fe6a6dcc151163e72b3ff2bb7e6b69e7c6fa1fc",
|
||||
"activation/audit.py": "7dc8af7c31de379a50bdcbd3c41243eb190e6a50e8ec00a30182e82a34e73627",
|
||||
"activation/run.py": "cba62a2d8b6344625f233309b166b091028154890d93e48278eb338cbcd19b18",
|
||||
"activation/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"tests/test_activation.py": "dee1756b63cd03c2051cdc92d678d2e27aff639fbfd3d3cb3169140760da4c68",
|
||||
"functional/model.py": "48a2a97d0445dc6e08ac7f27a935637a7553417d0982eb94122d6cb02bbb499c"
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
{
|
||||
"completed": true,
|
||||
"elapsed_seconds": 268.55615069903433,
|
||||
"peak_rss_kib": 155288,
|
||||
"config_activation": "silu",
|
||||
"layer_count": 24,
|
||||
"samples": [
|
||||
{
|
||||
"id": "fresh-zh-1",
|
||||
"language": "zh",
|
||||
"text": "\u690d\u7269\u5b66\u5bb6\u5728\u4e0d\u540c\u6d77\u62d4\u91c7\u96c6\u4e86\u53f6\u7247\u6837\u672c\uff0c\u5e76\u4e3a\u6bcf\u4e00\u4efd\u6807\u672c\u8bb0\u5f55\u6e29\u5ea6\u3001\u5149\u7167\u548c\u571f\u58e4\u6e7f\u5ea6\u3002\u56de\u5230\u5b9e\u9a8c\u5ba4\u540e\uff0c\u5979\u6309\u5730\u70b9\u6574\u7406\u6807\u7b7e\uff0c\u5148\u6838\u5bf9\u7f3a\u5931\u8bb0\u5f55\uff0c\u518d\u6bd4\u8f83\u4e0d\u540c\u73af\u5883\u4e2d\u7684\u53f6\u7247\u5f62\u72b6\u3002",
|
||||
"token_ids": [
|
||||
99951,
|
||||
101071,
|
||||
115802,
|
||||
111685,
|
||||
102099,
|
||||
95759,
|
||||
111583,
|
||||
109928,
|
||||
3709,
|
||||
115026,
|
||||
134176,
|
||||
116599,
|
||||
98151,
|
||||
99472,
|
||||
5205,
|
||||
114180,
|
||||
95793,
|
||||
104074,
|
||||
102454,
|
||||
1710,
|
||||
103744,
|
||||
103911,
|
||||
95946,
|
||||
3709,
|
||||
96343,
|
||||
96656,
|
||||
100560,
|
||||
99946,
|
||||
101659,
|
||||
3709,
|
||||
96218,
|
||||
113089
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "fresh-zh-2",
|
||||
"language": "zh",
|
||||
"text": "\u5982\u679c\u4e00\u4e2a\u76d2\u5b50\u91cc\u6709\u5341\u4e8c\u679a\u84dd\u8272\u68cb\u5b50\u548c\u516b\u679a\u767d\u8272\u68cb\u5b50\uff0c\u968f\u673a\u53d6\u51fa\u4e00\u679a\u540e\u4e0d\u653e\u56de\uff0c\u7b2c\u4e8c\u6b21\u53d6\u5230\u84dd\u8272\u7684\u6982\u7387\u9700\u8981\u6839\u636e\u7b2c\u4e00\u6b21\u7684\u7ed3\u679c\u5206\u522b\u8ba1\u7b97\u3002\u8bf7\u5148\u5217\u51fa\u5404\u4e2a\u4e8b\u4ef6\uff0c\u518d\u68c0\u67e5\u5b83\u4eec\u7684\u6982\u7387\u4e4b\u548c\u3002",
|
||||
"token_ids": [
|
||||
127356,
|
||||
98996,
|
||||
98970,
|
||||
95762,
|
||||
98175,
|
||||
101184,
|
||||
104145,
|
||||
99357,
|
||||
111324,
|
||||
96702,
|
||||
101184,
|
||||
103828,
|
||||
129730,
|
||||
3709,
|
||||
102038,
|
||||
96284,
|
||||
98938,
|
||||
101184,
|
||||
95946,
|
||||
122271,
|
||||
96120,
|
||||
3709,
|
||||
109387,
|
||||
96284,
|
||||
95839,
|
||||
116981,
|
||||
104514,
|
||||
122501,
|
||||
103720,
|
||||
109146,
|
||||
99446,
|
||||
97792
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "fresh-en-1",
|
||||
"language": "en",
|
||||
"text": "A technician recorded the vibration of a small motor before and after replacing its bearings. She used the same mounting position and sampling interval for both measurements. The final notebook included the raw traces, instrument settings, and a brief explanation of unusual observations.",
|
||||
"token_ids": [
|
||||
32,
|
||||
51715,
|
||||
12076,
|
||||
279,
|
||||
46219,
|
||||
314,
|
||||
264,
|
||||
2526,
|
||||
8604,
|
||||
1518,
|
||||
321,
|
||||
1238,
|
||||
24101,
|
||||
1141,
|
||||
33309,
|
||||
13,
|
||||
2838,
|
||||
1429,
|
||||
279,
|
||||
1788,
|
||||
32525,
|
||||
2234,
|
||||
321,
|
||||
24102,
|
||||
9581,
|
||||
364,
|
||||
2107,
|
||||
20934,
|
||||
13,
|
||||
561,
|
||||
1534,
|
||||
35935
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "fresh-en-2",
|
||||
"language": "en",
|
||||
"text": "The function walks through a list of integers and stores each running total in a new list. An empty input should return an empty result. Before changing the implementation, compare a short example by hand and make sure negative numbers preserve the intended behavior.",
|
||||
"token_ids": [
|
||||
760,
|
||||
709,
|
||||
21780,
|
||||
1472,
|
||||
264,
|
||||
1103,
|
||||
314,
|
||||
24959,
|
||||
321,
|
||||
10220,
|
||||
1754,
|
||||
4162,
|
||||
2702,
|
||||
303,
|
||||
264,
|
||||
491,
|
||||
1103,
|
||||
13,
|
||||
1473,
|
||||
4147,
|
||||
1879,
|
||||
1220,
|
||||
460,
|
||||
449,
|
||||
4147,
|
||||
1067,
|
||||
13,
|
||||
12851,
|
||||
9722,
|
||||
279,
|
||||
7873,
|
||||
11
|
||||
]
|
||||
}
|
||||
],
|
||||
"rows": 83616,
|
||||
"block_widths": [
|
||||
64,
|
||||
128
|
||||
],
|
||||
"threshold_reference": "RMS within each sample/module/block, thresholds 0.01 and 0.1; exact zero measured separately",
|
||||
"training": false,
|
||||
"weights_deleted": false,
|
||||
"limits": [
|
||||
"4 short texts, 32 tokens each, descriptive only",
|
||||
"Block is contiguous output channels, not Transformer block",
|
||||
"Small output does not prove removable computation or parameter interchangeability",
|
||||
"All samples previously used; no generalization claim",
|
||||
"Relative threshold differs between blocks; width=0 is whole module reference"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# Scientific delivery and retained caches
|
||||
|
||||
All figure CSV/JSON source data, per-token NLL, protocols, reports, metadata and historical logs are included.
|
||||
Three large reproducible intermediate activation caches remain on 8.211.154.134 and in the original full local archive;
|
||||
`external-activation-cache.json` records exact locations, sizes and SHA256. No weight or cache was deleted.
|
||||
The original full experiment manifest is `checksums-full-server.json`; the delivery-only manifest is
|
||||
`checksums-functional.json`. No model checkpoint or tokenizer payload is in this Git delivery.
|
||||
@@ -0,0 +1,36 @@
|
||||
# CPU learned-function repetition pilot
|
||||
|
||||
Primary question: do two distinct trained parts implement similar functions? Cost is not a success condition.
|
||||
- Existing learned RMSNorm function positive: True
|
||||
- Bidirectional network quality screen passed: True
|
||||
- Learned scalar MLP neuron search positive: False
|
||||
- Original 11 candidate run state: completed; selected: []
|
||||
- All model weights are retained on the server until the user explicitly requests deletion.
|
||||
|
||||
## Existing learned module evidence
|
||||
|
||||
Role: input_layernorm; layers 12 and 13; each maps 2048-dimensional input to output.
|
||||
Uniform real-arithmetic relative-error bound, first-to-second: 0.101851851852; reverse: 0.113402061856.
|
||||
Maximum heldout directional output relative L2: 0.04528510757179746; minimum cosine: 0.9994870299724158.
|
||||
Same epsilon and nonzero gains: the common RMS denominator cancels. For any nonzero input x,
|
||||
`||f_a(x)-f_b(x)|| / ||f_a(x)|| <= max_j |a_j-b_j|/|a_j|`; swap a/b for the reverse direction.
|
||||
Selection used only the tight all-input bound across 552 same-role pairs, before inspecting inputs.
|
||||
Real probes use four calibration and four heldout experiment-authored texts, 32 tokens each, and both source layers.
|
||||
These are learned, nonconstant gain vectors. The claim concerns RMSNorm modules; it does not establish attention/MLP-body duplication.
|
||||
|
||||
- Layer 12 uses 13: mean heldout NLL delta 3.25651368766e-05; sequence P95 delta 0.000984639618287; screen pass=True.
|
||||
- Layer 13 uses 12: mean heldout NLL delta -0.000363972997404; sequence P95 delta 0.000709721155035; screen pass=True.
|
||||
|
||||
## Negative results and separate algebraic result
|
||||
|
||||
The original whole-attention, whole-MLP and within-layer Q/K norm candidates did not pass their gates.
|
||||
The scalar neuron search excludes low-RMS/near-constant profiles and selects at most one pair without heldout feedback; consult its search summary for coverage.
|
||||
Q/K non-RoPE gain consolidation is a separately verified real-arithmetic identity, not evidence that two existing learned modules duplicate functions.
|
||||
Earlier local CPU timing records are preserved for provenance; performance is outside the current success criterion.
|
||||
|
||||
## Limits and provenance
|
||||
|
||||
Original BF16 weights were decoded into streaming FP32 CPU operators; no training, scale fitting, R fitting or GPU.
|
||||
The numerical reference includes 22 independent official Torch comparisons. Early adapter errors and two resource-guard stops are preserved as historical logs.
|
||||
The persistent computation ledger includes a conservative 180-second reserve for early checks; no budget reset after that reserve.
|
||||
The text sample is tiny and short. Network NLL checks are not broad task-accuracy validation.
|
||||
@@ -0,0 +1,88 @@
|
||||
[
|
||||
"DELIVERY.md",
|
||||
"FUNCTIONAL_REPORT.md",
|
||||
"attention-head-metrics.csv",
|
||||
"baseline-heldout-token-nll.npy",
|
||||
"calibration-metrics.csv",
|
||||
"candidate-summary.json",
|
||||
"checksums-full-server.json",
|
||||
"compute-budget-ledger.json",
|
||||
"download.log",
|
||||
"experiment.json",
|
||||
"external-activation-cache.json",
|
||||
"figures/algebraic_gain_identity.pdf",
|
||||
"figures/algebraic_gain_identity.png",
|
||||
"figures/algebraic_gain_identity.svg",
|
||||
"figures/candidate_function_errors.pdf",
|
||||
"figures/candidate_function_errors.png",
|
||||
"figures/candidate_function_errors.svg",
|
||||
"figures/learned_norm_function_errors.pdf",
|
||||
"figures/learned_norm_function_errors.png",
|
||||
"figures/learned_norm_function_errors.svg",
|
||||
"figures/learned_norm_network_substitution.pdf",
|
||||
"figures/learned_norm_network_substitution.png",
|
||||
"figures/learned_norm_network_substitution.svg",
|
||||
"final-report.log",
|
||||
"final-source-hashes.json",
|
||||
"final-tests.txt",
|
||||
"functional-code-hashes.json",
|
||||
"functional-environment.json",
|
||||
"functional-report.log",
|
||||
"functional-run.log",
|
||||
"functional-status.json",
|
||||
"gain-factorization-k_to_q-token-nll.npy",
|
||||
"gain-factorization-kernel-timing.csv",
|
||||
"gain-factorization-optimized-summary.json",
|
||||
"gain-factorization-optimized-timing.csv",
|
||||
"gain-factorization-optimized.log",
|
||||
"gain-factorization-protocol.json",
|
||||
"gain-factorization-q_to_k-token-nll.npy",
|
||||
"gain-factorization-score-metrics.csv",
|
||||
"gain-factorization-summary.json",
|
||||
"gain-factorization.log",
|
||||
"install-torch-disk-tmp.log",
|
||||
"install-torch.log",
|
||||
"manifest.json",
|
||||
"model_config.json",
|
||||
"neuron-reuse-protocol.json",
|
||||
"neuron-reuse-search-summary.json",
|
||||
"neuron-reuse-selection.json",
|
||||
"neuron-reuse-summary.json",
|
||||
"neuron-reuse.log",
|
||||
"norm-repetition-12-uses-13-token-nll.npy",
|
||||
"norm-repetition-13-uses-12-token-nll.npy",
|
||||
"norm-repetition-function-metrics.csv",
|
||||
"norm-repetition-protocol.json",
|
||||
"norm-repetition-selection.json",
|
||||
"norm-repetition-summary.json",
|
||||
"norm-repetition-uniform-bounds.csv",
|
||||
"norm-repetition.log",
|
||||
"preflight-first-attempt.log",
|
||||
"preflight-second-attempt.json",
|
||||
"preflight-second-attempt.log",
|
||||
"preflight.json",
|
||||
"preflight.log",
|
||||
"reference-check-first-attempt.log",
|
||||
"reference-check-second-attempt.log",
|
||||
"reference-check.json",
|
||||
"reference-check.log",
|
||||
"retention-policy.json",
|
||||
"samples-tokenized.json",
|
||||
"selection.json",
|
||||
"source_metadata.json",
|
||||
"storage-accounting.log",
|
||||
"storage-evidence.json",
|
||||
"supervisor-error.txt",
|
||||
"supervisor-first-attempt-error.txt",
|
||||
"supervisor-first-attempt.json",
|
||||
"supervisor-second-attempt.json",
|
||||
"supervisor-status.json",
|
||||
"supervisor-third-attempt.json",
|
||||
"supervisor.log",
|
||||
"tokenizer-download.log",
|
||||
"tokenizers-wheel.log",
|
||||
"unit-tests.txt",
|
||||
"checksums-functional.json",
|
||||
"audit-validation.json",
|
||||
"archive-files.json"
|
||||
]
|
||||
@@ -0,0 +1,193 @@
|
||||
candidate,source,sample_id,head,first_key_mass_a,first_key_mass_b,js_without_first_key,without_first_key_valid_rows,js_mean,js_p95,js_without_first_query,top5_overlap
|
||||
attn_3_7,3,cal-zh-1,0,0.178242027759552,0.44051653146743774,0.2887135446071625,31,0.2728434205055237,0.42193013429641724,0.2816448211669922,0.5875
|
||||
attn_3_7,3,cal-zh-1,1,0.14070242643356323,0.6567835807800293,0.154605433344841,31,0.273810476064682,0.45863786339759827,0.2826431095600128,0.5375
|
||||
attn_3_7,3,cal-zh-1,2,0.11500269174575806,0.4787790775299072,0.3218191862106323,31,0.35086748003959656,0.46183231472969055,0.3621857762336731,0.53125
|
||||
attn_3_7,3,cal-zh-1,3,0.17224811017513275,0.6523524522781372,0.22310931980609894,31,0.28077495098114014,0.43149834871292114,0.289832204580307,0.5
|
||||
attn_3_7,3,cal-zh-1,4,0.11534158885478973,0.6260660886764526,0.19559672474861145,31,0.2952086329460144,0.470927894115448,0.30473145842552185,0.53125
|
||||
attn_3_7,3,cal-zh-1,5,0.0896417498588562,0.34022626280784607,0.22164911031723022,31,0.2483729124069214,0.3841992914676666,0.256384938955307,0.54375
|
||||
attn_3_7,3,cal-zh-1,6,0.1247040405869484,0.7327346801757812,0.26632776856422424,31,0.37061089277267456,0.5524277091026306,0.38256609439849854,0.525
|
||||
attn_3_7,3,cal-zh-1,7,0.05083201080560684,0.44692301750183105,0.04695317894220352,31,0.20246444642543793,0.4956357181072235,0.20899559557437897,0.65625
|
||||
attn_3_7,3,cal-zh-2,0,0.14007353782653809,0.6036521196365356,0.2504415214061737,31,0.30694448947906494,0.4879894554615021,0.31684595346450806,0.59375
|
||||
attn_3_7,3,cal-zh-2,1,0.14963164925575256,0.7174584865570068,0.16050270199775696,31,0.2995006740093231,0.44737952947616577,0.3091619610786438,0.58125
|
||||
attn_3_7,3,cal-zh-2,2,0.1916198432445526,0.6128076314926147,0.24314163625240326,31,0.28848910331726074,0.42006126046180725,0.29779520630836487,0.63125
|
||||
attn_3_7,3,cal-zh-2,3,0.11550820618867874,0.6839271783828735,0.22851790487766266,31,0.3617430627346039,0.4926488697528839,0.373412162065506,0.43125
|
||||
attn_3_7,3,cal-zh-2,4,0.1432671993970871,0.714910089969635,0.16698074340820312,31,0.29421237111091614,0.44453173875808716,0.30370306968688965,0.55
|
||||
attn_3_7,3,cal-zh-2,5,0.15627557039260864,0.4676961600780487,0.22456194460391998,31,0.24842627346515656,0.35863032937049866,0.25644001364707947,0.53125
|
||||
attn_3_7,3,cal-zh-2,6,0.10968590527772903,0.8703562021255493,0.2677042484283447,31,0.44428783655166626,0.6032188534736633,0.45861977338790894,0.4625
|
||||
attn_3_7,3,cal-zh-2,7,0.07148394733667374,0.5658342838287354,0.050552818924188614,31,0.24003271758556366,0.5258023738861084,0.24777570366859436,0.6875
|
||||
attn_3_7,3,cal-en-1,0,0.11021165549755096,0.7443452477455139,0.2832939028739929,31,0.4321710467338562,0.5805379152297974,0.4461120665073395,0.5
|
||||
attn_3_7,3,cal-en-1,1,0.14157001674175262,0.6908999681472778,0.15555045008659363,31,0.3069734573364258,0.46220970153808594,0.3168758153915405,0.5562499999999999
|
||||
attn_3_7,3,cal-en-1,2,0.22632445394992828,0.6502443552017212,0.3039384186267853,31,0.33335912227630615,0.4760979115962982,0.34411266446113586,0.575
|
||||
attn_3_7,3,cal-en-1,3,0.1636783331632614,0.749056875705719,0.18588410317897797,31,0.31960076093673706,0.4827522933483124,0.3299104571342468,0.5062500000000001
|
||||
attn_3_7,3,cal-en-1,4,0.18975511193275452,0.5745540857315063,0.20487342774868011,31,0.2522231340408325,0.39599278569221497,0.26035937666893005,0.60625
|
||||
attn_3_7,3,cal-en-1,5,0.1436786651611328,0.45787984132766724,0.1883384883403778,31,0.2209610939025879,0.3852173388004303,0.2280888706445694,0.6187499999999999
|
||||
attn_3_7,3,cal-en-1,6,0.08422182500362396,0.8810427784919739,0.24220214784145355,31,0.4833376407623291,0.6262145638465881,0.49892911314964294,0.45625
|
||||
attn_3_7,3,cal-en-1,7,0.09002429246902466,0.49231916666030884,0.053437694907188416,31,0.19592277705669403,0.4695172905921936,0.20224282145500183,0.6624999999999999
|
||||
attn_3_7,3,cal-en-2,0,0.09620732069015503,0.7015095949172974,0.2738996148109436,31,0.3950675129890442,0.5772150158882141,0.40781161189079285,0.5874999999999999
|
||||
attn_3_7,3,cal-en-2,1,0.1168593019247055,0.7301980257034302,0.160212442278862,31,0.3232686221599579,0.4884706735610962,0.3336966037750244,0.55625
|
||||
attn_3_7,3,cal-en-2,2,0.21824826300144196,0.655203104019165,0.3244048058986664,31,0.3314599394798279,0.489634245634079,0.3421522378921509,0.49375
|
||||
attn_3_7,3,cal-en-2,3,0.15237370133399963,0.7099946737289429,0.253733366727829,31,0.34891438484191895,0.4875939190387726,0.3601696491241455,0.4
|
||||
attn_3_7,3,cal-en-2,4,0.20830751955509186,0.6707655191421509,0.16886863112449646,31,0.23844638466835022,0.41475459933280945,0.24613820016384125,0.58125
|
||||
attn_3_7,3,cal-en-2,5,0.20089492201805115,0.4360402226448059,0.20298565924167633,31,0.19701015949249268,0.3117577135562897,0.20336531102657318,0.5875
|
||||
attn_3_7,3,cal-en-2,6,0.08693217486143112,0.8322523832321167,0.28768372535705566,31,0.45854610204696655,0.604308545589447,0.47333794832229614,0.4625
|
||||
attn_3_7,3,cal-en-2,7,0.12079077959060669,0.5237122178077698,0.08786331117153168,31,0.1976630836725235,0.4211302399635315,0.2040393203496933,0.71875
|
||||
attn_3_7,7,cal-zh-1,0,0.08316324651241302,0.1214274913072586,0.22053609788417816,31,0.2072795033454895,0.32793501019477844,0.21396592259407043,0.5625
|
||||
attn_3_7,7,cal-zh-1,1,0.11647684127092361,0.187703475356102,0.09203154593706131,31,0.09238047897815704,0.16611215472221375,0.09536049515008926,0.66875
|
||||
attn_3_7,7,cal-zh-1,2,0.06550130248069763,0.07431766390800476,0.28803399205207825,31,0.2721514105796814,0.46315261721611023,0.28093045949935913,0.47500000000000003
|
||||
attn_3_7,7,cal-zh-1,3,0.10703553259372711,0.24631237983703613,0.1426287740468979,31,0.150299072265625,0.26700741052627563,0.1551474630832672,0.56875
|
||||
attn_3_7,7,cal-zh-1,4,0.04052526503801346,0.28515881299972534,0.11374201625585556,31,0.1819339096546173,0.2913167476654053,0.1878027319908142,0.5875
|
||||
attn_3_7,7,cal-zh-1,5,0.03951618820428848,0.12756675481796265,0.12323599308729172,31,0.13915526866912842,0.22263947129249573,0.14364413917064667,0.6062500000000001
|
||||
attn_3_7,7,cal-zh-1,6,0.09479819983243942,0.28205406665802,0.14449526369571686,31,0.16065017879009247,0.30267569422721863,0.16583245992660522,0.6375000000000001
|
||||
attn_3_7,7,cal-zh-1,7,0.031424712389707565,0.10597768425941467,0.029422910884022713,31,0.05383709818124771,0.10532202571630478,0.055573780089616776,0.60625
|
||||
attn_3_7,7,cal-zh-2,0,0.0902467742562294,0.11627861112356186,0.21221575140953064,31,0.19495421648025513,0.317206472158432,0.201243057847023,0.6187499999999999
|
||||
attn_3_7,7,cal-zh-2,1,0.11616441607475281,0.1248721182346344,0.0952492356300354,31,0.08693543076515198,0.16702036559581757,0.08973980695009232,0.5874999999999999
|
||||
attn_3_7,7,cal-zh-2,2,0.11578349769115448,0.08946777880191803,0.2738611102104187,31,0.2561575174331665,0.45070335268974304,0.26442068815231323,0.5
|
||||
attn_3_7,7,cal-zh-2,3,0.11586448550224304,0.16896863281726837,0.10842260718345642,31,0.10158580541610718,0.21354182064533234,0.1048627570271492,0.60625
|
||||
attn_3_7,7,cal-zh-2,4,0.044329218566417694,0.22534678876399994,0.15060655772686005,31,0.19093912839889526,0.3356643319129944,0.19709844887256622,0.61875
|
||||
attn_3_7,7,cal-zh-2,5,0.05062376335263252,0.12924723327159882,0.1047384962439537,31,0.11341066658496857,0.2176104635000229,0.1170690730214119,0.6312500000000001
|
||||
attn_3_7,7,cal-zh-2,6,0.08418147265911102,0.28032630681991577,0.1446688026189804,31,0.16730237007141113,0.24755442142486572,0.1726992279291153,0.5125
|
||||
attn_3_7,7,cal-zh-2,7,0.0315190926194191,0.11244469881057739,0.02086171880364418,31,0.04779163748025894,0.10416773706674576,0.04933330416679382,0.65
|
||||
attn_3_7,7,cal-en-1,0,0.08185911923646927,0.10868857800960541,0.24351894855499268,31,0.22597578167915344,0.35052549839019775,0.23326534032821655,0.66875
|
||||
attn_3_7,7,cal-en-1,1,0.12180840969085693,0.12996530532836914,0.1148008182644844,31,0.10937604308128357,0.1990041583776474,0.11290428787469864,0.6625
|
||||
attn_3_7,7,cal-en-1,2,0.12156520038843155,0.07304315268993378,0.32663044333457947,31,0.31218329071998596,0.4966602325439453,0.3222537338733673,0.4375
|
||||
attn_3_7,7,cal-en-1,3,0.09531049430370331,0.21274563670158386,0.13099102675914764,31,0.14007462561130524,0.2635233998298645,0.14459317922592163,0.5874999999999999
|
||||
attn_3_7,7,cal-en-1,4,0.051348961889743805,0.27256035804748535,0.17027397453784943,31,0.22669382393360138,0.33905521035194397,0.23400652408599854,0.59375
|
||||
attn_3_7,7,cal-en-1,5,0.05210518091917038,0.14343655109405518,0.11446496844291687,31,0.12723194062709808,0.23429512977600098,0.13133619725704193,0.64375
|
||||
attn_3_7,7,cal-en-1,6,0.09278014302253723,0.3040335178375244,0.20964911580085754,31,0.21833369135856628,0.34637004137039185,0.22537672519683838,0.53125
|
||||
attn_3_7,7,cal-en-1,7,0.031563661992549896,0.11319160461425781,0.02739104814827442,31,0.053969405591487885,0.1002146303653717,0.055710360407829285,0.5625000000000001
|
||||
attn_3_7,7,cal-en-2,0,0.07943743467330933,0.1426258534193039,0.21740850806236267,31,0.21001917123794556,0.35335251688957214,0.2167939990758896,0.58125
|
||||
attn_3_7,7,cal-en-2,1,0.13507506251335144,0.15443003177642822,0.10350806266069412,31,0.09826720505952835,0.18229186534881592,0.10143710672855377,0.575
|
||||
attn_3_7,7,cal-en-2,2,0.07290980964899063,0.08657881617546082,0.26718389987945557,31,0.259122759103775,0.4706645905971527,0.26748156547546387,0.45625
|
||||
attn_3_7,7,cal-en-2,3,0.06336543709039688,0.2253912389278412,0.11350395530462265,31,0.1445191204547882,0.30314192175865173,0.1491810381412506,0.5875
|
||||
attn_3_7,7,cal-en-2,4,0.04387465864419937,0.2312193661928177,0.14195290207862854,31,0.1880926638841629,0.3466520309448242,0.19416013360023499,0.5125
|
||||
attn_3_7,7,cal-en-2,5,0.05407806113362312,0.1308087259531021,0.15231285989284515,31,0.16046105325222015,0.3131849467754364,0.16563721001148224,0.5874999999999999
|
||||
attn_3_7,7,cal-en-2,6,0.10013270378112793,0.30412447452545166,0.17993809282779694,31,0.19388216733932495,0.34072187542915344,0.2001364380121231,0.5437500000000001
|
||||
attn_3_7,7,cal-en-2,7,0.03161787986755371,0.14472994208335876,0.04679951071739197,31,0.0830649882555008,0.13866016268730164,0.08574451506137848,0.65625
|
||||
attn_11_15,11,cal-zh-1,0,0.2780076861381531,0.40727436542510986,0.08935041725635529,31,0.08769044280052185,0.1605687141418457,0.09051916748285294,0.6937500000000001
|
||||
attn_11_15,11,cal-zh-1,1,0.599311351776123,0.1917644888162613,0.1712544858455658,31,0.22863143682479858,0.39283493161201477,0.23600666224956512,0.5750000000000001
|
||||
attn_11_15,11,cal-zh-1,2,0.15545204281806946,0.5101379156112671,0.08800674974918365,31,0.15655069053173065,0.3642641007900238,0.16160069406032562,0.73125
|
||||
attn_11_15,11,cal-zh-1,3,0.11032958328723907,0.4199199676513672,0.08535198122262955,31,0.14290741086006165,0.27922654151916504,0.14751732349395752,0.7
|
||||
attn_11_15,11,cal-zh-1,4,0.18725907802581787,0.3965998888015747,0.12378748506307602,31,0.1280820369720459,0.24588972330093384,0.13221368193626404,0.6937500000000001
|
||||
attn_11_15,11,cal-zh-1,5,0.3307006359100342,0.43053850531578064,0.12539583444595337,31,0.1220257431268692,0.27262142300605774,0.1259620636701584,0.6187499999999999
|
||||
attn_11_15,11,cal-zh-1,6,0.17290356755256653,0.4159870147705078,0.10268668830394745,31,0.12616759538650513,0.27286267280578613,0.13023751974105835,0.625
|
||||
attn_11_15,11,cal-zh-1,7,0.12546084821224213,0.4914926290512085,0.11725502461194992,31,0.17813995480537415,0.28658801317214966,0.18388642370700836,0.6625000000000001
|
||||
attn_11_15,11,cal-zh-2,0,0.2187591940164566,0.42793723940849304,0.09548557549715042,31,0.12088388949632645,0.2345586121082306,0.12478335946798325,0.6875
|
||||
attn_11_15,11,cal-zh-2,1,0.5546900033950806,0.1175224781036377,0.16409580409526825,31,0.25557559728622437,0.37492382526397705,0.26381993293762207,0.6125
|
||||
attn_11_15,11,cal-zh-2,2,0.11856245994567871,0.44309669733047485,0.08432265371084213,31,0.1634930670261383,0.37660637497901917,0.16876700520515442,0.65
|
||||
attn_11_15,11,cal-zh-2,3,0.09019850194454193,0.3149072527885437,0.09793759882450104,31,0.1334252804517746,0.24160735309123993,0.13772933185100555,0.71875
|
||||
attn_11_15,11,cal-zh-2,4,0.09969134628772736,0.20464956760406494,0.10986322164535522,31,0.11441972851753235,0.2605915665626526,0.11811067909002304,0.7
|
||||
attn_11_15,11,cal-zh-2,5,0.16705867648124695,0.412482887506485,0.20107370615005493,31,0.21316100656986237,0.44814038276672363,0.22003716230392456,0.6000000000000001
|
||||
attn_11_15,11,cal-zh-2,6,0.126181960105896,0.38109123706817627,0.10754827409982681,31,0.14080098271369934,0.2554462254047394,0.14534294605255127,0.6687500000000001
|
||||
attn_11_15,11,cal-zh-2,7,0.11085975170135498,0.5181387662887573,0.10885247588157654,31,0.2060571014881134,0.35480910539627075,0.2127041071653366,0.66875
|
||||
attn_11_15,11,cal-en-1,0,0.2882137894630432,0.45660895109176636,0.07201986759901047,31,0.08352888375520706,0.1487027406692505,0.08622336387634277,0.73125
|
||||
attn_11_15,11,cal-en-1,1,0.597124457359314,0.13483837246894836,0.22424918413162231,31,0.29736971855163574,0.529407799243927,0.3069622814655304,0.51875
|
||||
attn_11_15,11,cal-en-1,2,0.17265087366104126,0.4521681070327759,0.08010748028755188,31,0.13888895511627197,0.29661378264427185,0.14336924254894257,0.7375
|
||||
attn_11_15,11,cal-en-1,3,0.10834433138370514,0.319663405418396,0.08455760031938553,31,0.11557236313819885,0.24554768204689026,0.11930052191019058,0.84375
|
||||
attn_11_15,11,cal-en-1,4,0.157099187374115,0.3456929326057434,0.10397545993328094,31,0.11958309262990952,0.20836150646209717,0.12344060838222504,0.73125
|
||||
attn_11_15,11,cal-en-1,5,0.30003029108047485,0.3683816194534302,0.11273742467164993,31,0.11081759631633759,0.26781079173088074,0.11439235508441925,0.6875
|
||||
attn_11_15,11,cal-en-1,6,0.16862526535987854,0.5013703107833862,0.12122618407011032,31,0.1663668006658554,0.29310786724090576,0.17173348367214203,0.65
|
||||
attn_11_15,11,cal-en-1,7,0.14973583817481995,0.5537562966346741,0.1512605994939804,31,0.22106251120567322,0.3912945091724396,0.22819358110427856,0.64375
|
||||
attn_11_15,11,cal-en-2,0,0.3351830840110779,0.4993361234664917,0.08562158793210983,31,0.08981436491012573,0.19977226853370667,0.09271162003278732,0.675
|
||||
attn_11_15,11,cal-en-2,1,0.5792163610458374,0.1499037742614746,0.1789509803056717,31,0.2536986768245697,0.41500288248062134,0.2618825435638428,0.55
|
||||
attn_11_15,11,cal-en-2,2,0.20357520878314972,0.4823607802391052,0.11572320759296417,31,0.16091257333755493,0.35024091601371765,0.1661033034324646,0.6000000000000001
|
||||
attn_11_15,11,cal-en-2,3,0.11477383971214294,0.4060356318950653,0.08803554624319077,31,0.14013110101222992,0.2660136818885803,0.14465147256851196,0.75
|
||||
attn_11_15,11,cal-en-2,4,0.1895177811384201,0.2564787268638611,0.1033802479505539,31,0.10677468031644821,0.19931447505950928,0.11021901667118073,0.7125
|
||||
attn_11_15,11,cal-en-2,5,0.2725520133972168,0.3527078926563263,0.1301337331533432,31,0.12496069073677063,0.22729209065437317,0.12899169325828552,0.6312500000000001
|
||||
attn_11_15,11,cal-en-2,6,0.17815515398979187,0.4918685555458069,0.08680415898561478,31,0.1395310014486313,0.22975514829158783,0.14403200149536133,0.68125
|
||||
attn_11_15,11,cal-en-2,7,0.1471988707780838,0.4305167496204376,0.15007153153419495,31,0.1933930218219757,0.31820762157440186,0.1996314972639084,0.60625
|
||||
attn_11_15,15,cal-zh-1,0,0.20194272696971893,0.35520243644714355,0.1205381229519844,31,0.13211002945899963,0.2777846157550812,0.1363716572523117,0.63125
|
||||
attn_11_15,15,cal-zh-1,1,0.23890593647956848,0.12377866357564926,0.21396537125110626,31,0.21463359892368317,0.41781342029571533,0.22155724465847015,0.6062500000000001
|
||||
attn_11_15,15,cal-zh-1,2,0.13280686736106873,0.27719253301620483,0.1377590000629425,31,0.14551271498203278,0.2994697093963623,0.15020668506622314,0.65
|
||||
attn_11_15,15,cal-zh-1,3,0.04135940596461296,0.23285867273807526,0.21063239872455597,31,0.24926505982875824,0.45159438252449036,0.2573058605194092,0.6937500000000001
|
||||
attn_11_15,15,cal-zh-1,4,0.07648462802171707,0.4026046395301819,0.1620333045721054,31,0.23594452440738678,0.4158128798007965,0.24355560541152954,0.6500000000000001
|
||||
attn_11_15,15,cal-zh-1,5,0.14696139097213745,0.41105949878692627,0.1549629122018814,31,0.18883343040943146,0.3439426124095917,0.19492481648921967,0.6187499999999999
|
||||
attn_11_15,15,cal-zh-1,6,0.0764666199684143,0.34140151739120483,0.11151057481765747,31,0.16509875655174255,0.31560462713241577,0.17042450606822968,0.6625
|
||||
attn_11_15,15,cal-zh-1,7,0.10250869393348694,0.5306729078292847,0.16751603782176971,31,0.25549793243408203,0.3858420252799988,0.26373982429504395,0.6062500000000001
|
||||
attn_11_15,15,cal-zh-2,0,0.22696512937545776,0.35936564207077026,0.14069660007953644,31,0.13378489017486572,0.28451812267303467,0.1381005346775055,0.65
|
||||
attn_11_15,15,cal-zh-2,1,0.25547248125076294,0.10696703940629959,0.23399728536605835,31,0.24166268110275269,0.39466142654418945,0.24945826828479767,0.5875
|
||||
attn_11_15,15,cal-zh-2,2,0.17822568118572235,0.2864110469818115,0.08877820521593094,31,0.10718775540590286,0.2511947453022003,0.11064542829990387,0.6937500000000001
|
||||
attn_11_15,15,cal-zh-2,3,0.04604611545801163,0.23604938387870789,0.22704336047172546,31,0.2641073167324066,0.4154779016971588,0.2726269066333771,0.70625
|
||||
attn_11_15,15,cal-zh-2,4,0.08757959306240082,0.2918083965778351,0.22551555931568146,31,0.24939756095409393,0.48551467061042786,0.2574426531791687,0.6000000000000001
|
||||
attn_11_15,15,cal-zh-2,5,0.11609973013401031,0.3603805601596832,0.21242640912532806,31,0.23965227603912354,0.4984361231327057,0.2473829984664917,0.51875
|
||||
attn_11_15,15,cal-zh-2,6,0.0702231377363205,0.29952526092529297,0.12570251524448395,31,0.17031171917915344,0.32249733805656433,0.17580564320087433,0.6125
|
||||
attn_11_15,15,cal-zh-2,7,0.0856853500008583,0.4777143895626068,0.1792273223400116,31,0.27432966232299805,0.47331610321998596,0.28317901492118835,0.65625
|
||||
attn_11_15,15,cal-en-1,0,0.2137582153081894,0.36318275332450867,0.121327243745327,31,0.12573851644992828,0.2549639940261841,0.12979458272457123,0.64375
|
||||
attn_11_15,15,cal-en-1,1,0.31107524037361145,0.1114300861954689,0.24769999086856842,31,0.28352850675582886,0.4685184955596924,0.29267460107803345,0.53125
|
||||
attn_11_15,15,cal-en-1,2,0.17990511655807495,0.29312068223953247,0.12414757162332535,31,0.12930452823638916,0.3116541802883148,0.1334756314754486,0.74375
|
||||
attn_11_15,15,cal-en-1,3,0.048217516392469406,0.23240914940834045,0.20335303246974945,31,0.2404388189315796,0.3818458914756775,0.2481948882341385,0.70625
|
||||
attn_11_15,15,cal-en-1,4,0.10281141847372055,0.38790467381477356,0.18024703860282898,31,0.22299107909202576,0.4459393620491028,0.23018434643745422,0.70625
|
||||
attn_11_15,15,cal-en-1,5,0.15091386437416077,0.3693487346172333,0.1916365921497345,31,0.21596358716487885,0.39266589283943176,0.2229301631450653,0.53125
|
||||
attn_11_15,15,cal-en-1,6,0.0790158361196518,0.32175618410110474,0.11456245183944702,31,0.16404178738594055,0.30913954973220825,0.16933345794677734,0.6875
|
||||
attn_11_15,15,cal-en-1,7,0.10605430603027344,0.5771000385284424,0.18373095989227295,31,0.28234609961509705,0.4291541278362274,0.2914540469646454,0.625
|
||||
attn_11_15,15,cal-en-2,0,0.251964807510376,0.31455427408218384,0.10559824854135513,31,0.11457027494907379,0.24910703301429749,0.11826609075069427,0.675
|
||||
attn_11_15,15,cal-en-2,1,0.31838059425354004,0.11868949234485626,0.257511168718338,31,0.2719646394252777,0.44276586174964905,0.2807376980781555,0.5687500000000001
|
||||
attn_11_15,15,cal-en-2,2,0.26772984862327576,0.33754318952560425,0.0924711525440216,31,0.09108234941959381,0.191604882478714,0.09402050077915192,0.7375
|
||||
attn_11_15,15,cal-en-2,3,0.06395735591650009,0.2933264374732971,0.20108558237552643,31,0.2424471080303192,0.4563605785369873,0.25026798248291016,0.66875
|
||||
attn_11_15,15,cal-en-2,4,0.08209535479545593,0.3278740644454956,0.1982748657464981,31,0.24514394998550415,0.3975651264190674,0.2530518174171448,0.56875
|
||||
attn_11_15,15,cal-en-2,5,0.09166160225868225,0.44504809379577637,0.17847460508346558,31,0.2476060837507248,0.3910382390022278,0.2555933892726898,0.4875
|
||||
attn_11_15,15,cal-en-2,6,0.07513932138681412,0.45416805148124695,0.12279381603002548,31,0.22479453682899475,0.34578394889831543,0.2320459932088852,0.59375
|
||||
attn_11_15,15,cal-en-2,7,0.1007680892944336,0.5731154084205627,0.18980540335178375,31,0.3043324649333954,0.41584962606430054,0.3141496479511261,0.5375000000000001
|
||||
attn_19_23,19,cal-zh-1,0,0.0955502837896347,0.03435931354761124,0.08661527186632156,31,0.10083474218845367,0.1792067289352417,0.10408748686313629,0.73125
|
||||
attn_19_23,19,cal-zh-1,1,0.10103033483028412,0.04235740005970001,0.16347354650497437,31,0.16801373660564423,0.37647515535354614,0.17343351244926453,0.6125
|
||||
attn_19_23,19,cal-zh-1,2,0.047133591026067734,0.03135885298252106,0.47210854291915894,31,0.46042412519454956,0.6502387523651123,0.47527655959129333,0.5375000000000001
|
||||
attn_19_23,19,cal-zh-1,3,0.07069262862205505,0.06008598208427429,0.12148955464363098,31,0.11885681003332138,0.26471832394599915,0.12269090116024017,0.6625000000000001
|
||||
attn_19_23,19,cal-zh-1,4,0.10007724165916443,0.044495031237602234,0.16073106229305267,31,0.16553831100463867,0.3016175925731659,0.17087827622890472,0.68125
|
||||
attn_19_23,19,cal-zh-1,5,0.06431633979082108,0.040679484605789185,0.0816011056303978,31,0.08355634659528732,0.1771341860294342,0.08625171333551407,0.8
|
||||
attn_19_23,19,cal-zh-1,6,0.08145896345376968,0.03135719522833824,0.4502938687801361,31,0.44716787338256836,0.6495819091796875,0.4615926444530487,0.5
|
||||
attn_19_23,19,cal-zh-1,7,0.08670078217983246,0.03888973593711853,0.09126521646976471,31,0.09830940514802933,0.18466481566429138,0.10148067027330399,0.70625
|
||||
attn_19_23,19,cal-zh-2,0,0.06336566060781479,0.03736908361315727,0.07764910906553268,31,0.08064413070678711,0.16660116612911224,0.08324555307626724,0.8187500000000001
|
||||
attn_19_23,19,cal-zh-2,1,0.0888693630695343,0.06530671566724777,0.1942276507616043,31,0.18916305899620056,0.33451300859451294,0.19526511430740356,0.6125
|
||||
attn_19_23,19,cal-zh-2,2,0.07010967284440994,0.031316906213760376,0.3875632584095001,31,0.3861002027988434,0.6248269081115723,0.3985550105571747,0.65
|
||||
attn_19_23,19,cal-zh-2,3,0.08096092939376831,0.08616353571414948,0.08690906316041946,31,0.08501926809549332,0.19463855028152466,0.08776183426380157,0.7937500000000001
|
||||
attn_19_23,19,cal-zh-2,4,0.0936945378780365,0.04400797560811043,0.11036926507949829,31,0.11584575474262238,0.2122059315443039,0.11958272755146027,0.8187500000000001
|
||||
attn_19_23,19,cal-zh-2,5,0.056567154824733734,0.03972743824124336,0.06345413625240326,31,0.06394530087709427,0.16273385286331177,0.066008061170578,0.7937500000000001
|
||||
attn_19_23,19,cal-zh-2,6,0.08575102686882019,0.031342219561338425,0.4025454819202423,31,0.4032740592956543,0.5980108976364136,0.4162829518318176,0.60625
|
||||
attn_19_23,19,cal-zh-2,7,0.10350999981164932,0.0646558329463005,0.10814103484153748,31,0.10938012599945068,0.23185187578201294,0.11290851980447769,0.7375
|
||||
attn_19_23,19,cal-en-1,0,0.22517549991607666,0.09088313579559326,0.11986515671014786,31,0.1366778463125229,0.2391858845949173,0.14108680188655853,0.74375
|
||||
attn_19_23,19,cal-en-1,1,0.23973168432712555,0.11891130357980728,0.17766058444976807,31,0.16800963878631592,0.2676515281200409,0.17342931032180786,0.66875
|
||||
attn_19_23,19,cal-en-1,2,0.21452879905700684,0.03307320922613144,0.3807314932346344,31,0.4102427363395691,0.5871645212173462,0.42347636818885803,0.66875
|
||||
attn_19_23,19,cal-en-1,3,0.21709948778152466,0.14377164840698242,0.0770971029996872,31,0.08144749701023102,0.15173088014125824,0.08407483249902725,0.8125
|
||||
attn_19_23,19,cal-en-1,4,0.23791193962097168,0.19146007299423218,0.12041598558425903,31,0.11442764848470688,0.22197961807250977,0.11811887472867966,0.66875
|
||||
attn_19_23,19,cal-en-1,5,0.2485853135585785,0.10372771322727203,0.08068431913852692,31,0.11313603073358536,0.23292472958564758,0.11678558588027954,0.7562500000000001
|
||||
attn_19_23,19,cal-en-1,6,0.31094634532928467,0.031405214220285416,0.39337676763534546,31,0.45084744691848755,0.6603637933731079,0.4653908908367157,0.55
|
||||
attn_19_23,19,cal-en-1,7,0.2927525043487549,0.15012584626674652,0.12347250431776047,31,0.12942291796207428,0.2467067539691925,0.13359786570072174,0.68125
|
||||
attn_19_23,19,cal-en-2,0,0.19307208061218262,0.055295493453741074,0.1307787448167801,31,0.15591834485530853,0.3169764280319214,0.1609479784965515,0.5875
|
||||
attn_19_23,19,cal-en-2,1,0.1491451859474182,0.10034040361642838,0.14188656210899353,31,0.1398725062608719,0.2532970607280731,0.14438451826572418,0.59375
|
||||
attn_19_23,19,cal-en-2,2,0.11011949181556702,0.033411312848329544,0.4344772696495056,31,0.4410479664802551,0.6305621266365051,0.4552752673625946,0.5375
|
||||
attn_19_23,19,cal-en-2,3,0.11554233729839325,0.08585710823535919,0.1385604739189148,31,0.13558831810951233,0.3369371294975281,0.13996215164661407,0.5874999999999999
|
||||
attn_19_23,19,cal-en-2,4,0.1721733808517456,0.10996092110872269,0.1335446536540985,31,0.13328826427459717,0.24826908111572266,0.13758789002895355,0.625
|
||||
attn_19_23,19,cal-en-2,5,0.18817278742790222,0.06915841996669769,0.11790769547224045,31,0.13643309473991394,0.2266169786453247,0.14083418250083923,0.65625
|
||||
attn_19_23,19,cal-en-2,6,0.2252667248249054,0.03137722611427307,0.45010486245155334,31,0.4878306984901428,0.6629999876022339,0.503567099571228,0.49375
|
||||
attn_19_23,19,cal-en-2,7,0.19858212769031525,0.07953452318906784,0.1386381983757019,31,0.15347915887832642,0.2583900988101959,0.15843011438846588,0.5687500000000001
|
||||
attn_19_23,23,cal-zh-1,0,0.18854272365570068,0.06906979531049728,0.08094117045402527,31,0.10190774500370026,0.19865523278713226,0.10519509017467499,0.61875
|
||||
attn_19_23,23,cal-zh-1,1,0.12637057900428772,0.094294473528862,0.11472687125205994,31,0.11000899970531464,0.20533926784992218,0.11355767399072647,0.60625
|
||||
attn_19_23,23,cal-zh-1,2,0.06566040217876434,0.0320066399872303,0.3936012387275696,31,0.3894338607788086,0.6095475554466248,0.40199628472328186,0.53125
|
||||
attn_19_23,23,cal-zh-1,3,0.10236738622188568,0.07628713548183441,0.0909285917878151,31,0.09045256674289703,0.16597077250480652,0.09337039291858673,0.65625
|
||||
attn_19_23,23,cal-zh-1,4,0.11772166937589645,0.09994609653949738,0.11158378422260284,31,0.1082884818315506,0.2333190143108368,0.11178164929151535,0.6000000000000001
|
||||
attn_19_23,23,cal-zh-1,5,0.1445631980895996,0.05731264501810074,0.06436286121606827,31,0.07913714647293091,0.15170255303382874,0.08168993890285492,0.6625000000000001
|
||||
attn_19_23,23,cal-zh-1,6,0.13692563772201538,0.03156186267733574,0.42265841364860535,31,0.43705910444259644,0.6045969128608704,0.45115774869918823,0.5249999999999999
|
||||
attn_19_23,23,cal-zh-1,7,0.17913174629211426,0.0774894654750824,0.055066999047994614,31,0.07003086805343628,0.11456935852766037,0.07228992879390717,0.6875
|
||||
attn_19_23,23,cal-zh-2,0,0.08711955696344376,0.08616629242897034,0.09776511043310165,31,0.09617017209529877,0.2418135702610016,0.09927243739366531,0.7125
|
||||
attn_19_23,23,cal-zh-2,1,0.1001269742846489,0.1142689436674118,0.11429562419652939,31,0.11118914932012558,0.19028690457344055,0.1147758960723877,0.6625000000000001
|
||||
attn_19_23,23,cal-zh-2,2,0.13165870308876038,0.03296923264861107,0.32159483432769775,31,0.34172311425209045,0.5507174134254456,0.35274645686149597,0.675
|
||||
attn_19_23,23,cal-zh-2,3,0.10557965934276581,0.08546337485313416,0.10869138687849045,31,0.10796000063419342,0.267814040184021,0.11144257336854935,0.71875
|
||||
attn_19_23,23,cal-zh-2,4,0.0753588005900383,0.0625741258263588,0.09596671164035797,31,0.09504459798336029,0.18062597513198853,0.09811054915189743,0.6937500000000001
|
||||
attn_19_23,23,cal-zh-2,5,0.0798945426940918,0.0568334236741066,0.07381810247898102,31,0.0762210339307785,0.13966575264930725,0.07867977768182755,0.74375
|
||||
attn_19_23,23,cal-zh-2,6,0.0759878009557724,0.031536251306533813,0.39428046345710754,31,0.3959207534790039,0.5929224491119385,0.408692330121994,0.6375
|
||||
attn_19_23,23,cal-zh-2,7,0.11138643324375153,0.07136214524507523,0.07186198234558105,31,0.07652410864830017,0.15722090005874634,0.07899262756109238,0.7312500000000001
|
||||
attn_19_23,23,cal-en-1,0,0.12444712221622467,0.0752042829990387,0.10921256989240646,31,0.10872898995876312,0.22416618466377258,0.11223636567592621,0.6875
|
||||
attn_19_23,23,cal-en-1,1,0.10719993710517883,0.08359251916408539,0.12698784470558167,31,0.12113931775093079,0.22020384669303894,0.12504702806472778,0.7000000000000001
|
||||
attn_19_23,23,cal-en-1,2,0.13445816934108734,0.03345245122909546,0.3665089011192322,31,0.3763067126274109,0.5767470002174377,0.3884456157684326,0.65625
|
||||
attn_19_23,23,cal-en-1,3,0.10536500066518784,0.07050738483667374,0.07684175670146942,31,0.07960161566734314,0.14911630749702454,0.08216940611600876,0.78125
|
||||
attn_19_23,23,cal-en-1,4,0.0911213681101799,0.17202866077423096,0.10298387706279755,31,0.10929879546165466,0.20484577119350433,0.11282456666231155,0.61875
|
||||
attn_19_23,23,cal-en-1,5,0.18703660368919373,0.12409132719039917,0.09463418275117874,31,0.09024524688720703,0.15500988066196442,0.09315639734268188,0.70625
|
||||
attn_19_23,23,cal-en-1,6,0.13999314606189728,0.03152035176753998,0.4262007474899292,31,0.43630746006965637,0.6232555508613586,0.450381875038147,0.5187499999999999
|
||||
attn_19_23,23,cal-en-1,7,0.11322036385536194,0.10936357825994492,0.07323051989078522,31,0.07213389873504639,0.1506829559803009,0.07446079701185226,0.6125
|
||||
attn_19_23,23,cal-en-2,0,0.11863207072019577,0.13078393042087555,0.09141960740089417,31,0.08733218908309937,0.1577986180782318,0.09014936536550522,0.59375
|
||||
attn_19_23,23,cal-en-2,1,0.07288858294487,0.1372600495815277,0.1089932844042778,31,0.11363835632801056,0.1698836386203766,0.11730410903692245,0.50625
|
||||
attn_19_23,23,cal-en-2,2,0.07288709282875061,0.04088134318590164,0.376287043094635,31,0.3685654401779175,0.5480253100395203,0.3804546594619751,0.5375
|
||||
attn_19_23,23,cal-en-2,3,0.06728185713291168,0.07526300847530365,0.09231049567461014,31,0.08894366025924683,0.15198129415512085,0.09181280434131622,0.6187499999999999
|
||||
attn_19_23,23,cal-en-2,4,0.09862713515758514,0.12817975878715515,0.09404788166284561,31,0.08950259536504745,0.16771778464317322,0.09238976985216141,0.5562499999999999
|
||||
attn_19_23,23,cal-en-2,5,0.07161959260702133,0.0855005532503128,0.10532733052968979,31,0.10144606977701187,0.1908321976661682,0.10471852868795395,0.5625
|
||||
attn_19_23,23,cal-en-2,6,0.08469876646995544,0.03168217092752457,0.4412229359149933,31,0.43726012110710144,0.6215424537658691,0.45136526226997375,0.5437500000000001
|
||||
attn_19_23,23,cal-en-2,7,0.10539951920509338,0.08276306837797165,0.07327506691217422,31,0.0738329142332077,0.13249149918556213,0.07621461898088455,0.63125
|
||||
|
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"passed": true,
|
||||
"validated_unix": 1794204667.0190518,
|
||||
"checksummed_files": 83,
|
||||
"proof_recomputed_from_retained_weights": true,
|
||||
"heldout_nll_recomputed_from_saved_arrays": true,
|
||||
"weights_present_and_retained": true,
|
||||
"archive_excludes_weights_and_tokenizer": true,
|
||||
"delivery_excludes_external_activation_caches": true,
|
||||
"full_experiment_checksums": "checksums-full-server.json",
|
||||
"figure_source_tables_and_token_nll_complete": true
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
candidate,kind,source,sample_id,split,relative_l2,reverse_relative_l2,token_relative_p95,reverse_token_relative_p95,cosine,low_norm_tokens,first_key_mass_a,first_key_mass_b,js_without_first_key,without_first_key_valid_rows,js_mean,js_p95,js_without_first_query,top5_overlap
|
||||
attn_3_7,attn,3,cal-zh-1,calibration,1.75886973383732,1.2170194989630583,2.3326619869739242,1.3829599318796777,-0.001709405865837512,0,0.12333933264017105,0.5467976927757263,0.21484676003456116,248,0.2868691682815552,0.4794144630432129,0.2961229979991913,0.5515625
|
||||
attn_3_7,attn,3,cal-zh-2,calibration,2.0666622735799773,1.1397562572129543,2.6608388071181586,1.2319401946881372,0.004627105486643174,0,0.1346932351589203,0.6545802354812622,0.1990504413843155,248,0.3104545772075653,0.512997567653656,0.3204692304134369,0.55859375
|
||||
attn_3_7,attn,3,cal-en-1,calibration,1.9684586970451095,1.1687255334183004,2.5460869484043305,1.3209705033413297,-0.011291865355731309,0,0.1436830461025238,0.6550427675247192,0.2021898329257965,248,0.31806862354278564,0.5598381161689758,0.3283289074897766,0.56015625
|
||||
attn_3_7,attn,3,cal-en-2,calibration,2.1157833337453664,1.1413057345289206,2.896573536355606,1.279392467480941,-0.010752011897128681,0,0.1500767469406128,0.6574594974517822,0.2199564427137375,248,0.3112969994544983,0.5577057003974915,0.32133883237838745,0.5484375
|
||||
attn_3_7,attn,7,cal-zh-1,calibration,1.3340187814155438,1.42344327376934,1.4289276609634798,1.638356412458448,0.05265559345262384,0,0.07230515778064728,0.17881479859352112,0.144265815615654,248,0.15721087157726288,0.3267841339111328,0.16228218376636505,0.5890625
|
||||
attn_3_7,attn,7,cal-zh-2,calibration,1.3371723133481364,1.418275178551954,1.4336050300809013,1.6659403627988982,0.05349503065318622,0,0.081089086830616,0.1558690071105957,0.13882805407047272,248,0.1448846012353897,0.3248489499092102,0.14955829083919525,0.590625
|
||||
attn_3_7,attn,7,cal-en-1,calibration,1.405999268639987,1.3246539988272832,1.532711571208276,1.4346161336828325,0.07054514898566913,0,0.08104264736175537,0.16970808804035187,0.1672150194644928,248,0.17672982811927795,0.38887327909469604,0.18243078887462616,0.5859375
|
||||
attn_3_7,attn,7,cal-en-2,calibration,1.366473684595312,1.4009631878257847,1.4664096677417215,1.59944923669573,0.0431210172272288,0,0.07256138324737549,0.1774885654449463,0.1528259664773941,248,0.16717864573001862,0.3629882335662842,0.17257151007652283,0.5625
|
||||
attn_11_15,attn,11,cal-zh-1,calibration,2.7606058538571316,0.9703348793344666,2.4183673572578086,1.0857279648648543,0.2588922604193846,0,0.24492809176445007,0.4079643785953522,0.11288609355688095,248,0.1462744027376175,0.3241320848464966,0.15099292993545532,0.6625
|
||||
attn_11_15,attn,11,cal-zh-2,calibration,2.5044424857870546,0.9843061509576916,2.592796177795181,1.1478459097975344,0.23612970738935357,0,0.18575024604797363,0.3524782657623291,0.12114741653203964,248,0.16847708821296692,0.3656128942966461,0.17391183972358704,0.66328125
|
||||
attn_11_15,attn,11,cal-en-1,calibration,2.649979511635331,0.9795891219874814,2.4632888494810317,1.1094207865752836,0.23948147120552113,0,0.24272800981998444,0.39156001806259155,0.11876673251390457,248,0.15664874017238617,0.337306410074234,0.16170193254947662,0.6929687500000001
|
||||
attn_11_15,attn,11,cal-en-2,calibration,2.7191409308620766,0.9759398005295231,2.5703854656788505,1.1257459370791087,0.24568690002591262,0,0.2525215446949005,0.3836510181427002,0.11734011769294739,248,0.15115201473236084,0.3331157863140106,0.1560278832912445,0.65078125
|
||||
attn_11_15,attn,15,cal-zh-1,calibration,3.7267750977169203,0.9943195388381949,1.8571948100572258,1.4659544762265972,0.15463241076860404,0,0.12717953324317932,0.33434635400772095,0.15986472368240356,248,0.19836202263832092,0.40538591146469116,0.20476080477237701,0.6398437499999999
|
||||
attn_11_15,attn,15,cal-zh-2,calibration,3.484117411382163,0.9958762023786318,1.9555333671772042,1.5034310789069971,0.15731411020281283,0,0.13328716158866882,0.30227771401405334,0.17917340993881226,248,0.21005423367023468,0.41705968976020813,0.21683017909526825,0.628125
|
||||
attn_11_15,attn,15,cal-en-1,calibration,3.5714882610996845,0.9941664364521509,1.8393702843739006,1.5570787013529828,0.16007660497298756,0,0.14896893501281738,0.3320315480232239,0.17083808779716492,248,0.2080441117286682,0.4197816848754883,0.21475520730018616,0.646875
|
||||
attn_11_15,attn,15,cal-en-2,calibration,3.783713712256275,0.9885545400787986,2.0440754255967826,1.5107488942763196,0.17418988407724514,0,0.15646213293075562,0.35803988575935364,0.1682518720626831,248,0.2177426666021347,0.419617235660553,0.22476662695407867,0.6046875
|
||||
attn_19_23,attn,19,cal-zh-1,calibration,3.1071992972679547,1.080818751446137,3.9981135079246157,1.1800456131328154,-0.06780946108706973,0,0.08087001740932465,0.04044787213206291,0.20344728231430054,248,0.20533767342567444,0.5970298051834106,0.21196146309375763,0.65390625
|
||||
attn_19_23,attn,19,cal-zh-2,calibration,3.5223723842603682,1.066376496758468,4.7369591160509135,1.1555630164896329,-0.07515431162135316,0,0.08035354316234589,0.04998621344566345,0.17885737121105194,248,0.17917148768901825,0.5459575057029724,0.18495121598243713,0.72890625
|
||||
attn_19_23,attn,19,cal-en-1,calibration,3.7338041826396506,1.0390406833474568,4.724166114393082,1.1075162239519407,-0.0038920109670231525,0,0.24834147095680237,0.10791976749897003,0.18416298925876617,248,0.20052647590637207,0.5714813470840454,0.20699506998062134,0.69375
|
||||
attn_19_23,attn,19,cal-en-2,calibration,3.3431946049591024,1.0618542149778405,4.853161886124916,1.1462103851521934,-0.04195946512998055,0,0.169009268283844,0.07061692327260971,0.21073731780052185,248,0.22293230891227722,0.6151081323623657,0.23012366890907288,0.58125
|
||||
attn_19_23,attn,23,cal-zh-1,calibration,2.981238336078164,1.0546738615923779,3.342676305565292,1.0914181503369393,0.018114203094761517,0,0.1326604187488556,0.06724601984024048,0.1667337417602539,248,0.17328983545303345,0.5646554827690125,0.17887982726097107,0.6109375
|
||||
attn_19_23,attn,23,cal-zh-2,calibration,3.0395249971461062,1.0612041520781252,3.9775899363194043,1.111839148442333,-0.006099502317895858,0,0.09588906913995743,0.06764671951532364,0.15978427231311798,248,0.16259410977363586,0.5136446356773376,0.16783908009529114,0.6968749999999999
|
||||
attn_19_23,attn,23,cal-en-1,calibration,3.044278410194487,1.074729515389283,4.006931562831888,1.1811940201100057,-0.04307182449714221,0,0.12535521388053894,0.08747006952762604,0.1720750480890274,248,0.1742202639579773,0.5411514639854431,0.17984026670455933,0.66015625
|
||||
attn_19_23,attn,23,cal-en-2,calibration,2.9710652272259535,1.0799822705908066,3.68900214533588,1.1411985546671786,-0.0470831335221732,0,0.08650433272123337,0.08903923630714417,0.17286045849323273,248,0.17006517946720123,0.538245439529419,0.1755511462688446,0.56875
|
||||
mlp_5_6,mlp,5,cal-zh-1,calibration,1.2343440431264474,1.2448870136879528,1.4262659492232905,1.3330956688296154,0.23172673358878942,0,,,,,,,,
|
||||
mlp_5_6,mlp,5,cal-zh-2,calibration,1.2339654450576971,1.2535104800781527,1.32561843838562,1.329338987748564,0.22672917563938177,0,,,,,,,,
|
||||
mlp_5_6,mlp,5,cal-en-1,calibration,1.2263457192811411,1.2317267194400943,1.3474685872410954,1.321453653023078,0.2447481896291194,0,,,,,,,,
|
||||
mlp_5_6,mlp,5,cal-en-2,calibration,1.2077976165854318,1.2358845908873308,1.3068781752715062,1.3085733890221656,0.2539150140171328,0,,,,,,,,
|
||||
mlp_5_6,mlp,6,cal-zh-1,calibration,1.4662701939974856,1.3822306441896342,1.7481556583915787,1.7624732809638852,-0.011619417250216499,0,,,,,,,,
|
||||
mlp_5_6,mlp,6,cal-zh-2,calibration,1.4798445991262743,1.3637763123448376,1.6959117760237137,1.4894484186140093,-0.005750877367744503,0,,,,,,,,
|
||||
mlp_5_6,mlp,6,cal-en-1,calibration,1.464591579412775,1.3766590597797903,1.689543163635455,1.5032948778211077,-0.006204174235411236,0,,,,,,,,
|
||||
mlp_5_6,mlp,6,cal-en-2,calibration,1.4368842673613405,1.4008394919323996,1.6226235618647424,1.6896559214993705,-0.006099379702393146,0,,,,,,,,
|
||||
mlp_20_21,mlp,20,cal-zh-1,calibration,1.3631629826891347,1.3480373135423591,1.4508876157140895,1.4575901158218467,0.0812649689016906,0,,,,,,,,
|
||||
mlp_20_21,mlp,20,cal-zh-2,calibration,1.4305121300612613,1.314068906091469,1.5976490501921767,1.4075788062559882,0.06371076852261268,0,,,,,,,,
|
||||
mlp_20_21,mlp,20,cal-en-1,calibration,1.366192568032983,1.35226347926907,1.5789533371800022,1.5827466919073778,0.07632635231947486,0,,,,,,,,
|
||||
mlp_20_21,mlp,20,cal-en-2,calibration,1.4386161527552375,1.3312892565009653,1.5821573752114773,1.4214461315124072,0.045400137548793094,0,,,,,,,,
|
||||
mlp_20_21,mlp,21,cal-zh-1,calibration,1.389882929510158,1.3382556516005442,1.4917751564635304,1.4560073575192687,0.07070714893962673,0,,,,,,,,
|
||||
mlp_20_21,mlp,21,cal-zh-2,calibration,1.4299639779406776,1.3285677793009314,1.6132811807602088,1.41117608068315,0.052803821787486716,0,,,,,,,,
|
||||
mlp_20_21,mlp,21,cal-en-1,calibration,1.3453233062044447,1.4107978765350015,1.5399413812441296,1.7867758701030254,0.052139705952592985,0,,,,,,,,
|
||||
mlp_20_21,mlp,21,cal-en-2,calibration,1.4554092594533905,1.3180744101503734,1.5831740681011888,1.3865901398082663,0.045747088042376524,0,,,,,,,,
|
||||
qk_norm_3,qk_norm,q,cal-zh-1,calibration,0.22945597860473388,0.23195008932522895,0.24221562711880595,0.24569969899481256,0.973447272274363,0,,,,,,,,
|
||||
qk_norm_3,qk_norm,q,cal-zh-2,calibration,0.2290088724166579,0.23181448107574626,0.24542894690924066,0.24779202863840974,0.9735303499099761,0,,,,,,,,
|
||||
qk_norm_3,qk_norm,q,cal-en-1,calibration,0.23455492648208914,0.2376969550882275,0.24989139477418182,0.2529845119820021,0.972212040535478,0,,,,,,,,
|
||||
qk_norm_3,qk_norm,q,cal-en-2,calibration,0.22901516213757628,0.23221465328764443,0.24944281350466996,0.2558284584833273,0.9735059067182225,0,,,,,,,,
|
||||
qk_norm_3,qk_norm,k,cal-zh-1,calibration,0.19278924917702345,0.19044985719492102,0.21696829135487192,0.21613622029669263,0.9817161843232514,0,,,,,,,,
|
||||
qk_norm_3,qk_norm,k,cal-zh-2,calibration,0.1914737037557284,0.18949712918171538,0.22059518754606067,0.22263213250570094,0.98191197888193,0,,,,,,,,
|
||||
qk_norm_3,qk_norm,k,cal-en-1,calibration,0.19741689848184946,0.1948868605635172,0.25540160556856767,0.2544707934700031,0.9808462075453858,0,,,,,,,,
|
||||
qk_norm_3,qk_norm,k,cal-en-2,calibration,0.21059744905193553,0.20938264759903177,0.24188706740832974,0.24203851319432876,0.9779690077710401,0,,,,,,,,
|
||||
qk_norm_7,qk_norm,q,cal-zh-1,calibration,0.20847388940801903,0.20369709176427747,0.2170900495487928,0.21347731005429094,0.9790359000979272,0,,,,,,,,
|
||||
qk_norm_7,qk_norm,q,cal-zh-2,calibration,0.19935697980676284,0.19546641114417262,0.21545417284813181,0.20622001465458153,0.9807104227014257,0,,,,,,,,
|
||||
qk_norm_7,qk_norm,q,cal-en-1,calibration,0.20377890669282792,0.1992044511742432,0.2180618268213074,0.21066534853291913,0.9799609125477599,0,,,,,,,,
|
||||
qk_norm_7,qk_norm,q,cal-en-2,calibration,0.2049050681850306,0.20143020818672328,0.21865291387428726,0.20943815578722963,0.9795092387917065,0,,,,,,,,
|
||||
qk_norm_7,qk_norm,k,cal-zh-1,calibration,0.11058006301891404,0.10891256044231754,0.12484384056818072,0.12331584938512573,0.9940936589516192,0,,,,,,,,
|
||||
qk_norm_7,qk_norm,k,cal-zh-2,calibration,0.1025377174596076,0.10115362014926518,0.1190380009492926,0.11772165381976195,0.994906319610355,0,,,,,,,,
|
||||
qk_norm_7,qk_norm,k,cal-en-1,calibration,0.11061820718242668,0.10874403924660925,0.1246694172087446,0.12218803487494587,0.9941314653674382,0,,,,,,,,
|
||||
qk_norm_7,qk_norm,k,cal-en-2,calibration,0.1097129827694824,0.10824015260116268,0.12658812743768616,0.1257629217271933,0.9941536582549061,0,,,,,,,,
|
||||
qk_norm_11,qk_norm,q,cal-zh-1,calibration,0.13162251097797606,0.1336688160421926,0.14723992137490324,0.1503968566479842,0.9913220883632566,0,,,,,,,,
|
||||
qk_norm_11,qk_norm,q,cal-zh-2,calibration,0.1293519958781259,0.1314802843900349,0.15550840977823716,0.15903465263092675,0.9916295485881612,0,,,,,,,,
|
||||
qk_norm_11,qk_norm,q,cal-en-1,calibration,0.12647077725692374,0.12852946057966494,0.14803436556570124,0.1502912423902487,0.9920027531738658,0,,,,,,,,
|
||||
qk_norm_11,qk_norm,q,cal-en-2,calibration,0.1325318326855699,0.13489053569820655,0.15675391452711515,0.16029285586480232,0.9912169569277748,0,,,,,,,,
|
||||
qk_norm_11,qk_norm,k,cal-zh-1,calibration,0.19235633022629203,0.19080289992858507,0.2290122037106061,0.22871738277610806,0.9816818019088915,0,,,,,,,,
|
||||
qk_norm_11,qk_norm,k,cal-zh-2,calibration,0.20373761974053708,0.2026516990230578,0.22610646515999447,0.22641810348752162,0.9793703931467622,0,,,,,,,,
|
||||
qk_norm_11,qk_norm,k,cal-en-1,calibration,0.20072570704403014,0.1997337419816918,0.23210824690537907,0.232000375512668,0.9799664235115935,0,,,,,,,,
|
||||
qk_norm_11,qk_norm,k,cal-en-2,calibration,0.21292543194773159,0.2114735746425023,0.2540111544217496,0.253548340715113,0.9775093552656579,0,,,,,,,,
|
||||
qk_norm_15,qk_norm,q,cal-zh-1,calibration,0.15982234891287764,0.1668593847865133,0.1806429713396301,0.18971996556779416,0.9875945267208645,0,,,,,,,,
|
||||
qk_norm_15,qk_norm,q,cal-zh-2,calibration,0.15740332806536778,0.1630453842176067,0.17808143035469418,0.1865293914125642,0.987788243570594,0,,,,,,,,
|
||||
qk_norm_15,qk_norm,q,cal-en-1,calibration,0.16051291705164175,0.16606195948802505,0.18552144269008958,0.19215103895989022,0.9872500535949923,0,,,,,,,,
|
||||
qk_norm_15,qk_norm,q,cal-en-2,calibration,0.1646608571816797,0.17165005121760066,0.18445606954569943,0.19141765315408663,0.9867321292200623,0,,,,,,,,
|
||||
qk_norm_15,qk_norm,k,cal-zh-1,calibration,0.12891191745886205,0.12454504053986937,0.1385991791084394,0.1331904813118359,0.9925662013931714,0,,,,,,,,
|
||||
qk_norm_15,qk_norm,k,cal-zh-2,calibration,0.12161598809109211,0.11777013931789594,0.1368420974285716,0.1315377420603533,0.9933549654835544,0,,,,,,,,
|
||||
qk_norm_15,qk_norm,k,cal-en-1,calibration,0.12197566460111624,0.11819082207382924,0.135322184241321,0.13196489880351644,0.9932886289657402,0,,,,,,,,
|
||||
qk_norm_15,qk_norm,k,cal-en-2,calibration,0.12441025575886772,0.12064470117171276,0.1406080640306027,0.13504984145616641,0.9929676304409041,0,,,,,,,,
|
||||
qk_norm_19,qk_norm,q,cal-zh-1,calibration,0.35607606695379634,0.35506507510461943,0.4419932151127893,0.43353427677209583,0.9367889544420241,0,,,,,,,,
|
||||
qk_norm_19,qk_norm,q,cal-zh-2,calibration,0.3050017336245941,0.3063513991209177,0.35702892926241475,0.35499913749231526,0.9532908937392158,0,,,,,,,,
|
||||
qk_norm_19,qk_norm,q,cal-en-1,calibration,0.3004172668571062,0.30248734097466856,0.3551434800248225,0.3574678230240773,0.9545873680313379,0,,,,,,,,
|
||||
qk_norm_19,qk_norm,q,cal-en-2,calibration,0.332120216475189,0.33442277896716227,0.39234612989053624,0.3869494866775299,0.9444895843396817,0,,,,,,,,
|
||||
qk_norm_19,qk_norm,k,cal-zh-1,calibration,0.1494891933687725,0.1453919459232531,0.19873146648565732,0.1911951771845603,0.9895189305032556,0,,,,,,,,
|
||||
qk_norm_19,qk_norm,k,cal-zh-2,calibration,0.14909792210432973,0.14536281895078332,0.19307308117224836,0.18807685138750432,0.9894852004735976,0,,,,,,,,
|
||||
qk_norm_19,qk_norm,k,cal-en-1,calibration,0.1529571262250341,0.14878974314439253,0.19553431973346902,0.18740449249037416,0.9890023265976378,0,,,,,,,,
|
||||
qk_norm_19,qk_norm,k,cal-en-2,calibration,0.1608915089597201,0.15621975475373284,0.19992876686197072,0.1909273809291801,0.9878669550506567,0,,,,,,,,
|
||||
qk_norm_23,qk_norm,q,cal-zh-1,calibration,0.5472715903763039,0.4942115602598659,0.5959124252670717,0.5246077344510891,0.8699706486172409,0,,,,,,,,
|
||||
qk_norm_23,qk_norm,q,cal-zh-2,calibration,0.5066278025120974,0.4652273156892467,0.5698812253775749,0.505450409971441,0.8857874771365101,0,,,,,,,,
|
||||
qk_norm_23,qk_norm,q,cal-en-1,calibration,0.5396383470456222,0.4881273164223247,0.6104980922233472,0.5338668240636818,0.8733304573488526,0,,,,,,,,
|
||||
qk_norm_23,qk_norm,q,cal-en-2,calibration,0.5484944291943057,0.4948734608679084,0.6117866340678192,0.5354951226175159,0.8695786360146698,0,,,,,,,,
|
||||
qk_norm_23,qk_norm,k,cal-zh-1,calibration,0.1313144920837702,0.13005524261632884,0.18219490064170027,0.1762085222381826,0.9915073560564274,0,,,,,,,,
|
||||
qk_norm_23,qk_norm,k,cal-zh-2,calibration,0.12151622394280005,0.12124252528158447,0.1793544881596151,0.17483197862503747,0.9926360753692314,0,,,,,,,,
|
||||
qk_norm_23,qk_norm,k,cal-en-1,calibration,0.12730373699904377,0.12630314407300633,0.17809052202752992,0.17316093196082644,0.9919917024971001,0,,,,,,,,
|
||||
qk_norm_23,qk_norm,k,cal-en-2,calibration,0.15218433424490216,0.1492986535261055,0.1960834395064235,0.18960021577591676,0.9888227905277445,0,,,,,,,,
|
||||
|
@@ -0,0 +1,101 @@
|
||||
[
|
||||
{
|
||||
"id": "attn_3_7",
|
||||
"kind": "attn",
|
||||
"i": 3,
|
||||
"j": 7,
|
||||
"passed": false,
|
||||
"maximum_symmetric_relative_error": 2.1157833337453664,
|
||||
"donor_component_bytes": 29361152
|
||||
},
|
||||
{
|
||||
"id": "attn_11_15",
|
||||
"kind": "attn",
|
||||
"i": 11,
|
||||
"j": 15,
|
||||
"passed": false,
|
||||
"maximum_symmetric_relative_error": 3.783713712256275,
|
||||
"donor_component_bytes": 29361152
|
||||
},
|
||||
{
|
||||
"id": "attn_19_23",
|
||||
"kind": "attn",
|
||||
"i": 19,
|
||||
"j": 23,
|
||||
"passed": false,
|
||||
"maximum_symmetric_relative_error": 3.7338041826396506,
|
||||
"donor_component_bytes": 29361152
|
||||
},
|
||||
{
|
||||
"id": "mlp_5_6",
|
||||
"kind": "mlp",
|
||||
"i": 5,
|
||||
"j": 6,
|
||||
"passed": false,
|
||||
"maximum_symmetric_relative_error": 1.4798445991262743,
|
||||
"donor_component_bytes": 75497472
|
||||
},
|
||||
{
|
||||
"id": "mlp_20_21",
|
||||
"kind": "mlp",
|
||||
"i": 20,
|
||||
"j": 21,
|
||||
"passed": false,
|
||||
"maximum_symmetric_relative_error": 1.4554092594533905,
|
||||
"donor_component_bytes": 75497472
|
||||
},
|
||||
{
|
||||
"id": "qk_norm_3",
|
||||
"kind": "qk_norm",
|
||||
"i": 3,
|
||||
"j": 3,
|
||||
"passed": false,
|
||||
"maximum_symmetric_relative_error": 0.2376969550882275,
|
||||
"donor_component_bytes": 512
|
||||
},
|
||||
{
|
||||
"id": "qk_norm_7",
|
||||
"kind": "qk_norm",
|
||||
"i": 7,
|
||||
"j": 7,
|
||||
"passed": false,
|
||||
"maximum_symmetric_relative_error": 0.20847388940801903,
|
||||
"donor_component_bytes": 512
|
||||
},
|
||||
{
|
||||
"id": "qk_norm_11",
|
||||
"kind": "qk_norm",
|
||||
"i": 11,
|
||||
"j": 11,
|
||||
"passed": false,
|
||||
"maximum_symmetric_relative_error": 0.21292543194773159,
|
||||
"donor_component_bytes": 512
|
||||
},
|
||||
{
|
||||
"id": "qk_norm_15",
|
||||
"kind": "qk_norm",
|
||||
"i": 15,
|
||||
"j": 15,
|
||||
"passed": false,
|
||||
"maximum_symmetric_relative_error": 0.17165005121760066,
|
||||
"donor_component_bytes": 512
|
||||
},
|
||||
{
|
||||
"id": "qk_norm_19",
|
||||
"kind": "qk_norm",
|
||||
"i": 19,
|
||||
"j": 19,
|
||||
"passed": false,
|
||||
"maximum_symmetric_relative_error": 0.35607606695379634,
|
||||
"donor_component_bytes": 512
|
||||
},
|
||||
{
|
||||
"id": "qk_norm_23",
|
||||
"kind": "qk_norm",
|
||||
"i": 23,
|
||||
"j": 23,
|
||||
"passed": false,
|
||||
"maximum_symmetric_relative_error": 0.5484944291943057,
|
||||
"donor_component_bytes": 512
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"FUNCTIONAL_REPORT.md": "6bfde7e8843e4c87186f8229bf15ab1db919f08ddd8b40fd04aecdec20c7390d",
|
||||
"attention-head-metrics.csv": "732ada825914f8db49b72083cb129cf1305434c84c88253cc32b499ca1a9a119",
|
||||
"baseline-activations.npz": "a851b489a8917a63b07cb6615a47fd1399b36e62f62d6140be618c4966d204ef",
|
||||
"baseline-heldout-token-nll.npy": "303853deb86cb09848b63e2f8b62673db5e730c3b7984c7e65fef3f61c33cda1",
|
||||
"calibration-metrics.csv": "fff8d1e638c6dcfaed88df580de348083fb01621bae7cda7ca2f04ec29636137",
|
||||
"candidate-summary.json": "dc1d738760fa87ef681e33a72caf67cdb68db7413b66f364f80a67b0233fdbdc",
|
||||
"compute-budget-ledger.json": "33dac0f3e9aaf6a82a01c67c22f9a755dff9be8092710f5d3fa8236ce551b255",
|
||||
"download.log": "9f5b76650a94f15729e949605b50ab172ff0fc3a1d791b35dd2a88d4ace02dd0",
|
||||
"experiment.json": "911ba54b489547373b724bd0e719717d8f836807d8fad8aa221eadb5a525d05a",
|
||||
"figures/algebraic_gain_identity.pdf": "b9c44ed9f2df66f7b9172e9a1650db31ec3915290fef3d59b77320a0510ee6de",
|
||||
"figures/algebraic_gain_identity.png": "2e637bb3362ac1592959fbe8f84e67ba06b1ea00ec71dfeec80c45a7ce7520b1",
|
||||
"figures/algebraic_gain_identity.svg": "553ac72babfc005f67a91564f8b737b5edd279d62fb013b8d5d87f6884c4f1ac",
|
||||
"figures/candidate_function_errors.pdf": "370f9b888a6cff64d69bb5f52541e71c66695139cc0b1a45ca8115eae44aae33",
|
||||
"figures/candidate_function_errors.png": "a469f33e4f0a8ba81d4cbcaa333ddcf822f6fa2e4f33ea2c0a6d7da3cbd814b9",
|
||||
"figures/candidate_function_errors.svg": "a647cfcf58bd5d96770daed29cf14ffd245aef3a0c463706f3724bf84b800469",
|
||||
"figures/learned_norm_function_errors.pdf": "cba6296e9297d8f14b1f3346b4ab4015845a54bc880d0f153c8d4b586fe16f90",
|
||||
"figures/learned_norm_function_errors.png": "85b1bce927e1c152778b814629a52996bfdb4a0828995492f56e1fb12f68648f",
|
||||
"figures/learned_norm_function_errors.svg": "ce867a8b8aedfd941dde51ae53ad2541f4e407235c2572092dca6446e71d8f8c",
|
||||
"figures/learned_norm_network_substitution.pdf": "6d3440323d276b4a70209f71cd31e016d8eb78d257bdaa41ffc0468d2813a428",
|
||||
"figures/learned_norm_network_substitution.png": "e0dca3ce8082abf3e904aaa27aa581bd1c7ed1ff7a19285dde613dd88b3738ad",
|
||||
"figures/learned_norm_network_substitution.svg": "7753abfa3f85cda50fbc3a00491f54a597cbbb54fdb75f0c0b2fe7a7fcc131c5",
|
||||
"final-report.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"final-source-hashes.json": "52398645bce397827c36048c417f721a1cd8f76dc38eeaee530b8a5031b09e91",
|
||||
"final-tests.txt": "3eb63c08f7b8de12c4198e79da9909582d5d64cb821ef1b08d38de7e4e43eaf5",
|
||||
"functional-code-hashes.json": "3756c43b0904c53d9a3ea1fe92496cc9f890cc7b033a3c9577ef53cecd4d8536",
|
||||
"functional-environment.json": "b9a2b4b850b3f26cfa96efc1ac6a9470d678f17197f96a01d9c3bdf5111b148a",
|
||||
"functional-report.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"functional-run.log": "95684864b79b72dbefdf5485fca00bca3e80719c9e925a2a6fe1a6b0a07825d3",
|
||||
"functional-status.json": "fdda303b7e520f9e0065c65281df5b4bd6e9277edec52f9e5818047598a2a2ea",
|
||||
"gain-factorization-k_to_q-token-nll.npy": "767f2a885532e347a654a86ed0a7f19bd4938c52296dcc74db26876acb3fe6a1",
|
||||
"gain-factorization-kernel-timing.csv": "7ee790a456d4b9dac9d4756b71288f4df165c0c6111fe94657fa6804f91154d1",
|
||||
"gain-factorization-optimized-summary.json": "0e303074384a3933577b2c3c29a042fe00e64cf308eb8f6190db8f7e3db55e7b",
|
||||
"gain-factorization-optimized-timing.csv": "b5c85e1f9bcfb49bf317090470530a44546079c5a79c1df2365c00c36144dc10",
|
||||
"gain-factorization-optimized.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"gain-factorization-protocol.json": "7690e4cf5dec415e414813e5beb3434ae62d51d95e68ad5de48e698980e26cab",
|
||||
"gain-factorization-q_to_k-token-nll.npy": "6ea27edea56593c7269403ce5a0f7eb8673b9d80d1e00806d38bc6a2a681fff8",
|
||||
"gain-factorization-score-metrics.csv": "7cfcc997980cd0566721e529f6bb1bca2f95858da50d5cf533eb31742ab0c230",
|
||||
"gain-factorization-summary.json": "3bfde7dba2abd19e6dc945c05ad924181bc0927e0b88806337c9bbab9db7b359",
|
||||
"gain-factorization.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"install-torch-disk-tmp.log": "85ee085d264707b8fd0031876c3ae9cf4e36151db9cbf53edef979f10d144c13",
|
||||
"install-torch.log": "e297f77b38de146e85e6159025ea1e0ec93622fe26ef46698df180c7c96378b8",
|
||||
"manifest.json": "28efbaf94a5034333339a35f08ead151459a7d20c6c2d2f07a451e7f3bf154de",
|
||||
"model_config.json": "ed1c1723241f23f7f4e23430759cbd7dcfb4103cbdfe052bfe7626b57c2615b4",
|
||||
"neuron-reuse-activations.npz": "0ce0b7ba4efef0164a68d91595e8eb47a6347f1f364eeda764835cfa09b09448",
|
||||
"neuron-reuse-protocol.json": "cc4fcf06ebd4ee5420933534021006df6e62259b00fd922f6e8fabada89472f7",
|
||||
"neuron-reuse-search-summary.json": "30a5ef914c4ff766e9bde09e3784a229bdbe7a10cea871bef3be327df8047c25",
|
||||
"neuron-reuse-selection.json": "afafc7f8d35c562940f5afe47c5edaf3c5b7ca97744152bb5f9988b9910797a4",
|
||||
"neuron-reuse-summary.json": "f14999d51d262c67f90e2e37918701b6b56107c7d5c47fad6da1cdfeb35d62a2",
|
||||
"neuron-reuse.log": "be387fa429688a6a34131f0a5899a81586a2bde85cf209253c2da977e625168c",
|
||||
"norm-repetition-12-uses-13-token-nll.npy": "fb05b796fd40122aa0a1b05ce92585c980f47a1cb1c771df4fabc720ade4bbd8",
|
||||
"norm-repetition-13-uses-12-token-nll.npy": "5470a87f22f100ed8e43caf90a05831453b4277707d6d7085eecc4bd43ae8cb6",
|
||||
"norm-repetition-function-metrics.csv": "d5f4eed05a9f5c6e0f971331dd9d0b834d6141b4aeb9e3c725a5bee1f4314593",
|
||||
"norm-repetition-input-profiles.npz": "7e3415b8f28d8844658facf2c37415cc0f3a4de8f6d39d3e0c4b01e1b3a4d7e0",
|
||||
"norm-repetition-protocol.json": "ad8d2319572b4a1daa5d3ae227bd344b5f1db7941ee567b43d1f25dbd963f6a0",
|
||||
"norm-repetition-selection.json": "4dae5a62da0889c0ed4de7813a8f720bb94991e468b9d6cdee8c5327d549ac55",
|
||||
"norm-repetition-summary.json": "70b5067d0820b5a5bc7062c71b9f29c5590d9bb12bf538beb961135d1aab8834",
|
||||
"norm-repetition-uniform-bounds.csv": "48e71a9cac9410d110483cef8356e02b2dcdeae1120bcb243ae86903852fb32a",
|
||||
"norm-repetition.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"preflight-first-attempt.log": "1a336568f0ed99ac306ab1d690ff00f325c9c73ec6be84df4ace4374d490c650",
|
||||
"preflight-second-attempt.json": "a6b68d31710e45cbf09ee100b490c781547334f76ecfbb3e09332779e953b30c",
|
||||
"preflight-second-attempt.log": "42a07ef0a3fd8cb1a6475bec6e7958f754a24012fb8269073d8625b1b891594f",
|
||||
"preflight.json": "86113ecbf499f4a84ea4d7fd7893e8c12f2784b6e4678b5cbcbb0e022e295e4b",
|
||||
"preflight.log": "66dd7d1e0b146fc448a1064efbde5d693126d3f3cbb2fc9abdeb4485ead7c951",
|
||||
"reference-check-first-attempt.log": "ed77d6619c19551401938a54fae0ef1aa50846b943ea1ba3321750c9cb985428",
|
||||
"reference-check-second-attempt.log": "5923802faaba183a099d0eb313d5dc2de4825b1d52ec6ce0699a8201f68d99af",
|
||||
"reference-check.json": "e82b0d8634ccae0671269587da960e06cce33e0a0e2ed15db15d946f6399d9ed",
|
||||
"reference-check.log": "e4a1d55d309bff39535ecab272bd2aa6d8fe183656724b7731e4171d03150f11",
|
||||
"retention-policy.json": "e3cdb6707985d2fa1fcb7f088f8f46f9eafb89eea13e37f51c554f57790acd6e",
|
||||
"samples-tokenized.json": "2e56e14a4eefedd702bfe09d3edb2f17f360f53dd420e29fcf0c0ec1affc0184",
|
||||
"selection.json": "c8c86d12fe7db6fb8fffca8078ec0ff5438b97998088c89862db8f9b6152daa3",
|
||||
"source_metadata.json": "d3be2a8560f4270b8af27891d1076cb7cf80bd84c4c19fe7790d5fb06f3a342e",
|
||||
"storage-accounting.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"storage-evidence.json": "c6968f4143910cef9d1359d3cd3342d289b9c791c6e2a6ab598fe235b105e0d9",
|
||||
"supervisor-error.txt": "4cba26d15e963620745ab3d4625f4de967859a9c43993f78ca1ce2e5c06aeb42",
|
||||
"supervisor-first-attempt-error.txt": "e689f94e983b84cfc4e6b372175826d77dcd2d5c9b8d166598bc8607227afbba",
|
||||
"supervisor-first-attempt.json": "93d7185df1810aec2aa396fd8247e188b8a37a821731ef681e66389695bd9a8e",
|
||||
"supervisor-second-attempt.json": "7333a3634f7d169bc78d9eeb5e47d8fbd2970c8401b4d6160b92038ad2a89f55",
|
||||
"supervisor-status.json": "ae078d540c9c683bac468313a85754d8ecf1a88be482a2d5895bbfca0c610404",
|
||||
"supervisor-third-attempt.json": "e86ce8e2f55f75ab3c61ffd7b4a1517e627cebbdb85ee7f966615c5d683722ed",
|
||||
"supervisor.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"tokenizer-download.log": "1d9c8b608f3c79c9d7af93c593543ddd14db3e077e2c108738bccd518df9a79a",
|
||||
"tokenizers-wheel.log": "f0b4f7c1360ff1a00e04fe443e619682c7d7b024df55545d31f54951b3001480",
|
||||
"unit-tests.txt": "fa8ffc7277ea722b9261da462b797710ed4ae3eb8975ad51937c419b3052e3af"
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"DELIVERY.md": "8f4608add548dc4c6bc3785ccc262a4c695098c043563f43193edac904702cb1",
|
||||
"FUNCTIONAL_REPORT.md": "6bfde7e8843e4c87186f8229bf15ab1db919f08ddd8b40fd04aecdec20c7390d",
|
||||
"attention-head-metrics.csv": "732ada825914f8db49b72083cb129cf1305434c84c88253cc32b499ca1a9a119",
|
||||
"baseline-heldout-token-nll.npy": "303853deb86cb09848b63e2f8b62673db5e730c3b7984c7e65fef3f61c33cda1",
|
||||
"calibration-metrics.csv": "fff8d1e638c6dcfaed88df580de348083fb01621bae7cda7ca2f04ec29636137",
|
||||
"candidate-summary.json": "dc1d738760fa87ef681e33a72caf67cdb68db7413b66f364f80a67b0233fdbdc",
|
||||
"checksums-full-server.json": "152305bd23c849a75a0e0b5b686cadd93e5db017ea9f2733a52aa771353ed5f3",
|
||||
"compute-budget-ledger.json": "33dac0f3e9aaf6a82a01c67c22f9a755dff9be8092710f5d3fa8236ce551b255",
|
||||
"download.log": "9f5b76650a94f15729e949605b50ab172ff0fc3a1d791b35dd2a88d4ace02dd0",
|
||||
"experiment.json": "911ba54b489547373b724bd0e719717d8f836807d8fad8aa221eadb5a525d05a",
|
||||
"external-activation-cache.json": "ceb8ec04ac1ca6fe1a0466520b0c58180741339541b4ace4c5696c359ed25917",
|
||||
"figures/algebraic_gain_identity.pdf": "b9c44ed9f2df66f7b9172e9a1650db31ec3915290fef3d59b77320a0510ee6de",
|
||||
"figures/algebraic_gain_identity.png": "2e637bb3362ac1592959fbe8f84e67ba06b1ea00ec71dfeec80c45a7ce7520b1",
|
||||
"figures/algebraic_gain_identity.svg": "553ac72babfc005f67a91564f8b737b5edd279d62fb013b8d5d87f6884c4f1ac",
|
||||
"figures/candidate_function_errors.pdf": "370f9b888a6cff64d69bb5f52541e71c66695139cc0b1a45ca8115eae44aae33",
|
||||
"figures/candidate_function_errors.png": "a469f33e4f0a8ba81d4cbcaa333ddcf822f6fa2e4f33ea2c0a6d7da3cbd814b9",
|
||||
"figures/candidate_function_errors.svg": "a647cfcf58bd5d96770daed29cf14ffd245aef3a0c463706f3724bf84b800469",
|
||||
"figures/learned_norm_function_errors.pdf": "cba6296e9297d8f14b1f3346b4ab4015845a54bc880d0f153c8d4b586fe16f90",
|
||||
"figures/learned_norm_function_errors.png": "85b1bce927e1c152778b814629a52996bfdb4a0828995492f56e1fb12f68648f",
|
||||
"figures/learned_norm_function_errors.svg": "ce867a8b8aedfd941dde51ae53ad2541f4e407235c2572092dca6446e71d8f8c",
|
||||
"figures/learned_norm_network_substitution.pdf": "6d3440323d276b4a70209f71cd31e016d8eb78d257bdaa41ffc0468d2813a428",
|
||||
"figures/learned_norm_network_substitution.png": "e0dca3ce8082abf3e904aaa27aa581bd1c7ed1ff7a19285dde613dd88b3738ad",
|
||||
"figures/learned_norm_network_substitution.svg": "7753abfa3f85cda50fbc3a00491f54a597cbbb54fdb75f0c0b2fe7a7fcc131c5",
|
||||
"final-report.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"final-source-hashes.json": "52398645bce397827c36048c417f721a1cd8f76dc38eeaee530b8a5031b09e91",
|
||||
"final-tests.txt": "3eb63c08f7b8de12c4198e79da9909582d5d64cb821ef1b08d38de7e4e43eaf5",
|
||||
"functional-code-hashes.json": "3756c43b0904c53d9a3ea1fe92496cc9f890cc7b033a3c9577ef53cecd4d8536",
|
||||
"functional-environment.json": "b9a2b4b850b3f26cfa96efc1ac6a9470d678f17197f96a01d9c3bdf5111b148a",
|
||||
"functional-report.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"functional-run.log": "95684864b79b72dbefdf5485fca00bca3e80719c9e925a2a6fe1a6b0a07825d3",
|
||||
"functional-status.json": "fdda303b7e520f9e0065c65281df5b4bd6e9277edec52f9e5818047598a2a2ea",
|
||||
"gain-factorization-k_to_q-token-nll.npy": "767f2a885532e347a654a86ed0a7f19bd4938c52296dcc74db26876acb3fe6a1",
|
||||
"gain-factorization-kernel-timing.csv": "7ee790a456d4b9dac9d4756b71288f4df165c0c6111fe94657fa6804f91154d1",
|
||||
"gain-factorization-optimized-summary.json": "0e303074384a3933577b2c3c29a042fe00e64cf308eb8f6190db8f7e3db55e7b",
|
||||
"gain-factorization-optimized-timing.csv": "b5c85e1f9bcfb49bf317090470530a44546079c5a79c1df2365c00c36144dc10",
|
||||
"gain-factorization-optimized.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"gain-factorization-protocol.json": "7690e4cf5dec415e414813e5beb3434ae62d51d95e68ad5de48e698980e26cab",
|
||||
"gain-factorization-q_to_k-token-nll.npy": "6ea27edea56593c7269403ce5a0f7eb8673b9d80d1e00806d38bc6a2a681fff8",
|
||||
"gain-factorization-score-metrics.csv": "7cfcc997980cd0566721e529f6bb1bca2f95858da50d5cf533eb31742ab0c230",
|
||||
"gain-factorization-summary.json": "3bfde7dba2abd19e6dc945c05ad924181bc0927e0b88806337c9bbab9db7b359",
|
||||
"gain-factorization.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"install-torch-disk-tmp.log": "85ee085d264707b8fd0031876c3ae9cf4e36151db9cbf53edef979f10d144c13",
|
||||
"install-torch.log": "e297f77b38de146e85e6159025ea1e0ec93622fe26ef46698df180c7c96378b8",
|
||||
"manifest.json": "28efbaf94a5034333339a35f08ead151459a7d20c6c2d2f07a451e7f3bf154de",
|
||||
"model_config.json": "ed1c1723241f23f7f4e23430759cbd7dcfb4103cbdfe052bfe7626b57c2615b4",
|
||||
"neuron-reuse-protocol.json": "cc4fcf06ebd4ee5420933534021006df6e62259b00fd922f6e8fabada89472f7",
|
||||
"neuron-reuse-search-summary.json": "30a5ef914c4ff766e9bde09e3784a229bdbe7a10cea871bef3be327df8047c25",
|
||||
"neuron-reuse-selection.json": "afafc7f8d35c562940f5afe47c5edaf3c5b7ca97744152bb5f9988b9910797a4",
|
||||
"neuron-reuse-summary.json": "f14999d51d262c67f90e2e37918701b6b56107c7d5c47fad6da1cdfeb35d62a2",
|
||||
"neuron-reuse.log": "be387fa429688a6a34131f0a5899a81586a2bde85cf209253c2da977e625168c",
|
||||
"norm-repetition-12-uses-13-token-nll.npy": "fb05b796fd40122aa0a1b05ce92585c980f47a1cb1c771df4fabc720ade4bbd8",
|
||||
"norm-repetition-13-uses-12-token-nll.npy": "5470a87f22f100ed8e43caf90a05831453b4277707d6d7085eecc4bd43ae8cb6",
|
||||
"norm-repetition-function-metrics.csv": "d5f4eed05a9f5c6e0f971331dd9d0b834d6141b4aeb9e3c725a5bee1f4314593",
|
||||
"norm-repetition-protocol.json": "ad8d2319572b4a1daa5d3ae227bd344b5f1db7941ee567b43d1f25dbd963f6a0",
|
||||
"norm-repetition-selection.json": "4dae5a62da0889c0ed4de7813a8f720bb94991e468b9d6cdee8c5327d549ac55",
|
||||
"norm-repetition-summary.json": "70b5067d0820b5a5bc7062c71b9f29c5590d9bb12bf538beb961135d1aab8834",
|
||||
"norm-repetition-uniform-bounds.csv": "48e71a9cac9410d110483cef8356e02b2dcdeae1120bcb243ae86903852fb32a",
|
||||
"norm-repetition.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"preflight-first-attempt.log": "1a336568f0ed99ac306ab1d690ff00f325c9c73ec6be84df4ace4374d490c650",
|
||||
"preflight-second-attempt.json": "a6b68d31710e45cbf09ee100b490c781547334f76ecfbb3e09332779e953b30c",
|
||||
"preflight-second-attempt.log": "42a07ef0a3fd8cb1a6475bec6e7958f754a24012fb8269073d8625b1b891594f",
|
||||
"preflight.json": "86113ecbf499f4a84ea4d7fd7893e8c12f2784b6e4678b5cbcbb0e022e295e4b",
|
||||
"preflight.log": "66dd7d1e0b146fc448a1064efbde5d693126d3f3cbb2fc9abdeb4485ead7c951",
|
||||
"reference-check-first-attempt.log": "ed77d6619c19551401938a54fae0ef1aa50846b943ea1ba3321750c9cb985428",
|
||||
"reference-check-second-attempt.log": "5923802faaba183a099d0eb313d5dc2de4825b1d52ec6ce0699a8201f68d99af",
|
||||
"reference-check.json": "e82b0d8634ccae0671269587da960e06cce33e0a0e2ed15db15d946f6399d9ed",
|
||||
"reference-check.log": "e4a1d55d309bff39535ecab272bd2aa6d8fe183656724b7731e4171d03150f11",
|
||||
"retention-policy.json": "e3cdb6707985d2fa1fcb7f088f8f46f9eafb89eea13e37f51c554f57790acd6e",
|
||||
"samples-tokenized.json": "2e56e14a4eefedd702bfe09d3edb2f17f360f53dd420e29fcf0c0ec1affc0184",
|
||||
"selection.json": "c8c86d12fe7db6fb8fffca8078ec0ff5438b97998088c89862db8f9b6152daa3",
|
||||
"source_metadata.json": "d3be2a8560f4270b8af27891d1076cb7cf80bd84c4c19fe7790d5fb06f3a342e",
|
||||
"storage-accounting.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"storage-evidence.json": "c6968f4143910cef9d1359d3cd3342d289b9c791c6e2a6ab598fe235b105e0d9",
|
||||
"supervisor-error.txt": "4cba26d15e963620745ab3d4625f4de967859a9c43993f78ca1ce2e5c06aeb42",
|
||||
"supervisor-first-attempt-error.txt": "e689f94e983b84cfc4e6b372175826d77dcd2d5c9b8d166598bc8607227afbba",
|
||||
"supervisor-first-attempt.json": "93d7185df1810aec2aa396fd8247e188b8a37a821731ef681e66389695bd9a8e",
|
||||
"supervisor-second-attempt.json": "7333a3634f7d169bc78d9eeb5e47d8fbd2970c8401b4d6160b92038ad2a89f55",
|
||||
"supervisor-status.json": "ae078d540c9c683bac468313a85754d8ecf1a88be482a2d5895bbfca0c610404",
|
||||
"supervisor-third-attempt.json": "e86ce8e2f55f75ab3c61ffd7b4a1517e627cebbdb85ee7f966615c5d683722ed",
|
||||
"supervisor.log": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"tokenizer-download.log": "1d9c8b608f3c79c9d7af93c593543ddd14db3e077e2c108738bccd518df9a79a",
|
||||
"tokenizers-wheel.log": "f0b4f7c1360ff1a00e04fe443e619682c7d7b024df55545d31f54951b3001480",
|
||||
"unit-tests.txt": "fa8ffc7277ea722b9261da462b797710ed4ae3eb8975ad51937c419b3052e3af"
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"spent_seconds": 1167.355532555841,
|
||||
"initial_reserve_reason": "Conservative reserve for early reference checks and stopped preflight, not a measured runtime",
|
||||
"calls": [
|
||||
{
|
||||
"module": "functional.reference_check",
|
||||
"seconds": 6.833657197188586
|
||||
},
|
||||
{
|
||||
"module": "functional.preflight",
|
||||
"seconds": 27.313251950312406
|
||||
},
|
||||
{
|
||||
"module": "functional.report",
|
||||
"seconds": 2.1849583038128912
|
||||
},
|
||||
{
|
||||
"module": "functional.reference_check",
|
||||
"seconds": 16.264290761202574
|
||||
},
|
||||
{
|
||||
"module": "functional.preflight",
|
||||
"seconds": 58.00242758495733
|
||||
},
|
||||
{
|
||||
"module": "functional.run",
|
||||
"seconds": 204.33689004788175
|
||||
},
|
||||
{
|
||||
"module": "functional.storage",
|
||||
"seconds": 1.2859071069397032
|
||||
},
|
||||
{
|
||||
"module": "functional.report",
|
||||
"seconds": 10.058376160915941
|
||||
},
|
||||
{
|
||||
"module": "functional.gain_factorization",
|
||||
"seconds": 232.08875080291182
|
||||
},
|
||||
{
|
||||
"module": "functional.benchmark_factorization",
|
||||
"seconds": 4.185962562914938
|
||||
},
|
||||
{
|
||||
"module": "functional.neuron_reuse",
|
||||
"seconds": 55.004304428584874
|
||||
},
|
||||
{
|
||||
"module": "functional.norm_repetition",
|
||||
"seconds": 369.7967556482181
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
Downloading README.md, expected 62814 bytes
|
||||
Downloading config.json, expected 2908 bytes
|
||||
Downloading model.safetensors-00001-of-00001.safetensors, expected 4548221488 bytes
|
||||
Weight download 67108864/4548221488 bytes (1.5%)
|
||||
Weight download 134217728/4548221488 bytes (3.0%)
|
||||
Weight download 201326592/4548221488 bytes (4.4%)
|
||||
Weight download 268435456/4548221488 bytes (5.9%)
|
||||
Weight download 335544320/4548221488 bytes (7.4%)
|
||||
Weight download 402653184/4548221488 bytes (8.9%)
|
||||
Weight download 469762048/4548221488 bytes (10.3%)
|
||||
Weight download 536870912/4548221488 bytes (11.8%)
|
||||
Weight download 603979776/4548221488 bytes (13.3%)
|
||||
Weight download 671088640/4548221488 bytes (14.8%)
|
||||
Weight download 738197504/4548221488 bytes (16.2%)
|
||||
Weight download 805306368/4548221488 bytes (17.7%)
|
||||
Weight download 872415232/4548221488 bytes (19.2%)
|
||||
Weight download 939524096/4548221488 bytes (20.7%)
|
||||
Weight download 1006632960/4548221488 bytes (22.1%)
|
||||
Weight download 1073741824/4548221488 bytes (23.6%)
|
||||
Weight download 1140850688/4548221488 bytes (25.1%)
|
||||
Weight download 1207959552/4548221488 bytes (26.6%)
|
||||
Weight download 1275068416/4548221488 bytes (28.0%)
|
||||
Weight download 1342177280/4548221488 bytes (29.5%)
|
||||
Weight download 1409286144/4548221488 bytes (31.0%)
|
||||
Weight download 1476395008/4548221488 bytes (32.5%)
|
||||
Weight download 1543503872/4548221488 bytes (33.9%)
|
||||
Weight download 1610612736/4548221488 bytes (35.4%)
|
||||
Weight download 1677721600/4548221488 bytes (36.9%)
|
||||
Weight download 1744830464/4548221488 bytes (38.4%)
|
||||
Weight download 1811939328/4548221488 bytes (39.8%)
|
||||
Weight download 1879048192/4548221488 bytes (41.3%)
|
||||
Weight download 1946157056/4548221488 bytes (42.8%)
|
||||
Weight download 2013265920/4548221488 bytes (44.3%)
|
||||
Weight download 2080374784/4548221488 bytes (45.7%)
|
||||
Weight download 2147483648/4548221488 bytes (47.2%)
|
||||
Weight download 2214592512/4548221488 bytes (48.7%)
|
||||
Weight download 2281701376/4548221488 bytes (50.2%)
|
||||
Weight download 2348810240/4548221488 bytes (51.6%)
|
||||
Weight download 2415919104/4548221488 bytes (53.1%)
|
||||
Weight download 2483027968/4548221488 bytes (54.6%)
|
||||
Weight download 2550136832/4548221488 bytes (56.1%)
|
||||
Weight download 2617245696/4548221488 bytes (57.5%)
|
||||
Weight download 2684354560/4548221488 bytes (59.0%)
|
||||
Weight download 2751463424/4548221488 bytes (60.5%)
|
||||
Weight download 2818572288/4548221488 bytes (62.0%)
|
||||
Weight download 2885681152/4548221488 bytes (63.4%)
|
||||
Weight download 2952790016/4548221488 bytes (64.9%)
|
||||
Weight download 3019898880/4548221488 bytes (66.4%)
|
||||
Weight download 3087007744/4548221488 bytes (67.9%)
|
||||
Weight download 3154116608/4548221488 bytes (69.3%)
|
||||
Weight download 3221225472/4548221488 bytes (70.8%)
|
||||
Weight download 3288334336/4548221488 bytes (72.3%)
|
||||
Weight download 3355443200/4548221488 bytes (73.8%)
|
||||
Weight download 3422552064/4548221488 bytes (75.3%)
|
||||
Weight download 3489660928/4548221488 bytes (76.7%)
|
||||
Weight download 3556769792/4548221488 bytes (78.2%)
|
||||
Weight download 3623878656/4548221488 bytes (79.7%)
|
||||
Weight download 3690987520/4548221488 bytes (81.2%)
|
||||
Weight download 3758096384/4548221488 bytes (82.6%)
|
||||
Weight download 3825205248/4548221488 bytes (84.1%)
|
||||
Weight download 3892314112/4548221488 bytes (85.6%)
|
||||
Weight download 3959422976/4548221488 bytes (87.1%)
|
||||
Weight download 4026531840/4548221488 bytes (88.5%)
|
||||
Weight download 4093640704/4548221488 bytes (90.0%)
|
||||
Weight download 4160749568/4548221488 bytes (91.5%)
|
||||
Weight download 4227858432/4548221488 bytes (93.0%)
|
||||
Weight download 4294967296/4548221488 bytes (94.4%)
|
||||
Weight download 4346894896/4548221488 bytes (95.6%)
|
||||
Weight download 4414003760/4548221488 bytes (97.0%)
|
||||
Weight download 4481112624/4548221488 bytes (98.5%)
|
||||
Weight download 4548221488/4548221488 bytes (100.0%)
|
||||
Downloading model.safetensors.index.json, expected 64460 bytes
|
||||
{"revision": "15852e8c16360a2fea060d615a32b45270f8a8fc", "bytes": 4548351670}
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"revision": "15852e8c16360a2fea060d615a32b45270f8a8fc",
|
||||
"attention_pairs": [
|
||||
[
|
||||
3,
|
||||
7
|
||||
],
|
||||
[
|
||||
11,
|
||||
15
|
||||
],
|
||||
[
|
||||
19,
|
||||
23
|
||||
]
|
||||
],
|
||||
"mlp_pairs": [
|
||||
[
|
||||
5,
|
||||
6
|
||||
],
|
||||
[
|
||||
20,
|
||||
21
|
||||
]
|
||||
],
|
||||
"norm_layers": [
|
||||
3,
|
||||
7,
|
||||
11,
|
||||
15,
|
||||
19,
|
||||
23
|
||||
],
|
||||
"seconds": 6849,
|
||||
"output_relative_l2_limit": 0.05,
|
||||
"token_p95_limit": 0.1,
|
||||
"attention_js_limit": 0.01,
|
||||
"attention_top5_min": 0.8,
|
||||
"heldout_nll_mean_delta_limit": 0.01,
|
||||
"heldout_nll_sequence_p95_delta_limit": 0.05,
|
||||
"max_intervention_candidates": 1,
|
||||
"directions_per_selected_candidate": 2,
|
||||
"training": false,
|
||||
"search_R": false,
|
||||
"automatic_weight_cleanup": false,
|
||||
"dtype": "original weights decoded to FP32; not a BF16 backend benchmark",
|
||||
"blas_threads": "1"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"host": "8.211.154.134",
|
||||
"files": [
|
||||
{
|
||||
"name": "baseline-activations.npz",
|
||||
"server_path": "/opt/exp-model-parameter-similarity/runs/cpu-qwen35-2b/baseline-activations.npz",
|
||||
"bytes": 38802964,
|
||||
"sha256": "a851b489a8917a63b07cb6615a47fd1399b36e62f62d6140be618c4966d204ef",
|
||||
"retained": true,
|
||||
"reproducible_by": "functional.run / functional.neuron_reuse / functional.norm_repetition"
|
||||
},
|
||||
{
|
||||
"name": "neuron-reuse-activations.npz",
|
||||
"server_path": "/opt/exp-model-parameter-similarity/runs/cpu-qwen35-2b/neuron-reuse-activations.npz",
|
||||
"bytes": 25166826,
|
||||
"sha256": "0ce0b7ba4efef0164a68d91595e8eb47a6347f1f364eeda764835cfa09b09448",
|
||||
"retained": true,
|
||||
"reproducible_by": "functional.run / functional.neuron_reuse / functional.norm_repetition"
|
||||
},
|
||||
{
|
||||
"name": "norm-repetition-input-profiles.npz",
|
||||
"server_path": "/opt/exp-model-parameter-similarity/runs/cpu-qwen35-2b/norm-repetition-input-profiles.npz",
|
||||
"bytes": 4194818,
|
||||
"sha256": "7e3415b8f28d8844658facf2c37415cc0f3a4de8f6d39d3e0c4b01e1b3a4d7e0",
|
||||
"retained": true,
|
||||
"reproducible_by": "functional.run / functional.neuron_reuse / functional.norm_repetition"
|
||||
}
|
||||
],
|
||||
"not_model_weights": true,
|
||||
"reason": "Large intermediate caches retained on the authorized server; all figure source tables and token NLL arrays are delivered in Git."
|
||||
}
|
||||
|
After Width: | Height: | Size: 135 KiB |
@@ -0,0 +1,581 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="712.424062pt" height="285.518438pt" viewBox="0 0 712.424062 285.518438" xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||
<metadata>
|
||||
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
<cc:Work>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:date>2026-11-09T14:11:02.311213</dc:date>
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Matplotlib v3.11.2, https://matplotlib.org/</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs>
|
||||
<style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style>
|
||||
</defs>
|
||||
<g id="figure_1">
|
||||
<g id="patch_1">
|
||||
<path d="M 0 285.518438
|
||||
L 712.424062 285.518438
|
||||
L 712.424062 -0
|
||||
L 0 -0
|
||||
z
|
||||
" style="fill: #ffffff"/>
|
||||
</g>
|
||||
<g id="axes_1">
|
||||
<g id="patch_2">
|
||||
<path d="M 50.466406 247.317656
|
||||
L 353.864062 247.317656
|
||||
L 353.864062 45.880469
|
||||
L 50.466406 45.880469
|
||||
z
|
||||
" style="fill: #ffffff"/>
|
||||
</g>
|
||||
<g id="matplotlib.axis_1">
|
||||
<g id="xtick_1">
|
||||
<g id="line2d_1">
|
||||
<defs>
|
||||
<path id="m50faf94306" d="M 0 0
|
||||
L 0 3.5
|
||||
" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</defs>
|
||||
<g>
|
||||
<use xlink:href="#m50faf94306" x="64.257209" y="247.317656" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_1">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="64.257209" y="261.915313" transform="rotate(-0 64.257209 261.915313)">3</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_2">
|
||||
<g id="line2d_2">
|
||||
<g>
|
||||
<use xlink:href="#m50faf94306" x="119.420419" y="247.317656" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_2">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="119.420419" y="261.915313" transform="rotate(-0 119.420419 261.915313)">7</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_3">
|
||||
<g id="line2d_3">
|
||||
<g>
|
||||
<use xlink:href="#m50faf94306" x="174.583629" y="247.317656" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_3">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="174.583629" y="261.915313" transform="rotate(-0 174.583629 261.915313)">11</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_4">
|
||||
<g id="line2d_4">
|
||||
<g>
|
||||
<use xlink:href="#m50faf94306" x="229.746839" y="247.317656" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_4">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="229.746839" y="261.915313" transform="rotate(-0 229.746839 261.915313)">15</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_5">
|
||||
<g id="line2d_5">
|
||||
<g>
|
||||
<use xlink:href="#m50faf94306" x="284.91005" y="247.317656" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_5">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="284.91005" y="261.915313" transform="rotate(-0 284.91005 261.915313)">19</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_6">
|
||||
<g id="line2d_6">
|
||||
<g>
|
||||
<use xlink:href="#m50faf94306" x="340.07326" y="247.317656" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_6">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="340.07326" y="261.915313" transform="rotate(-0 340.07326 261.915313)">23</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_7">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="202.165234" y="275.916094" transform="rotate(-0 202.165234 275.916094)">Full-attention layer index</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="matplotlib.axis_2">
|
||||
<g id="ytick_1">
|
||||
<g id="line2d_7">
|
||||
<defs>
|
||||
<path id="m9a2e91a9aa" d="M 0 0
|
||||
L -3.5 0
|
||||
" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</defs>
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="50.466406" y="229.265954" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_8">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="233.064782" transform="rotate(-0 43.466406 233.064782)">2.00</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_2">
|
||||
<g id="line2d_8">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="50.466406" y="205.263431" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_9">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="209.06226" transform="rotate(-0 43.466406 209.06226)">2.25</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_3">
|
||||
<g id="line2d_9">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="50.466406" y="181.260909" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_10">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="185.059737" transform="rotate(-0 43.466406 185.059737)">2.50</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_4">
|
||||
<g id="line2d_10">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="50.466406" y="157.258386" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_11">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="161.057214" transform="rotate(-0 43.466406 161.057214)">2.75</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_5">
|
||||
<g id="line2d_11">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="50.466406" y="133.255863" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_12">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="137.054691" transform="rotate(-0 43.466406 137.054691)">3.00</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_6">
|
||||
<g id="line2d_12">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="50.466406" y="109.25334" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_13">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="113.052169" transform="rotate(-0 43.466406 113.052169)">3.25</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_7">
|
||||
<g id="line2d_13">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="50.466406" y="85.250818" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_14">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="89.049646" transform="rotate(-0 43.466406 89.049646)">3.50</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_8">
|
||||
<g id="line2d_14">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="50.466406" y="61.248295" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_15">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="65.047123" transform="rotate(-0 43.466406 65.047123)">3.75</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_16">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="14.798438" y="146.599063" transform="rotate(-90 14.798438 146.599063)">Maximum absolute score error</text>
|
||||
</g>
|
||||
<g id="text_17">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="50.466406" y="42.880469" transform="rotate(-0 50.466406 42.880469)">1e−6</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="line2d_15">
|
||||
<path d="M 64.257209 238.16142
|
||||
L 119.420419 238.16142
|
||||
L 174.583629 238.16142
|
||||
L 229.746839 146.599063
|
||||
L 284.91005 55.036705
|
||||
L 340.07326 55.036705
|
||||
" clip-path="url(#p0542a2a98b)" style="fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<defs>
|
||||
<path id="m9b4cc9d8d2" d="M 0 3
|
||||
C 0.795609 3 1.55874 2.683901 2.12132 2.12132
|
||||
C 2.683901 1.55874 3 0.795609 3 0
|
||||
C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132
|
||||
C 1.55874 -2.683901 0.795609 -3 0 -3
|
||||
C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132
|
||||
C -2.683901 -1.55874 -3 -0.795609 -3 0
|
||||
C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132
|
||||
C -1.55874 2.683901 -0.795609 3 0 3
|
||||
z
|
||||
" style="stroke: #1f77b4"/>
|
||||
</defs>
|
||||
<g clip-path="url(#p0542a2a98b)">
|
||||
<use xlink:href="#m9b4cc9d8d2" x="64.257209" y="238.16142" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m9b4cc9d8d2" x="119.420419" y="238.16142" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m9b4cc9d8d2" x="174.583629" y="238.16142" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m9b4cc9d8d2" x="229.746839" y="146.599063" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m9b4cc9d8d2" x="284.91005" y="55.036705" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m9b4cc9d8d2" x="340.07326" y="55.036705" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="line2d_16">
|
||||
<path d="M 64.257209 238.16142
|
||||
L 119.420419 238.16142
|
||||
L 174.583629 146.599063
|
||||
L 229.746839 238.16142
|
||||
L 284.91005 238.16142
|
||||
L 340.07326 55.036705
|
||||
" clip-path="url(#p0542a2a98b)" style="fill: none; stroke: #ff7f0e; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<defs>
|
||||
<path id="m556f16804f" d="M 0 3
|
||||
C 0.795609 3 1.55874 2.683901 2.12132 2.12132
|
||||
C 2.683901 1.55874 3 0.795609 3 0
|
||||
C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132
|
||||
C 1.55874 -2.683901 0.795609 -3 0 -3
|
||||
C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132
|
||||
C -2.683901 -1.55874 -3 -0.795609 -3 0
|
||||
C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132
|
||||
C -1.55874 2.683901 -0.795609 3 0 3
|
||||
z
|
||||
" style="stroke: #ff7f0e"/>
|
||||
</defs>
|
||||
<g clip-path="url(#p0542a2a98b)">
|
||||
<use xlink:href="#m556f16804f" x="64.257209" y="238.16142" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m556f16804f" x="119.420419" y="238.16142" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m556f16804f" x="174.583629" y="146.599063" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m556f16804f" x="229.746839" y="238.16142" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m556f16804f" x="284.91005" y="238.16142" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m556f16804f" x="340.07326" y="55.036705" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="patch_3">
|
||||
<path d="M 50.466406 247.317656
|
||||
L 50.466406 45.880469
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_4">
|
||||
<path d="M 353.864062 247.317656
|
||||
L 353.864062 45.880469
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_5">
|
||||
<path d="M 50.466406 247.317656
|
||||
L 353.864062 247.317656
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_6">
|
||||
<path d="M 50.466406 45.880469
|
||||
L 353.864062 45.880469
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="legend_1">
|
||||
<g id="patch_7">
|
||||
<path d="M 56.066406 76.281719
|
||||
L 107.408906 76.281719
|
||||
Q 109.008906 76.281719 109.008906 74.681719
|
||||
L 109.008906 51.480469
|
||||
Q 109.008906 49.880469 107.408906 49.880469
|
||||
L 56.066406 49.880469
|
||||
Q 54.466406 49.880469 54.466406 51.480469
|
||||
L 54.466406 74.681719
|
||||
Q 54.466406 76.281719 56.066406 76.281719
|
||||
z
|
||||
" style="fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter"/>
|
||||
</g>
|
||||
<g id="line2d_17">
|
||||
<path d="M 57.666406 56.359219
|
||||
L 65.666406 56.359219
|
||||
L 73.666406 56.359219
|
||||
" style="fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<g>
|
||||
<use xlink:href="#m9b4cc9d8d2" x="65.666406" y="56.359219" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_18">
|
||||
<text style="font-size: 8px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="80.066406" y="59.159219" transform="rotate(-0 80.066406 59.159219)">q_to_k</text>
|
||||
</g>
|
||||
<g id="line2d_18">
|
||||
<path d="M 57.666406 68.359844
|
||||
L 65.666406 68.359844
|
||||
L 73.666406 68.359844
|
||||
" style="fill: none; stroke: #ff7f0e; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<g>
|
||||
<use xlink:href="#m556f16804f" x="65.666406" y="68.359844" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_19">
|
||||
<text style="font-size: 8px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="80.066406" y="71.159844" transform="rotate(-0 80.066406 71.159844)">k_to_q</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="axes_2">
|
||||
<g id="patch_8">
|
||||
<path d="M 401.826406 247.317656
|
||||
L 705.224062 247.317656
|
||||
L 705.224062 45.880469
|
||||
L 401.826406 45.880469
|
||||
z
|
||||
" style="fill: #ffffff"/>
|
||||
</g>
|
||||
<g id="matplotlib.axis_3">
|
||||
<g id="xtick_7">
|
||||
<g id="line2d_19">
|
||||
<g>
|
||||
<use xlink:href="#m50faf94306" x="415.617209" y="247.317656" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_20">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="415.617209" y="261.915313" transform="rotate(-0 415.617209 261.915313)">3</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_8">
|
||||
<g id="line2d_20">
|
||||
<g>
|
||||
<use xlink:href="#m50faf94306" x="470.780419" y="247.317656" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_21">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="470.780419" y="261.915313" transform="rotate(-0 470.780419 261.915313)">7</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_9">
|
||||
<g id="line2d_21">
|
||||
<g>
|
||||
<use xlink:href="#m50faf94306" x="525.943629" y="247.317656" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_22">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="525.943629" y="261.915313" transform="rotate(-0 525.943629 261.915313)">11</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_10">
|
||||
<g id="line2d_22">
|
||||
<g>
|
||||
<use xlink:href="#m50faf94306" x="581.106839" y="247.317656" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_23">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="581.106839" y="261.915313" transform="rotate(-0 581.106839 261.915313)">15</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_11">
|
||||
<g id="line2d_23">
|
||||
<g>
|
||||
<use xlink:href="#m50faf94306" x="636.27005" y="247.317656" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_24">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="636.27005" y="261.915313" transform="rotate(-0 636.27005 261.915313)">19</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_12">
|
||||
<g id="line2d_24">
|
||||
<g>
|
||||
<use xlink:href="#m50faf94306" x="691.43326" y="247.317656" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_25">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="691.43326" y="261.915313" transform="rotate(-0 691.43326 261.915313)">23</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_26">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="553.525234" y="275.916094" transform="rotate(-0 553.525234 275.916094)">Full-attention layer index</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="matplotlib.axis_4">
|
||||
<g id="ytick_9">
|
||||
<g id="line2d_25">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="401.826406" y="242.241146" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_27">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="394.826406" y="246.039974" transform="rotate(-0 394.826406 246.039974)">5.0</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_10">
|
||||
<g id="line2d_26">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="401.826406" y="211.517917" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_28">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="394.826406" y="215.316745" transform="rotate(-0 394.826406 215.316745)">5.5</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_11">
|
||||
<g id="line2d_27">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="401.826406" y="180.794688" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_29">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="394.826406" y="184.593516" transform="rotate(-0 394.826406 184.593516)">6.0</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_12">
|
||||
<g id="line2d_28">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="401.826406" y="150.071459" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_30">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="394.826406" y="153.870287" transform="rotate(-0 394.826406 153.870287)">6.5</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_13">
|
||||
<g id="line2d_29">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="401.826406" y="119.34823" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_31">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="394.826406" y="123.147058" transform="rotate(-0 394.826406 123.147058)">7.0</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_14">
|
||||
<g id="line2d_30">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="401.826406" y="88.625" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_32">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="394.826406" y="92.423829" transform="rotate(-0 394.826406 92.423829)">7.5</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_15">
|
||||
<g id="line2d_31">
|
||||
<g>
|
||||
<use xlink:href="#m9a2e91a9aa" x="401.826406" y="57.901771" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_33">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="394.826406" y="61.700599" transform="rotate(-0 394.826406 61.700599)">8.0</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_34">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="372.520938" y="146.599063" transform="rotate(-90 372.520938 146.599063)">Maximum absolute probability error</text>
|
||||
</g>
|
||||
<g id="text_35">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="401.826406" y="42.880469" transform="rotate(-0 401.826406 42.880469)">1e−7</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="line2d_32">
|
||||
<path d="M 415.617209 238.16142
|
||||
L 470.780419 55.036705
|
||||
L 525.943629 146.599063
|
||||
L 581.106839 109.974119
|
||||
L 636.27005 183.224006
|
||||
L 691.43326 219.848949
|
||||
" clip-path="url(#p601cd532af)" style="fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<g clip-path="url(#p601cd532af)">
|
||||
<use xlink:href="#m9b4cc9d8d2" x="415.617209" y="238.16142" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m9b4cc9d8d2" x="470.780419" y="55.036705" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m9b4cc9d8d2" x="525.943629" y="146.599063" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m9b4cc9d8d2" x="581.106839" y="109.974119" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m9b4cc9d8d2" x="636.27005" y="183.224006" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m9b4cc9d8d2" x="691.43326" y="219.848949" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="line2d_33">
|
||||
<path d="M 415.617209 219.848949
|
||||
L 470.780419 183.224006
|
||||
L 525.943629 128.286591
|
||||
L 581.106839 109.974119
|
||||
L 636.27005 183.224006
|
||||
L 691.43326 146.599063
|
||||
" clip-path="url(#p601cd532af)" style="fill: none; stroke: #ff7f0e; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<g clip-path="url(#p601cd532af)">
|
||||
<use xlink:href="#m556f16804f" x="415.617209" y="219.848949" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m556f16804f" x="470.780419" y="183.224006" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m556f16804f" x="525.943629" y="128.286591" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m556f16804f" x="581.106839" y="109.974119" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m556f16804f" x="636.27005" y="183.224006" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m556f16804f" x="691.43326" y="146.599063" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="patch_9">
|
||||
<path d="M 401.826406 247.317656
|
||||
L 401.826406 45.880469
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_10">
|
||||
<path d="M 705.224062 247.317656
|
||||
L 705.224062 45.880469
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_11">
|
||||
<path d="M 401.826406 247.317656
|
||||
L 705.224062 247.317656
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_12">
|
||||
<path d="M 401.826406 45.880469
|
||||
L 705.224062 45.880469
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="legend_2">
|
||||
<g id="patch_13">
|
||||
<path d="M 407.426406 76.281719
|
||||
L 458.768906 76.281719
|
||||
Q 460.368906 76.281719 460.368906 74.681719
|
||||
L 460.368906 51.480469
|
||||
Q 460.368906 49.880469 458.768906 49.880469
|
||||
L 407.426406 49.880469
|
||||
Q 405.826406 49.880469 405.826406 51.480469
|
||||
L 405.826406 74.681719
|
||||
Q 405.826406 76.281719 407.426406 76.281719
|
||||
z
|
||||
" style="fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter"/>
|
||||
</g>
|
||||
<g id="line2d_34">
|
||||
<path d="M 409.026406 56.359219
|
||||
L 417.026406 56.359219
|
||||
L 425.026406 56.359219
|
||||
" style="fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<g>
|
||||
<use xlink:href="#m9b4cc9d8d2" x="417.026406" y="56.359219" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_36">
|
||||
<text style="font-size: 8px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="431.426406" y="59.159219" transform="rotate(-0 431.426406 59.159219)">q_to_k</text>
|
||||
</g>
|
||||
<g id="line2d_35">
|
||||
<path d="M 409.026406 68.359844
|
||||
L 417.026406 68.359844
|
||||
L 425.026406 68.359844
|
||||
" style="fill: none; stroke: #ff7f0e; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<g>
|
||||
<use xlink:href="#m556f16804f" x="417.026406" y="68.359844" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_37">
|
||||
<text style="font-size: 8px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="431.426406" y="71.159844" transform="rotate(-0 431.426406 71.159844)">k_to_q</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_38">
|
||||
<text style="font-size: 12px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="356.024063" y="16.318125" transform="rotate(-0 356.024063 16.318125)">Supplement: algebraic reparameterization, separate from learned-function repetition</text>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="p0542a2a98b">
|
||||
<rect x="50.466406" y="45.880469" width="303.397656" height="201.437187"/>
|
||||
</clipPath>
|
||||
<clipPath id="p601cd532af">
|
||||
<rect x="401.826406" y="45.880469" width="303.397656" height="201.437187"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 79 KiB |
@@ -0,0 +1,467 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="712.218437pt" height="280.996571pt" viewBox="0 0 712.218437 280.996571" xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||
<metadata>
|
||||
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
<cc:Work>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:date>2026-11-09T14:10:51.395327</dc:date>
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Matplotlib v3.11.2, https://matplotlib.org/</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs>
|
||||
<style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style>
|
||||
</defs>
|
||||
<g id="figure_1">
|
||||
<g id="patch_1">
|
||||
<path d="M 0 280.996571
|
||||
L 712.218437 280.996571
|
||||
L 712.218437 0
|
||||
L 0 0
|
||||
z
|
||||
" style="fill: #ffffff"/>
|
||||
</g>
|
||||
<g id="axes_1">
|
||||
<g id="patch_2">
|
||||
<path d="M 51.700781 195.511975
|
||||
L 705.018437 195.511975
|
||||
L 705.018437 37.922578
|
||||
L 51.700781 37.922578
|
||||
z
|
||||
" style="fill: #ffffff"/>
|
||||
</g>
|
||||
<g id="patch_3">
|
||||
<path d="M 81.397038 76335.575007
|
||||
L 125.391493 76335.575007
|
||||
L 125.391493 64.33392
|
||||
L 81.397038 64.33392
|
||||
z
|
||||
" clip-path="url(#pf9e7526e4c)" style="fill: #9e9e9e"/>
|
||||
</g>
|
||||
<g id="patch_4">
|
||||
<path d="M 136.390107 76335.575007
|
||||
L 180.384562 76335.575007
|
||||
L 180.384562 45.085733
|
||||
L 136.390107 45.085733
|
||||
z
|
||||
" clip-path="url(#pf9e7526e4c)" style="fill: #9e9e9e"/>
|
||||
</g>
|
||||
<g id="patch_5">
|
||||
<path d="M 191.383176 76335.575007
|
||||
L 235.377631 76335.575007
|
||||
L 235.377631 45.525425
|
||||
L 191.383176 45.525425
|
||||
z
|
||||
" clip-path="url(#pf9e7526e4c)" style="fill: #9e9e9e"/>
|
||||
</g>
|
||||
<g id="patch_6">
|
||||
<path d="M 246.376244 76335.575007
|
||||
L 290.370699 76335.575007
|
||||
L 290.370699 76.171564
|
||||
L 246.376244 76.171564
|
||||
z
|
||||
" clip-path="url(#pf9e7526e4c)" style="fill: #9e9e9e"/>
|
||||
</g>
|
||||
<g id="patch_7">
|
||||
<path d="M 301.369313 76335.575007
|
||||
L 345.363768 76335.575007
|
||||
L 345.363768 76.722901
|
||||
L 301.369313 76.722901
|
||||
z
|
||||
" clip-path="url(#pf9e7526e4c)" style="fill: #9e9e9e"/>
|
||||
</g>
|
||||
<g id="patch_8">
|
||||
<path d="M 356.362382 76335.575007
|
||||
L 400.356837 76335.575007
|
||||
L 400.356837 136.725903
|
||||
L 356.362382 136.725903
|
||||
z
|
||||
" clip-path="url(#pf9e7526e4c)" style="fill: #9e9e9e"/>
|
||||
</g>
|
||||
<g id="patch_9">
|
||||
<path d="M 411.355451 76335.575007
|
||||
L 455.349906 76335.575007
|
||||
L 455.349906 141.06981
|
||||
L 411.355451 141.06981
|
||||
z
|
||||
" clip-path="url(#pf9e7526e4c)" style="fill: #9e9e9e"/>
|
||||
</g>
|
||||
<g id="patch_10">
|
||||
<path d="M 466.348519 76335.575007
|
||||
L 510.342974 76335.575007
|
||||
L 510.342974 140.370183
|
||||
L 466.348519 140.370183
|
||||
z
|
||||
" clip-path="url(#pf9e7526e4c)" style="fill: #9e9e9e"/>
|
||||
</g>
|
||||
<g id="patch_11">
|
||||
<path d="M 521.341588 76335.575007
|
||||
L 565.336043 76335.575007
|
||||
L 565.336043 147.505598
|
||||
L 521.341588 147.505598
|
||||
z
|
||||
" clip-path="url(#pf9e7526e4c)" style="fill: #9e9e9e"/>
|
||||
</g>
|
||||
<g id="patch_12">
|
||||
<path d="M 576.334657 76335.575007
|
||||
L 620.329112 76335.575007
|
||||
L 620.329112 123.343194
|
||||
L 576.334657 123.343194
|
||||
z
|
||||
" clip-path="url(#pf9e7526e4c)" style="fill: #9e9e9e"/>
|
||||
</g>
|
||||
<g id="patch_13">
|
||||
<path d="M 631.327725 76335.575007
|
||||
L 675.32218 76335.575007
|
||||
L 675.32218 109.03712
|
||||
L 631.327725 109.03712
|
||||
z
|
||||
" clip-path="url(#pf9e7526e4c)" style="fill: #9e9e9e"/>
|
||||
</g>
|
||||
<g id="matplotlib.axis_1">
|
||||
<g id="xtick_1">
|
||||
<g id="line2d_1">
|
||||
<defs>
|
||||
<path id="mc7fdb9fc78" d="M 0 0
|
||||
L 0 3.5
|
||||
" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</defs>
|
||||
<g>
|
||||
<use xlink:href="#mc7fdb9fc78" x="103.394266" y="195.511975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_1">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(71.267864 238.312018) rotate(-45)">attn_3_7</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_2">
|
||||
<g id="line2d_2">
|
||||
<g>
|
||||
<use xlink:href="#mc7fdb9fc78" x="158.387335" y="195.511975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_2">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(117.262999 247.309952) rotate(-45)">attn_11_15</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_3">
|
||||
<g id="line2d_3">
|
||||
<g>
|
||||
<use xlink:href="#mc7fdb9fc78" x="213.380403" y="195.511975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_3">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(172.256067 247.309952) rotate(-45)">attn_19_23</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_4">
|
||||
<g id="line2d_4">
|
||||
<g>
|
||||
<use xlink:href="#mc7fdb9fc78" x="268.373472" y="195.511975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_4">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(237.264641 237.295) rotate(-45)">mlp_5_6</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_5">
|
||||
<g id="line2d_5">
|
||||
<g>
|
||||
<use xlink:href="#mc7fdb9fc78" x="323.366541" y="195.511975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_5">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(283.259775 246.292933) rotate(-45)">mlp_20_21</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_6">
|
||||
<g id="line2d_6">
|
||||
<g>
|
||||
<use xlink:href="#mc7fdb9fc78" x="378.359609" y="195.511975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_6">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(338.028559 246.517219) rotate(-45)">qk_norm_3</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_7">
|
||||
<g id="line2d_7">
|
||||
<g>
|
||||
<use xlink:href="#mc7fdb9fc78" x="433.352678" y="195.511975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_7">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(393.021627 246.517219) rotate(-45)">qk_norm_7</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_8">
|
||||
<g id="line2d_8">
|
||||
<g>
|
||||
<use xlink:href="#mc7fdb9fc78" x="488.345747" y="195.511975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_8">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(443.515729 251.016186) rotate(-45)">qk_norm_11</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_9">
|
||||
<g id="line2d_9">
|
||||
<g>
|
||||
<use xlink:href="#mc7fdb9fc78" x="543.338815" y="195.511975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_9">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(498.508798 251.016186) rotate(-45)">qk_norm_15</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_10">
|
||||
<g id="line2d_10">
|
||||
<g>
|
||||
<use xlink:href="#mc7fdb9fc78" x="598.331884" y="195.511975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_10">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(553.501867 251.016186) rotate(-45)">qk_norm_19</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_11">
|
||||
<g id="line2d_11">
|
||||
<g>
|
||||
<use xlink:href="#mc7fdb9fc78" x="653.324953" y="195.511975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_11">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(608.494935 251.016186) rotate(-45)">qk_norm_23</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="matplotlib.axis_2">
|
||||
<g id="ytick_1">
|
||||
<g id="line2d_12">
|
||||
<defs>
|
||||
<path id="mdcab3d4c70" d="M 0 0
|
||||
L -3.5 0
|
||||
" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</defs>
|
||||
<g>
|
||||
<use xlink:href="#mdcab3d4c70" x="51.700781" y="165.39636" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_12">
|
||||
<!-- $\mathdefault{10^{-1}}$ -->
|
||||
<g transform="translate(21.200781 170.04636)">
|
||||
<text>
|
||||
<tspan x="0" y="-0.762187" style="font-size: 10px; font-family: 'DejaVu Sans'">1</tspan>
|
||||
<tspan x="6.362305" y="-0.762187" style="font-size: 10px; font-family: 'DejaVu Sans'">0</tspan>
|
||||
<tspan x="12.820312" y="-4.892187" style="font-size: 7px; font-family: 'DejaVu Sans'">−</tspan>
|
||||
<tspan x="18.685547" y="-4.892187" style="font-size: 7px; font-family: 'DejaVu Sans'">1</tspan>
|
||||
</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_2">
|
||||
<g id="line2d_13">
|
||||
<g>
|
||||
<use xlink:href="#mdcab3d4c70" x="51.700781" y="89.149935" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_13">
|
||||
<!-- $\mathdefault{10^{0}}$ -->
|
||||
<g transform="translate(27.100781 93.849935)">
|
||||
<text>
|
||||
<tspan x="0" y="-0.674688" style="font-size: 10px; font-family: 'DejaVu Sans'">1</tspan>
|
||||
<tspan x="6.362305" y="-0.674688" style="font-size: 10px; font-family: 'DejaVu Sans'">0</tspan>
|
||||
<tspan x="12.820312" y="-4.804688" style="font-size: 7px; font-family: 'DejaVu Sans'">0</tspan>
|
||||
</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_3">
|
||||
<g id="line2d_14">
|
||||
<defs>
|
||||
<path id="md42a30ea1c" d="M 0 0
|
||||
L -2 0
|
||||
" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</defs>
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="188.348821" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_4">
|
||||
<g id="line2d_15">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="182.311534" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_5">
|
||||
<g id="line2d_16">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="177.20708" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_6">
|
||||
<g id="line2d_17">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="172.785402" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_7">
|
||||
<g id="line2d_18">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="168.885205" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_8">
|
||||
<g id="line2d_19">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="142.443899" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_9">
|
||||
<g id="line2d_20">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="129.01757" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_10">
|
||||
<g id="line2d_21">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="119.491438" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_11">
|
||||
<g id="line2d_22">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="112.102396" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_12">
|
||||
<g id="line2d_23">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="106.065109" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_13">
|
||||
<g id="line2d_24">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="100.960655" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_14">
|
||||
<g id="line2d_25">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="96.538977" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_15">
|
||||
<g id="line2d_26">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="92.63878" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_16">
|
||||
<g id="line2d_27">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="66.197474" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_17">
|
||||
<g id="line2d_28">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="52.771145" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_18">
|
||||
<g id="line2d_29">
|
||||
<g>
|
||||
<use xlink:href="#md42a30ea1c" x="51.700781" y="43.245012" style="stroke: #000000; stroke-width: 0.6"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_14">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="14.798438" y="116.717277" transform="rotate(-90 14.798438 116.717277)">Worst calibration directional relative L2</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="line2d_30">
|
||||
<path d="M 51.700781 188.348821
|
||||
L 705.018437 188.348821
|
||||
" clip-path="url(#pf9e7526e4c)" style="fill: none; stroke-dasharray: 5.55,2.4; stroke-dashoffset: 0; stroke: #b2182b; stroke-width: 1.5"/>
|
||||
</g>
|
||||
<g id="patch_14">
|
||||
<path d="M 51.700781 195.511975
|
||||
L 51.700781 37.922578
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_15">
|
||||
<path d="M 705.018437 195.511975
|
||||
L 705.018437 37.922578
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_16">
|
||||
<path d="M 51.700781 195.511975
|
||||
L 705.018437 195.511975
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_17">
|
||||
<path d="M 51.700781 37.922578
|
||||
L 705.018437 37.922578
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="text_15">
|
||||
<text style="font-size: 12px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(226.773359 17.519297)">Fixed candidates; same-input function comparison</text>
|
||||
<text style="font-size: 12px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(254.193359 31.922578)">4 calibration texts, 32 tokens; no training</text>
|
||||
</g>
|
||||
<g id="legend_1">
|
||||
<g id="patch_18">
|
||||
<path d="M 57.300781 273.796571
|
||||
L 280.582031 273.796571
|
||||
Q 282.182031 273.796571 282.182031 272.196571
|
||||
L 282.182031 260.995946
|
||||
Q 282.182031 259.395946 280.582031 259.395946
|
||||
L 57.300781 259.395946
|
||||
Q 55.700781 259.395946 55.700781 260.995946
|
||||
L 55.700781 272.196571
|
||||
Q 55.700781 273.796571 57.300781 273.796571
|
||||
z
|
||||
" style="fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter"/>
|
||||
</g>
|
||||
<g id="line2d_31">
|
||||
<path d="M 58.900781 265.874696
|
||||
L 66.900781 265.874696
|
||||
L 74.900781 265.874696
|
||||
" style="fill: none; stroke-dasharray: 5.55,2.4; stroke-dashoffset: 0; stroke: #b2182b; stroke-width: 1.5"/>
|
||||
</g>
|
||||
<g id="text_16">
|
||||
<text style="font-size: 8px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="81.300781" y="268.674696" transform="rotate(-0 81.300781 268.674696)">Relative L2 screen = 0.05; other gates also apply</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="pf9e7526e4c">
|
||||
<rect x="51.700781" y="37.922578" width="653.317656" height="157.589397"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 104 KiB |
@@ -0,0 +1,388 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="640.424062pt" height="312.347793pt" viewBox="0 0 640.424062 312.347793" xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||
<metadata>
|
||||
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
<cc:Work>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:date>2026-11-09T14:10:55.472730</dc:date>
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Matplotlib v3.11.2, https://matplotlib.org/</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs>
|
||||
<style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style>
|
||||
</defs>
|
||||
<g id="figure_1">
|
||||
<g id="patch_1">
|
||||
<path d="M 0 312.347793
|
||||
L 640.424062 312.347793
|
||||
L 640.424062 0
|
||||
L 0 0
|
||||
z
|
||||
" style="fill: #ffffff"/>
|
||||
</g>
|
||||
<g id="axes_1">
|
||||
<g id="patch_2">
|
||||
<path d="M 50.466406 208.18075
|
||||
L 633.224062 208.18075
|
||||
L 633.224062 37.922578
|
||||
L 50.466406 37.922578
|
||||
z
|
||||
" style="fill: #ffffff"/>
|
||||
</g>
|
||||
<g id="matplotlib.axis_1">
|
||||
<g id="xtick_1">
|
||||
<g id="line2d_1">
|
||||
<defs>
|
||||
<path id="mb7bbc15d82" d="M 0 0
|
||||
L 0 3.5
|
||||
" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</defs>
|
||||
<g>
|
||||
<use xlink:href="#mb7bbc15d82" x="76.955391" y="208.18075" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_1">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(41.486676 241.545565) rotate(-30)">cal-zh-1</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_2">
|
||||
<g id="line2d_2">
|
||||
<g>
|
||||
<use xlink:href="#mb7bbc15d82" x="152.638203" y="208.18075" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_2">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(117.169489 241.545565) rotate(-30)">cal-zh-2</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_3">
|
||||
<g id="line2d_3">
|
||||
<g>
|
||||
<use xlink:href="#mb7bbc15d82" x="228.321016" y="208.18075" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_3">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(192.068819 241.997909) rotate(-30)">cal-en-1</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_4">
|
||||
<g id="line2d_4">
|
||||
<g>
|
||||
<use xlink:href="#mb7bbc15d82" x="304.003828" y="208.18075" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_4">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(267.751631 241.997909) rotate(-30)">cal-en-2</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_5">
|
||||
<g id="line2d_5">
|
||||
<g>
|
||||
<use xlink:href="#mb7bbc15d82" x="379.686641" y="208.18075" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_5">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(340.062357 243.944784) rotate(-30)">test-zh-1</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_6">
|
||||
<g id="line2d_6">
|
||||
<g>
|
||||
<use xlink:href="#mb7bbc15d82" x="455.369453" y="208.18075" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_6">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(415.74517 243.944784) rotate(-30)">test-zh-2</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_7">
|
||||
<g id="line2d_7">
|
||||
<g>
|
||||
<use xlink:href="#mb7bbc15d82" x="531.052266" y="208.18075" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_7">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(490.6445 244.396451) rotate(-30)">test-en-1</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_8">
|
||||
<g id="line2d_8">
|
||||
<g>
|
||||
<use xlink:href="#mb7bbc15d82" x="606.735078" y="208.18075" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_8">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(566.327312 244.396451) rotate(-30)">test-en-2</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="matplotlib.axis_2">
|
||||
<g id="ytick_1">
|
||||
<g id="line2d_9">
|
||||
<defs>
|
||||
<path id="ma0713fe695" d="M 0 0
|
||||
L -3.5 0
|
||||
" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</defs>
|
||||
<g>
|
||||
<use xlink:href="#ma0713fe695" x="50.466406" y="204.137497" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_9">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="207.936325" transform="rotate(-0 43.466406 207.936325)">0.04</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_2">
|
||||
<g id="line2d_10">
|
||||
<g>
|
||||
<use xlink:href="#ma0713fe695" x="50.466406" y="182.54738" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_10">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="186.346208" transform="rotate(-0 43.466406 186.346208)">0.05</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_3">
|
||||
<g id="line2d_11">
|
||||
<g>
|
||||
<use xlink:href="#ma0713fe695" x="50.466406" y="160.957263" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_11">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="164.756091" transform="rotate(-0 43.466406 164.756091)">0.06</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_4">
|
||||
<g id="line2d_12">
|
||||
<g>
|
||||
<use xlink:href="#ma0713fe695" x="50.466406" y="139.367146" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_12">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="143.165974" transform="rotate(-0 43.466406 143.165974)">0.07</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_5">
|
||||
<g id="line2d_13">
|
||||
<g>
|
||||
<use xlink:href="#ma0713fe695" x="50.466406" y="117.777029" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_13">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="121.575857" transform="rotate(-0 43.466406 121.575857)">0.08</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_6">
|
||||
<g id="line2d_14">
|
||||
<g>
|
||||
<use xlink:href="#ma0713fe695" x="50.466406" y="96.186911" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_14">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="99.98574" transform="rotate(-0 43.466406 99.98574)">0.09</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_7">
|
||||
<g id="line2d_15">
|
||||
<g>
|
||||
<use xlink:href="#ma0713fe695" x="50.466406" y="74.596794" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_15">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="78.395623" transform="rotate(-0 43.466406 78.395623)">0.10</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_8">
|
||||
<g id="line2d_16">
|
||||
<g>
|
||||
<use xlink:href="#ma0713fe695" x="50.466406" y="53.006677" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_16">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="43.466406" y="56.805505" transform="rotate(-0 43.466406 56.805505)">0.11</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_17">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="14.798438" y="123.051664" transform="rotate(-90 14.798438 123.051664)">Worst of two directional relative L2 errors</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="line2d_17">
|
||||
<path d="M 76.955391 197.451805
|
||||
L 152.638203 192.877368
|
||||
L 228.321016 193.610655
|
||||
L 304.003828 199.099794
|
||||
L 379.686641 196.376861
|
||||
L 455.369453 192.726888
|
||||
L 531.052266 194.835109
|
||||
L 606.735078 198.558148
|
||||
" clip-path="url(#pc5e8d93515)" style="fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<defs>
|
||||
<path id="m8708773af9" d="M 0 3
|
||||
C 0.795609 3 1.55874 2.683901 2.12132 2.12132
|
||||
C 2.683901 1.55874 3 0.795609 3 0
|
||||
C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132
|
||||
C 1.55874 -2.683901 0.795609 -3 0 -3
|
||||
C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132
|
||||
C -2.683901 -1.55874 -3 -0.795609 -3 0
|
||||
C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132
|
||||
C -1.55874 2.683901 -0.795609 3 0 3
|
||||
z
|
||||
" style="stroke: #1f77b4"/>
|
||||
</defs>
|
||||
<g clip-path="url(#pc5e8d93515)">
|
||||
<use xlink:href="#m8708773af9" x="76.955391" y="197.451805" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m8708773af9" x="152.638203" y="192.877368" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m8708773af9" x="228.321016" y="193.610655" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m8708773af9" x="304.003828" y="199.099794" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m8708773af9" x="379.686641" y="196.376861" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m8708773af9" x="455.369453" y="192.726888" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m8708773af9" x="531.052266" y="194.835109" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#m8708773af9" x="606.735078" y="198.558148" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="line2d_18">
|
||||
<path d="M 76.955391 198.934893
|
||||
L 152.638203 194.123521
|
||||
L 228.321016 195.5305
|
||||
L 304.003828 200.441742
|
||||
L 379.686641 197.894474
|
||||
L 455.369453 194.413382
|
||||
L 531.052266 196.725517
|
||||
L 606.735078 199.872446
|
||||
" clip-path="url(#pc5e8d93515)" style="fill: none; stroke: #ff7f0e; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<defs>
|
||||
<path id="m5a845d07a0" d="M 0 3
|
||||
C 0.795609 3 1.55874 2.683901 2.12132 2.12132
|
||||
C 2.683901 1.55874 3 0.795609 3 0
|
||||
C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132
|
||||
C 1.55874 -2.683901 0.795609 -3 0 -3
|
||||
C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132
|
||||
C -2.683901 -1.55874 -3 -0.795609 -3 0
|
||||
C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132
|
||||
C -1.55874 2.683901 -0.795609 3 0 3
|
||||
z
|
||||
" style="stroke: #ff7f0e"/>
|
||||
</defs>
|
||||
<g clip-path="url(#pc5e8d93515)">
|
||||
<use xlink:href="#m5a845d07a0" x="76.955391" y="198.934893" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m5a845d07a0" x="152.638203" y="194.123521" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m5a845d07a0" x="228.321016" y="195.5305" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m5a845d07a0" x="304.003828" y="200.441742" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m5a845d07a0" x="379.686641" y="197.894474" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m5a845d07a0" x="455.369453" y="194.413382" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m5a845d07a0" x="531.052266" y="196.725517" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m5a845d07a0" x="606.735078" y="199.872446" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="line2d_19">
|
||||
<path d="M 50.466406 182.54738
|
||||
L 633.224062 182.54738
|
||||
" clip-path="url(#pc5e8d93515)" style="fill: none; stroke-dasharray: 5.55,2.4; stroke-dashoffset: 0; stroke: #b2182b; stroke-width: 1.5"/>
|
||||
</g>
|
||||
<g id="line2d_20">
|
||||
<path d="M 50.466406 45.661586
|
||||
L 633.224062 45.661586
|
||||
" clip-path="url(#pc5e8d93515)" style="fill: none; stroke-dasharray: 1.5,2.475; stroke-dashoffset: 0; stroke: #6a51a3; stroke-width: 1.5"/>
|
||||
</g>
|
||||
<g id="line2d_21">
|
||||
<path d="M 341.845234 208.18075
|
||||
L 341.845234 37.922578
|
||||
" clip-path="url(#pc5e8d93515)" style="fill: none; stroke: #808080; stroke-width: 0.8; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_3">
|
||||
<path d="M 50.466406 208.18075
|
||||
L 50.466406 37.922578
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_4">
|
||||
<path d="M 633.224062 208.18075
|
||||
L 633.224062 37.922578
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_5">
|
||||
<path d="M 50.466406 208.18075
|
||||
L 633.224063 208.18075
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_6">
|
||||
<path d="M 50.466406 37.922578
|
||||
L 633.224063 37.922578
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="text_18">
|
||||
<text style="font-size: 12px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(126.937422 17.519297)">Learned input RMSNorm at layer indices 12/13: same-input comparison</text>
|
||||
<text style="font-size: 12px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif" transform="translate(137.227422 31.922578)">Calibration (left) / independent heldout texts (right), 32 tokens each</text>
|
||||
</g>
|
||||
<g id="legend_1">
|
||||
<g id="patch_7">
|
||||
<path d="M 56.066406 305.147793
|
||||
L 211.338906 305.147793
|
||||
Q 212.938906 305.147793 212.938906 303.547793
|
||||
L 212.938906 256.345293
|
||||
Q 212.938906 254.745293 211.338906 254.745293
|
||||
L 56.066406 254.745293
|
||||
Q 54.466406 254.745293 54.466406 256.345293
|
||||
L 54.466406 303.547793
|
||||
Q 54.466406 305.147793 56.066406 305.147793
|
||||
z
|
||||
" style="fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter"/>
|
||||
</g>
|
||||
<g id="line2d_22">
|
||||
<path d="M 57.666406 261.224043
|
||||
L 65.666406 261.224043
|
||||
L 73.666406 261.224043
|
||||
" style="fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<g>
|
||||
<use xlink:href="#m8708773af9" x="65.666406" y="261.224043" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_19">
|
||||
<text style="font-size: 8px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="80.066406" y="264.024043" transform="rotate(-0 80.066406 264.024043)">Input captured at layer 12</text>
|
||||
</g>
|
||||
<g id="line2d_23">
|
||||
<path d="M 57.666406 273.224668
|
||||
L 65.666406 273.224668
|
||||
L 73.666406 273.224668
|
||||
" style="fill: none; stroke: #ff7f0e; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<g>
|
||||
<use xlink:href="#m5a845d07a0" x="65.666406" y="273.224668" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_20">
|
||||
<text style="font-size: 8px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="80.066406" y="276.024668" transform="rotate(-0 80.066406 276.024668)">Input captured at layer 13</text>
|
||||
</g>
|
||||
<g id="line2d_24">
|
||||
<path d="M 57.666406 285.225293
|
||||
L 65.666406 285.225293
|
||||
L 73.666406 285.225293
|
||||
" style="fill: none; stroke-dasharray: 5.55,2.4; stroke-dashoffset: 0; stroke: #b2182b; stroke-width: 1.5"/>
|
||||
</g>
|
||||
<g id="text_21">
|
||||
<text style="font-size: 8px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="80.066406" y="288.025293" transform="rotate(-0 80.066406 288.025293)">Heldout empirical screen = 0.05</text>
|
||||
</g>
|
||||
<g id="line2d_25">
|
||||
<path d="M 57.666406 297.225918
|
||||
L 65.666406 297.225918
|
||||
L 73.666406 297.225918
|
||||
" style="fill: none; stroke-dasharray: 1.5,2.475; stroke-dashoffset: 0; stroke: #6a51a3; stroke-width: 1.5"/>
|
||||
</g>
|
||||
<g id="text_22">
|
||||
<text style="font-size: 8px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="80.066406" y="300.025918" transform="rotate(-0 80.066406 300.025918)">Proven uniform all-input bound</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="pc5e8d93515">
|
||||
<rect x="50.466406" y="37.922578" width="582.757656" height="170.258172"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 100 KiB |
@@ -0,0 +1,286 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="567.92875pt" height="308.816598pt" viewBox="0 0 567.92875 308.816598" xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||
<metadata>
|
||||
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
<cc:Work>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:date>2026-11-09T14:10:58.596152</dc:date>
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Matplotlib v3.11.2, https://matplotlib.org/</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs>
|
||||
<style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style>
|
||||
</defs>
|
||||
<g id="figure_1">
|
||||
<g id="patch_1">
|
||||
<path d="M 0 308.816598
|
||||
L 567.92875 308.816598
|
||||
L 567.92875 0
|
||||
L 0 0
|
||||
z
|
||||
" style="fill: #ffffff"/>
|
||||
</g>
|
||||
<g id="axes_1">
|
||||
<g id="patch_2">
|
||||
<path d="M 71.571094 233.247975
|
||||
L 560.72875 233.247975
|
||||
L 560.72875 22.318125
|
||||
L 71.571094 22.318125
|
||||
z
|
||||
" style="fill: #ffffff"/>
|
||||
</g>
|
||||
<g id="matplotlib.axis_1">
|
||||
<g id="xtick_1">
|
||||
<g id="line2d_1">
|
||||
<defs>
|
||||
<path id="m4de31d702a" d="M 0 0
|
||||
L 0 3.5
|
||||
" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</defs>
|
||||
<g>
|
||||
<use xlink:href="#m4de31d702a" x="93.805533" y="233.247975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_1">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="93.805533" y="247.846412" transform="rotate(-0 93.805533 247.846412)">zh1</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_2">
|
||||
<g id="line2d_2">
|
||||
<g>
|
||||
<use xlink:href="#m4de31d702a" x="242.035125" y="233.247975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_2">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="242.035125" y="247.846412" transform="rotate(-0 242.035125 247.846412)">zh2</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_3">
|
||||
<g id="line2d_3">
|
||||
<g>
|
||||
<use xlink:href="#m4de31d702a" x="390.264718" y="233.247975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_3">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="390.264718" y="247.845631" transform="rotate(-0 390.264718 247.845631)">en1</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="xtick_4">
|
||||
<g id="line2d_4">
|
||||
<g>
|
||||
<use xlink:href="#m4de31d702a" x="538.494311" y="233.247975" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_4">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="538.494311" y="247.845631" transform="rotate(-0 538.494311 247.845631)">en2</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_5">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="316.149922" y="261.847194" transform="rotate(-0 316.149922 261.847194)">Independent heldout text (32 tokens)</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="matplotlib.axis_2">
|
||||
<g id="ytick_1">
|
||||
<g id="line2d_5">
|
||||
<defs>
|
||||
<path id="m32017c2f5a" d="M 0 0
|
||||
L -3.5 0
|
||||
" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</defs>
|
||||
<g>
|
||||
<use xlink:href="#m32017c2f5a" x="71.571094" y="231.508072" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_6">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="64.571094" y="235.3069" transform="rotate(-0 64.571094 235.3069)">−0.0015</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_2">
|
||||
<g id="line2d_6">
|
||||
<g>
|
||||
<use xlink:href="#m32017c2f5a" x="71.571094" y="192.395623" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_7">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="64.571094" y="196.194451" transform="rotate(-0 64.571094 196.194451)">−0.0010</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_3">
|
||||
<g id="line2d_7">
|
||||
<g>
|
||||
<use xlink:href="#m32017c2f5a" x="71.571094" y="153.283173" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_8">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="64.571094" y="157.082001" transform="rotate(-0 64.571094 157.082001)">−0.0005</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_4">
|
||||
<g id="line2d_8">
|
||||
<g>
|
||||
<use xlink:href="#m32017c2f5a" x="71.571094" y="114.170724" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_9">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="64.571094" y="117.969552" transform="rotate(-0 64.571094 117.969552)">0.0000</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_5">
|
||||
<g id="line2d_9">
|
||||
<g>
|
||||
<use xlink:href="#m32017c2f5a" x="71.571094" y="75.058274" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_10">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="64.571094" y="78.857102" transform="rotate(-0 64.571094 78.857102)">0.0005</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="ytick_6">
|
||||
<g id="line2d_10">
|
||||
<g>
|
||||
<use xlink:href="#m32017c2f5a" x="71.571094" y="35.945825" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_11">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: end" x="64.571094" y="39.744653" transform="rotate(-0 64.571094 39.744653)">0.0010</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_12">
|
||||
<text style="font-size: 10px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="14.798438" y="127.78305" transform="rotate(-90 14.798438 127.78305)">Mean token NLL change (nat/token)</text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="line2d_11">
|
||||
<path d="M 93.805533 31.905845
|
||||
L 242.035125 223.660255
|
||||
L 390.264718 124.077707
|
||||
L 538.494311 66.84947
|
||||
" clip-path="url(#p78d521230c)" style="fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<defs>
|
||||
<path id="ma59ebf376b" d="M 0 3
|
||||
C 0.795609 3 1.55874 2.683901 2.12132 2.12132
|
||||
C 2.683901 1.55874 3 0.795609 3 0
|
||||
C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132
|
||||
C 1.55874 -2.683901 0.795609 -3 0 -3
|
||||
C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132
|
||||
C -2.683901 -1.55874 -3 -0.795609 -3 0
|
||||
C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132
|
||||
C -1.55874 2.683901 -0.795609 3 0 3
|
||||
z
|
||||
" style="stroke: #1f77b4"/>
|
||||
</defs>
|
||||
<g clip-path="url(#p78d521230c)">
|
||||
<use xlink:href="#ma59ebf376b" x="93.805533" y="31.905845" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#ma59ebf376b" x="242.035125" y="223.660255" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#ma59ebf376b" x="390.264718" y="124.077707" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
<use xlink:href="#ma59ebf376b" x="538.494311" y="66.84947" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="line2d_12">
|
||||
<path d="M 93.805533 45.225019
|
||||
L 242.035125 215.36524
|
||||
L 390.264718 134.743944
|
||||
L 538.494311 175.235695
|
||||
" clip-path="url(#p78d521230c)" style="fill: none; stroke: #ff7f0e; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<defs>
|
||||
<path id="m2ce5b34917" d="M 0 3
|
||||
C 0.795609 3 1.55874 2.683901 2.12132 2.12132
|
||||
C 2.683901 1.55874 3 0.795609 3 0
|
||||
C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132
|
||||
C 1.55874 -2.683901 0.795609 -3 0 -3
|
||||
C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132
|
||||
C -2.683901 -1.55874 -3 -0.795609 -3 0
|
||||
C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132
|
||||
C -1.55874 2.683901 -0.795609 3 0 3
|
||||
z
|
||||
" style="stroke: #ff7f0e"/>
|
||||
</defs>
|
||||
<g clip-path="url(#p78d521230c)">
|
||||
<use xlink:href="#m2ce5b34917" x="93.805533" y="45.225019" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m2ce5b34917" x="242.035125" y="215.36524" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m2ce5b34917" x="390.264718" y="134.743944" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
<use xlink:href="#m2ce5b34917" x="538.494311" y="175.235695" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="line2d_13">
|
||||
<path d="M 71.571094 114.170724
|
||||
L 560.72875 114.170724
|
||||
" clip-path="url(#p78d521230c)" style="fill: none; stroke: #808080; stroke-width: 0.8; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_3">
|
||||
<path d="M 71.571094 233.247975
|
||||
L 71.571094 22.318125
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_4">
|
||||
<path d="M 560.72875 233.247975
|
||||
L 560.72875 22.318125
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_5">
|
||||
<path d="M 71.571094 233.247975
|
||||
L 560.72875 233.247975
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_6">
|
||||
<path d="M 71.571094 22.318125
|
||||
L 560.72875 22.318125
|
||||
" style="fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="text_13">
|
||||
<text style="font-size: 12px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: middle" x="316.149922" y="16.318125" transform="rotate(-0 316.149922 16.318125)">Bidirectional single-site substitution of existing learned RMSNorm modules</text>
|
||||
</g>
|
||||
<g id="legend_1">
|
||||
<g id="patch_7">
|
||||
<path d="M 77.171094 301.616598
|
||||
L 257.259844 301.616598
|
||||
Q 258.859844 301.616598 258.859844 300.016598
|
||||
L 258.859844 276.815348
|
||||
Q 258.859844 275.215348 257.259844 275.215348
|
||||
L 77.171094 275.215348
|
||||
Q 75.571094 275.215348 75.571094 276.815348
|
||||
L 75.571094 300.016598
|
||||
Q 75.571094 301.616598 77.171094 301.616598
|
||||
z
|
||||
" style="fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter"/>
|
||||
</g>
|
||||
<g id="line2d_14">
|
||||
<path d="M 78.771094 281.694098
|
||||
L 86.771094 281.694098
|
||||
L 94.771094 281.694098
|
||||
" style="fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<g>
|
||||
<use xlink:href="#ma59ebf376b" x="86.771094" y="281.694098" style="fill: #1f77b4; stroke: #1f77b4"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_14">
|
||||
<text style="font-size: 8px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="101.171094" y="284.494098" transform="rotate(-0 101.171094 284.494098)">Layer 12 uses 13; mean=3.2565e-05</text>
|
||||
</g>
|
||||
<g id="line2d_15">
|
||||
<path d="M 78.771094 293.694723
|
||||
L 86.771094 293.694723
|
||||
L 94.771094 293.694723
|
||||
" style="fill: none; stroke: #ff7f0e; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
<g>
|
||||
<use xlink:href="#m2ce5b34917" x="86.771094" y="293.694723" style="fill: #ff7f0e; stroke: #ff7f0e"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_15">
|
||||
<text style="font-size: 8px; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Computer Modern Sans Serif', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', sans-serif; text-anchor: start" x="101.171094" y="296.494723" transform="rotate(-0 101.171094 296.494723)">Layer 13 uses 12; mean=-0.00036397</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="p78d521230c">
|
||||
<rect x="71.571094" y="22.318125" width="489.157656" height="210.92985"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 13 KiB |