diff --git a/crossqkv/lisa_decode.py b/crossqkv/lisa_decode.py new file mode 100644 index 0000000..73a3496 --- /dev/null +++ b/crossqkv/lisa_decode.py @@ -0,0 +1,101 @@ +"""Incremental full-attention sites for measuring LiSA's real K/V allocation. + +The scheduler supplies the earlier full-attention site's raw score row for +the same query. This file measures an attention site, excluding GDN, MLP, +embedding, and scheduler overhead. +""" +import math + +import torch + +from crossqkv.lisa_tail import TorchTail, rotate + + +class AttentionSiteCache: + def __init__(self, tail: TorchTail, layer, batch_size, capacity, adapter=None, + dtype=torch.float32): + self.tail, self.adapter = tail, adapter + self.name = f'layers.{layer}.self_attn.' + self.heads = tail.c['num_attention_heads'] + self.kv_heads = tail.c['num_key_value_heads'] + self.head_dim = tail.c['head_dim'] + self.key_dim = adapter.rank if adapter is not None else self.head_dim + self.capacity = capacity + self.next_position = 0 + self.k = torch.empty(batch_size, capacity, self.kv_heads, self.key_dim, dtype=dtype) + self.v = torch.empty(batch_size, capacity, self.kv_heads, self.head_dim, dtype=dtype) + rp = tail.c['rope_parameters'] + n = int(self.head_dim * rp['partial_rotary_factor']) + self.rotary_frequency = rp['rope_theta'] ** (-torch.arange(0, n, 2, dtype=dtype) / n) + + def reset(self): + self.next_position = 0 + + @property + def allocated_bytes(self): + return {'k': self.k.numel()*self.k.element_size(), + 'v': self.v.numel()*self.v.element_size()} + + def native_rotate(self, x, position): + angle = self.rotary_frequency * position + a, b = x[..., :2*len(angle)].chunk(2, -1) + angle = torch.cat((angle, angle)) + return torch.cat((torch.cat((a, b), -1)*angle.cos() + + torch.cat((-b, a), -1)*angle.sin(), + x[..., 2*len(self.rotary_frequency):]), -1) + + @torch.no_grad() + def prefill(self, h): + """Populate K/V from a fresh prefix without scoring its queries.""" + n = h.shape[1] + if h.shape[0] != self.k.shape[0] or n > self.capacity: + raise ValueError('Prefix does not fit the attention cache') + base, name = self.tail, self.name + if self.adapter is None: + rp = base.c['rope_parameters'] + k = base.linear(h, name+'k_proj').unflatten(-1, (self.kv_heads, self.head_dim)) + k = rotate(base.norm(k, name+'k_norm'), rp['rope_theta'], rp['partial_rotary_factor']) + else: + a = self.adapter + k = a.k_proj(h).unflatten(-1, (self.kv_heads, self.key_dim)) + k = a.rotate(k, torch.arange(n, device=h.device)[None, :]) + self.k[:, :n].copy_(k) + self.v[:, :n].copy_(base.linear(h, name+'v_proj').unflatten(-1, (self.kv_heads, self.head_dim))) + self.next_position = n + + @torch.no_grad() + def step(self, h, donor=None): + """h has shape (batch, 1, hidden). Return output and unmasked score row.""" + pos = self.next_position + if h.shape[:2] != (self.k.shape[0], 1) or pos >= self.capacity: + raise ValueError('Wrong input shape or full attention cache') + if self.adapter is not None and (donor is None or + donor.shape != (len(h), self.heads, 1, pos+1)): + raise ValueError('LiSA requires the upstream score row for its full prefix') + base = self.tail + name = self.name + if self.adapter is None: + packed = base.linear(h, name+'q_proj').unflatten(-1, (self.heads, 2*self.head_dim)) + q, gate = packed.chunk(2, -1) + k = base.linear(h, name+'k_proj').unflatten(-1, (self.kv_heads, self.head_dim)) + q = self.native_rotate(base.norm(q, name+'q_norm'), pos) + k = self.native_rotate(base.norm(k, name+'k_norm'), pos) + else: + a = self.adapter + position = torch.tensor([[pos]], device=h.device) + q = a.rotate(a.q_proj(h).unflatten(-1, (self.heads, self.key_dim)), position) + k = a.rotate(a.k_proj(h).unflatten(-1, (self.kv_heads, self.key_dim)), position) + gate = base.gate_only(h, name) + v = base.linear(h, name+'v_proj').unflatten(-1, (self.kv_heads, self.head_dim)) + self.k[:, pos:pos+1].copy_(k) + self.v[:, pos:pos+1].copy_(v) + self.next_position += 1 + groups = self.heads // self.kv_heads + keys = self.k[:, :pos+1].repeat_interleave(groups, 2) + values = self.v[:, :pos+1].repeat_interleave(groups, 2) + scores = torch.einsum('bthd,bshd->bhts', q, keys) / math.sqrt(self.key_dim) + if self.adapter is not None: + both = torch.cat((scores, donor), dim=1).permute(0, 2, 3, 1) + scores = self.adapter.fuse(both).permute(0, 3, 1, 2) + context = torch.einsum('bhts,bshd->bthd', scores.softmax(-1), values) + return base.linear((context * gate.sigmoid()).flatten(-2), name+'o_proj'), scores diff --git a/crossqkv/lisa_decode_bench.py b/crossqkv/lisa_decode_bench.py new file mode 100644 index 0000000..2348c74 --- /dev/null +++ b/crossqkv/lisa_decode_bench.py @@ -0,0 +1,130 @@ +"""Measure real K/V allocation and isolated incremental attention on Qwen.""" +import argparse +import json +import time +from statistics import median +from pathlib import Path + +import numpy as np +import torch +from torch.nn import functional as F + +from crossqkv.lisa_decode import AttentionSiteCache +from crossqkv.lisa_tail import TorchTail, weight_chunks +from crossqkv.lisa_train import LearnableSharingAttention +from functional.model import PREFIX, StreamingLM +from functional.run import write_json + + +class TracedTail(TorchTail): + def full(self, h, layer, donor, lengths, mode, recipients, keep_teacher): + self.inputs[layer] = (h, donor) + return super().full(h, layer, donor, lengths, mode, recipients, keep_teacher) + + +class ResidentSite: + """Keep one site's frozen projections resident to isolate compute latency.""" + + def __init__(self, tail, layer): + self.tail, self.c = tail, tail.c + self.name = f'layers.{layer}.self_attn.' + self.weights = {} + for k in ('q_proj', 'k_proj', 'v_proj', 'o_proj'): + t = tail.source.tensors[PREFIX + self.name + k + '.weight'] + self.weights[self.name+k] = torch.cat(list(weight_chunks(t, 0, t.shape[0]))) + w = self.weights[self.name+'q_proj'] + heads, dim = self.c['num_attention_heads'], self.c['head_dim'] + self.gate_weight = w.reshape(heads, 2*dim, -1)[:, dim:].reshape(heads*dim, -1).contiguous() + + def linear(self, h, name, start=0, end=None): + return F.linear(h, self.weights[name][start:end]) + + def gate_only(self, h, name): + if name != self.name: + raise ValueError('Resident gate called for the wrong site') + return F.linear(h, self.gate_weight).unflatten(-1, + (self.c['num_attention_heads'], self.c['head_dim'])) + + def norm(self, *args): + return self.tail.norm(*args) + + +def timed_site(groups, h, donor, n, samples=3, rounds=4): + timings = {k: [] for k in groups} + states = {} + for i in range(rounds): + order = tuple(groups) if i % 2 == 0 else tuple(reversed(groups)) + for mode in order: + cache = groups[mode] + cache.reset() + cache.prefill(h[:, :n-samples]) + for pos in range(n-samples, n): + row = donor[:, :, pos:pos+1, :pos+1].contiguous() if mode == 'lisa' else None + start = time.perf_counter() + result, attention = cache.step(h[:, pos:pos+1], row) + elapsed = time.perf_counter() - start + if i: + timings[mode].append(elapsed) + if not torch.isfinite(result).all(): + raise FloatingPointError('Invalid cached decode') + states[mode] = result, attention + return timings, states + + +def run(source, capture, checkpoint, out): + torch.set_num_threads(1) + spec = json.loads((capture/'selection.json').read_text()) + sites = spec['sites'] + source = StreamingLM(source/'weights', json.loads((source/'model_config.json').read_text())) + cfg = source.config + rope = cfg['rope_parameters'] + adap = {i: LearnableSharingAttention(cfg['hidden_size'], cfg['num_attention_heads'], + cfg['num_key_value_heads'], 40, rope['rope_theta'], rope['partial_rotary_factor'], + bias=cfg.get('attention_bias', False)) for i in sites} + tail = TracedTail(source, sites[0], adap) + tail.adapters.load_state_dict(torch.load(checkpoint, map_location='cpu', weights_only=True)) + with np.load(sorted(capture.glob('validation-*.npz'))[0], allow_pickle=False) as f: + n = int(f['lengths'][0]) + data = {k: torch.from_numpy(f[k][:1]) for k in ('residual', 'donor', 'lengths')} + data['residual'] = data['residual'][:, :n] + data['donor'] = data['donor'][:, :, :n, :n] + tail.inputs = {} + measurements = {} + with torch.no_grad(): + tail(data['residual'], data['donor'], data['lengths'], 'native', ()) + for layer in sites: + h, donor = tail.inputs[layer] + groups = {'native': AttentionSiteCache(tail, layer, 1, n), + 'lisa': AttentionSiteCache(tail, layer, 1, n, adap[layer])} + timings, reference = timed_site(groups, h, donor, n) + resident = ResidentSite(tail, layer) + resident_groups = {mode: AttentionSiteCache(resident, layer, 1, n, + adap[layer] if mode == 'lisa' else None) for mode in groups} + warm, checked = timed_site(resident_groups, h, donor, n) + for mode in groups: + for actual, expected in zip(checked[mode], reference[mode]): + torch.testing.assert_close(actual, expected, rtol=5e-5, atol=5e-5) + measurements[layer] = {'seconds_per_token': timings, + 'resident_seconds_per_token': warm, + 'resident_median_s_per_token': {k: median(v) for k,v in warm.items()}, + 'resident_matches_streamed': True, + 'allocated_bytes': {k: v.allocated_bytes for k, v in groups.items()}, + 'lisa_input_score_row_bytes': ( + cfg['num_attention_heads'] * n * h.element_size()), + 'sequence_length': n} + write_json(out, {'scope': 'isolated full-attention recipient, FP32, frozen true activations; ' + 'excludes donor generation and full-model decode', 'sites': measurements, + 'streamed_timings_include_weight_reads': True, + 'resident_timings_exclude_projection_load': True}) + + +def main(): + p = argparse.ArgumentParser(description=__doc__) + for name in ('source', 'capture', 'checkpoint', 'out'): + p.add_argument('--'+name, type=Path, required=True) + a = p.parse_args() + run(a.source, a.capture, a.checkpoint, a.out) + + +if __name__ == '__main__': + main() diff --git a/crossqkv/lisa_effect.py b/crossqkv/lisa_effect.py new file mode 100644 index 0000000..0b9766c --- /dev/null +++ b/crossqkv/lisa_effect.py @@ -0,0 +1,296 @@ +"""Train matched multi-recipient sharing adapters and evaluate the frozen test set.""" +import argparse +import hashlib +import json +import time +from pathlib import Path + +import numpy as np + +from crossqkv.core import QKVModel +from crossqkv.lisa_effect_screen import TASKS +from crossqkv.lisa_pilot import batch, scores +from functional.model import PREFIX +from functional.run import write_json + +CANDIDATES = ('linear', 'lisa', 'lisa_answer_weighted') + + +def selection(screen): + eligible = [] + for task, modes in screen.items(): + base = modes['native'] + if base['correct'] < 5: + continue + for name, sites in [('direct_23', [23]), ('direct_19_23', [19, 23])]: + row = modes[name] + if row['native_wins_lost']: + eligible.append((row['native_wins_lost'], len(sites), + base['correct']-row['correct'], task, sites)) + if not eligible: + raise ValueError('No task/schedule met the prespecified development eligibility rule') + _, _, _, task, sites = max(eligible) + return {'task': task, 'sites': sites} + + +class Capture(QKVModel): + def normalization(self, x, name): + if name == f'layers.{self.first}.input_layernorm': + self.residual = x + return super().normalization(x, name) + + def full_attention(self, h, layer, shared_p=None): + if layer != self.first - 4: + return super().full_attention(h, layer, shared_p) + part = self.parts(h, layer, heads=False) + self.donor = scores(part['q'], part['k']) + return part['output'], part['p'] + + +def capture(source, screen_dir, out, schedule): + from tokenizers import Tokenizer + + fixed_path = screen_dir/'fixed-problems.json' + fixed = json.loads(fixed_path.read_text()) + chosen = selection(json.loads((screen_dir/'screen-summary.json').read_text())) + if schedule == 'chain': + modes = json.loads((screen_dir/'screen-summary.json').read_text())[chosen['task']] + if not modes['direct_19_23']['native_wins_lost']: + raise ValueError('The development-selected task has no recorded losses under the chain') + chosen['sites'] = [19, 23] + model = Capture(source/'weights', json.loads((source/'model_config.json').read_text()), + seconds=7200) + model.first = chosen['sites'][0] + tok = Tokenizer.from_file(str(source/'tokenizer.json')) + sha = lambda path: hashlib.sha256(path.read_bytes()).hexdigest() + write_json(out/'selection.json', {**chosen, 'fixed_problems_sha256': sha(fixed_path), + 'source_sha256': {n: sha(source/n) for n in + ('manifest.json', 'model_config.json', 'tokenizer.json')}}) + for split in ('fit', 'validation', 'test'): + selected = [ex for ex in fixed[split] if ex['task'] == chosen['task']] + for start in range(0, len(selected), 4): + group = selected[start:start+4] + ids, lengths, labels = batch(tok, group) + gold = np.array([r['answer_index'] for r in group]) + ids = np.pad(ids, ((0, 0), (0, 1))) + ids[np.arange(len(group)), lengths] = np.asarray(labels)[gold] + h, _ = model.forward(ids) + pending = out/f'{split}-{start:03}.tmp.npz' + np.savez(pending, ids=ids, lengths=np.asarray(lengths)+1, labels=labels, gold=gold, + residual=model.residual, donor=model.donor, expected=h, + names=[x['id'] for x in group]) + pending.replace(out/f'{split}-{start:03}.npz') + print('capture', split, start+len(group), '/', len(selected), flush=True) + + +def train(source, cache, out, epochs, resume=False): + import torch + from torch import nn + from crossqkv.lisa_tail import TorchTail + from crossqkv.lisa_train import LearnableSharingAttention, huber_distillation, language_model_loss + from functional.model import StreamingLM + + torch.set_num_threads(1) + torch.manual_seed(415005) + spec = json.loads((cache/'selection.json').read_text()) + if any(hashlib.sha256((source/n).read_bytes()).hexdigest() != s + for n, s in spec['source_sha256'].items()): + raise ValueError('Checkpoint provenance mismatch') + expected_batches = {'fit':12, 'validation':12, 'test':32} + for split, count in expected_batches.items(): + actual = 0 + for p in cache.glob(f'{split}-*.npz'): + with np.load(p, allow_pickle=False) as b: + actual += len(b['names']) + if actual != count: + raise ValueError(f'Expected {count} {split} examples, found {actual}') + run_config = {'epochs': epochs, 'selection': spec, 'optimizer': 'AdamW', + 'lr': .0003, 'weight_decay': .1, 'answer_weight': 16., 'seed': 415005} + config_path = out/'train-protocol.json' + if resume: + if json.loads(config_path.read_text()) != run_config: + raise ValueError('Training configuration differs from the original run') + else: + write_json(config_path, run_config) + model = StreamingLM(source/'weights', json.loads((source/'model_config.json').read_text())) + sites = tuple(spec['sites']) + cfg = model.config + heads = cfg['num_attention_heads'] + rope = cfg['rope_parameters'] + t = model.tensors[PREFIX+'embed_tokens.weight'] + + def vocab(): + for start in range(0, t.shape[0], 1024): + end = min(start+1024, t.shape[0]) + yield start, torch.from_numpy(t.read(slice(start*t.shape[1], end*t.shape[1])) + .reshape(end-start, t.shape[1])) + t.evict() + + def batches(split, micro=False): + for path in sorted(cache.glob(f'{split}-*.npz')): + with np.load(path, allow_pickle=False) as f: + b = {k: torch.from_numpy(f[k]) for k in f.files if k != 'names'} + names = f['names'].tolist() + if not micro: + yield b, names + else: + for j, name in enumerate(names): + yield {k: v if k == 'labels' else v[j:j+1] for k, v in b.items()}, [name] + + def make(candidate): + torch.manual_seed(415005) + if candidate == 'linear': + blocks = {i: nn.Linear(heads, heads, bias=False) for i in sites} + for value in blocks.values(): + with torch.no_grad(): + value.weight.copy_(torch.eye(heads)) + else: + blocks = {i: LearnableSharingAttention(cfg['hidden_size'], heads, + cfg['num_key_value_heads'], 40, rope['rope_theta'], + rope['partial_rotary_factor'], bias=cfg.get('attention_bias', False)) + for i in sites} + return TorchTail(model, sites[0], blocks) + + def run(tail, b, mode, teacher=False): + return tail(b['residual'], b['donor'], b['lengths'], mode, sites, teacher) + + def score(h, b): + index = b['lengths'] - 2 + f = h[torch.arange(len(index)), index] + labels = b['labels'].tolist() + weights = np.stack([t.read(slice(i*t.shape[1], (i+1)*t.shape[1])) for i in labels]) + t.evict() + logits = f @ torch.from_numpy(weights).T + nll = torch.logsumexp(logits, -1) - logits[torch.arange(len(index)), b['gold']] + return logits, nll + + def evaluate(tail, split, mode): + rows = [] + with torch.no_grad(): + for b, names in batches(split): + h, _ = run(tail, b, mode) + if mode == 'native': + valid = torch.arange(h.shape[1])[None] < b['lengths'][:, None] + torch.testing.assert_close(h[valid], b['expected'][valid], rtol=7e-5, atol=8e-5) + logits, nll = score(h, b) + rows.extend({'id': name, 'gold': int(g), 'logits': x.tolist(), + 'pred': int(x.argmax()), 'answer_nll': float(v)} + for name, g, x, v in zip(names, b['gold'], logits, nll)) + if not rows: + raise ValueError(f'No cached rows for {split}') + return rows + + def mean_nll(rows): + return sum(r['answer_nll'] for r in rows) / len(rows) + + trace = {} + for candidate in CANDIDATES: + tail = make(candidate) + mode = 'linear' if candidate == 'linear' else 'lisa' + optim = torch.optim.AdamW(tail.parameters(), lr=.0003, weight_decay=.1) + ans_weight = 16.0 if candidate == 'lisa_answer_weighted' else 1.0 + best = float('inf') + best_weights = None + trace[candidate] = [] + last = out/f'{candidate}-resume.pt' + if resume and last.exists(): + state = torch.load(last, weights_only=True, map_location='cpu') + tail.adapters.load_state_dict(state['parameters']) + optim.load_state_dict(state['optimizer']) + trace[candidate] = state['trace'] + best = state['best'] + best_weights = state['best_parameters'] + for epoch in range(len(trace[candidate]), epochs): + loss_total = 0. + count = 0 + for b, _ in batches('fit', micro=True): + optim.zero_grad(set_to_none=True) + h, layer = run(tail, b, mode, teacher=True) + kd = torch.stack([huber_distillation(*layer[i], b['lengths']) for i in sites]).mean() + ce = None if mode == 'linear' else language_model_loss( + h, b['ids'], b['lengths'], vocab, answer_weight=ans_weight) + loss = kd if ce is None else .25 * kd + .75 * ce + loss.backward() + if any(p.grad is None or not torch.isfinite(p.grad).all() for p in tail.parameters()): + raise FloatingPointError('Invalid adapter gradients') + optim.step() + loss_total += float(loss.detach()) + count += 1 + rows = evaluate(tail, 'validation', mode) + val = mean_nll(rows) + trace[candidate].append({'epoch': epoch+1, 'fit_loss': loss_total/count, + 'validation_answer_nll': val}) + if val < best: + best = val + best_weights = {k: v.detach().clone() for k, v in tail.adapters.state_dict().items()} + pending = last.with_suffix('.tmp') + torch.save({'parameters': tail.adapters.state_dict(), 'optimizer': optim.state_dict(), + 'trace': trace[candidate], 'best': best, 'best_parameters': best_weights}, + pending) + pending.replace(last) + write_json(out/'trace.json', trace) + print(candidate, epoch+1, 'validation answer NLL', val, flush=True) + selected = out/f'{candidate}.pt' + pending = selected.with_suffix('.tmp') + torch.save(best_weights, pending) + pending.replace(selected) + + # All checkpoints are frozen before evaluating holdout. Native and direct + # go through the same path, including numerical parity with NumPy. + results = {} + empty = TorchTail(model, sites[0]) + for mode in ('native', 'direct'): + results[mode] = evaluate(empty, 'test', mode) + for name in CANDIDATES: + tail = make(name) + tail.adapters.load_state_dict(torch.load(out/f'{name}.pt', map_location='cpu', weights_only=True)) + results[name] = evaluate(tail, 'test', 'linear' if name == 'linear' else 'lisa') + write_json(out/'test-items.json', results) + + b, _ = next(batches('validation')) + b = {k: v if k == 'labels' else v[:1] for k, v in b.items()} + trained = make('lisa') + trained.adapters.load_state_dict(torch.load(out/'lisa.pt', weights_only=True)) + timing = {'native': [], 'direct': [], 'lisa': []} + with torch.no_grad(): + for turn in range(4): + modes = list(timing) + for mode in modes[turn % 3:] + modes[:turn % 3]: + t0 = time.perf_counter() + _, _ = run(trained if mode == 'lisa' else empty, b, mode) + if turn: + timing[mode].append(time.perf_counter()-t0) + tokens = int(b['lengths'][0]) + kv, d = cfg['num_key_value_heads'], cfg['head_dim'] + cache_bytes = {'scope': 'formula for one sequence, BF16 keys and score buffers', + 'native_recipient_key_bytes': len(sites)*tokens*kv*d*2, + 'lisa_recipient_key_bytes': len(sites)*tokens*kv*40*2, + 'one_shared_decode_score_row_bytes': heads*tokens*2, + 'one_full_prefill_score_matrix_bytes': heads*tokens*tokens*2} + write_json(out/'performance.json', {'scope': 'cached-prefix last layers, prefill', + 'seconds': timing, 'real_tokens': tokens, 'cache_estimate': cache_bytes}) + + +def main(): + p = argparse.ArgumentParser(description=__doc__) + p.add_argument('phase', choices=('capture', 'train')) + p.add_argument('--source', required=True, type=Path) + p.add_argument('--input', required=True, type=Path) + p.add_argument('--out', required=True, type=Path) + p.add_argument('--schedule', choices=('best','chain'), default='best') + p.add_argument('--epochs', type=int, default=2) + p.add_argument('--resume', action='store_true') + a = p.parse_args() + if a.epochs < 1: + p.error('--epochs must be positive') + if a.resume and a.phase != 'train': + p.error('--resume is for training with saved epoch checkpoints') + a.out.mkdir(exist_ok=a.resume) + if a.phase == 'capture': + capture(a.source, a.input, a.out, a.schedule) + else: + train(a.source, a.input, a.out, a.epochs, a.resume) + + +if __name__ == '__main__': + main() diff --git a/crossqkv/lisa_effect_answer_audit.py b/crossqkv/lisa_effect_answer_audit.py new file mode 100644 index 0000000..5685743 --- /dev/null +++ b/crossqkv/lisa_effect_answer_audit.py @@ -0,0 +1,115 @@ +"""Compare one vs two recipients on the same task using full-vocabulary answers.""" +import argparse +import json +from pathlib import Path + +import numpy as np +import torch +from torch.nn import functional as F + +from crossqkv.lisa_tail import TorchTail, weight_chunks +from crossqkv.lisa_train import LearnableSharingAttention +from functional.model import PREFIX, StreamingLM +from functional.run import write_json + + +def vocabulary_scores(hidden, targets, embedding): + n = len(hidden) + peak = hidden.new_full((n,), -torch.inf) + total = peak.clone() + top = torch.zeros(n, dtype=torch.int64) + true = torch.zeros_like(peak) + start = 0 + for w in weight_chunks(embedding, 0, embedding.shape[0], rows=1024): + logits = F.linear(hidden, w) + total = torch.logaddexp(total, logits.logsumexp(dim=-1)) + values, indices = logits.max(dim=-1) + top = torch.where(values > peak, indices + start, top) + peak = torch.maximum(values, peak) + local = (targets >= start) & (targets < start + len(w)) + true[local] = logits[local, targets[local]-start] + start += len(w) + return top, total-true + + +def run(source, cache, trained, out): + torch.set_num_threads(1) + spec = json.loads((cache/'selection.json').read_text()) + sites = tuple(spec['sites']) + stream = StreamingLM(source/'weights', json.loads((source/'model_config.json').read_text())) + cfg = stream.config + rp = cfg['rope_parameters'] + heads, kv = cfg['num_attention_heads'], cfg['num_key_value_heads'] + + def loaded(mode): + if mode == 'linear': + from torch import nn + + modules = {site: nn.Linear(heads, heads, bias=False) for site in sites} + else: + modules = {site: LearnableSharingAttention(cfg['hidden_size'], heads, kv, 40, + rp['rope_theta'], rp['partial_rotary_factor'], + bias=cfg.get('attention_bias', False)) for site in sites} + tail = TorchTail(stream, sites[0], modules) + tail.adapters.load_state_dict(torch.load(trained/f'{mode}.pt', weights_only=True, + map_location='cpu')) + return tail + + empty = TorchTail(stream, sites[0]) + fitted = loaded('lisa') + arms = [('native', empty, 'native', ()), + ('direct_23', empty, 'direct', (sites[-1],)), + ('lisa_23_ablation', fitted, 'lisa', (sites[-1],))] + if len(sites) > 1: + arms.extend([('direct_chain', empty, 'direct', sites), + ('lisa_chain', fitted, 'lisa', sites)]) + arms.extend([('linear', loaded('linear'), 'linear', sites), + ('lisa_answer_weighted', loaded('lisa_answer_weighted'), 'lisa', sites)]) + answers = {name: [] for name, *_ in arms} + ids, labels, options = [], [], [] + with torch.no_grad(): + for path in sorted(cache.glob('test-*.npz')): + with np.load(path, allow_pickle=False) as f: + b = {k: torch.from_numpy(f[k]) for k in f.files if k != 'names'} + ids.extend(f['names'].tolist()) + labels.append(b['labels'][b['gold']]) + options.append(b['labels'].expand(len(b['gold']), -1)) + for name, tail, mode, chosen in arms: + h, _ = tail(b['residual'], b['donor'], b['lengths'], mode, chosen) + answers[name].append(h[torch.arange(len(h)), b['lengths']-2]) + print('matched full-vocabulary audit', len(ids), flush=True) + if not ids: + raise ValueError('No captured holdout batches') + y = torch.cat(labels) + t = stream.tensors[PREFIX+'embed_tokens.weight'] + hidden = torch.cat([torch.cat(answers[k]) for k in answers]) + pred, nll = vocabulary_scores(hidden, y.repeat(len(answers)), t) + result = {} + opts = torch.cat(options) + for (name, h), p, v in zip(answers.items(), pred.split(len(y)), nll.split(len(y))): + option_w = torch.stack([torch.from_numpy(t.read(slice(i*t.shape[1], (i+1)*t.shape[1]))) + for i in opts[0].tolist()]) + if not torch.equal(opts, opts[0].expand_as(opts)): + raise ValueError('Option token IDs unexpectedly vary across items') + t.evict() + choice = opts[torch.arange(len(y)), F.linear(torch.cat(h), option_w).argmax(-1)] + result[name] = {'n': len(y), 'full_vocab_correct': int((p==y).sum()), + 'four_choice_correct': int((choice==y).sum()), + 'full_vocab_nll': float(v.mean()), + 'rows': [{'id': key, 'gold_id': int(g), 'greedy_id': int(j), + 'choice_id': int(c), 'nll': float(s)} + for key, g, j, c, s in zip(ids, y, p, choice, v)]} + write_json(out, {'single_lisa_is_ablation_of_joint_checkpoint': len(sites) > 1, + 'candidate_sites': list(sites), 'arms': result}) + + +def main(): + p = argparse.ArgumentParser(description=__doc__) + for name in ('source', 'cache', 'trained', 'out'): + p.add_argument('--'+name, type=Path, required=True) + a = p.parse_args() + run(a.source, a.cache, a.trained, a.out) + + +if __name__ == '__main__': + main() diff --git a/crossqkv/lisa_effect_audit.py b/crossqkv/lisa_effect_audit.py new file mode 100644 index 0000000..67a9cb2 --- /dev/null +++ b/crossqkv/lisa_effect_audit.py @@ -0,0 +1,98 @@ +"""Independently validate frozen test outputs and report paired capability recovery.""" +import argparse +import hashlib +import json +import math +from pathlib import Path +from statistics import median + +import numpy as np + +from functional.run import write_json + +MODES = ('native', 'direct', 'linear', 'lisa', 'lisa_answer_weighted') + + +def paired(native, direct, candidate): + damaged = native & ~direct + rescued = damaged & candidate + newly_lost = native & direct & ~candidate + candidate_only = ~direct & candidate + direct_only = direct & ~candidate + delta = candidate.astype(int) - direct.astype(int) + rng = np.random.default_rng(415006) + draw = rng.integers(0, len(delta), size=(10000, len(delta))) + ci = np.quantile(delta[draw].mean(1), [.025, .975]) + a, b = int(candidate_only.sum()), int(direct_only.sum()) + k = a + b + p = min(1., 2. * sum(math.comb(k, i) for i in range(min(a, b)+1)) / 2**k) + return {'native_correct_lost_by_direct': int(damaged.sum()), 'rescued': int(rescued.sum()), + 'newly_lost_among_native_and_direct_correct': int(newly_lost.sum()), + 'candidate_correct_direct_wrong': a, 'direct_correct_candidate_wrong': b, + 'accuracy_delta_vs_direct': float(delta.mean()), + 'paired_prompt_bootstrap_95': ci.tolist(), 'mcnemar_exact_p': p} + + +def audit(fixed, selection, items, perf=None, decode=None): + spec = json.loads(selection.read_text()) + if hashlib.sha256(fixed.read_bytes()).hexdigest() != spec['fixed_problems_sha256']: + raise ValueError('Fixed problems provenance mismatch') + problem = json.loads(fixed.read_text()) + task = spec['task'] + expected = [(r['id'], r['answer_index']) for r in problem['test'] if r['task'] == task] + data = json.loads(items.read_text()) + if set(data) != set(MODES) or not expected: + raise ValueError('Unexpected test arms or empty selected split') + correct = {} + mean_losses = {} + for mode, rows in data.items(): + if [(r['id'], r['gold']) for r in rows] != expected: + raise ValueError(f'{mode} result does not match the locked challenge') + logits = np.array([r['logits'] for r in rows]) + gold = np.array([r['gold'] for r in rows]) + pred = np.array([r['pred'] for r in rows]) + nll = np.logaddexp.reduce(logits, 1) - logits[np.arange(len(rows)), gold] + if (logits.shape != (len(rows), 4) or not np.isfinite(logits).all() + or not np.array_equal(logits.argmax(1), pred)): + raise ValueError(f'Invalid choice scores for {mode}') + np.testing.assert_allclose(nll, [row['answer_nll'] for row in rows], atol=3e-6, rtol=2e-6) + correct[mode], mean_losses[mode] = pred == gold, float(nll.mean()) + metrics = {'selected_task': task, 'sites': spec['sites'], 'n': len(expected), + 'arms': {mode: {'correct': int(correct[mode].sum()), 'answer_nll_4': mean_losses[mode], + **paired(correct['native'], correct['direct'], correct[mode])} + for mode in MODES}} + if perf: + measured = json.loads(perf.read_text()) + med = {k: median(v) for k,v in measured['seconds'].items()} + metrics['prefill'] = {'scope': measured['scope'], 'median_s': med, + 'lisa_median_ratio_to_native': med['lisa']/med['native']} + if decode: + measured = json.loads(decode.read_text()) + metrics['decode'] = {'scope': measured['scope'], 'sites': {}} + for layer, raw in measured['sites'].items(): + times = {k: median(v) for k,v in raw['seconds_per_token'].items()} + mem = raw['allocated_bytes'] + native = mem['native']['k'] + mem['native']['v'] + lisa = mem['lisa']['k'] + mem['lisa']['v'] + nn = raw['lisa_input_score_row_bytes'] + assert mem['lisa']['v'] == mem['native']['v'] and mem['lisa']['k'] < mem['native']['k'] + metrics['decode']['sites'][layer] = { + 'median_s_per_token': times, 'measured_kv_bytes': {'native': native, 'lisa': lisa}, + 'lisa_upstream_score_row_bytes': nn, 'recipient_bytes_delta': lisa+nn-native, + } + return metrics + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + for name in ('fixed', 'selection', 'items', 'out'): + parser.add_argument('--'+name, type=Path, required=True) + parser.add_argument('--perf', type=Path) + parser.add_argument('--decode', type=Path) + a = parser.parse_args() + report = audit(a.fixed, a.selection, a.items, a.perf, a.decode) + write_json(a.out, report) + + +if __name__ == '__main__': + main() diff --git a/crossqkv/lisa_effect_screen.py b/crossqkv/lisa_effect_screen.py new file mode 100644 index 0000000..9ef9912 --- /dev/null +++ b/crossqkv/lisa_effect_screen.py @@ -0,0 +1,183 @@ +"""Screen task difficulty and joint sharing schedules without opening test results.""" +import argparse +import json +import random +from pathlib import Path + +import numpy as np +from tokenizers import Tokenizer + +from crossqkv.core import QKVModel +from crossqkv.lisa_pilot import batch +from functional.model import PREFIX +from functional.run import write_json +from pilot.tensors import decode + +MODES = ('native', 'direct_23', 'direct_19_23') +SITES = (15, 19, 23) +TASKS = ('lookup8', 'lookup16', 'latest8', 'arithmetic') +SPLIT_SEEDS = {'screen': 415001, 'fit': 415002, 'validation': 415003, 'test': 415004} +WORDS = ('amber birch cedar dune elm fern grove heath iris jade kelp larch ' + 'maple nettle olive pine quartz reed slate thyme umber vine willow yew').split() + + +def problems(split, per_task): + rng = random.Random(SPLIT_SEEDS[split]) + rows = [] + for task in TASKS: + answers = [i % 4 for i in range(per_task)] + rng.shuffle(answers) + for i, answer in enumerate(answers): + if task == 'arithmetic': + a, b = rng.sample(range(12, 99), 2) + target = a + b + distractors = [target - 10, target + 10, target + rng.choice((-1, 1))] + question = f'What is {a} + {b}?' + else: + size = 16 if task == 'lookup16' else 8 + keys, vals = rng.sample(WORDS, size), rng.sample(range(10, 100), size) + if task == 'latest8': + first = rng.randrange(size - 1) + last = rng.randrange(first + 1, size) + keys[last] = keys[first] + target = vals[last] + remaining = [v for j, v in enumerate(vals) if j not in (first, last)] + distractors = [vals[first], *rng.sample(remaining, 2)] + key = keys[first] + else: + match = rng.randrange(size) + target, key = vals[match], keys[match] + distractors = rng.sample([v for v in vals if v != target], 3) + table = '\n'.join(f'{k}: {v}' for k, v in zip(keys, vals)) + request = 'latest value' if task == 'latest8' else 'value' + order = ' (oldest first)' if task == 'latest8' else '' + question = f'Use the lookup table{order}.\n{table}\nWhich option is the {request} for {key}?' + rng.shuffle(distractors) + distractors.insert(answer, target) + options = '\n'.join(f'{j+1}. {v}' for j, v in enumerate(distractors)) + prompt = f'{question}\n{options}\nAnswer with only the option number.\nAnswer:' + rows.append({'id': f'{split}-{task}-{i:03}', 'task': task, + 'prompt': prompt, 'answer_index': answer}) + return rows + + +class ScreeningModel(QKVModel): + def normalization(self, h, name): + if getattr(self, 'capture_prefix', False) and name == 'layers.19.input_layernorm': + self.residual_19 = h + return super().normalization(h, name) + + def full_attention(self, h, layer, shared_p=None): + if layer not in SITES: + return super().full_attention(h, layer, shared_p) + own = self.parts(h, layer, heads=False) + p = own['p'].copy() + if getattr(self, 'capture_prefix', False): + if layer == 15: + self.donor_15 = p + return own['output'], p + if layer == 19: + p[self.chain] = self.prior[self.chain] + elif layer == 23: + p[self.shared] = self.prior[self.shared] + self.prior = p + repeats = self.config['num_attention_heads'] // self.config['num_key_value_heads'] + v = np.repeat(own['v'], repeats, axis=2) + out = self.project(np.einsum('bhts,bshd->bthd', p, v), own['gate'], layer) + return out, p + + +def evaluate(model, tokenizer, examples): + ids, lengths, labels = batch(tokenizer, examples) + n = len(examples) + model.chain = slice(2*n, 3*n) + model.shared = slice(n, 3*n) + if not getattr(model, 'reuse_prefix', False): + h, _ = model.forward(np.tile(ids, (len(MODES), 1))) + else: + model.capture_prefix = True + native, _ = model.forward(ids) + model.capture_prefix = False + h = np.concatenate([model.residual_19] * len(MODES)) + model.prior = np.concatenate([model.donor_15] * len(MODES)) + for layer, kind in enumerate(model.config['layer_types'][19:], 19): + model.guard() + p = f'layers.{layer}.' + n_h = model.normalization(h, p+'input_layernorm') + out = (model.full_attention(n_h, layer)[0] if kind == 'full_attention' + else model.linear_attention(n_h, layer)) + h = h + out + h = h + model.mlp(model.normalization(h, p+'post_attention_layernorm'), layer) + h = model.normalization(h, 'norm') + np.testing.assert_allclose(h[:n], native, atol=4e-5, rtol=3e-5) + t = model.tensors[PREFIX + 'embed_tokens.weight'] + digit_weights = decode(t.raw.reshape(t.shape)[labels], t.dtype) + t.evict() + scores = [x[np.arange(n), np.asarray(lengths) - 1] @ digit_weights.T + for x in np.split(h, len(MODES))] + rows = [] + for i, ex in enumerate(examples): + gold = ex['answer_index'] + item = {'id': ex['id'], 'task': ex['task'], 'gold': gold, 'scores': {}} + for mode, logits in zip(MODES, scores): + values = logits[i].astype(float) + item['scores'][mode] = {'pred': int(values.argmax()), 'logits': values.tolist(), + 'nll': float(np.logaddexp.reduce(values) - values[gold])} + rows.append(item) + return rows + + +def summarize(rows): + table = {} + for task in TASKS: + group = [r for r in rows if r['task'] == task] + if not group: + continue + table[task] = {} + for mode in MODES: + table[task][mode] = { + 'n': len(group), + 'correct': sum(r['scores'][mode]['pred'] == r['gold'] for r in group), + 'native_wins_lost': sum(r['scores']['native']['pred'] == r['gold'] + and r['scores'][mode]['pred'] != r['gold'] for r in group), + 'nll': float(np.mean([r['scores'][mode]['nll'] for r in group])), + } + return table + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--source', required=True, type=Path) + parser.add_argument('--out', required=True, type=Path) + parser.add_argument('--resume', action='store_true', help='Keep completed batches') + parser.add_argument('--reuse-prefix', action='store_true', help='Run layers 0–18 once per input') + args = parser.parse_args() + args.out.mkdir(exist_ok=args.resume) + model = ScreeningModel(args.source/'weights', + json.loads((args.source/'model_config.json').read_text()), seconds=3600) + if any(model.config['layer_types'][ix] != 'full_attention' for ix in SITES): + raise ValueError('Scheduled layers must all have full attention') + model.reuse_prefix = args.reuse_prefix + tok = Tokenizer.from_file(str(args.source/'tokenizer.json')) + data = {split: problems(split, n) for split, n in + [('screen', 8), ('fit', 12), ('validation', 12), ('test', 32)]} + prompts = [r['prompt'] for xs in data.values() for r in xs] + if len(set(prompts)) != len(prompts): + raise ValueError('Prompt sets overlap') + manifest = args.out/'fixed-problems.json' + collected = args.out/'screen-rows.json' + if args.resume and manifest.exists() and json.loads(manifest.read_text()) != data: + raise ValueError('Fixed prompts changed') + write_json(manifest, data) + rows = json.loads(collected.read_text()) if args.resume and collected.exists() else [] + if len(rows) % 4 or [r['id'] for r in rows] != [r['id'] for r in data['screen'][:len(rows)]]: + raise ValueError('Existing screen does not match the fixed prompt sequence') + for i in range(len(rows), len(data['screen']), 4): + rows.extend(evaluate(model, tok, data['screen'][i:i+4])) + write_json(args.out/'screen-rows.json', rows) + print('screen', len(rows), flush=True) + write_json(args.out/'screen-summary.json', summarize(rows)) + + +if __name__ == '__main__': + main() diff --git a/crossqkv/lisa_tail.py b/crossqkv/lisa_tail.py new file mode 100644 index 0000000..3b097d5 --- /dev/null +++ b/crossqkv/lisa_tail.py @@ -0,0 +1,173 @@ +"""Differentiable Qwen text tail with streamed frozen weights and LiSA sites.""" +import math + +import torch +from torch import nn +from torch.nn import functional as F +from torch.utils.checkpoint import checkpoint + +from crossqkv.lisa_train import causal_attention +from functional.model import PREFIX + + +def weight_chunks(tensor, start, end, rows=512): + width = tensor.shape[1] + for lo in range(start, end, rows): + hi = min(lo + rows, end) + yield torch.from_numpy(tensor.read(slice(lo * width, hi * width)).reshape(hi-lo, width)) + tensor.evict() + + +class FrozenLinear(torch.autograd.Function): + """Read only the requested output rows and stream them again for dX.""" + + @staticmethod + def forward(ctx, hidden, weight, start, end): + ctx.weight, ctx.start, ctx.end = weight, start, end + return torch.cat([F.linear(hidden, w) for w in weight_chunks(weight, start, end)], dim=-1) + + @staticmethod + def backward(ctx, grad): + out = grad.new_zeros((*grad.shape[:-1], ctx.weight.shape[1])) + lo = 0 + for w in weight_chunks(ctx.weight, ctx.start, ctx.end): + hi = lo + len(w) + out = out + grad[..., lo:hi] @ w + lo = hi + return out, None, None, None + + +def rotate(x, theta, fraction): + d = int(x.shape[-1] * fraction) + inv = theta ** (-torch.arange(0, d, 2, dtype=x.dtype, device=x.device) / d) + phase = torch.arange(x.shape[1], dtype=x.dtype, device=x.device)[:, None] * inv + angle = torch.cat((phase, phase), dim=-1)[None, :, None, :] + a, b = x[..., :d].chunk(2, dim=-1) + return torch.cat((x[..., :d] * angle.cos() + torch.cat((-b, a), -1) * angle.sin(), + x[..., d:]), dim=-1) + + +def gated_delta(q, k, v, g, beta): + q = q * (q.square().sum(-1, keepdim=True) + 1e-6).rsqrt() / math.sqrt(q.shape[-1]) + k = k * (k.square().sum(-1, keepdim=True) + 1e-6).rsqrt() + state = v.new_zeros(v.shape[0], v.shape[2], k.shape[-1], v.shape[-1]) + rows = [] + for i in range(v.shape[1]): + qt, kt, vt = q[:, i], k[:, i], v[:, i] + state = state * g[:, i, :, None, None].exp() + delta = (vt - (state * kt.unsqueeze(-1)).sum(-2)) * beta[:, i, :, None] + state = state + kt.unsqueeze(-1) * delta.unsqueeze(-2) + rows.append((state * qt.unsqueeze(-1)).sum(-2)) + return torch.stack(rows, dim=1) + + +class TorchTail(nn.Module): + """Inputs start immediately before the first trainable recipient.""" + + def __init__(self, source_model, start, adapters=None): + super().__init__() + self.source = source_model + self.c = source_model.config + self.eps = source_model.eps + self.start = start + self.adapters = nn.ModuleDict({str(k): v for k, v in (adapters or {}).items()}) + self._small = {} + + def small(self, name): + if name not in self._small: + self._small[name] = torch.from_numpy(self.source.small(name)) + return self._small[name] + + def linear(self, h, name, start=0, end=None): + t = self.source.tensors[PREFIX + name + '.weight'] + return FrozenLinear.apply(h, t, start, t.shape[0] if end is None else end) + + def norm(self, x, name, centered=True): + w = self.small(name + '.weight') + return x * (x.square().mean(-1, keepdim=True) + self.eps).rsqrt() * (1+w if centered else w) + + def gate_only(self, h, name): + heads, dim = self.c['num_attention_heads'], self.c['head_dim'] + return torch.stack([self.linear(h, name+'q_proj', (2*j+1)*dim, (2*j+2)*dim) + for j in range(heads)], dim=2) + + def native_scores(self, q, h, name): + c = self.c + k = self.linear(h, name+'k_proj').unflatten(-1, (c['num_key_value_heads'], c['head_dim'])) + params = c['rope_parameters'] + q = rotate(self.norm(q, name+'q_norm'), params['rope_theta'], params['partial_rotary_factor']) + k = rotate(self.norm(k, name+'k_norm'), params['rope_theta'], params['partial_rotary_factor']) + k = k.repeat_interleave(q.shape[2] // k.shape[2], dim=2) + return torch.einsum('bthd,bshd->bhts', q, k) / math.sqrt(q.shape[-1]) + + def full(self, h, layer, donor, lengths, mode, recipients, keep_teacher): + c = self.c + heads, kv_heads, dim = c['num_attention_heads'], c['num_key_value_heads'], c['head_dim'] + name = f'layers.{layer}.self_attn.' + shared = layer in recipients and mode != 'native' + if not shared or keep_teacher: + packed = self.linear(h, name+'q_proj').unflatten(-1, (heads, 2*dim)) + q, gate = packed.chunk(2, dim=-1) + if shared: + with torch.no_grad(): + native = self.native_scores(q, h, name) + else: + native = self.native_scores(q, h, name) + else: + gate = self.gate_only(h, name) + native = None + if not shared: + scores = native + elif mode == 'direct': + scores = donor + elif mode == 'lisa': + pos = torch.arange(h.shape[1], device=h.device)[None, :] + scores = self.adapters[str(layer)](h, donor, pos) + elif mode == 'linear': + matrix = self.adapters[str(layer)] + scores = matrix(donor.permute(0, 2, 3, 1)).permute(0, 3, 1, 2) + else: + raise ValueError(f'Unknown mode {mode}') + v = self.linear(h, name+'v_proj').unflatten(-1, (kv_heads, dim)) + out = causal_attention(scores, v, lengths) * gate.sigmoid() + return self.linear(out.flatten(-2), name+'o_proj'), scores, native + + def linear_attention(self, x, layer): + p = f'layers.{layer}.linear_attn.' + c = self.c + kh, vh = c['linear_num_key_heads'], c['linear_num_value_heads'] + kd, vd = c['linear_key_head_dim'], c['linear_value_head_dim'] + projected = self.linear(x, p+'in_proj_qkv').transpose(1, 2) + kernel = self.small(p+'conv1d.weight') + convolved = F.conv1d(projected, kernel, padding=kernel.shape[-1]-1, + groups=projected.shape[1])[..., :x.shape[1]] + q, k, v = F.silu(convolved.transpose(1, 2)).split((kh*kd, kh*kd, vh*vd), dim=-1) + q = q.unflatten(-1, (kh, kd)).repeat_interleave(vh//kh, dim=2) + k = k.unflatten(-1, (kh, kd)).repeat_interleave(vh//kh, dim=2) + v = v.unflatten(-1, (vh, vd)) + gate = self.linear(x, p+'in_proj_z').unflatten(-1, (vh, vd)) + beta = self.linear(x, p+'in_proj_b').sigmoid() + a = self.linear(x, p+'in_proj_a') + g = -self.small(p+'A_log').exp() * F.softplus(a + self.small(p+'dt_bias')) + out = gated_delta(q, k, v, g, beta) + return self.linear((self.norm(out, p+'norm', centered=False)*F.silu(gate)).flatten(-2), + p+'out_proj') + + def forward(self, h, donor, lengths, mode, recipients, keep_teacher=False): + side = {} + for layer, kind in enumerate(self.c['layer_types'][self.start:], self.start): + p = f'layers.{layer}.' + n = self.norm(h, p+'input_layernorm') + if kind == 'full_attention': + out, donor, native = self.full(n, layer, donor, lengths, mode, recipients, + keep_teacher) + side[layer] = (donor, native) + elif torch.is_grad_enabled() and n.requires_grad: + out = checkpoint(self.linear_attention, n, layer, use_reentrant=True) + else: + out = self.linear_attention(n, layer) + h = h + out + n = self.norm(h, p+'post_attention_layernorm') + x = F.silu(self.linear(n, p+'mlp.gate_proj')) * self.linear(n, p+'mlp.up_proj') + h = h + self.linear(x, p+'mlp.down_proj') + return self.norm(h, 'norm'), side diff --git a/crossqkv/lisa_train.py b/crossqkv/lisa_train.py index b57031b..2b0ff3b 100644 --- a/crossqkv/lisa_train.py +++ b/crossqkv/lisa_train.py @@ -90,7 +90,7 @@ class _FrozenVocabularyCE(torch.autograd.Function): """Exact full-vocabulary CE with a streamed frozen head in both passes.""" @staticmethod - def forward(ctx, hidden, targets, vocabulary): + def forward(ctx, hidden, targets, weights, vocabulary): log_total = hidden.new_full((hidden.shape[0],), -torch.inf) selected = hidden.new_zeros(hidden.shape[0]) for start, w in vocabulary(): @@ -98,24 +98,26 @@ class _FrozenVocabularyCE(torch.autograd.Function): log_total = torch.logaddexp(log_total, logits.logsumexp(dim=-1)) belongs = (targets >= start) & (targets < start + w.shape[0]) selected[belongs] = logits[belongs, targets[belongs] - start] - ctx.save_for_backward(hidden, targets, log_total) + ctx.save_for_backward(hidden, targets, log_total, weights) ctx.vocabulary = vocabulary - return (log_total - selected).mean() + return ((log_total - selected) * weights).sum() / weights.sum() @staticmethod def backward(ctx, gradient): - hidden, targets, log_total = ctx.saved_tensors + hidden, targets, log_total, weights = ctx.saved_tensors grad_hidden = torch.zeros_like(hidden) for start, w in ctx.vocabulary(): probs = (F.linear(hidden, w) - log_total[:, None]).exp() belongs = (targets >= start) & (targets < start + w.shape[0]) probs[belongs, targets[belongs] - start] -= 1 grad_hidden.addmm_(probs, w) - return grad_hidden * (gradient / hidden.shape[0]), None, None + return grad_hidden * (gradient * weights[:, None] / weights.sum()), None, None, None -def language_model_loss(hidden, ids, lengths, vocabulary): +def language_model_loss(hidden, ids, lengths, vocabulary, answer_weight=1.0): """Train on all valid next-token targets, avoiding padding and final positions.""" positions = torch.arange(ids.shape[1] - 1, device=ids.device) valid = positions[None, :] + 1 < lengths[:, None] - return _FrozenVocabularyCE.apply(hidden[:, :-1][valid], ids[:, 1:][valid], vocabulary) + weights = torch.where(positions[None, :] + 2 == lengths[:, None], answer_weight, 1.0) + return _FrozenVocabularyCE.apply(hidden[:, :-1][valid], ids[:, 1:][valid], + weights[valid].to(dtype=hidden.dtype), vocabulary) diff --git a/docs/LISA_EFFECT_PROTOCOL.md b/docs/LISA_EFFECT_PROTOCOL.md new file mode 100644 index 0000000..7765511 --- /dev/null +++ b/docs/LISA_EFFECT_PROTOCOL.md @@ -0,0 +1,151 @@ +# LiSA effect reproduction on Qwen3.5-2B + +The earlier single-layer training verified the method but used an evaluation +where the frozen 2B model answered only one of sixteen items. This protocol +measures retention of an existing capability and the cost of exercising it. + +## Comparison with the published experiment + +The 96.44% in Table 2 is the average performance retained by LLaMA2-13B +with 22 recipient layers across the reported benchmarks excluding LAMBADA. +At the same 22 layers, direct score sharing retained 46.76% and the direct +sharing plus LoRA baseline retained 65.95%. The published main uptraining +used 4.2 billion sampled RedPajama tokens on eight A800 GPUs. This experiment +uses a frozen Qwen3.5-2B backbone, two recipient layers, 12 synthetic fit +prompts and a single CPU runner. The comparable effect is an improvement +over direct sharing under a fixed layer schedule. The magnitude on a +32-item lookup test and the timing of CPU attention should be interpreted +within those settings. [Mu et al., Table 2 and Appendix C.1](https://aclanthology.org/2026.tacl-1.30.pdf) + +## Task and layer screening + +All four tasks, answer-position balances, and generators are fixed in +`crossqkv/lisa_effect_screen.py`. The screening split is used only for +selecting a primary task family and the schedule. Fit, validation, and test +prompts have disjoint fixed seeds. The screen must finish before opening +test metrics. + +Test original attention, 19→23 direct reuse, and a chained 15→19→23 +configuration, with each donor providing its actual scores in the current +run. Primary eligibility on the development screen requires original accuracy +at least 5/8 and at least one original-correct item lost under shared +attention. Compare candidate schedules by the count of native-correct items +lost, preferring the two-receiver schedule among ties and recording net +accuracy and four-option NLL. If none qualify, retain the screen and expand +development coverage before choosing a new task; never pick based on test +errors. The fixed test also reports all outcomes on the chosen task, including +native-incorrect items. + +## Performance comparison + +Compare native, direct, fit-only linear calibration and trainable LiSA on +identical prompts. Preserve Qwen recipient gates, V, and output projection. +Compare the published 0.25 Huber and 0.75 next-token CE objective with an +explicit answer-weighted variant. All adaptation and model selection use +only fit/validation. Record the whole-sequence training loss. On held-out prompts, report +answer-only loss, correctly recovered and newly lost questions, net +accuracy, and performance at one and two recipients. A measured failure to recover is a valid outcome. + +For speed, use a path that actually skips dense Q/K at shared sites, keeping +gate rows. Verify against a reference first. With identical prompts, +checkpoint and runner, report measured latency for the implemented prefill +or decode path and its true scope. Account for both the reduced K storage +and additional score tensors. Do not call analytical estimates measured +speed or apply paper throughput figures to this CPU implementation. + +The incremental recipient benchmark uses actual K/V buffers and compares the +shared implementation with native attention at the same prefix length and FP32 +storage format. Numerical tests compare incremental scores and outputs with +batched causal attention at every query position. Report observed allocation +for K/V and the donor score row separately from end-to-end prefill or decode. +It does not include upstream score generation or the rest of the decoder. + +```sh +python -B -m crossqkv.lisa_decode_bench --source runs/cpu-qwen35-2b \ + --capture runs/LISA_EFFECT_CAPTURE --checkpoint runs/LISA_EFFECT_RESULTS/lisa.pt \ + --out runs/LISA_EFFECT_RESULTS/decode.json +``` + +An interrupted development screen can resume with the same fixed prompt set +using `--resume`. Use `--reuse-prefix` to compute the frozen prefix once per +prompt. The replay checks original-mode parity before accepting results. + +## Recorded development selection + +The fixed screen completed with 32 prompts. The prespecified eligibility rule +selected the 16-entry lookup task with recipients at layers 19 and 23. Native +and one-recipient direct sharing each scored 8/8. Two-recipient direct sharing +scored 7/8 and lost one native-correct answer. The selected configuration, +all screened logits, and the disjoint prompt manifest are archived under +`results/lisa-effect-reproduction/`. This was selection evidence only. + +The held-out analysis records rescue of native-correct errors, newly introduced +errors, paired uncertainty and answer NLL. A second pass streams the complete +vocabulary at the same answer positions and compares one- and two-recipient +forward paths. In the one-recipient LiSA ablation the final adapter comes from +the joint checkpoint. It is evaluated unchanged, with the earlier recipient +restored to native attention. + +Training also saves each finished epoch's adapter, AdamW state, validation +history and selected weights atomically per variant. For interrupted training, +re-run the same command with `--resume` and the same output directory and epoch +budget. Resume verifies the frozen training configuration, preserves finished +epochs and re-scores the locked test set from the validation-selected weights. +The separate selected checkpoints retain the original weights-only schema. + +The development error was `screen-lookup16-005`. Its correct choice was +option 4. Across native, single-recipient direct reuse and chained direct reuse, +the four-choice probability of option 4 was 0.706, 0.815 and 0.403, +respectively. Its correct-versus-best-distractor logit margins were ++1.265, +1.861 and −0.258. The chained result chose option 2. These are +development observations that describe the selected condition, not test +results or a basis for changing the frozen prompts. + +## Reproduction commands + +Run from the project code root on the confirmed remote CPU environment. +Choose new output directories. Keep the same source checkpoint across all +commands. The fixed manifest contains all four split definitions, and capture +writes an independent selection record and source fingerprints. + +```sh +export OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 +PYTHON=venv/bin/python +SOURCE=runs/cpu-qwen35-2b +SCREEN=runs/NEW_EFFECT_SCREEN +CAPTURE=runs/NEW_EFFECT_CAPTURE +RESULT=runs/NEW_EFFECT_RESULT + +"$PYTHON" -B -m crossqkv.lisa_effect_screen --source "$SOURCE" --out "$SCREEN" --reuse-prefix +"$PYTHON" -B -m crossqkv.lisa_effect capture --source "$SOURCE" --input "$SCREEN" --out "$CAPTURE" +"$PYTHON" -B -m crossqkv.lisa_effect train --source "$SOURCE" --input "$CAPTURE" --out "$RESULT" --epochs 2 +"$PYTHON" -B -m crossqkv.lisa_decode_bench --source "$SOURCE" --capture "$CAPTURE" \ + --checkpoint "$RESULT/lisa.pt" --out "$RESULT/decode.json" +"$PYTHON" -B -m crossqkv.lisa_effect_answer_audit --source "$SOURCE" --cache "$CAPTURE" \ + --trained "$RESULT" --out "$RESULT/full-vocab-answers.json" +"$PYTHON" -B -m crossqkv.lisa_effect_audit --fixed "$SCREEN/fixed-problems.json" \ + --selection "$CAPTURE/selection.json" --items "$RESULT/test-items.json" \ + --perf "$RESULT/performance.json" --decode "$RESULT/decode.json" --out "$RESULT/paired-audit.json" +``` + +The paired audit defines a rescue as a native-correct item made wrong by +direct sharing and made correct again by the tested adapter. It reports +newly lost native-and-direct-correct items separately. An improvement in +mean four-option answer NLL, including among items already answered +correctly, does not by itself establish a rescue. + +Training scores *all* valid shifted tokens with exact full-vocabulary CE +and uses the validation four-option answer loss to freeze checkpoints. The +answer audit scores only the answer position over the whole vocabulary. +It does not report whole-prompt CE for the held-out items or free-form +multi-token answer accuracy. That distinction is important for interpreting +the previous experiment, in which those two losses moved in opposite +directions. + +For the isolated incremental attention timing, report both streamed +checkpoint projections and an otherwise identical timing with only that +site's frozen projections resident in memory. Verify output and raw score +parity before interpreting the pair of timings. The resident measurements +exclude weight-load time, and both timings exclude upstream computation and +other decoder blocks. K/V and upstream score-row allocation are itemized +separately; neither timing is an end-to-end server throughput claim. diff --git a/results/lisa-effect-reproduction/development-native-reference.json b/results/lisa-effect-reproduction/development-native-reference.json new file mode 100644 index 0000000..1ccecd6 --- /dev/null +++ b/results/lisa-effect-reproduction/development-native-reference.json @@ -0,0 +1,10 @@ +{ + "task": "lookup16", + "source": "frozen Qwen3.5-2B hidden states at the answer position from native forward", + "metric": "4-option accuracy and mean NLL over four option logits", + "frozen_native_reference": { + "fit": {"samples": 12, "native_correct": 12, "choice_nll": 0.13035377124382475}, + "validation": {"samples": 12, "native_correct": 12, "choice_nll": 0.13171539331834095} + }, + "test_predictions_opened": false +} diff --git a/results/lisa-effect-reproduction/fixed-problems.json b/results/lisa-effect-reproduction/fixed-problems.json new file mode 100644 index 0000000..08bbeb1 --- /dev/null +++ b/results/lisa-effect-reproduction/fixed-problems.json @@ -0,0 +1,1546 @@ +{ + "screen": [ + { + "id": "screen-lookup8-000", + "task": "lookup8", + "prompt": "Use the lookup table.\nyew: 51\namber: 99\nbirch: 38\nwillow: 45\nslate: 42\number: 12\nquartz: 18\nmaple: 36\nWhich option is the value for quartz?\n1. 18\n2. 36\n3. 45\n4. 38\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "screen-lookup8-001", + "task": "lookup8", + "prompt": "Use the lookup table.\namber: 99\nlarch: 70\nyew: 82\ndune: 44\njade: 32\nquartz: 77\nbirch: 23\nthyme: 54\nWhich option is the value for yew?\n1. 23\n2. 82\n3. 70\n4. 54\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "screen-lookup8-002", + "task": "lookup8", + "prompt": "Use the lookup table.\nyew: 50\nlarch: 47\nnettle: 31\nslate: 60\nelm: 39\ncedar: 80\nfern: 82\number: 49\nWhich option is the value for larch?\n1. 50\n2. 80\n3. 47\n4. 82\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "screen-lookup8-003", + "task": "lookup8", + "prompt": "Use the lookup table.\nnettle: 48\nheath: 44\nbirch: 72\npine: 40\ngrove: 65\nyew: 75\nwillow: 70\nmaple: 83\nWhich option is the value for yew?\n1. 72\n2. 44\n3. 75\n4. 40\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "screen-lookup8-004", + "task": "lookup8", + "prompt": "Use the lookup table.\nwillow: 16\nlarch: 60\nreed: 68\nbirch: 37\njade: 14\number: 61\nmaple: 40\ndune: 62\nWhich option is the value for dune?\n1. 61\n2. 62\n3. 14\n4. 68\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "screen-lookup8-005", + "task": "lookup8", + "prompt": "Use the lookup table.\nlarch: 10\namber: 85\njade: 62\npine: 14\nolive: 94\nquartz: 37\nvine: 53\nbirch: 40\nWhich option is the value for jade?\n1. 37\n2. 94\n3. 40\n4. 62\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "screen-lookup8-006", + "task": "lookup8", + "prompt": "Use the lookup table.\namber: 86\nkelp: 23\njade: 72\nnettle: 60\nyew: 18\nthyme: 13\nslate: 29\number: 38\nWhich option is the value for nettle?\n1. 72\n2. 29\n3. 38\n4. 60\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "screen-lookup8-007", + "task": "lookup8", + "prompt": "Use the lookup table.\npine: 27\nkelp: 99\nreed: 41\nthyme: 34\number: 49\namber: 71\nlarch: 76\nelm: 77\nWhich option is the value for reed?\n1. 41\n2. 49\n3. 99\n4. 27\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "screen-lookup16-000", + "task": "lookup16", + "prompt": "Use the lookup table.\nelm: 66\ndune: 90\nbirch: 53\nheath: 92\ncedar: 64\nnettle: 21\nthyme: 57\nyew: 63\nkelp: 13\nreed: 52\nvine: 93\nlarch: 76\nslate: 24\number: 89\nmaple: 94\npine: 48\nWhich option is the value for vine?\n1. 21\n2. 57\n3. 13\n4. 93\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "screen-lookup16-001", + "task": "lookup16", + "prompt": "Use the lookup table.\nolive: 47\nbirch: 52\nkelp: 19\nfern: 55\nelm: 38\ngrove: 11\nslate: 84\njade: 77\nquartz: 58\nthyme: 56\nlarch: 87\number: 51\nreed: 96\npine: 67\nyew: 99\nmaple: 43\nWhich option is the value for jade?\n1. 77\n2. 96\n3. 55\n4. 51\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "screen-lookup16-002", + "task": "lookup16", + "prompt": "Use the lookup table.\nvine: 85\nmaple: 95\nbirch: 46\nwillow: 18\nlarch: 70\nslate: 75\nquartz: 83\number: 90\nelm: 30\nolive: 61\nfern: 43\nkelp: 36\ngrove: 39\nyew: 60\npine: 78\njade: 29\nWhich option is the value for umber?\n1. 46\n2. 90\n3. 29\n4. 83\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "screen-lookup16-003", + "task": "lookup16", + "prompt": "Use the lookup table.\namber: 12\nbirch: 34\nolive: 84\nlarch: 79\njade: 21\nslate: 68\nkelp: 19\nvine: 73\nmaple: 65\number: 64\npine: 50\nheath: 94\nthyme: 47\ncedar: 55\nquartz: 49\nelm: 51\nWhich option is the value for amber?\n1. 12\n2. 34\n3. 64\n4. 79\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "screen-lookup16-004", + "task": "lookup16", + "prompt": "Use the lookup table.\nreed: 64\number: 47\ndune: 24\nelm: 79\npine: 91\nvine: 88\ncedar: 25\namber: 81\nolive: 18\nlarch: 72\nwillow: 14\nheath: 30\nnettle: 34\nbirch: 92\nquartz: 67\nthyme: 83\nWhich option is the value for elm?\n1. 92\n2. 79\n3. 72\n4. 67\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "screen-lookup16-005", + "task": "lookup16", + "prompt": "Use the lookup table.\nkelp: 93\ngrove: 91\number: 11\nyew: 15\niris: 80\ncedar: 31\nlarch: 55\nnettle: 71\namber: 87\nthyme: 22\ndune: 41\njade: 63\nolive: 90\nquartz: 92\nfern: 54\nbirch: 72\nWhich option is the value for grove?\n1. 55\n2. 15\n3. 41\n4. 91\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "screen-lookup16-006", + "task": "lookup16", + "prompt": "Use the lookup table.\ncedar: 70\nkelp: 76\nnettle: 19\nheath: 73\namber: 55\nvine: 40\nquartz: 23\nreed: 98\nwillow: 20\nfern: 30\nbirch: 39\npine: 78\nlarch: 10\number: 93\ndune: 61\nolive: 50\nWhich option is the value for reed?\n1. 78\n2. 93\n3. 98\n4. 55\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "screen-lookup16-007", + "task": "lookup16", + "prompt": "Use the lookup table.\namber: 77\nwillow: 90\njade: 53\number: 58\nelm: 17\ndune: 52\nfern: 21\nlarch: 46\nnettle: 36\nreed: 71\npine: 62\nheath: 16\nquartz: 98\nthyme: 59\nvine: 78\nolive: 85\nWhich option is the value for jade?\n1. 77\n2. 98\n3. 53\n4. 90\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "screen-latest8-000", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nvine: 24\njade: 45\nolive: 33\namber: 16\ngrove: 20\nkelp: 14\nbirch: 60\nkelp: 63\nWhich option is the latest value for kelp?\n1. 63\n2. 20\n3. 14\n4. 24\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "screen-latest8-001", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nelm: 33\ndune: 92\nbirch: 26\npine: 71\niris: 82\nheath: 25\nreed: 79\nreed: 74\nWhich option is the latest value for reed?\n1. 79\n2. 33\n3. 74\n4. 71\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "screen-latest8-002", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\npine: 58\nlarch: 28\nthyme: 84\nelm: 89\nyew: 83\ndune: 32\nyew: 55\ngrove: 10\nWhich option is the latest value for yew?\n1. 58\n2. 83\n3. 55\n4. 28\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "screen-latest8-003", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\ndune: 28\nyew: 22\nnettle: 65\njade: 94\nnettle: 85\nfern: 82\nvine: 88\number: 35\nWhich option is the latest value for nettle?\n1. 65\n2. 85\n3. 28\n4. 94\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "screen-latest8-004", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\ndune: 20\nthyme: 91\namber: 61\ncedar: 72\nlarch: 24\nreed: 38\ncedar: 55\nnettle: 82\nWhich option is the latest value for cedar?\n1. 72\n2. 55\n3. 24\n4. 91\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "screen-latest8-005", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nwillow: 37\nmaple: 35\npine: 54\nfern: 27\nreed: 56\nbirch: 57\nbirch: 74\ngrove: 31\nWhich option is the latest value for birch?\n1. 57\n2. 56\n3. 31\n4. 74\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "screen-latest8-006", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\ndune: 62\npine: 36\ncedar: 42\number: 25\namber: 61\number: 45\njade: 13\ngrove: 19\nWhich option is the latest value for umber?\n1. 45\n2. 25\n3. 19\n4. 36\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "screen-latest8-007", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nfern: 28\nfern: 95\nolive: 86\nthyme: 90\nelm: 70\nbirch: 64\nreed: 46\nmaple: 84\nWhich option is the latest value for fern?\n1. 90\n2. 28\n3. 46\n4. 95\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "screen-arithmetic-000", + "task": "arithmetic", + "prompt": "What is 44 + 80?\n1. 114\n2. 125\n3. 124\n4. 134\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "screen-arithmetic-001", + "task": "arithmetic", + "prompt": "What is 91 + 38?\n1. 130\n2. 139\n3. 129\n4. 119\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "screen-arithmetic-002", + "task": "arithmetic", + "prompt": "What is 53 + 74?\n1. 117\n2. 127\n3. 137\n4. 126\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "screen-arithmetic-003", + "task": "arithmetic", + "prompt": "What is 20 + 13?\n1. 23\n2. 33\n3. 43\n4. 32\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "screen-arithmetic-004", + "task": "arithmetic", + "prompt": "What is 87 + 95?\n1. 182\n2. 172\n3. 181\n4. 192\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "screen-arithmetic-005", + "task": "arithmetic", + "prompt": "What is 47 + 92?\n1. 140\n2. 149\n3. 129\n4. 139\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "screen-arithmetic-006", + "task": "arithmetic", + "prompt": "What is 19 + 22?\n1. 31\n2. 40\n3. 51\n4. 41\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "screen-arithmetic-007", + "task": "arithmetic", + "prompt": "What is 95 + 22?\n1. 117\n2. 127\n3. 107\n4. 118\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + } + ], + "fit": [ + { + "id": "fit-lookup8-000", + "task": "lookup8", + "prompt": "Use the lookup table.\nkelp: 35\ndune: 16\nthyme: 23\nyew: 51\npine: 41\nbirch: 72\number: 60\nnettle: 47\nWhich option is the value for nettle?\n1. 47\n2. 35\n3. 51\n4. 60\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "fit-lookup8-001", + "task": "lookup8", + "prompt": "Use the lookup table.\namber: 15\njade: 52\ncedar: 67\nreed: 29\nvine: 12\nnettle: 61\npine: 14\nwillow: 44\nWhich option is the value for pine?\n1. 61\n2. 67\n3. 52\n4. 14\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "fit-lookup8-002", + "task": "lookup8", + "prompt": "Use the lookup table.\npine: 45\njade: 86\nolive: 37\nyew: 17\nelm: 83\nbirch: 30\nheath: 95\nslate: 20\nWhich option is the value for olive?\n1. 20\n2. 17\n3. 37\n4. 45\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "fit-lookup8-003", + "task": "lookup8", + "prompt": "Use the lookup table.\npine: 76\nheath: 78\nvine: 35\ndune: 94\ngrove: 97\niris: 88\nelm: 32\nnettle: 98\nWhich option is the value for heath?\n1. 88\n2. 78\n3. 97\n4. 76\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "fit-lookup8-004", + "task": "lookup8", + "prompt": "Use the lookup table.\ngrove: 66\npine: 80\nwillow: 52\number: 85\nbirch: 61\namber: 42\nyew: 56\nfern: 12\nWhich option is the value for pine?\n1. 66\n2. 42\n3. 80\n4. 61\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "fit-lookup8-005", + "task": "lookup8", + "prompt": "Use the lookup table.\nwillow: 99\nmaple: 95\nelm: 94\nslate: 31\number: 68\ncedar: 23\njade: 77\nbirch: 66\nWhich option is the value for birch?\n1. 66\n2. 94\n3. 31\n4. 77\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "fit-lookup8-006", + "task": "lookup8", + "prompt": "Use the lookup table.\npine: 49\nquartz: 23\nvine: 67\ncedar: 88\nthyme: 41\ndune: 44\njade: 81\namber: 89\nWhich option is the value for amber?\n1. 49\n2. 23\n3. 88\n4. 89\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "fit-lookup8-007", + "task": "lookup8", + "prompt": "Use the lookup table.\nyew: 18\number: 77\ncedar: 63\nlarch: 17\ngrove: 89\niris: 76\nmaple: 15\nwillow: 33\nWhich option is the value for iris?\n1. 18\n2. 76\n3. 33\n4. 77\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "fit-lookup8-008", + "task": "lookup8", + "prompt": "Use the lookup table.\nnettle: 14\nslate: 86\ngrove: 74\niris: 78\nwillow: 30\nfern: 55\nreed: 25\nolive: 51\nWhich option is the value for olive?\n1. 25\n2. 78\n3. 74\n4. 51\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "fit-lookup8-009", + "task": "lookup8", + "prompt": "Use the lookup table.\namber: 95\nyew: 65\nolive: 57\nbirch: 22\ngrove: 44\npine: 55\nnettle: 31\nquartz: 70\nWhich option is the value for amber?\n1. 22\n2. 55\n3. 95\n4. 57\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "fit-lookup8-010", + "task": "lookup8", + "prompt": "Use the lookup table.\ndune: 11\nheath: 25\nwillow: 97\nolive: 81\nlarch: 94\ncedar: 23\nvine: 74\npine: 10\nWhich option is the value for heath?\n1. 97\n2. 25\n3. 23\n4. 11\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "fit-lookup8-011", + "task": "lookup8", + "prompt": "Use the lookup table.\nlarch: 61\nquartz: 93\nbirch: 37\nwillow: 10\nkelp: 86\nvine: 64\nmaple: 21\npine: 25\nWhich option is the value for larch?\n1. 61\n2. 10\n3. 93\n4. 25\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "fit-lookup16-000", + "task": "lookup16", + "prompt": "Use the lookup table.\nwillow: 50\nheath: 74\nquartz: 22\njade: 58\nthyme: 60\nvine: 83\ndune: 16\nlarch: 69\niris: 13\nmaple: 97\nolive: 81\nbirch: 34\nreed: 44\nkelp: 42\nnettle: 26\number: 62\nWhich option is the value for umber?\n1. 60\n2. 16\n3. 83\n4. 62\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "fit-lookup16-001", + "task": "lookup16", + "prompt": "Use the lookup table.\nquartz: 16\nwillow: 67\njade: 89\nyew: 11\nnettle: 85\ndune: 40\nlarch: 68\nbirch: 29\npine: 38\ncedar: 69\namber: 41\nheath: 78\nolive: 97\nmaple: 80\nslate: 24\nreed: 56\nWhich option is the value for amber?\n1. 29\n2. 80\n3. 41\n4. 67\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "fit-lookup16-002", + "task": "lookup16", + "prompt": "Use the lookup table.\nheath: 10\nslate: 17\nvine: 65\nreed: 79\njade: 96\nolive: 69\nquartz: 56\nnettle: 62\ncedar: 57\ndune: 23\nmaple: 91\nkelp: 60\number: 82\nfern: 31\nwillow: 66\nyew: 44\nWhich option is the value for dune?\n1. 23\n2. 31\n3. 66\n4. 69\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "fit-lookup16-003", + "task": "lookup16", + "prompt": "Use the lookup table.\ngrove: 81\nthyme: 44\nkelp: 23\nreed: 75\nbirch: 15\njade: 65\niris: 95\nolive: 62\nlarch: 60\nslate: 30\nquartz: 31\npine: 34\nwillow: 54\nnettle: 97\nheath: 56\nfern: 66\nWhich option is the value for kelp?\n1. 60\n2. 56\n3. 23\n4. 30\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "fit-lookup16-004", + "task": "lookup16", + "prompt": "Use the lookup table.\nwillow: 48\nkelp: 17\niris: 75\nfern: 34\nyew: 43\nnettle: 40\nquartz: 77\namber: 16\nvine: 41\nolive: 60\ngrove: 92\nheath: 57\nlarch: 54\nelm: 35\nreed: 82\ncedar: 85\nWhich option is the value for grove?\n1. 43\n2. 85\n3. 75\n4. 92\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "fit-lookup16-005", + "task": "lookup16", + "prompt": "Use the lookup table.\njade: 67\nslate: 97\nelm: 35\number: 14\ngrove: 33\namber: 51\nreed: 18\nwillow: 38\nmaple: 83\ncedar: 43\ndune: 46\nlarch: 22\nheath: 17\nthyme: 45\niris: 61\nbirch: 23\nWhich option is the value for willow?\n1. 97\n2. 38\n3. 46\n4. 35\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "fit-lookup16-006", + "task": "lookup16", + "prompt": "Use the lookup table.\ngrove: 87\nnettle: 59\namber: 44\nfern: 96\nthyme: 85\npine: 26\ndune: 69\nyew: 12\nvine: 79\number: 49\ncedar: 84\njade: 35\nreed: 52\nquartz: 78\nkelp: 32\nelm: 13\nWhich option is the value for vine?\n1. 79\n2. 13\n3. 35\n4. 59\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "fit-lookup16-007", + "task": "lookup16", + "prompt": "Use the lookup table.\nolive: 17\nyew: 49\npine: 15\nheath: 35\nvine: 28\ngrove: 92\nkelp: 88\nbirch: 39\namber: 25\nslate: 91\ndune: 60\nmaple: 72\nquartz: 95\niris: 48\nelm: 34\nnettle: 16\nWhich option is the value for quartz?\n1. 60\n2. 28\n3. 95\n4. 91\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "fit-lookup16-008", + "task": "lookup16", + "prompt": "Use the lookup table.\nvine: 34\niris: 41\ncedar: 52\nwillow: 23\nreed: 50\nmaple: 29\nlarch: 14\nyew: 79\namber: 67\nheath: 16\number: 47\njade: 20\nthyme: 80\nkelp: 24\nbirch: 70\nfern: 94\nWhich option is the value for thyme?\n1. 80\n2. 34\n3. 94\n4. 14\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "fit-lookup16-009", + "task": "lookup16", + "prompt": "Use the lookup table.\nkelp: 15\nwillow: 46\niris: 37\number: 63\nfern: 34\nreed: 77\nnettle: 71\nolive: 84\namber: 51\nelm: 78\njade: 69\ndune: 99\nquartz: 83\ncedar: 43\nheath: 81\nthyme: 61\nWhich option is the value for iris?\n1. 51\n2. 37\n3. 15\n4. 34\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "fit-lookup16-010", + "task": "lookup16", + "prompt": "Use the lookup table.\nelm: 85\nthyme: 49\nwillow: 41\nmaple: 33\npine: 15\niris: 62\nyew: 50\nquartz: 30\ncedar: 63\nfern: 31\njade: 13\nslate: 36\nlarch: 69\ndune: 43\number: 37\nbirch: 17\nWhich option is the value for slate?\n1. 31\n2. 36\n3. 85\n4. 30\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "fit-lookup16-011", + "task": "lookup16", + "prompt": "Use the lookup table.\nreed: 67\nfern: 60\ngrove: 37\nbirch: 75\nnettle: 14\nmaple: 91\nolive: 99\nslate: 61\nelm: 13\nwillow: 54\nlarch: 66\nquartz: 88\ndune: 57\nthyme: 76\npine: 89\nyew: 38\nWhich option is the value for pine?\n1. 38\n2. 99\n3. 57\n4. 89\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "fit-latest8-000", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nmaple: 93\nheath: 77\nreed: 65\nwillow: 73\nvine: 54\nelm: 57\nkelp: 96\nvine: 14\nWhich option is the latest value for vine?\n1. 73\n2. 54\n3. 14\n4. 93\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "fit-latest8-001", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nlarch: 25\ngrove: 24\ndune: 13\nelm: 73\number: 40\nyew: 44\nlarch: 56\nheath: 36\nWhich option is the latest value for larch?\n1. 44\n2. 25\n3. 36\n4. 56\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "fit-latest8-002", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\npine: 37\nslate: 14\nquartz: 59\nreed: 80\namber: 51\nquartz: 46\nlarch: 12\njade: 64\nWhich option is the latest value for quartz?\n1. 80\n2. 59\n3. 46\n4. 12\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "fit-latest8-003", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\npine: 13\nelm: 37\nbirch: 63\njade: 75\ngrove: 79\nmaple: 16\nquartz: 91\nquartz: 93\nWhich option is the latest value for quartz?\n1. 75\n2. 93\n3. 91\n4. 79\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "fit-latest8-004", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nelm: 10\number: 79\nheath: 80\nnettle: 43\nelm: 37\npine: 38\nthyme: 73\ncedar: 13\nWhich option is the latest value for elm?\n1. 38\n2. 13\n3. 10\n4. 37\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "fit-latest8-005", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nelm: 55\nolive: 67\namber: 31\nmaple: 65\npine: 48\nmaple: 93\nfern: 68\ngrove: 45\nWhich option is the latest value for maple?\n1. 45\n2. 93\n3. 31\n4. 65\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "fit-latest8-006", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\npine: 22\nolive: 87\nkelp: 94\nheath: 70\ngrove: 16\nwillow: 61\number: 92\number: 13\nWhich option is the latest value for umber?\n1. 70\n2. 94\n3. 92\n4. 13\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "fit-latest8-007", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nthyme: 94\number: 21\ndune: 19\nheath: 55\niris: 95\nheath: 14\nquartz: 18\nolive: 48\nWhich option is the latest value for heath?\n1. 14\n2. 19\n3. 55\n4. 48\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "fit-latest8-008", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nheath: 66\nquartz: 43\nlarch: 76\ngrove: 25\nbirch: 27\nolive: 95\ngrove: 87\nkelp: 29\nWhich option is the latest value for grove?\n1. 87\n2. 27\n3. 29\n4. 25\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "fit-latest8-009", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\njade: 92\ndune: 33\nquartz: 24\namber: 74\number: 73\nthyme: 79\npine: 78\nthyme: 86\nWhich option is the latest value for thyme?\n1. 86\n2. 92\n3. 79\n4. 24\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "fit-latest8-010", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nmaple: 29\nolive: 53\nnettle: 46\nfern: 16\ncedar: 33\nbirch: 50\ncedar: 31\njade: 81\nWhich option is the latest value for cedar?\n1. 16\n2. 31\n3. 33\n4. 50\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "fit-latest8-011", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nelm: 12\nlarch: 42\nvine: 20\ngrove: 44\nbirch: 43\number: 52\niris: 33\ngrove: 53\nWhich option is the latest value for grove?\n1. 20\n2. 33\n3. 53\n4. 44\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "fit-arithmetic-000", + "task": "arithmetic", + "prompt": "What is 48 + 76?\n1. 134\n2. 125\n3. 114\n4. 124\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "fit-arithmetic-001", + "task": "arithmetic", + "prompt": "What is 67 + 86?\n1. 154\n2. 153\n3. 143\n4. 163\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "fit-arithmetic-002", + "task": "arithmetic", + "prompt": "What is 13 + 39?\n1. 52\n2. 62\n3. 53\n4. 42\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "fit-arithmetic-003", + "task": "arithmetic", + "prompt": "What is 34 + 55?\n1. 99\n2. 88\n3. 89\n4. 79\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "fit-arithmetic-004", + "task": "arithmetic", + "prompt": "What is 16 + 63?\n1. 78\n2. 69\n3. 89\n4. 79\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "fit-arithmetic-005", + "task": "arithmetic", + "prompt": "What is 68 + 40?\n1. 98\n2. 118\n3. 108\n4. 107\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "fit-arithmetic-006", + "task": "arithmetic", + "prompt": "What is 64 + 29?\n1. 94\n2. 93\n3. 103\n4. 83\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "fit-arithmetic-007", + "task": "arithmetic", + "prompt": "What is 60 + 26?\n1. 86\n2. 87\n3. 76\n4. 96\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "fit-arithmetic-008", + "task": "arithmetic", + "prompt": "What is 66 + 70?\n1. 146\n2. 137\n3. 136\n4. 126\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "fit-arithmetic-009", + "task": "arithmetic", + "prompt": "What is 35 + 30?\n1. 65\n2. 64\n3. 75\n4. 55\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "fit-arithmetic-010", + "task": "arithmetic", + "prompt": "What is 13 + 47?\n1. 50\n2. 61\n3. 70\n4. 60\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "fit-arithmetic-011", + "task": "arithmetic", + "prompt": "What is 90 + 64?\n1. 144\n2. 154\n3. 155\n4. 164\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + } + ], + "validation": [ + { + "id": "validation-lookup8-000", + "task": "lookup8", + "prompt": "Use the lookup table.\nelm: 89\nolive: 35\ndune: 45\nfern: 92\niris: 71\nbirch: 20\number: 95\namber: 26\nWhich option is the value for elm?\n1. 26\n2. 92\n3. 89\n4. 71\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "validation-lookup8-001", + "task": "lookup8", + "prompt": "Use the lookup table.\nwillow: 91\nthyme: 95\nolive: 58\nfern: 12\nlarch: 47\njade: 53\nbirch: 73\nheath: 49\nWhich option is the value for fern?\n1. 12\n2. 53\n3. 91\n4. 47\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "validation-lookup8-002", + "task": "lookup8", + "prompt": "Use the lookup table.\nelm: 43\nheath: 82\nnettle: 66\nfern: 24\njade: 57\namber: 74\nolive: 54\nbirch: 12\nWhich option is the value for jade?\n1. 74\n2. 57\n3. 66\n4. 12\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "validation-lookup8-003", + "task": "lookup8", + "prompt": "Use the lookup table.\ncedar: 93\nslate: 23\nmaple: 13\nyew: 43\njade: 17\nnettle: 86\nlarch: 39\nkelp: 31\nWhich option is the value for jade?\n1. 93\n2. 13\n3. 17\n4. 31\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "validation-lookup8-004", + "task": "lookup8", + "prompt": "Use the lookup table.\nkelp: 56\nheath: 42\nthyme: 61\nolive: 92\nslate: 21\nelm: 20\ncedar: 95\nreed: 62\nWhich option is the value for heath?\n1. 56\n2. 42\n3. 92\n4. 62\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "validation-lookup8-005", + "task": "lookup8", + "prompt": "Use the lookup table.\ngrove: 68\njade: 93\number: 10\nmaple: 71\nlarch: 70\nheath: 79\nslate: 60\ndune: 31\nWhich option is the value for maple?\n1. 60\n2. 93\n3. 31\n4. 71\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "validation-lookup8-006", + "task": "lookup8", + "prompt": "Use the lookup table.\number: 66\nolive: 63\nnettle: 97\njade: 71\nmaple: 33\niris: 16\nelm: 91\nwillow: 79\nWhich option is the value for nettle?\n1. 66\n2. 97\n3. 71\n4. 33\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "validation-lookup8-007", + "task": "lookup8", + "prompt": "Use the lookup table.\nlarch: 83\nnettle: 43\nwillow: 44\niris: 62\nvine: 97\ncedar: 41\nfern: 33\nkelp: 22\nWhich option is the value for iris?\n1. 62\n2. 44\n3. 43\n4. 22\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "validation-lookup8-008", + "task": "lookup8", + "prompt": "Use the lookup table.\njade: 98\nreed: 75\nquartz: 77\nthyme: 72\nlarch: 33\nolive: 60\nyew: 15\nfern: 36\nWhich option is the value for olive?\n1. 60\n2. 77\n3. 72\n4. 33\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "validation-lookup8-009", + "task": "lookup8", + "prompt": "Use the lookup table.\ngrove: 66\number: 39\nkelp: 50\namber: 99\npine: 92\nnettle: 31\ncedar: 46\nheath: 97\nWhich option is the value for amber?\n1. 39\n2. 66\n3. 31\n4. 99\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "validation-lookup8-010", + "task": "lookup8", + "prompt": "Use the lookup table.\ngrove: 79\nthyme: 91\nlarch: 12\nheath: 92\nolive: 62\njade: 23\ndune: 76\namber: 31\nWhich option is the value for thyme?\n1. 76\n2. 79\n3. 91\n4. 31\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "validation-lookup8-011", + "task": "lookup8", + "prompt": "Use the lookup table.\nbirch: 68\niris: 16\nmaple: 63\namber: 41\nnettle: 42\ndune: 26\ncedar: 21\njade: 48\nWhich option is the value for nettle?\n1. 16\n2. 48\n3. 41\n4. 42\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "validation-lookup16-000", + "task": "lookup16", + "prompt": "Use the lookup table.\npine: 96\number: 12\nlarch: 30\njade: 74\nwillow: 69\nbirch: 66\nolive: 76\nquartz: 99\nyew: 14\ngrove: 41\nthyme: 32\nkelp: 11\nnettle: 42\nelm: 78\namber: 13\nslate: 15\nWhich option is the value for elm?\n1. 69\n2. 30\n3. 78\n4. 96\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "validation-lookup16-001", + "task": "lookup16", + "prompt": "Use the lookup table.\nthyme: 47\nelm: 59\nyew: 12\nheath: 43\njade: 87\nfern: 71\nreed: 19\nquartz: 83\nmaple: 98\ncedar: 62\nslate: 80\namber: 55\npine: 27\nvine: 26\nbirch: 93\number: 81\nWhich option is the value for maple?\n1. 19\n2. 12\n3. 47\n4. 98\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "validation-lookup16-002", + "task": "lookup16", + "prompt": "Use the lookup table.\nslate: 94\nfern: 75\nnettle: 18\nkelp: 51\number: 69\nolive: 41\nquartz: 80\nvine: 11\nreed: 93\nheath: 87\ndune: 61\njade: 73\nyew: 28\npine: 46\nelm: 54\niris: 42\nWhich option is the value for iris?\n1. 42\n2. 51\n3. 80\n4. 94\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "validation-lookup16-003", + "task": "lookup16", + "prompt": "Use the lookup table.\niris: 18\nkelp: 65\nreed: 72\nmaple: 96\ndune: 66\ngrove: 40\nvine: 11\nlarch: 54\nthyme: 15\nwillow: 31\nbirch: 24\nquartz: 29\ncedar: 10\nslate: 77\nyew: 85\nolive: 76\nWhich option is the value for yew?\n1. 66\n2. 76\n3. 31\n4. 85\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "validation-lookup16-004", + "task": "lookup16", + "prompt": "Use the lookup table.\niris: 79\nwillow: 10\njade: 30\nkelp: 74\nheath: 56\ngrove: 12\npine: 63\nbirch: 26\nvine: 66\namber: 87\nmaple: 42\nslate: 81\nyew: 70\nnettle: 44\nquartz: 67\ndune: 54\nWhich option is the value for amber?\n1. 70\n2. 56\n3. 87\n4. 12\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "validation-lookup16-005", + "task": "lookup16", + "prompt": "Use the lookup table.\nheath: 82\niris: 33\nyew: 11\nolive: 49\nslate: 56\nthyme: 90\njade: 60\nnettle: 47\nvine: 35\nkelp: 92\ncedar: 44\ngrove: 29\namber: 58\nbirch: 95\nwillow: 37\nquartz: 91\nWhich option is the value for birch?\n1. 90\n2. 29\n3. 95\n4. 56\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "validation-lookup16-006", + "task": "lookup16", + "prompt": "Use the lookup table.\nwillow: 84\ncedar: 93\number: 83\nslate: 56\namber: 85\nreed: 51\nlarch: 29\nthyme: 62\nnettle: 98\njade: 75\nyew: 10\nkelp: 71\nolive: 18\nvine: 54\nbirch: 67\nfern: 17\nWhich option is the value for jade?\n1. 51\n2. 75\n3. 62\n4. 17\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "validation-lookup16-007", + "task": "lookup16", + "prompt": "Use the lookup table.\nmaple: 25\ncedar: 64\niris: 90\nelm: 77\njade: 46\nwillow: 75\nyew: 65\nreed: 15\npine: 95\nslate: 88\number: 94\nvine: 10\nheath: 89\nthyme: 71\ndune: 53\namber: 51\nWhich option is the value for vine?\n1. 53\n2. 10\n3. 77\n4. 94\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "validation-lookup16-008", + "task": "lookup16", + "prompt": "Use the lookup table.\nelm: 22\nreed: 41\nlarch: 96\nheath: 56\nyew: 54\nvine: 86\ndune: 68\nfern: 44\nmaple: 37\ncedar: 23\nthyme: 81\nwillow: 69\nolive: 48\npine: 28\nslate: 61\nquartz: 80\nWhich option is the value for slate?\n1. 61\n2. 22\n3. 80\n4. 37\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "validation-lookup16-009", + "task": "lookup16", + "prompt": "Use the lookup table.\niris: 52\nmaple: 36\nfern: 83\ndune: 37\nelm: 38\nbirch: 64\ngrove: 57\njade: 78\nolive: 66\nthyme: 41\nslate: 75\nquartz: 94\npine: 40\number: 88\nheath: 76\nwillow: 84\nWhich option is the value for fern?\n1. 64\n2. 83\n3. 37\n4. 78\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "validation-lookup16-010", + "task": "lookup16", + "prompt": "Use the lookup table.\ndune: 42\nslate: 11\nyew: 63\ngrove: 32\number: 36\nolive: 20\nnettle: 72\nwillow: 60\nheath: 82\njade: 16\namber: 45\nkelp: 33\nvine: 58\nthyme: 90\nfern: 17\nbirch: 62\nWhich option is the value for willow?\n1. 42\n2. 11\n3. 82\n4. 60\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "validation-lookup16-011", + "task": "lookup16", + "prompt": "Use the lookup table.\nnettle: 97\njade: 28\nmaple: 29\nvine: 88\nheath: 71\nfern: 63\nelm: 43\ncedar: 95\nkelp: 61\nreed: 84\nslate: 26\nyew: 94\nquartz: 72\ngrove: 68\niris: 14\nlarch: 66\nWhich option is the value for quartz?\n1. 72\n2. 94\n3. 68\n4. 28\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "validation-latest8-000", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nbirch: 79\nkelp: 86\njade: 73\nfern: 11\nfern: 52\nmaple: 61\nwillow: 39\ncedar: 42\nWhich option is the latest value for fern?\n1. 52\n2. 42\n3. 11\n4. 86\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "validation-latest8-001", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\ncedar: 78\namber: 97\nnettle: 53\namber: 58\number: 63\npine: 35\nyew: 77\niris: 32\nWhich option is the latest value for amber?\n1. 97\n2. 77\n3. 58\n4. 53\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "validation-latest8-002", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nolive: 57\nvine: 33\nslate: 78\nreed: 61\namber: 58\nmaple: 65\nkelp: 73\nkelp: 60\nWhich option is the latest value for kelp?\n1. 73\n2. 60\n3. 61\n4. 58\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "validation-latest8-003", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nyew: 73\nslate: 97\nfern: 29\number: 91\nquartz: 76\nfern: 68\nmaple: 57\npine: 96\nWhich option is the latest value for fern?\n1. 68\n2. 91\n3. 29\n4. 96\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "validation-latest8-004", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nlarch: 96\namber: 88\nquartz: 34\njade: 36\nyew: 91\niris: 48\niris: 67\nwillow: 78\nWhich option is the latest value for iris?\n1. 34\n2. 78\n3. 48\n4. 67\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "validation-latest8-005", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nreed: 25\nfern: 74\njade: 39\niris: 38\number: 41\ndune: 64\nheath: 30\nheath: 75\nWhich option is the latest value for heath?\n1. 30\n2. 39\n3. 75\n4. 74\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "validation-latest8-006", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nvine: 25\ndune: 72\nreed: 43\nlarch: 77\nvine: 44\nmaple: 64\nslate: 30\nquartz: 14\nWhich option is the latest value for vine?\n1. 77\n2. 44\n3. 64\n4. 25\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "validation-latest8-007", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\niris: 93\nyew: 26\nvine: 91\npine: 88\nquartz: 30\nreed: 53\nquartz: 60\njade: 94\nWhich option is the latest value for quartz?\n1. 30\n2. 53\n3. 60\n4. 94\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "validation-latest8-008", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nvine: 37\nyew: 78\nkelp: 71\niris: 36\njade: 18\nquartz: 76\nolive: 11\niris: 45\nWhich option is the latest value for iris?\n1. 11\n2. 71\n3. 36\n4. 45\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "validation-latest8-009", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nvine: 98\njade: 54\nfern: 50\nheath: 89\nnettle: 41\nreed: 40\nkelp: 57\nvine: 81\nWhich option is the latest value for vine?\n1. 81\n2. 57\n3. 89\n4. 98\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "validation-latest8-010", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nheath: 41\ndune: 14\nthyme: 97\nolive: 68\nolive: 96\nvine: 13\nkelp: 53\nnettle: 54\nWhich option is the latest value for olive?\n1. 68\n2. 53\n3. 97\n4. 96\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "validation-latest8-011", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nquartz: 63\nthyme: 49\nnettle: 30\nreed: 24\nelm: 43\niris: 65\nvine: 10\nquartz: 82\nWhich option is the latest value for quartz?\n1. 65\n2. 82\n3. 49\n4. 63\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "validation-arithmetic-000", + "task": "arithmetic", + "prompt": "What is 16 + 71?\n1. 77\n2. 97\n3. 87\n4. 88\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "validation-arithmetic-001", + "task": "arithmetic", + "prompt": "What is 63 + 47?\n1. 100\n2. 110\n3. 111\n4. 120\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "validation-arithmetic-002", + "task": "arithmetic", + "prompt": "What is 18 + 42?\n1. 60\n2. 70\n3. 59\n4. 50\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "validation-arithmetic-003", + "task": "arithmetic", + "prompt": "What is 17 + 43?\n1. 50\n2. 60\n3. 59\n4. 70\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "validation-arithmetic-004", + "task": "arithmetic", + "prompt": "What is 67 + 51?\n1. 128\n2. 108\n3. 117\n4. 118\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "validation-arithmetic-005", + "task": "arithmetic", + "prompt": "What is 31 + 70?\n1. 111\n2. 101\n3. 100\n4. 91\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "validation-arithmetic-006", + "task": "arithmetic", + "prompt": "What is 40 + 50?\n1. 100\n2. 80\n3. 90\n4. 91\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "validation-arithmetic-007", + "task": "arithmetic", + "prompt": "What is 87 + 55?\n1. 152\n2. 143\n3. 132\n4. 142\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "validation-arithmetic-008", + "task": "arithmetic", + "prompt": "What is 78 + 52?\n1. 140\n2. 120\n3. 131\n4. 130\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "validation-arithmetic-009", + "task": "arithmetic", + "prompt": "What is 98 + 16?\n1. 114\n2. 124\n3. 104\n4. 113\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "validation-arithmetic-010", + "task": "arithmetic", + "prompt": "What is 78 + 41?\n1. 120\n2. 109\n3. 119\n4. 129\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "validation-arithmetic-011", + "task": "arithmetic", + "prompt": "What is 63 + 13?\n1. 76\n2. 66\n3. 86\n4. 77\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + } + ], + "test": [ + { + "id": "test-lookup8-000", + "task": "lookup8", + "prompt": "Use the lookup table.\ngrove: 81\ndune: 82\nquartz: 22\nlarch: 28\nheath: 74\njade: 61\number: 27\nelm: 80\nWhich option is the value for heath?\n1. 28\n2. 74\n3. 22\n4. 81\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup8-001", + "task": "lookup8", + "prompt": "Use the lookup table.\njade: 72\number: 79\nbirch: 63\nyew: 71\nreed: 74\nfern: 57\nkelp: 23\niris: 37\nWhich option is the value for kelp?\n1. 71\n2. 72\n3. 57\n4. 23\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup8-002", + "task": "lookup8", + "prompt": "Use the lookup table.\nvine: 70\ndune: 42\nreed: 62\nheath: 23\namber: 10\nelm: 49\nyew: 30\nwillow: 57\nWhich option is the value for yew?\n1. 23\n2. 30\n3. 42\n4. 70\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup8-003", + "task": "lookup8", + "prompt": "Use the lookup table.\ndune: 59\ngrove: 19\nyew: 85\nbirch: 22\namber: 25\nquartz: 83\nkelp: 50\nelm: 30\nWhich option is the value for birch?\n1. 50\n2. 85\n3. 83\n4. 22\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup8-004", + "task": "lookup8", + "prompt": "Use the lookup table.\nthyme: 73\nolive: 49\namber: 61\niris: 70\ncedar: 86\nnettle: 35\ngrove: 79\nquartz: 44\nWhich option is the value for cedar?\n1. 86\n2. 73\n3. 61\n4. 79\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup8-005", + "task": "lookup8", + "prompt": "Use the lookup table.\nwillow: 66\nthyme: 59\nslate: 77\ngrove: 65\njade: 10\nreed: 33\niris: 26\nyew: 99\nWhich option is the value for grove?\n1. 65\n2. 10\n3. 99\n4. 77\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup8-006", + "task": "lookup8", + "prompt": "Use the lookup table.\namber: 88\number: 77\nheath: 80\niris: 76\nelm: 25\nreed: 21\ngrove: 66\nlarch: 34\nWhich option is the value for grove?\n1. 66\n2. 80\n3. 34\n4. 21\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup8-007", + "task": "lookup8", + "prompt": "Use the lookup table.\nheath: 59\ngrove: 92\nlarch: 91\nolive: 66\npine: 96\nslate: 14\nquartz: 83\njade: 73\nWhich option is the value for jade?\n1. 83\n2. 59\n3. 73\n4. 14\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup8-008", + "task": "lookup8", + "prompt": "Use the lookup table.\nwillow: 35\nheath: 50\nbirch: 72\nfern: 73\nslate: 70\nyew: 94\nquartz: 84\nreed: 46\nWhich option is the value for willow?\n1. 46\n2. 35\n3. 73\n4. 50\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup8-009", + "task": "lookup8", + "prompt": "Use the lookup table.\nyew: 30\nkelp: 61\nlarch: 63\nslate: 70\nheath: 38\namber: 69\nthyme: 96\nreed: 87\nWhich option is the value for larch?\n1. 87\n2. 38\n3. 61\n4. 63\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup8-010", + "task": "lookup8", + "prompt": "Use the lookup table.\niris: 19\nfern: 73\nreed: 83\nquartz: 57\npine: 48\nmaple: 92\nbirch: 32\namber: 23\nWhich option is the value for reed?\n1. 83\n2. 57\n3. 23\n4. 32\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup8-011", + "task": "lookup8", + "prompt": "Use the lookup table.\nkelp: 80\nwillow: 53\ndune: 34\nslate: 70\nyew: 74\ncedar: 51\njade: 43\nreed: 81\nWhich option is the value for cedar?\n1. 70\n2. 53\n3. 51\n4. 81\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup8-012", + "task": "lookup8", + "prompt": "Use the lookup table.\nlarch: 81\nelm: 53\nvine: 19\nyew: 80\nbirch: 20\nheath: 27\njade: 91\nreed: 57\nWhich option is the value for jade?\n1. 19\n2. 91\n3. 53\n4. 27\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup8-013", + "task": "lookup8", + "prompt": "Use the lookup table.\nbirch: 25\niris: 67\nnettle: 37\nquartz: 27\nvine: 99\ncedar: 93\nmaple: 43\nfern: 19\nWhich option is the value for birch?\n1. 93\n2. 67\n3. 25\n4. 99\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup8-014", + "task": "lookup8", + "prompt": "Use the lookup table.\nwillow: 24\niris: 73\njade: 77\nreed: 88\nvine: 56\nkelp: 38\ngrove: 39\namber: 54\nWhich option is the value for grove?\n1. 77\n2. 56\n3. 54\n4. 39\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup8-015", + "task": "lookup8", + "prompt": "Use the lookup table.\nvine: 25\ncedar: 53\namber: 29\nquartz: 84\njade: 85\nslate: 30\nreed: 94\nyew: 36\nWhich option is the value for reed?\n1. 29\n2. 94\n3. 85\n4. 84\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup8-016", + "task": "lookup8", + "prompt": "Use the lookup table.\nkelp: 59\nwillow: 51\nreed: 68\namber: 72\number: 49\nslate: 54\nthyme: 46\njade: 60\nWhich option is the value for amber?\n1. 51\n2. 59\n3. 46\n4. 72\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup8-017", + "task": "lookup8", + "prompt": "Use the lookup table.\nolive: 27\nmaple: 60\nlarch: 88\nelm: 30\nbirch: 69\nnettle: 84\npine: 76\nyew: 19\nWhich option is the value for elm?\n1. 30\n2. 27\n3. 84\n4. 60\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup8-018", + "task": "lookup8", + "prompt": "Use the lookup table.\nkelp: 95\nbirch: 30\nelm: 48\nquartz: 42\nwillow: 51\nyew: 12\nreed: 64\ngrove: 68\nWhich option is the value for reed?\n1. 51\n2. 68\n3. 64\n4. 95\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup8-019", + "task": "lookup8", + "prompt": "Use the lookup table.\ndune: 33\nslate: 55\ngrove: 88\nelm: 68\nkelp: 20\nyew: 78\nolive: 40\nmaple: 71\nWhich option is the value for maple?\n1. 78\n2. 55\n3. 71\n4. 33\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup8-020", + "task": "lookup8", + "prompt": "Use the lookup table.\ngrove: 67\nnettle: 17\npine: 12\nkelp: 94\nelm: 90\ncedar: 89\namber: 30\nheath: 42\nWhich option is the value for heath?\n1. 30\n2. 12\n3. 42\n4. 94\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup8-021", + "task": "lookup8", + "prompt": "Use the lookup table.\nvine: 30\ncedar: 32\nlarch: 14\nmaple: 33\nnettle: 90\number: 74\nreed: 41\ngrove: 56\nWhich option is the value for grove?\n1. 74\n2. 56\n3. 90\n4. 32\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup8-022", + "task": "lookup8", + "prompt": "Use the lookup table.\ndune: 80\nslate: 65\nmaple: 50\nbirch: 89\ngrove: 27\nfern: 26\npine: 34\nthyme: 52\nWhich option is the value for maple?\n1. 65\n2. 52\n3. 34\n4. 50\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup8-023", + "task": "lookup8", + "prompt": "Use the lookup table.\ndune: 17\nlarch: 46\nslate: 11\nkelp: 63\nbirch: 69\nolive: 68\nvine: 20\namber: 19\nWhich option is the value for larch?\n1. 68\n2. 20\n3. 46\n4. 19\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup8-024", + "task": "lookup8", + "prompt": "Use the lookup table.\njade: 85\nthyme: 63\number: 71\nelm: 95\nnettle: 44\nreed: 83\niris: 72\nheath: 30\nWhich option is the value for thyme?\n1. 71\n2. 85\n3. 63\n4. 44\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup8-025", + "task": "lookup8", + "prompt": "Use the lookup table.\nslate: 57\nreed: 30\nquartz: 56\ngrove: 98\nyew: 21\nthyme: 18\niris: 37\number: 82\nWhich option is the value for grove?\n1. 18\n2. 98\n3. 57\n4. 56\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup8-026", + "task": "lookup8", + "prompt": "Use the lookup table.\nheath: 40\nquartz: 33\nnettle: 81\njade: 94\nfern: 34\nelm: 50\nolive: 18\nlarch: 10\nWhich option is the value for quartz?\n1. 94\n2. 81\n3. 10\n4. 33\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup8-027", + "task": "lookup8", + "prompt": "Use the lookup table.\number: 16\namber: 67\nolive: 93\nheath: 70\njade: 85\npine: 68\nyew: 90\ndune: 23\nWhich option is the value for yew?\n1. 70\n2. 16\n3. 85\n4. 90\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup8-028", + "task": "lookup8", + "prompt": "Use the lookup table.\ncedar: 82\nolive: 35\nheath: 22\nnettle: 95\niris: 23\npine: 33\nreed: 59\nmaple: 14\nWhich option is the value for iris?\n1. 23\n2. 14\n3. 82\n4. 33\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup8-029", + "task": "lookup8", + "prompt": "Use the lookup table.\nwillow: 80\niris: 41\nmaple: 43\nbirch: 34\nfern: 15\nnettle: 56\nkelp: 94\nheath: 19\nWhich option is the value for birch?\n1. 41\n2. 34\n3. 56\n4. 94\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup8-030", + "task": "lookup8", + "prompt": "Use the lookup table.\nyew: 38\niris: 87\nquartz: 58\nheath: 93\ndune: 96\number: 52\nreed: 51\nolive: 85\nWhich option is the value for umber?\n1. 52\n2. 87\n3. 93\n4. 38\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup8-031", + "task": "lookup8", + "prompt": "Use the lookup table.\nfern: 95\namber: 26\nbirch: 54\nkelp: 88\ndune: 77\ngrove: 47\nyew: 97\nheath: 92\nWhich option is the value for kelp?\n1. 88\n2. 97\n3. 47\n4. 54\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup16-000", + "task": "lookup16", + "prompt": "Use the lookup table.\ncedar: 23\njade: 44\nwillow: 78\nreed: 91\nmaple: 42\npine: 97\nvine: 92\nheath: 68\nlarch: 40\nnettle: 64\nelm: 86\nslate: 15\niris: 11\nfern: 57\ngrove: 27\nolive: 85\nWhich option is the value for iris?\n1. 11\n2. 27\n3. 42\n4. 85\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup16-001", + "task": "lookup16", + "prompt": "Use the lookup table.\number: 67\nlarch: 30\nelm: 27\npine: 43\namber: 89\niris: 41\nfern: 20\nwillow: 91\nvine: 15\ncedar: 52\njade: 21\nkelp: 28\nolive: 92\nyew: 99\nreed: 86\nnettle: 32\nWhich option is the value for amber?\n1. 43\n2. 32\n3. 99\n4. 89\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup16-002", + "task": "lookup16", + "prompt": "Use the lookup table.\nreed: 72\nmaple: 27\nfern: 93\nyew: 14\nslate: 10\nnettle: 79\ngrove: 40\number: 29\nelm: 70\njade: 54\ndune: 43\nlarch: 35\nbirch: 21\nolive: 73\nwillow: 68\nthyme: 41\nWhich option is the value for jade?\n1. 54\n2. 41\n3. 27\n4. 79\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup16-003", + "task": "lookup16", + "prompt": "Use the lookup table.\njade: 55\nvine: 22\nquartz: 64\nelm: 45\nheath: 12\ncedar: 90\nfern: 82\nslate: 92\nkelp: 59\nbirch: 37\nwillow: 27\npine: 56\nmaple: 48\nyew: 68\nlarch: 32\namber: 66\nWhich option is the value for amber?\n1. 27\n2. 66\n3. 64\n4. 45\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup16-004", + "task": "lookup16", + "prompt": "Use the lookup table.\npine: 41\ndune: 40\nvine: 92\ncedar: 89\nthyme: 82\nfern: 18\nreed: 54\nlarch: 16\nyew: 85\nmaple: 72\nquartz: 69\nelm: 43\niris: 48\nwillow: 98\number: 13\nbirch: 26\nWhich option is the value for iris?\n1. 89\n2. 48\n3. 69\n4. 40\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup16-005", + "task": "lookup16", + "prompt": "Use the lookup table.\nbirch: 24\npine: 17\namber: 69\niris: 13\nslate: 77\nelm: 75\nquartz: 57\nnettle: 93\nreed: 58\nmaple: 40\ndune: 53\nolive: 15\nheath: 80\nwillow: 70\nvine: 72\nyew: 61\nWhich option is the value for reed?\n1. 75\n2. 58\n3. 93\n4. 70\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup16-006", + "task": "lookup16", + "prompt": "Use the lookup table.\nolive: 94\nbirch: 45\njade: 43\nelm: 97\nmaple: 99\ndune: 63\nlarch: 59\nslate: 85\npine: 96\nyew: 98\niris: 68\nreed: 87\nfern: 93\nnettle: 54\nquartz: 15\nthyme: 69\nWhich option is the value for elm?\n1. 97\n2. 99\n3. 87\n4. 93\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup16-007", + "task": "lookup16", + "prompt": "Use the lookup table.\namber: 37\nslate: 43\nnettle: 47\nolive: 75\ndune: 10\nmaple: 21\nyew: 88\npine: 62\ncedar: 45\nlarch: 30\nvine: 99\nquartz: 51\nkelp: 77\nreed: 98\nheath: 63\ngrove: 60\nWhich option is the value for olive?\n1. 47\n2. 99\n3. 75\n4. 98\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup16-008", + "task": "lookup16", + "prompt": "Use the lookup table.\nkelp: 47\nlarch: 71\ncedar: 95\nheath: 80\nthyme: 45\nslate: 87\nvine: 48\nyew: 83\nfern: 77\nquartz: 61\namber: 86\njade: 22\nelm: 27\nbirch: 25\nwillow: 12\ngrove: 97\nWhich option is the value for thyme?\n1. 27\n2. 22\n3. 48\n4. 45\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup16-009", + "task": "lookup16", + "prompt": "Use the lookup table.\nmaple: 42\nkelp: 48\nthyme: 35\nnettle: 97\niris: 16\ndune: 70\namber: 82\nvine: 57\nfern: 85\nreed: 64\number: 88\ngrove: 91\ncedar: 18\nwillow: 96\nyew: 54\nelm: 71\nWhich option is the value for fern?\n1. 85\n2. 18\n3. 42\n4. 64\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup16-010", + "task": "lookup16", + "prompt": "Use the lookup table.\ngrove: 36\nslate: 64\nvine: 38\nkelp: 66\nelm: 80\ncedar: 88\nquartz: 55\ndune: 26\nyew: 11\npine: 17\namber: 73\nfern: 90\nwillow: 30\nreed: 16\niris: 51\nlarch: 18\nWhich option is the value for fern?\n1. 26\n2. 90\n3. 73\n4. 17\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup16-011", + "task": "lookup16", + "prompt": "Use the lookup table.\nnettle: 47\nslate: 66\ncedar: 25\nolive: 39\nheath: 32\nmaple: 34\nwillow: 31\nreed: 36\npine: 27\ndune: 64\nthyme: 24\nyew: 14\nelm: 50\nbirch: 54\nfern: 89\nlarch: 79\nWhich option is the value for cedar?\n1. 25\n2. 34\n3. 79\n4. 24\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup16-012", + "task": "lookup16", + "prompt": "Use the lookup table.\ncedar: 96\niris: 95\namber: 23\nkelp: 37\nquartz: 48\njade: 30\number: 43\nslate: 86\nelm: 47\nnettle: 94\nwillow: 97\nmaple: 50\nolive: 70\nvine: 31\nfern: 88\ndune: 91\nWhich option is the value for olive?\n1. 88\n2. 94\n3. 23\n4. 70\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup16-013", + "task": "lookup16", + "prompt": "Use the lookup table.\nlarch: 26\nyew: 28\ncedar: 40\nquartz: 29\npine: 39\nkelp: 44\nbirch: 78\nolive: 59\nelm: 73\namber: 69\niris: 79\nwillow: 30\ngrove: 52\nthyme: 12\nmaple: 56\nreed: 21\nWhich option is the value for kelp?\n1. 44\n2. 59\n3. 39\n4. 79\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup16-014", + "task": "lookup16", + "prompt": "Use the lookup table.\nelm: 55\nyew: 58\niris: 29\nthyme: 47\nvine: 71\nnettle: 36\npine: 78\nbirch: 39\ngrove: 23\nlarch: 69\nquartz: 44\number: 79\nolive: 28\ncedar: 90\nmaple: 27\njade: 75\nWhich option is the value for larch?\n1. 69\n2. 28\n3. 71\n4. 75\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup16-015", + "task": "lookup16", + "prompt": "Use the lookup table.\nquartz: 38\nyew: 24\nvine: 37\ngrove: 85\nelm: 27\nslate: 50\ndune: 19\nreed: 91\number: 63\nkelp: 81\nolive: 46\npine: 39\niris: 26\nheath: 96\nbirch: 48\nmaple: 92\nWhich option is the value for yew?\n1. 85\n2. 24\n3. 81\n4. 38\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup16-016", + "task": "lookup16", + "prompt": "Use the lookup table.\niris: 22\nnettle: 35\nolive: 49\ndune: 93\nfern: 67\nkelp: 36\nheath: 17\nmaple: 96\nwillow: 38\number: 63\namber: 89\ngrove: 12\nbirch: 59\nslate: 85\nvine: 61\nthyme: 10\nWhich option is the value for fern?\n1. 35\n2. 49\n3. 36\n4. 67\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup16-017", + "task": "lookup16", + "prompt": "Use the lookup table.\nslate: 94\nelm: 85\nreed: 58\nkelp: 56\nmaple: 54\nthyme: 71\number: 45\nnettle: 73\nvine: 93\nwillow: 64\nfern: 76\njade: 25\ncedar: 31\nyew: 23\ngrove: 63\nbirch: 78\nWhich option is the value for reed?\n1. 56\n2. 93\n3. 64\n4. 58\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup16-018", + "task": "lookup16", + "prompt": "Use the lookup table.\ngrove: 81\nnettle: 49\nreed: 59\nlarch: 64\nquartz: 73\nyew: 72\number: 96\nbirch: 56\namber: 76\nslate: 77\nheath: 40\nolive: 20\nwillow: 51\nmaple: 50\ndune: 98\ncedar: 37\nWhich option is the value for cedar?\n1. 64\n2. 37\n3. 73\n4. 49\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup16-019", + "task": "lookup16", + "prompt": "Use the lookup table.\nvine: 36\nwillow: 46\number: 55\ngrove: 47\npine: 62\nreed: 34\ncedar: 22\nyew: 28\nfern: 72\nlarch: 69\nbirch: 71\nnettle: 43\niris: 97\nthyme: 57\ndune: 16\nslate: 35\nWhich option is the value for umber?\n1. 28\n2. 72\n3. 55\n4. 43\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup16-020", + "task": "lookup16", + "prompt": "Use the lookup table.\nolive: 19\nkelp: 12\njade: 58\nelm: 75\ndune: 31\nyew: 35\niris: 43\nbirch: 22\nquartz: 98\ngrove: 39\namber: 70\nheath: 85\nvine: 57\number: 60\nreed: 64\nmaple: 81\nWhich option is the value for vine?\n1. 64\n2. 57\n3. 60\n4. 22\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup16-021", + "task": "lookup16", + "prompt": "Use the lookup table.\ncedar: 41\nelm: 90\nvine: 28\nnettle: 58\njade: 94\nlarch: 66\npine: 38\nwillow: 53\nslate: 11\niris: 56\nquartz: 36\nolive: 33\number: 42\nreed: 47\nthyme: 52\nyew: 61\nWhich option is the value for quartz?\n1. 38\n2. 47\n3. 36\n4. 66\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup16-022", + "task": "lookup16", + "prompt": "Use the lookup table.\nreed: 18\nwillow: 17\nfern: 30\nbirch: 90\ncedar: 24\nheath: 89\nmaple: 20\nquartz: 48\nkelp: 15\nvine: 74\nyew: 16\ndune: 85\npine: 19\ngrove: 54\nslate: 38\njade: 25\nWhich option is the value for slate?\n1. 17\n2. 90\n3. 74\n4. 38\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup16-023", + "task": "lookup16", + "prompt": "Use the lookup table.\nnettle: 95\nelm: 36\nmaple: 69\number: 77\njade: 53\nolive: 21\ndune: 55\nreed: 60\nheath: 67\nyew: 85\nwillow: 90\namber: 73\nkelp: 32\npine: 76\nvine: 11\nthyme: 98\nWhich option is the value for umber?\n1. 90\n2. 11\n3. 77\n4. 73\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup16-024", + "task": "lookup16", + "prompt": "Use the lookup table.\ncedar: 79\number: 11\namber: 44\ndune: 22\nbirch: 34\nnettle: 30\nfern: 55\nquartz: 19\nthyme: 58\nlarch: 83\nolive: 14\nwillow: 24\ngrove: 43\nkelp: 57\nslate: 21\niris: 89\nWhich option is the value for iris?\n1. 34\n2. 24\n3. 19\n4. 89\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup16-025", + "task": "lookup16", + "prompt": "Use the lookup table.\ngrove: 15\niris: 68\nquartz: 10\npine: 44\ncedar: 76\nreed: 91\nthyme: 52\nfern: 81\nnettle: 74\nlarch: 30\nolive: 36\nmaple: 60\nslate: 19\namber: 12\nwillow: 24\nvine: 13\nWhich option is the value for grove?\n1. 76\n2. 15\n3. 68\n4. 81\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-lookup16-026", + "task": "lookup16", + "prompt": "Use the lookup table.\nnettle: 49\namber: 60\nvine: 37\nreed: 45\ngrove: 24\nwillow: 14\nyew: 82\npine: 11\nelm: 90\nthyme: 27\ndune: 23\nheath: 80\nquartz: 92\nmaple: 86\number: 13\nlarch: 71\nWhich option is the value for yew?\n1. 71\n2. 11\n3. 82\n4. 90\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup16-027", + "task": "lookup16", + "prompt": "Use the lookup table.\npine: 54\nnettle: 42\nslate: 45\nwillow: 20\ndune: 70\ncedar: 52\nmaple: 91\nquartz: 12\njade: 36\namber: 46\number: 81\niris: 89\nfern: 80\nyew: 53\nkelp: 84\nlarch: 17\nWhich option is the value for kelp?\n1. 89\n2. 20\n3. 84\n4. 45\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup16-028", + "task": "lookup16", + "prompt": "Use the lookup table.\npine: 91\nfern: 62\nreed: 15\nnettle: 92\nyew: 98\nthyme: 95\nvine: 58\nlarch: 53\nkelp: 37\niris: 18\nwillow: 19\ndune: 45\nbirch: 85\nelm: 28\nquartz: 23\nmaple: 60\nWhich option is the value for kelp?\n1. 60\n2. 62\n3. 37\n4. 85\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-lookup16-029", + "task": "lookup16", + "prompt": "Use the lookup table.\nfern: 32\ncedar: 91\npine: 77\namber: 84\nolive: 58\nreed: 97\ngrove: 62\number: 93\ndune: 25\nelm: 33\nmaple: 27\nvine: 79\nquartz: 54\nheath: 16\niris: 50\nyew: 13\nWhich option is the value for olive?\n1. 54\n2. 77\n3. 84\n4. 58\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-lookup16-030", + "task": "lookup16", + "prompt": "Use the lookup table.\nelm: 23\niris: 92\npine: 25\nwillow: 13\nvine: 88\nkelp: 29\nheath: 66\nlarch: 84\nyew: 35\nthyme: 44\njade: 93\nquartz: 94\number: 32\namber: 10\ndune: 75\ngrove: 28\nWhich option is the value for dune?\n1. 75\n2. 66\n3. 35\n4. 32\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-lookup16-031", + "task": "lookup16", + "prompt": "Use the lookup table.\ngrove: 39\nbirch: 87\nwillow: 84\number: 92\nvine: 17\ncedar: 35\namber: 77\npine: 29\nolive: 68\nslate: 50\nheath: 41\niris: 96\nfern: 12\nquartz: 99\nmaple: 58\nreed: 66\nWhich option is the value for grove?\n1. 17\n2. 58\n3. 39\n4. 12\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-latest8-000", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nwillow: 62\nreed: 14\nelm: 25\ngrove: 34\nbirch: 13\nquartz: 21\njade: 29\njade: 99\nWhich option is the latest value for jade?\n1. 62\n2. 99\n3. 34\n4. 29\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-latest8-001", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nyew: 31\nvine: 58\nmaple: 70\nvine: 87\nheath: 43\nthyme: 16\nwillow: 71\nelm: 55\nWhich option is the latest value for vine?\n1. 16\n2. 87\n3. 58\n4. 43\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-latest8-002", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nwillow: 76\nnettle: 81\nreed: 94\nbirch: 36\npine: 86\nheath: 30\niris: 34\niris: 70\nWhich option is the latest value for iris?\n1. 30\n2. 34\n3. 36\n4. 70\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-latest8-003", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\ngrove: 61\nkelp: 52\niris: 70\nmaple: 44\nolive: 46\nyew: 65\number: 89\number: 37\nWhich option is the latest value for umber?\n1. 65\n2. 61\n3. 37\n4. 89\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-latest8-004", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nreed: 70\nfern: 84\nlarch: 35\nvine: 68\nslate: 89\number: 55\nkelp: 60\nvine: 30\nWhich option is the latest value for vine?\n1. 68\n2. 30\n3. 60\n4. 35\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-latest8-005", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nfern: 22\nyew: 86\nslate: 16\number: 62\nslate: 57\nlarch: 93\nheath: 65\nbirch: 37\nWhich option is the latest value for slate?\n1. 16\n2. 86\n3. 57\n4. 22\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-latest8-006", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nelm: 63\number: 26\njade: 82\ngrove: 54\nthyme: 33\nreed: 93\nheath: 90\njade: 21\nWhich option is the latest value for jade?\n1. 21\n2. 54\n3. 82\n4. 33\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-latest8-007", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nreed: 63\number: 46\namber: 19\nlarch: 94\ndune: 48\npine: 24\nwillow: 54\ndune: 39\nWhich option is the latest value for dune?\n1. 48\n2. 24\n3. 39\n4. 46\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-latest8-008", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\namber: 62\nnettle: 95\nelm: 38\niris: 24\nlarch: 59\nthyme: 80\nlarch: 74\number: 11\nWhich option is the latest value for larch?\n1. 59\n2. 24\n3. 74\n4. 62\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-latest8-009", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nbirch: 39\nmaple: 96\nthyme: 87\namber: 12\number: 91\nfern: 20\npine: 35\number: 23\nWhich option is the latest value for umber?\n1. 39\n2. 23\n3. 20\n4. 91\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-latest8-010", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nyew: 23\nreed: 67\nvine: 91\nmaple: 24\nheath: 10\nbirch: 11\nbirch: 81\nkelp: 38\nWhich option is the latest value for birch?\n1. 11\n2. 10\n3. 23\n4. 81\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-latest8-011", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nyew: 64\nheath: 46\ngrove: 42\nquartz: 91\nslate: 33\npine: 61\npine: 85\nfern: 82\nWhich option is the latest value for pine?\n1. 46\n2. 61\n3. 64\n4. 85\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-latest8-012", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nquartz: 78\nelm: 80\nkelp: 99\njade: 24\npine: 41\namber: 50\namber: 65\nbirch: 88\nWhich option is the latest value for amber?\n1. 88\n2. 50\n3. 99\n4. 65\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-latest8-013", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\ngrove: 53\nquartz: 19\ncedar: 56\ncedar: 68\nbirch: 64\nlarch: 96\nmaple: 20\ndune: 17\nWhich option is the latest value for cedar?\n1. 68\n2. 53\n3. 96\n4. 56\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-latest8-014", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nwillow: 15\npine: 45\nmaple: 44\ndune: 17\nreed: 49\nreed: 18\niris: 72\number: 95\nWhich option is the latest value for reed?\n1. 44\n2. 49\n3. 18\n4. 45\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-latest8-015", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nfern: 21\nlarch: 46\namber: 82\nreed: 98\nwillow: 70\number: 33\ndune: 38\nwillow: 91\nWhich option is the latest value for willow?\n1. 38\n2. 91\n3. 46\n4. 70\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-latest8-016", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\njade: 22\namber: 92\nheath: 35\nbirch: 26\npine: 73\niris: 44\ndune: 11\namber: 59\nWhich option is the latest value for amber?\n1. 59\n2. 26\n3. 92\n4. 73\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-latest8-017", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\npine: 39\nelm: 49\nolive: 22\niris: 66\number: 72\nheath: 55\niris: 88\njade: 45\nWhich option is the latest value for iris?\n1. 66\n2. 39\n3. 72\n4. 88\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-latest8-018", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nreed: 79\nbirch: 57\ngrove: 80\niris: 15\nolive: 20\niris: 74\nlarch: 64\namber: 88\nWhich option is the latest value for iris?\n1. 74\n2. 20\n3. 15\n4. 64\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-latest8-019", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nreed: 83\nslate: 53\number: 61\nvine: 85\nfern: 51\nelm: 48\npine: 47\number: 21\nWhich option is the latest value for umber?\n1. 21\n2. 61\n3. 47\n4. 85\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-latest8-020", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\namber: 21\nvine: 28\nyew: 54\nlarch: 62\ncedar: 44\njade: 26\number: 75\namber: 35\nWhich option is the latest value for amber?\n1. 21\n2. 28\n3. 75\n4. 35\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-latest8-021", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nyew: 42\ndune: 73\nlarch: 44\njade: 40\nmaple: 68\nlarch: 30\npine: 47\ngrove: 13\nWhich option is the latest value for larch?\n1. 47\n2. 30\n3. 44\n4. 42\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-latest8-022", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nlarch: 28\nmaple: 22\nbirch: 91\nelm: 32\nwillow: 21\ncedar: 69\nyew: 49\nbirch: 40\nWhich option is the latest value for birch?\n1. 21\n2. 91\n3. 40\n4. 49\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-latest8-023", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nlarch: 43\npine: 15\ndune: 30\nmaple: 14\nreed: 86\nmaple: 96\nolive: 99\nkelp: 70\nWhich option is the latest value for maple?\n1. 99\n2. 70\n3. 96\n4. 14\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-latest8-024", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\npine: 42\nreed: 43\nslate: 76\njade: 94\nreed: 56\nlarch: 11\niris: 48\nquartz: 61\nWhich option is the latest value for reed?\n1. 43\n2. 42\n3. 48\n4. 56\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-latest8-025", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nreed: 51\nyew: 46\nlarch: 85\ncedar: 90\nvine: 78\nvine: 59\nwillow: 12\niris: 43\nWhich option is the latest value for vine?\n1. 78\n2. 59\n3. 85\n4. 51\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-latest8-026", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\npine: 66\nkelp: 17\nelm: 20\ncedar: 63\nelm: 50\nquartz: 75\nnettle: 94\number: 71\nWhich option is the latest value for elm?\n1. 75\n2. 20\n3. 66\n4. 50\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-latest8-027", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nthyme: 28\nwillow: 17\nfern: 60\nelm: 77\nbirch: 10\nelm: 46\namber: 69\npine: 37\nWhich option is the latest value for elm?\n1. 46\n2. 69\n3. 37\n4. 77\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-latest8-028", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nolive: 98\nmaple: 32\nelm: 50\number: 82\nnettle: 79\nslate: 78\ncedar: 63\nelm: 30\nWhich option is the latest value for elm?\n1. 30\n2. 50\n3. 98\n4. 63\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-latest8-029", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\njade: 77\niris: 30\nthyme: 40\nbirch: 71\nelm: 24\nquartz: 91\nquartz: 25\nyew: 65\nWhich option is the latest value for quartz?\n1. 91\n2. 25\n3. 65\n4. 40\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-latest8-030", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\nthyme: 60\njade: 75\nolive: 47\nmaple: 91\nnettle: 58\ncedar: 36\nnettle: 87\number: 41\nWhich option is the latest value for nettle?\n1. 87\n2. 47\n3. 41\n4. 58\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-latest8-031", + "task": "latest8", + "prompt": "Use the lookup table (oldest first).\njade: 39\npine: 26\nvine: 34\nmaple: 62\nlarch: 96\nheath: 51\nmaple: 17\ndune: 11\nWhich option is the latest value for maple?\n1. 51\n2. 62\n3. 17\n4. 96\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-arithmetic-000", + "task": "arithmetic", + "prompt": "What is 69 + 55?\n1. 124\n2. 134\n3. 114\n4. 123\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-arithmetic-001", + "task": "arithmetic", + "prompt": "What is 22 + 40?\n1. 63\n2. 72\n3. 62\n4. 52\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-arithmetic-002", + "task": "arithmetic", + "prompt": "What is 33 + 30?\n1. 73\n2. 53\n3. 63\n4. 62\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-arithmetic-003", + "task": "arithmetic", + "prompt": "What is 60 + 58?\n1. 119\n2. 128\n3. 108\n4. 118\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-arithmetic-004", + "task": "arithmetic", + "prompt": "What is 54 + 12?\n1. 56\n2. 66\n3. 76\n4. 65\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-arithmetic-005", + "task": "arithmetic", + "prompt": "What is 73 + 62?\n1. 136\n2. 135\n3. 145\n4. 125\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-arithmetic-006", + "task": "arithmetic", + "prompt": "What is 61 + 49?\n1. 111\n2. 120\n3. 110\n4. 100\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-arithmetic-007", + "task": "arithmetic", + "prompt": "What is 49 + 74?\n1. 133\n2. 113\n3. 122\n4. 123\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-arithmetic-008", + "task": "arithmetic", + "prompt": "What is 36 + 62?\n1. 88\n2. 99\n3. 108\n4. 98\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-arithmetic-009", + "task": "arithmetic", + "prompt": "What is 28 + 22?\n1. 60\n2. 49\n3. 40\n4. 50\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-arithmetic-010", + "task": "arithmetic", + "prompt": "What is 83 + 29?\n1. 112\n2. 102\n3. 111\n4. 122\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-arithmetic-011", + "task": "arithmetic", + "prompt": "What is 66 + 18?\n1. 74\n2. 84\n3. 85\n4. 94\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-arithmetic-012", + "task": "arithmetic", + "prompt": "What is 17 + 21?\n1. 39\n2. 38\n3. 48\n4. 28\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-arithmetic-013", + "task": "arithmetic", + "prompt": "What is 46 + 52?\n1. 98\n2. 99\n3. 88\n4. 108\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-arithmetic-014", + "task": "arithmetic", + "prompt": "What is 76 + 12?\n1. 98\n2. 78\n3. 87\n4. 88\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-arithmetic-015", + "task": "arithmetic", + "prompt": "What is 22 + 27?\n1. 50\n2. 49\n3. 59\n4. 39\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-arithmetic-016", + "task": "arithmetic", + "prompt": "What is 89 + 40?\n1. 129\n2. 119\n3. 139\n4. 130\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-arithmetic-017", + "task": "arithmetic", + "prompt": "What is 15 + 74?\n1. 79\n2. 88\n3. 99\n4. 89\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-arithmetic-018", + "task": "arithmetic", + "prompt": "What is 35 + 62?\n1. 107\n2. 87\n3. 97\n4. 98\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-arithmetic-019", + "task": "arithmetic", + "prompt": "What is 96 + 61?\n1. 157\n2. 167\n3. 147\n4. 158\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-arithmetic-020", + "task": "arithmetic", + "prompt": "What is 14 + 98?\n1. 102\n2. 112\n3. 111\n4. 122\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-arithmetic-021", + "task": "arithmetic", + "prompt": "What is 30 + 12?\n1. 43\n2. 52\n3. 32\n4. 42\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-arithmetic-022", + "task": "arithmetic", + "prompt": "What is 95 + 23?\n1. 118\n2. 119\n3. 128\n4. 108\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-arithmetic-023", + "task": "arithmetic", + "prompt": "What is 41 + 84?\n1. 135\n2. 126\n3. 125\n4. 115\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-arithmetic-024", + "task": "arithmetic", + "prompt": "What is 89 + 45?\n1. 144\n2. 134\n3. 135\n4. 124\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-arithmetic-025", + "task": "arithmetic", + "prompt": "What is 52 + 51?\n1. 104\n2. 103\n3. 113\n4. 93\nAnswer with only the option number.\nAnswer:", + "answer_index": 1 + }, + { + "id": "test-arithmetic-026", + "task": "arithmetic", + "prompt": "What is 29 + 51?\n1. 80\n2. 90\n3. 70\n4. 81\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-arithmetic-027", + "task": "arithmetic", + "prompt": "What is 20 + 28?\n1. 48\n2. 38\n3. 49\n4. 58\nAnswer with only the option number.\nAnswer:", + "answer_index": 0 + }, + { + "id": "test-arithmetic-028", + "task": "arithmetic", + "prompt": "What is 42 + 28?\n1. 80\n2. 60\n3. 70\n4. 71\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-arithmetic-029", + "task": "arithmetic", + "prompt": "What is 98 + 69?\n1. 166\n2. 157\n3. 167\n4. 177\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + }, + { + "id": "test-arithmetic-030", + "task": "arithmetic", + "prompt": "What is 48 + 35?\n1. 82\n2. 93\n3. 73\n4. 83\nAnswer with only the option number.\nAnswer:", + "answer_index": 3 + }, + { + "id": "test-arithmetic-031", + "task": "arithmetic", + "prompt": "What is 82 + 92?\n1. 164\n2. 184\n3. 174\n4. 175\nAnswer with only the option number.\nAnswer:", + "answer_index": 2 + } + ] +} diff --git a/results/lisa-effect-reproduction/real-model-preflight.json b/results/lisa-effect-reproduction/real-model-preflight.json new file mode 100644 index 0000000..8e5221c --- /dev/null +++ b/results/lisa-effect-reproduction/real-model-preflight.json @@ -0,0 +1,12 @@ +{ + "date": "2026-11-23", + "task": "lookup16", + "item": "fit-lookup16-000", + "recipient_layers": [19, 23], + "sample_tokens_including_answer": 158, + "native_hidden_max_abs_error_against_streaming_reference": 0.000020503997802734375, + "skipped_dense_qk_max_abs_difference": 0.0, + "finite_nonzero_huber_gradients_for_all_adapter_parameters": true, + "peak_rss_kib": 555036, + "scope": "One real Qwen3.5-2B fit sample, synthetic task; the backward path used attention distillation only." +} diff --git a/results/lisa-effect-reproduction/runtime.json b/results/lisa-effect-reproduction/runtime.json new file mode 100644 index 0000000..299566e --- /dev/null +++ b/results/lisa-effect-reproduction/runtime.json @@ -0,0 +1,40 @@ +{ + "runtime": "3.14.4", + "platform": "Linux", + "machine": "x86_64", + "logical_cpus": 2, + "cpu": "Intel(R) Xeon(R) Platinum", + "numpy": "2.5.4", + "torch": "2.15.0+cpu", + "tokenizers": "0.23.3", + "main_code_sha256": { + "lisa_effect.py": "8a3ecad71f23e3e8b8faf4a7c21c0c93f00fd0bffe14bdee6117921b548dce8a", + "lisa_tail.py": "4bd2c3c8690a8ae30cc1a9573ec17b7bbe25edf43a33507482719dc03cfeb9af", + "lisa_train.py": "d9b96258111e13a3c72483c954714b9ee56e1f308ec4371bafe47026246051a5", + "lisa_decode.py": "9c723fa245ee4dd8f4d0f9a0d7a3d15e3db3ae40db3fa82ea413ecd24fe20f06", + "lisa_decode_bench.py": "979e566a3391b9418b49beb10c200a48aac706ee95c145510850c929bcc2885a", + "lisa_effect_screen.py": "8aaf515d888f921e60082b69d898cb5037a160c5d09a584db2599f197c4aa74b" + }, + "audit_code_sha256": { + "lisa_effect_audit.py": "75c3445d96521daa2832ee96eb128383fc81f6914d491c2804a9337d1d6af35b", + "lisa_effect_answer_audit.py": "e1d70b10863dab1e13dfa9573c0d87fc6ca017039c3cf9b90f7628f3e7fe5664" + }, + "local_code_match": { + "lisa_effect.py": true, + "lisa_tail.py": true, + "lisa_train.py": true, + "lisa_decode.py": true, + "lisa_decode_bench.py": true, + "lisa_effect_screen.py": true, + "lisa_effect_audit.py": true, + "lisa_effect_answer_audit.py": true + }, + "phase_updates": { + "lisa_decode_bench.py": { + "initial_unexecuted_benchmark_sha256": "0b9867b3f17dbe6373627fa3901c2ea113fc7e0d690b4a358350cfaae62ef223", + "validated_remote_benchmark_sha256": "979e566a3391b9418b49beb10c200a48aac706ee95c145510850c929bcc2885a", + "reason": "Measure compute with resident projections separately from streamed execution", + "remote_numeric_tests": "4 passed; resident projection outputs compared with streamed output" + } + } +} diff --git a/results/lisa-effect-reproduction/screen-rows.json b/results/lisa-effect-reproduction/screen-rows.json new file mode 100644 index 0000000..038db48 --- /dev/null +++ b/results/lisa-effect-reproduction/screen-rows.json @@ -0,0 +1,1186 @@ +[ + { + "id": "screen-lookup8-000", + "task": "lookup8", + "gold": 0, + "scores": { + "native": { + "pred": 0, + "logits": [ + 20.697460174560547, + 18.13253402709961, + 17.23704719543457, + 18.382965087890625 + ], + "nll": 0.18826859815924024 + }, + "direct_23": { + "pred": 0, + "logits": [ + 21.718294143676758, + 19.000667572021484, + 17.991352081298828, + 18.993675231933594 + ], + "nll": 0.1446792172733815 + }, + "direct_19_23": { + "pred": 0, + "logits": [ + 20.506038665771484, + 18.599021911621094, + 16.00601577758789, + 16.803054809570312 + ], + "nll": 0.16913618866019675 + } + } + }, + { + "id": "screen-lookup8-001", + "task": "lookup8", + "gold": 1, + "scores": { + "native": { + "pred": 1, + "logits": [ + 17.993316650390625, + 20.213001251220703, + 17.064828872680664, + 16.967247009277344 + ], + "nll": 0.1743843647157064 + }, + "direct_23": { + "pred": 1, + "logits": [ + 18.686172485351562, + 21.39635467529297, + 17.978986740112305, + 17.087114334106445 + ], + "nll": 0.10684979025862162 + }, + "direct_19_23": { + "pred": 1, + "logits": [ + 17.07736587524414, + 20.15271759033203, + 16.02193832397461, + 15.23991870880127 + ], + "nll": 0.06728065084290336 + } + } + }, + { + "id": "screen-lookup8-002", + "task": "lookup8", + "gold": 2, + "scores": { + "native": { + "pred": 2, + "logits": [ + 17.969684600830078, + 19.48763656616211, + 20.10470199584961, + 18.060754776000977 + ], + "nll": 0.580697370729272 + }, + "direct_23": { + "pred": 2, + "logits": [ + 18.40570068359375, + 20.240917205810547, + 21.170637130737305, + 18.763084411621094 + ], + "nll": 0.4367568411604914 + }, + "direct_19_23": { + "pred": 2, + "logits": [ + 16.879804611206055, + 19.079893112182617, + 19.610210418701172, + 16.44618797302246 + ], + "nll": 0.5281938127388521 + } + } + }, + { + "id": "screen-lookup8-003", + "task": "lookup8", + "gold": 2, + "scores": { + "native": { + "pred": 2, + "logits": [ + 17.80279541015625, + 17.356037139892578, + 20.488859176635742, + 17.542217254638672 + ], + "nll": 0.15208485144998818 + }, + "direct_23": { + "pred": 2, + "logits": [ + 18.156017303466797, + 17.959136962890625, + 21.564891815185547, + 18.242450714111328 + ], + "nll": 0.09195001851948703 + }, + "direct_19_23": { + "pred": 2, + "logits": [ + 15.852276802062988, + 15.687746047973633, + 20.15203285217285, + 15.23642349243164 + ], + "nll": 0.031901708322191524 + } + } + }, + { + "id": "screen-lookup8-004", + "task": "lookup8", + "gold": 1, + "scores": { + "native": { + "pred": 1, + "logits": [ + 18.573863983154297, + 20.055904388427734, + 16.86414337158203, + 16.80960464477539 + ], + "nll": 0.26788061162177357 + }, + "direct_23": { + "pred": 1, + "logits": [ + 19.246421813964844, + 21.05280303955078, + 17.82854461669922, + 17.277767181396484 + ], + "nll": 0.20454688401779464 + }, + "direct_19_23": { + "pred": 1, + "logits": [ + 17.159854888916016, + 19.307003021240234, + 15.381502151489258, + 14.98310375213623 + ], + "nll": 0.1395855834527282 + } + } + }, + { + "id": "screen-lookup8-005", + "task": "lookup8", + "gold": 3, + "scores": { + "native": { + "pred": 3, + "logits": [ + 16.94013023376465, + 16.542648315429688, + 16.951459884643555, + 19.380550384521484 + ], + "nll": 0.21009036362156408 + }, + "direct_23": { + "pred": 3, + "logits": [ + 17.16890525817871, + 16.96182632446289, + 17.722496032714844, + 20.468090057373047 + ], + "nll": 0.12321909594288272 + }, + "direct_19_23": { + "pred": 3, + "logits": [ + 15.292197227478027, + 15.98039436340332, + 16.50947380065918, + 19.044109344482422 + ], + "nll": 0.13930728560993444 + } + } + }, + { + "id": "screen-lookup8-006", + "task": "lookup8", + "gold": 3, + "scores": { + "native": { + "pred": 3, + "logits": [ + 17.11652374267578, + 16.14908218383789, + 16.275728225708008, + 19.959869384765625 + ], + "nll": 0.10027963923007377 + }, + "direct_23": { + "pred": 3, + "logits": [ + 17.39360809326172, + 16.45057487487793, + 17.1256103515625, + 21.291948318481445 + ], + "nll": 0.04275358876917679 + }, + "direct_19_23": { + "pred": 3, + "logits": [ + 15.398442268371582, + 14.57382869720459, + 14.703670501708984, + 19.809391021728516 + ], + "nll": 0.023256900522234503 + } + } + }, + { + "id": "screen-lookup8-007", + "task": "lookup8", + "gold": 0, + "scores": { + "native": { + "pred": 0, + "logits": [ + 20.262374877929688, + 17.43246078491211, + 15.70324420928955, + 17.130813598632812 + ], + "nll": 0.10718366130955204 + }, + "direct_23": { + "pred": 0, + "logits": [ + 21.62911605834961, + 18.648624420166016, + 17.04732894897461, + 17.904937744140625 + ], + "nll": 0.08170659308651906 + }, + "direct_19_23": { + "pred": 0, + "logits": [ + 20.235082626342773, + 17.353370666503906, + 15.869649887084961, + 16.078411102294922 + ], + "nll": 0.08103374813177666 + } + } + }, + { + "id": "screen-lookup16-000", + "task": "lookup16", + "gold": 3, + "scores": { + "native": { + "pred": 3, + "logits": [ + 16.88872528076172, + 16.14708709716797, + 16.960010528564453, + 20.079208374023438 + ], + "nll": 0.09979704099154674 + }, + "direct_23": { + "pred": 3, + "logits": [ + 17.269792556762695, + 16.450607299804688, + 17.859764099121094, + 21.387218475341797 + ], + "nll": 0.051495908317470196 + }, + "direct_19_23": { + "pred": 3, + "logits": [ + 15.100671768188477, + 14.745397567749023, + 16.411354064941406, + 19.365415573120117 + ], + "nll": 0.07328358868863205 + } + } + }, + { + "id": "screen-lookup16-001", + "task": "lookup16", + "gold": 0, + "scores": { + "native": { + "pred": 0, + "logits": [ + 20.488510131835938, + 17.09787368774414, + 16.0688533782959, + 17.28851318359375 + ], + "nll": 0.08295040432784617 + }, + "direct_23": { + "pred": 0, + "logits": [ + 21.710893630981445, + 18.390300750732422, + 17.250085830688477, + 18.02066421508789 + ], + "nll": 0.0701328789746114 + }, + "direct_19_23": { + "pred": 0, + "logits": [ + 19.679229736328125, + 17.18025016784668, + 16.085111618041992, + 16.89003562927246 + ], + "nll": 0.15796435327756697 + } + } + }, + { + "id": "screen-lookup16-002", + "task": "lookup16", + "gold": 1, + "scores": { + "native": { + "pred": 1, + "logits": [ + 18.018705368041992, + 20.121662139892578, + 16.618919372558594, + 16.30113983154297 + ], + "nll": 0.1605239648974255 + }, + "direct_23": { + "pred": 1, + "logits": [ + 19.12122344970703, + 21.744884490966797, + 18.049671173095703, + 17.430601119995117 + ], + "nll": 0.10504005561457674 + }, + "direct_19_23": { + "pred": 1, + "logits": [ + 17.223630905151367, + 20.322059631347656, + 15.973359107971191, + 15.117138862609863 + ], + "nll": 0.06159650102341985 + } + } + }, + { + "id": "screen-lookup16-003", + "task": "lookup16", + "gold": 0, + "scores": { + "native": { + "pred": 0, + "logits": [ + 20.98879051208496, + 17.163719177246094, + 15.632684707641602, + 16.214885711669922 + ], + "nll": 0.034385443742909416 + }, + "direct_23": { + "pred": 0, + "logits": [ + 22.326194763183594, + 18.373859405517578, + 16.568424224853516, + 17.02125358581543 + ], + "nll": 0.026967995342591422 + }, + "direct_19_23": { + "pred": 0, + "logits": [ + 20.691299438476562, + 17.465137481689453, + 15.097968101501465, + 16.2298641204834 + ], + "nll": 0.05351991302140391 + } + } + }, + { + "id": "screen-lookup16-004", + "task": "lookup16", + "gold": 1, + "scores": { + "native": { + "pred": 1, + "logits": [ + 17.79214859008789, + 20.568031311035156, + 17.15114974975586, + 16.350915908813477 + ], + "nll": 0.10422502879557527 + }, + "direct_23": { + "pred": 1, + "logits": [ + 18.620220184326172, + 21.931278228759766, + 18.35892677307129, + 17.025081634521484 + ], + "nll": 0.06949608548148234 + }, + "direct_19_23": { + "pred": 1, + "logits": [ + 17.17837142944336, + 20.638917922973633, + 16.43758773803711, + 15.169323921203613 + ], + "nll": 0.04936254889545211 + } + } + }, + { + "id": "screen-lookup16-005", + "task": "lookup16", + "gold": 3, + "scores": { + "native": { + "pred": 3, + "logits": [ + 17.53479766845703, + 18.68415069580078, + 16.84090232849121, + 19.94956398010254 + ], + "nll": 0.34795716558404166 + }, + "direct_23": { + "pred": 3, + "logits": [ + 18.01866340637207, + 19.504764556884766, + 18.044052124023438, + 21.36577606201172 + ], + "nll": 0.20440231236331385 + }, + "direct_19_23": { + "pred": 1, + "logits": [ + 16.836557388305664, + 19.233001708984375, + 16.32568359375, + 18.974531173706055 + ], + "nll": 0.9096987131989565 + } + } + }, + { + "id": "screen-lookup16-006", + "task": "lookup16", + "gold": 2, + "scores": { + "native": { + "pred": 2, + "logits": [ + 16.98921775817871, + 16.484724044799805, + 19.493764877319336, + 15.481636047363281 + ], + "nll": 0.13901941414050611 + }, + "direct_23": { + "pred": 2, + "logits": [ + 17.624340057373047, + 17.223094940185547, + 20.87921905517578, + 16.869972229003906 + ], + "nll": 0.07933321586813946 + }, + "direct_19_23": { + "pred": 2, + "logits": [ + 15.367234230041504, + 15.439410209655762, + 19.528045654296875, + 15.187620162963867 + ], + "nll": 0.044388081510245314 + } + } + }, + { + "id": "screen-lookup16-007", + "task": "lookup16", + "gold": 2, + "scores": { + "native": { + "pred": 2, + "logits": [ + 17.033109664916992, + 16.85562515258789, + 19.78887939453125, + 15.847414016723633 + ], + "nll": 0.12769232460464508 + }, + "direct_23": { + "pred": 2, + "logits": [ + 17.37920379638672, + 17.565170288085938, + 21.109859466552734, + 17.02695655822754 + ], + "nll": 0.06739054010574463 + }, + "direct_19_23": { + "pred": 2, + "logits": [ + 15.072863578796387, + 15.016660690307617, + 19.528406143188477, + 14.411680221557617 + ], + "nll": 0.028187879817352268 + } + } + }, + { + "id": "screen-latest8-000", + "task": "latest8", + "gold": 0, + "scores": { + "native": { + "pred": 0, + "logits": [ + 20.48825454711914, + 19.02859115600586, + 17.22644805908203, + 18.19845962524414 + ], + "nll": 0.3162118050706191 + }, + "direct_23": { + "pred": 0, + "logits": [ + 21.713150024414062, + 20.182950973510742, + 18.389938354492188, + 19.083599090576172 + ], + "nll": 0.2811409618603946 + }, + "direct_19_23": { + "pred": 0, + "logits": [ + 20.123878479003906, + 19.056987762451172, + 17.07024383544922, + 17.242122650146484 + ], + "nll": 0.36969980568397176 + } + } + }, + { + "id": "screen-latest8-001", + "task": "latest8", + "gold": 2, + "scores": { + "native": { + "pred": 2, + "logits": [ + 19.185199737548828, + 18.878978729248047, + 20.27124786376953, + 18.270465850830078 + ], + "nll": 0.5430728817198087 + }, + "direct_23": { + "pred": 2, + "logits": [ + 19.902921676635742, + 19.681293487548828, + 21.37285804748535, + 19.145679473876953 + ], + "nll": 0.4200275035566996 + }, + "direct_19_23": { + "pred": 2, + "logits": [ + 17.883634567260742, + 17.9761962890625, + 19.26708984375, + 17.797462463378906 + ], + "nll": 0.5628943384753597 + } + } + }, + { + "id": "screen-latest8-002", + "task": "latest8", + "gold": 2, + "scores": { + "native": { + "pred": 1, + "logits": [ + 19.411632537841797, + 20.273160934448242, + 19.094589233398438, + 17.588376998901367 + ], + "nll": 1.7655078325020277 + }, + "direct_23": { + "pred": 1, + "logits": [ + 20.324417114257812, + 21.398067474365234, + 20.202526092529297, + 18.477771759033203 + ], + "nll": 1.7251199975768792 + }, + "direct_19_23": { + "pred": 1, + "logits": [ + 18.58944320678711, + 19.974435806274414, + 18.346458435058594, + 16.285293579101562 + ], + "nll": 2.01435843303085 + } + } + }, + { + "id": "screen-latest8-003", + "task": "latest8", + "gold": 1, + "scores": { + "native": { + "pred": 1, + "logits": [ + 18.382789611816406, + 20.32406997680664, + 16.999725341796875, + 17.628414154052734 + ], + "nll": 0.2207521149768965 + }, + "direct_23": { + "pred": 1, + "logits": [ + 19.164691925048828, + 21.479473114013672, + 18.02234649658203, + 18.22458267211914 + ], + "nll": 0.15605718716187056 + }, + "direct_19_23": { + "pred": 1, + "logits": [ + 17.740764617919922, + 20.329431533813477, + 16.395824432373047, + 16.229106903076172 + ], + "nll": 0.10549482572956492 + } + } + }, + { + "id": "screen-latest8-004", + "task": "latest8", + "gold": 1, + "scores": { + "native": { + "pred": 0, + "logits": [ + 20.318523406982422, + 20.134471893310547, + 18.298242568969727, + 18.965839385986328 + ], + "nll": 0.9829345877203579 + }, + "direct_23": { + "pred": 0, + "logits": [ + 21.20392608642578, + 21.05996322631836, + 19.185420989990234, + 19.673099517822266 + ], + "nll": 0.9392742179943205 + }, + "direct_19_23": { + "pred": 1, + "logits": [ + 19.751558303833008, + 19.838382720947266, + 17.46748924255371, + 17.94879913330078 + ], + "nll": 0.7707422952809324 + } + } + }, + { + "id": "screen-latest8-005", + "task": "latest8", + "gold": 3, + "scores": { + "native": { + "pred": 3, + "logits": [ + 17.792476654052734, + 17.54779815673828, + 17.14533233642578, + 20.314836502075195 + ], + "nll": 0.16986281051144303 + }, + "direct_23": { + "pred": 3, + "logits": [ + 18.431991577148438, + 18.296232223510742, + 18.052762985229492, + 21.479644775390625 + ], + "nll": 0.11457992750260004 + }, + "direct_19_23": { + "pred": 3, + "logits": [ + 16.172147750854492, + 16.870895385742188, + 15.963250160217285, + 19.890804290771484 + ], + "nll": 0.0887102557959949 + } + } + }, + { + "id": "screen-latest8-006", + "task": "latest8", + "gold": 0, + "scores": { + "native": { + "pred": 0, + "logits": [ + 21.09866714477539, + 19.31722640991211, + 18.00760269165039, + 19.855213165283203 + ], + "nll": 0.40695421204076965 + }, + "direct_23": { + "pred": 0, + "logits": [ + 22.25229263305664, + 20.419591903686523, + 19.064666748046875, + 20.844146728515625 + ], + "nll": 0.36869532316333675 + }, + "direct_19_23": { + "pred": 0, + "logits": [ + 21.04738998413086, + 19.66586685180664, + 17.489246368408203, + 19.02706527709961 + ], + "nll": 0.34521938450031087 + } + } + }, + { + "id": "screen-latest8-007", + "task": "latest8", + "gold": 3, + "scores": { + "native": { + "pred": 3, + "logits": [ + 17.785877227783203, + 18.612308502197266, + 16.874256134033203, + 19.940074920654297 + ], + "nll": 0.3560511196193694 + }, + "direct_23": { + "pred": 3, + "logits": [ + 18.56637954711914, + 19.643047332763672, + 18.121681213378906, + 21.367156982421875 + ], + "nll": 0.24533124790591998 + }, + "direct_19_23": { + "pred": 3, + "logits": [ + 16.443283081054688, + 17.8532657623291, + 15.948772430419922, + 19.68533706665039 + ], + "nll": 0.2013076983721156 + } + } + }, + { + "id": "screen-arithmetic-000", + "task": "arithmetic", + "gold": 2, + "scores": { + "native": { + "pred": 0, + "logits": [ + 21.679140090942383, + 20.980295181274414, + 20.54197120666504, + 20.532123565673828 + ], + "nll": 1.8958546372911016 + }, + "direct_23": { + "pred": 0, + "logits": [ + 22.5401668548584, + 21.86333465576172, + 21.388681411743164, + 21.146757125854492 + ], + "nll": 1.8802982958227012 + }, + "direct_19_23": { + "pred": 0, + "logits": [ + 20.587997436523438, + 20.481082916259766, + 19.995311737060547, + 19.891740798950195 + ], + "nll": 1.6744538161832914 + } + } + }, + { + "id": "screen-arithmetic-001", + "task": "arithmetic", + "gold": 2, + "scores": { + "native": { + "pred": 0, + "logits": [ + 21.53711700439453, + 21.3193359375, + 20.240156173706055, + 19.73122787475586 + ], + "nll": 2.1043251929197027 + }, + "direct_23": { + "pred": 0, + "logits": [ + 22.545793533325195, + 22.452268600463867, + 21.374902725219727, + 20.46916389465332 + ], + "nll": 2.0236698535596425 + }, + "direct_19_23": { + "pred": 1, + "logits": [ + 20.53709602355957, + 20.710960388183594, + 19.288074493408203, + 18.25749969482422 + ], + "nll": 2.196425171642886 + } + } + }, + { + "id": "screen-arithmetic-002", + "task": "arithmetic", + "gold": 1, + "scores": { + "native": { + "pred": 0, + "logits": [ + 21.6807861328125, + 21.088253021240234, + 20.17969512939453, + 19.821975708007812 + ], + "nll": 1.2509178549084687 + }, + "direct_23": { + "pred": 0, + "logits": [ + 22.524755477905273, + 21.986984252929688, + 20.931936264038086, + 20.321147918701172 + ], + "nll": 1.1784687462927046 + }, + "direct_19_23": { + "pred": 1, + "logits": [ + 20.465808868408203, + 20.511062622070312, + 19.321434020996094, + 18.32925796508789 + ], + "nll": 0.8641241765862162 + } + } + }, + { + "id": "screen-arithmetic-003", + "task": "arithmetic", + "gold": 1, + "scores": { + "native": { + "pred": 1, + "logits": [ + 21.122547149658203, + 21.34246826171875, + 20.70867919921875, + 20.044897079467773 + ], + "nll": 0.9579523991962695 + }, + "direct_23": { + "pred": 1, + "logits": [ + 21.866296768188477, + 22.33220863342285, + 21.721757888793945, + 20.74059295654297 + ], + "nll": 0.8646879173074673 + }, + "direct_19_23": { + "pred": 1, + "logits": [ + 19.823379516601562, + 20.549484252929688, + 20.15471839904785, + 18.400344848632812 + ], + "nll": 0.8216336440219969 + } + } + }, + { + "id": "screen-arithmetic-004", + "task": "arithmetic", + "gold": 0, + "scores": { + "native": { + "pred": 0, + "logits": [ + 21.85274887084961, + 21.080223083496094, + 19.965991973876953, + 20.453893661499023 + ], + "nll": 0.6207308008329804 + }, + "direct_23": { + "pred": 0, + "logits": [ + 22.839492797851562, + 22.0347900390625, + 20.95907974243164, + 21.18810272216797 + ], + "nll": 0.5830705950657702 + }, + "direct_19_23": { + "pred": 0, + "logits": [ + 21.061513900756836, + 20.75944709777832, + 19.17621612548828, + 18.908721923828125 + ], + "nll": 0.6967566197153197 + } + } + }, + { + "id": "screen-arithmetic-005", + "task": "arithmetic", + "gold": 3, + "scores": { + "native": { + "pred": 0, + "logits": [ + 21.582143783569336, + 21.089305877685547, + 20.387611389160156, + 20.789596557617188 + ], + "nll": 1.6539280417608495 + }, + "direct_23": { + "pred": 0, + "logits": [ + 22.518150329589844, + 22.081573486328125, + 21.37140655517578, + 21.587909698486328 + ], + "nll": 1.7882126509472052 + }, + "direct_19_23": { + "pred": 0, + "logits": [ + 20.543651580810547, + 20.318185806274414, + 19.306381225585938, + 19.54574203491211 + ], + "nll": 1.896837969683311 + } + } + }, + { + "id": "screen-arithmetic-006", + "task": "arithmetic", + "gold": 3, + "scores": { + "native": { + "pred": 0, + "logits": [ + 20.83462905883789, + 20.510099411010742, + 20.457305908203125, + 20.674678802490234 + ], + "nll": 1.341906845703143 + }, + "direct_23": { + "pred": 0, + "logits": [ + 21.454994201660156, + 21.409591674804688, + 21.38341522216797, + 21.451438903808594 + ], + "nll": 1.3601598745372243 + }, + "direct_19_23": { + "pred": 0, + "logits": [ + 20.444381713867188, + 19.630416870117188, + 19.463001251220703, + 19.576095581054688 + ], + "nll": 1.6736727051787526 + } + } + }, + { + "id": "screen-arithmetic-007", + "task": "arithmetic", + "gold": 0, + "scores": { + "native": { + "pred": 0, + "logits": [ + 21.727981567382812, + 20.88080596923828, + 20.016000747680664, + 19.921415328979492 + ], + "nll": 0.5728697175954665 + }, + "direct_23": { + "pred": 0, + "logits": [ + 22.749502182006836, + 21.910072326660156, + 20.962127685546875, + 20.60371971130371 + ], + "nll": 0.5401896313612511 + }, + "direct_19_23": { + "pred": 0, + "logits": [ + 21.038467407226562, + 20.210037231445312, + 19.096824645996094, + 18.499927520751953 + ], + "nll": 0.5063259482237896 + } + } + } +] diff --git a/results/lisa-effect-reproduction/screen-summary.json b/results/lisa-effect-reproduction/screen-summary.json new file mode 100644 index 0000000..79bc657 --- /dev/null +++ b/results/lisa-effect-reproduction/screen-summary.json @@ -0,0 +1,82 @@ +{ + "lookup8": { + "native": { + "n": 8, + "correct": 8, + "native_wins_lost": 0, + "nll": 0.22260868260464628 + }, + "direct_23": { + "n": 8, + "correct": 8, + "native_wins_lost": 0, + "nll": 0.15405775362854435 + }, + "direct_19_23": { + "n": 8, + "correct": 8, + "native_wins_lost": 0, + "nll": 0.1474619847851022 + } + }, + "lookup16": { + "native": { + "n": 8, + "correct": 8, + "native_wins_lost": 0, + "nll": 0.137068848385562 + }, + "direct_23": { + "n": 8, + "correct": 8, + "native_wins_lost": 0, + "nll": 0.08428237400849126 + }, + "direct_19_23": { + "n": 8, + "correct": 7, + "native_wins_lost": 1, + "nll": 0.17225019742912862 + } + }, + "latest8": { + "native": { + "n": 8, + "correct": 6, + "native_wins_lost": 0, + "nll": 0.5951684205201615 + }, + "direct_23": { + "n": 8, + "correct": 6, + "native_wins_lost": 0, + "nll": 0.5312782958402527 + }, + "direct_19_23": { + "n": 8, + "correct": 7, + "native_wins_lost": 0, + "nll": 0.5573033796086375 + } + }, + "arithmetic": { + "native": { + "n": 8, + "correct": 3, + "native_wins_lost": 0, + "nll": 1.2998106862759977 + }, + "direct_23": { + "n": 8, + "correct": 3, + "native_wins_lost": 0, + "nll": 1.2773446956117458 + }, + "direct_19_23": { + "n": 8, + "correct": 4, + "native_wins_lost": 0, + "nll": 1.2912787564044454 + } + } +} diff --git a/results/lisa-effect-reproduction/selection.json b/results/lisa-effect-reproduction/selection.json new file mode 100644 index 0000000..24bf5bd --- /dev/null +++ b/results/lisa-effect-reproduction/selection.json @@ -0,0 +1,13 @@ +{ + "task": "lookup16", + "sites": [ + 19, + 23 + ], + "fixed_problems_sha256": "34252a9e02e79c0e0d786ee8b90bb0c5a4fe22e97852929fedf73db7b6dc7826", + "source_sha256": { + "manifest.json": "28efbaf94a5034333339a35f08ead151459a7d20c6c2d2f07a451e7f3bf154de", + "model_config.json": "ed1c1723241f23f7f4e23430759cbd7dcfb4103cbdfe052bfe7626b57c2615b4", + "tokenizer.json": "5f9e4d4901a92b997e463c1f46055088b6cca5ca61a6522d1b9f64c4bb81cb42" + } +} diff --git a/tests/test_lisa_effect_audit.py b/tests/test_lisa_effect_audit.py new file mode 100644 index 0000000..dfd10c9 --- /dev/null +++ b/tests/test_lisa_effect_audit.py @@ -0,0 +1,30 @@ +"""Check answer-only metrics and isolate recovery from newly lost items.""" +import unittest + +import numpy as np +import torch +from torch.nn import functional as F + +from crossqkv.lisa_effect_answer_audit import vocabulary_scores +from crossqkv.lisa_effect_audit import paired +from tests.test_lisa_tail import Tensor + + +class EffectAuditTests(unittest.TestCase): + def test_paired_rescue_excludes_natively_wrong_items(self): + native, direct, candidate = (np.array(x, dtype=bool) for x in + [(1, 1, 1, 0), (0, 0, 1, 1), (1, 0, 0, 1)]) + result = paired(native, direct, candidate) + self.assertEqual(result['native_correct_lost_by_direct'], 2) + self.assertEqual(result['rescued'], 1) + self.assertEqual(result['newly_lost_among_native_and_direct_correct'], 1) + self.assertEqual(result['accuracy_delta_vs_direct'], 0) + + def test_streamed_answer_scores_match_full_reference(self): + g = torch.Generator().manual_seed(9) + h, w = torch.randn(4, 6, generator=g), torch.randn(1033, 6, generator=g) + target = torch.tensor([2, 1032, 22, 1024]) + actual, loss = vocabulary_scores(h, target, Tensor(w.numpy())) + logits = F.linear(h, w) + torch.testing.assert_close(actual, logits.argmax(-1)) + torch.testing.assert_close(loss, F.cross_entropy(logits, target, reduction='none')) diff --git a/tests/test_lisa_effect_resume.py b/tests/test_lisa_effect_resume.py new file mode 100644 index 0000000..c446758 --- /dev/null +++ b/tests/test_lisa_effect_resume.py @@ -0,0 +1,62 @@ +"""Check exact epoch resume through the actual LiSA training entry point.""" +import json +from pathlib import Path +from tempfile import TemporaryDirectory +import unittest +from unittest.mock import patch + +import numpy as np +import torch + +from crossqkv.lisa_effect import train +from functional.model import PREFIX +from functional.reference_check import ArrayLM +from tests.test_lisa_tail import Tensor + + +class TrainingResumeTests(unittest.TestCase): + def test_checkpoint_resume_preserves_all_selected_outputs(self): + rng = np.random.default_rng(22) + + def rand(shape): + return (.13*rng.standard_normal(shape)).astype('f4') + + torch.set_num_threads(1) + c = {'rms_norm_eps': 1e-6, 'layer_types': ['full_attention'], 'hidden_size': 8, + 'num_attention_heads': 2, 'num_key_value_heads': 1, 'head_dim': 8, + 'rope_parameters': {'rope_theta': 10000., 'partial_rotary_factor': .5}} + shapes = {'input_layernorm': (8,), 'post_attention_layernorm': (8,), + 'self_attn.q_proj': (32, 8), 'self_attn.k_proj': (8, 8), + 'self_attn.v_proj': (8, 8), 'self_attn.o_proj': (8, 16), + 'self_attn.q_norm': (8,), 'self_attn.k_norm': (8,), + 'mlp.gate_proj': (13, 8), 'mlp.up_proj': (13, 8), 'mlp.down_proj': (8, 13)} + weights = {f'layers.0.{k}.weight': rand(v) for k, v in shapes.items()} + weights.update({'embed_tokens.weight': rand((12,8)), 'norm.weight': rand((8,))}) + model = ArrayLM(weights, c) + model.tensors = {PREFIX+k: Tensor(v) for k,v in weights.items()} + with TemporaryDirectory() as directory: + p = Path(directory) + cache, out = p/'cache', p/'out' + cache.mkdir() + out.mkdir() + (p/'model_config.json').write_text(json.dumps(c)) + (cache/'selection.json').write_text(json.dumps({'sites':[0], 'task':'fixture', + 'source_sha256':{}})) + labels = np.arange(1, 5, dtype=np.int64) + for split, count in [('fit',12), ('validation',12), ('test',32)]: + for i in range(0, count, 4): + ids = rng.integers(1, 12, size=(4, 4)) + gold = rng.integers(0, 4, size=4) + ids[:, -1] = labels[gold] + expected, _ = model.forward(ids) + np.savez(cache/f'{split}-{i:03}.npz', ids=ids, lengths=np.full(4,4), + labels=labels, gold=gold, residual=model.embedding(ids), + donor=rand((4,2,4,4)), expected=expected, + names=[f'{split}-{k}' for k in range(i,i+4)]) + with patch('functional.model.StreamingLM', return_value=model), patch('builtins.print'): + train(p, cache, out, 1) + before = (out/'test-items.json').read_bytes() + lines = (out/'trace.json').read_bytes() + train(p, cache, out, 1, resume=True) + self.assertEqual(before, (out/'test-items.json').read_bytes()) + self.assertEqual(lines, (out/'trace.json').read_bytes()) diff --git a/tests/test_lisa_effect_screen.py b/tests/test_lisa_effect_screen.py new file mode 100644 index 0000000..c96c022 --- /dev/null +++ b/tests/test_lisa_effect_screen.py @@ -0,0 +1,53 @@ +"""Prove shared-prefix replay matches the original replicated-batch screen.""" +import unittest + +import numpy as np +from tokenizers import Tokenizer +from tokenizers.models import WordLevel +from tokenizers.pre_tokenizers import Whitespace + +from crossqkv.lisa_effect_screen import MODES, ScreeningModel, evaluate, problems +from functional.model import PREFIX +from functional.reference_check import ArrayLM + + +class ArrayTensor: + def __init__(self, values): + self.raw = values + self.shape = values.shape + self.dtype = 'F32' + + def evict(self): + pass + + +class TinyScreen(ScreeningModel, ArrayLM): + pass + + +class ScreenTests(unittest.TestCase): + def test_replay_preserves_all_three_arms(self): + rng = np.random.default_rng(11) + cfg = {'rms_norm_eps': 1e-6, 'layer_types': ['full_attention']*24, + 'num_attention_heads': 2, 'num_key_value_heads': 1, 'head_dim': 8, + 'rope_parameters': {'rope_theta': 10000., 'partial_rotary_factor': .5}} + rand = lambda shape: (.12*rng.standard_normal(shape)).astype('f4') + weights = {'norm.weight': rand((8,)), 'embed_tokens.weight': rand((15, 8))} + shapes = {'input_layernorm': (8,), 'post_attention_layernorm': (8,), + 'self_attn.q_proj': (32, 8), 'self_attn.k_proj': (8, 8), + 'self_attn.v_proj': (8, 8), 'self_attn.o_proj': (8, 16), + 'self_attn.q_norm': (8,), 'self_attn.k_norm': (8,), + 'mlp.gate_proj': (13, 8), 'mlp.up_proj': (13, 8), 'mlp.down_proj': (8, 13)} + weights.update({f'layers.{i}.{k}.weight': rand(v) for i in range(24) for k,v in shapes.items()}) + model = TinyScreen(weights, cfg) + model.tensors = {PREFIX+k: ArrayTensor(v) for k,v in weights.items()} + tok = Tokenizer(WordLevel({'[UNK]': 0, **{str(i): i for i in range(1, 10)}}, unk_token='[UNK]')) + tok.pre_tokenizer = Whitespace() + examples = problems('screen', 2) + originals = evaluate(model, tok, examples) + model.reuse_prefix = True + replay = evaluate(model, tok, examples) + for orig, new in zip(originals, replay): + for key in MODES: + np.testing.assert_allclose(orig['scores'][key]['logits'], + new['scores'][key]['logits'], atol=1e-6) diff --git a/tests/test_lisa_tail.py b/tests/test_lisa_tail.py new file mode 100644 index 0000000..8373cbb --- /dev/null +++ b/tests/test_lisa_tail.py @@ -0,0 +1,138 @@ +"""Check streamed frozen gradients and the Torch tail against the CPU reference.""" +import unittest + +import numpy as np +import torch +from torch.nn import functional as F + +from crossqkv.lisa_decode import AttentionSiteCache +from crossqkv.lisa_decode_bench import ResidentSite, timed_site +from crossqkv.lisa_tail import FrozenLinear, TorchTail, gated_delta, rotate +from crossqkv.lisa_train import LearnableSharingAttention +from functional.model import PREFIX, delta_rule, rope +from functional.reference_check import ArrayLM + + +class Tensor: + def __init__(self, value): + self.value = value + self.shape = value.shape + + def read(self, selection): + return self.value.ravel()[selection] + + def evict(self): + pass + + +class TailTests(unittest.TestCase): + def test_frozen_rows_and_input_gradient(self): + torch.manual_seed(4) + x = torch.randn(2, 3, 5, requires_grad=True) + w = torch.randn(14, 5) + actual = FrozenLinear.apply(x, Tensor(w.numpy()), 2, 11) + dense = F.linear(x, w[2:11]) + torch.testing.assert_close(actual, dense) + torch.testing.assert_close(torch.autograd.grad(actual.square().sum(), x)[0], + torch.autograd.grad(dense.square().sum(), x)[0]) + + def test_rotary_and_gated_delta(self): + rng = np.random.default_rng(8) + q, k, v = [rng.normal(size=(2, 5, 2, 8)).astype('f4') for _ in range(3)] + g = -np.abs(rng.normal(size=(2, 5, 2)).astype('f4')) + b = rng.uniform(size=(2, 5, 2)).astype('f4') + tx = torch.tensor(q) + torch.testing.assert_close(rotate(tx, 10000000., .5), + torch.tensor(rope(q, 10000000., .5))) + actual = gated_delta(*map(torch.tensor, (q, k, v, g, b))) + torch.testing.assert_close(actual, torch.tensor(delta_rule(q, k, v, g, b)[0])) + + def test_two_recipient_forward_parity_and_both_get_gradients(self): + rng = np.random.default_rng(5) + cfg = {'rms_norm_eps': 1e-6, 'layer_types': ['full_attention', 'linear_attention', + 'full_attention'], 'num_attention_heads': 2, 'num_key_value_heads': 1, + 'head_dim': 8, 'linear_num_key_heads': 1, 'linear_num_value_heads': 2, + 'linear_key_head_dim': 4, 'linear_value_head_dim': 4, + 'rope_parameters': {'rope_theta': 10000., 'partial_rotary_factor': .5}} + + def rand(*shape): + return (rng.normal(size=shape) * .2).astype('f4') + + a = {'norm.weight': rand(8), 'embed_tokens.weight': rand(10, 8)} + for i, kind in enumerate(cfg['layer_types']): + names = {'input_layernorm': (8,), 'post_attention_layernorm': (8,), + 'mlp.gate_proj': (12, 8), 'mlp.up_proj': (12, 8), 'mlp.down_proj': (8, 12)} + if kind == 'full_attention': + names.update({'self_attn.q_proj': (32, 8), 'self_attn.k_proj': (8, 8), + 'self_attn.v_proj': (8, 8), 'self_attn.o_proj': (8, 16), + 'self_attn.q_norm': (8,), 'self_attn.k_norm': (8,)}) + else: + names.update({'linear_attn.in_proj_qkv': (16, 8), 'linear_attn.in_proj_z': (8, 8), + 'linear_attn.in_proj_b': (2, 8), 'linear_attn.in_proj_a': (2, 8), + 'linear_attn.out_proj': (8, 8), 'linear_attn.norm': (4,), + 'linear_attn.conv1d': (16, 1, 3)}) + a[f'layers.{i}.linear_attn.A_log'] = rand(2) + a[f'layers.{i}.linear_attn.dt_bias'] = rand(2) + a.update({f'layers.{i}.{name}.weight': rand(*shape) for name, shape in names.items()}) + original = ArrayLM(a, cfg) + original.tensors = {PREFIX+k: Tensor(v) for k,v in a.items()} + ids = rng.integers(0, 10, (2, 5)) + h = torch.tensor(original.embedding(ids)) + expected, _ = original.forward(ids) + adapters = {i: LearnableSharingAttention(8, 2, 1, 4, 10000., .5, 16) + for i in (0, 2)} + tail = TorchTail(original, 0, adapters) + lengths = torch.tensor([5, 5]) + native, _ = tail(h, None, lengths, 'native', ()) + torch.testing.assert_close(native, torch.tensor(expected), atol=2e-5, rtol=2e-5) + donor = torch.tensor(rand(2, 2, 5, 5)) + run, _ = tail(h, donor, lengths, 'lisa', (0,2), keep_teacher=False) + ref, _ = tail(h, donor, lengths, 'lisa', (0,2), keep_teacher=True) + torch.testing.assert_close(run, ref) + run.square().sum().backward() + self.assertTrue(all(p.grad is not None and p.grad.abs().sum() > 0 for p in tail.parameters())) + + + def test_decode_uses_rotary_offsets_and_compact_key_cache(self): + rng = np.random.default_rng(252) + cfg = {'rms_norm_eps': 1e-6, 'layer_types': ['full_attention'], + 'num_attention_heads': 2, 'num_key_value_heads': 1, 'head_dim': 16, + 'rope_parameters': {'rope_theta': 10000., 'partial_rotary_factor': .5}} + names = {'q_proj': (64, 8), 'k_proj': (16, 8), 'v_proj': (16, 8), + 'o_proj': (8, 32), 'q_norm': (16,), 'k_norm': (16,)} + weights = {'layers.0.self_attn.' + k + '.weight': + rng.normal(0, .2, shape).astype('f4') for k, shape in names.items()} + source = ArrayLM(weights, cfg) + source.tensors = {PREFIX+k: Tensor(v) for k,v in weights.items()} + adapter = LearnableSharingAttention(8, 2, 1, 4, 10000., .5, width=12) + tail = TorchTail(source, 0, {0: adapter}) + hidden = torch.tensor(rng.normal(0, .8, (2, 5, 8)).astype('f4')) + donor = torch.tensor(rng.normal(0, 1, (2, 2, 5, 5)).astype('f4')) + lengths = torch.tensor([5, 5]) + native = AttentionSiteCache(tail, 0, 2, 5) + shared = AttentionSiteCache(tail, 0, 2, 5, adapter) + for mode, cache in [('native', native), ('lisa', shared)]: + out, raw, _ = tail.full(hidden, 0, donor, lengths, mode, (0,), False) + for pos in range(hidden.shape[1]): + row = donor[:, :, pos:pos+1, :pos+1] if mode == 'lisa' else None + actual, scores = cache.step(hidden[:, pos:pos+1], row) + torch.testing.assert_close(actual, out[:, pos:pos+1], atol=2e-6, rtol=2e-5) + torch.testing.assert_close(scores, raw[:, :, pos:pos+1, :pos+1], + atol=2e-6, rtol=2e-5) + cache.reset() + cache.prefill(hidden[:, :4]) + row = donor[:, :, 4:5, :] if mode == 'lisa' else None + actual, scores = cache.step(hidden[:, 4:5], row) + torch.testing.assert_close(actual, out[:, 4:5], atol=2e-6, rtol=2e-5) + torch.testing.assert_close(scores, raw[:, :, 4:5, :], atol=2e-6, rtol=2e-5) + self.assertEqual(shared.allocated_bytes['v'], native.allocated_bytes['v']) + self.assertEqual(shared.allocated_bytes['k']*4, native.allocated_bytes['k']) + resident = ResidentSite(tail, 0) + _, original_states = timed_site({'native': native, 'lisa': shared}, hidden, donor, 5, + samples=2, rounds=2) + _, warm_states = timed_site({'native': AttentionSiteCache(resident, 0, 2, 5), + 'lisa': AttentionSiteCache(resident, 0, 2, 5, adapter)}, + hidden, donor, 5, samples=2, rounds=2) + for mode in ('native', 'lisa'): + for old, new in zip(original_states[mode], warm_states[mode]): + torch.testing.assert_close(old, new, atol=2e-6, rtol=2e-5) diff --git a/tests/test_lisa_train.py b/tests/test_lisa_train.py index ae659c7..ea4f280 100644 --- a/tests/test_lisa_train.py +++ b/tests/test_lisa_train.py @@ -27,6 +27,22 @@ class LiSATrainingTests(unittest.TestCase): torch.testing.assert_close(torch.autograd.grad(streamed, hidden)[0], torch.autograd.grad(dense, hidden)[0]) + def test_answer_weighted_ce_matches_dense(self): + torch.manual_seed(12) + h = torch.randn((2, 4, 3), dtype=torch.float64, requires_grad=True) + w = torch.randn((5, 3), dtype=h.dtype) + ids = torch.randint(0, 5, (2, 4)) + lengths = torch.tensor([4, 3]) + valid = torch.arange(1, 4) < lengths[:, None] + answer = torch.arange(2, 5) == lengths[:, None] + weights = torch.where(answer, 16., 1.)[valid] + ce = F.cross_entropy(F.linear(h[:, :-1][valid], w), ids[:, 1:][valid], reduction='none') + dense = (ce * weights).sum() / weights.sum() + streamed = language_model_loss(h, ids, lengths, lambda: iter([(0, w)]), answer_weight=16.) + torch.testing.assert_close(streamed, dense) + torch.testing.assert_close(torch.autograd.grad(streamed, h)[0], + torch.autograd.grad(dense, h)[0]) + def test_causality_and_gradients_for_both_adapter_components(self): torch.manual_seed(9) a = LearnableSharingAttention(8, 2, 1, 8, 10000, .25, width=10)