harness-everything 1.3.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.github/workflows/release.yml +23 -6
  4. package/CHANGELOG.md +42 -0
  5. package/RELEASING.md +2 -0
  6. package/ci/fixtures/system-one-colab-fit-layer-sitecustomize.py +72 -0
  7. package/ci/mechanism-2x-release-automation.test.js +17 -0
  8. package/ci/mechanism-system-one-colab.test.js +528 -0
  9. package/ci/mechanism-system-one-contract.test.js +30 -0
  10. package/ci/mechanism-system-one-curves.test.js +85 -0
  11. package/ci/mechanism-system-one-cycle.test.js +344 -34
  12. package/ci/mechanism-system-one-install.test.js +47 -0
  13. package/ci/mechanism-system-one-provider.test.js +2 -0
  14. package/ci/mechanism-system-one-resident.test.js +69 -0
  15. package/ci/system-one-adapter-test.py +86 -0
  16. package/ci/system-one-fit-layer-test.py +371 -0
  17. package/ci/system-one-layer-test.py +122 -0
  18. package/ci/system-one-train-test.py +26 -0
  19. package/docs/system-one-cycle.md +10 -0
  20. package/docs/system-one-training.md +3 -1
  21. package/harness-everything/SKILL.md +1 -1
  22. package/harness-everything/scripts/system-one/cua_adapter.py +36 -1
  23. package/harness-everything/scripts/system-one/install.js +10 -0
  24. package/harness-everything/scripts/system-one/layer.py +178 -0
  25. package/harness-everything/scripts/system-one/manifest.js +8 -1
  26. package/harness-everything/scripts/system-one/provider.js +12 -2
  27. package/opencode-plugin/plugin.json +1 -1
  28. package/package.json +1 -1
  29. package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
  30. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  31. package/plugins/harness-everything/plugin.json +1 -1
  32. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  33. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/cua_adapter.py +36 -1
  34. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/install.js +10 -0
  35. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/layer.py +178 -0
  36. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/manifest.js +8 -1
  37. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/provider.js +12 -2
  38. package/sbom.cdx.json +7 -7
  39. package/scripts/system-one-colab.js +240 -0
  40. package/scripts/system-one-curves.js +52 -8
  41. package/scripts/system-one-cycle/evaluate.js +56 -5
  42. package/scripts/system-one-cycle/package.js +61 -3
  43. package/scripts/system-one-cycle/score.py +23 -2
  44. package/scripts/system-one-cycle/train.js +212 -20
  45. package/scripts/system-one-fit-layer.py +369 -0
  46. package/scripts/system-one-train.py +36 -9
@@ -120,13 +120,33 @@ def make_batches(lengths, token_budget, n_options, option_tokens):
120
120
  return batches
121
121
 
122
122
 
123
+ def resolve_device(requested, cuda_available):
124
+ """Resolve a requested training device without importing torch."""
125
+ if requested == 'cpu':
126
+ return 'cpu'
127
+ if requested == 'auto':
128
+ return 'cuda' if cuda_available else 'cpu'
129
+ if requested == 'cuda':
130
+ if cuda_available:
131
+ return 'cuda'
132
+ raise ValueError('CUDA was requested but is unavailable')
133
+ raise ValueError(f'unknown device: {requested!r}')
134
+
135
+
123
136
  def train(args):
124
137
  import torch
125
138
  from cua_s1.model import ChoiceExample, make_system, save_checkpoint
126
139
 
140
+ try:
141
+ device = resolve_device(args.device, torch.cuda.is_available())
142
+ except ValueError as exc:
143
+ raise SystemExit(f'error: {exc}') from None
127
144
  random.seed(args.seed)
128
145
  torch.manual_seed(args.seed)
129
- torch.set_num_threads(max(1, args.threads))
146
+ if device == 'cuda':
147
+ torch.cuda.manual_seed_all(args.seed)
148
+ else:
149
+ torch.set_num_threads(max(1, args.threads))
130
150
  data_dir = Path(args.data_dir)
131
151
  catalog = catalog_for(args.task, args.holdout)
132
152
  labels_file = ('labels-intent-scores.jsonl' if args.target == 'scores' else 'labels-intent.jsonl') \
@@ -136,7 +156,10 @@ def train(args):
136
156
  split = {name: [e for e in examples if e['split'] == name] for name in ('train', 'validation')}
137
157
  config = {'encoder': 'tinyx', 'width': 128, 'rank': 128, 'layers': 2, 'heads': 4, 'dropout': 0.1,
138
158
  'context_tokens': args.context_tokens, 'option_tokens': OPTION_TOKENS}
139
- model, collator = make_system(config, 'cpu')
159
+ model, collator = make_system(config, device)
160
+
161
+ def collate(rows):
162
+ return {name: tensor.to(device) for name, tensor in collator(rows).items()}
140
163
 
141
164
  def to_examples(rows):
142
165
  examples = []
@@ -160,9 +183,9 @@ def train(args):
160
183
  nll, correct, probs = 0.0, 0, [None] * len(val_x)
161
184
  with torch.inference_mode():
162
185
  for batch in val_batches:
163
- tensors = collator([val_x[i] for i in batch])
186
+ tensors = collate([val_x[i] for i in batch])
164
187
  logits = model(tensors)
165
- targets = val_targets[batch]
188
+ targets = val_targets[batch].to(device)
166
189
  nll += torch.nn.functional.binary_cross_entropy_with_logits(logits, targets, reduction='sum').item()
167
190
  p = logits.sigmoid()
168
191
  correct += ((p >= 0.5) == targets.bool()).all(dim=-1).sum().item()
@@ -179,8 +202,9 @@ def train(args):
179
202
  total = 0.0
180
203
  for b in order:
181
204
  batch = train_batches[b]
182
- tensors = collator([train_x[i] for i in batch])
183
- loss = torch.nn.functional.binary_cross_entropy_with_logits(model(tensors), train_targets[batch])
205
+ tensors = collate([train_x[i] for i in batch])
206
+ targets = train_targets[batch].to(device)
207
+ loss = torch.nn.functional.binary_cross_entropy_with_logits(model(tensors), targets)
184
208
  optimizer.zero_grad()
185
209
  loss.backward()
186
210
  torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0)
@@ -191,7 +215,7 @@ def train(args):
191
215
  print(json.dumps(history[-1]), flush=True)
192
216
  if best is None or metrics['nll'] < best['metrics']['nll']:
193
217
  best = {'epoch': epoch, 'metrics': metrics, 'scores': probs,
194
- 'state': {k: v.detach().clone() for k, v in model.state_dict().items()}}
218
+ 'state': {k: v.detach().cpu().clone() for k, v in model.state_dict().items()}}
195
219
 
196
220
  model.load_state_dict(best['state'])
197
221
  out = Path(args.out)
@@ -199,7 +223,8 @@ def train(args):
199
223
  datasets = {name: sha256_file(data_dir / name) for name in ('prompts.jsonl', labels_file)}
200
224
  metadata = {'domain': 'harness-routing-v1', 'bestEpoch': best['epoch'], 'validation': best['metrics'],
201
225
  'datasets': datasets, 'seed': args.seed, 'catalog': [o['id'] for o in catalog],
202
- 'task': args.task, 'target': args.target, 'loss': 'binary_cross_entropy'}
226
+ 'task': args.task, 'target': args.target, 'loss': 'binary_cross_entropy',
227
+ 'device': device, 'torch': torch.__version__}
203
228
  save_checkpoint(out / 'harness-routing-v1.safetensors', model, config, metadata)
204
229
  with (out / 'val-scores.jsonl').open('w', encoding='utf-8') as fh:
205
230
  for row, scores in zip(split['validation'], best['scores']):
@@ -207,7 +232,7 @@ def train(args):
207
232
  counts = {name: len(rows) for name, rows in split.items()}
208
233
  report = {'schemaVersion': 1, 'config': config, 'counts': counts, 'bestEpoch': best['epoch'], 'history': history,
209
234
  'datasets': datasets, 'seed': args.seed, 'task': args.task, 'target': args.target,
210
- 'catalog': [o['id'] for o in catalog]}
235
+ 'catalog': [o['id'] for o in catalog], 'device': device, 'torch': torch.__version__}
211
236
  (out / 'train-report.json').write_text(json.dumps(report, indent=2) + '\n', encoding='utf-8')
212
237
  print(json.dumps({'counts': counts, 'bestEpoch': best['epoch'], 'validation': best['metrics']}))
213
238
 
@@ -221,6 +246,8 @@ def main(argv=None):
221
246
  parser.add_argument('--lr', type=float, default=1e-3)
222
247
  parser.add_argument('--seed', type=int, default=7)
223
248
  parser.add_argument('--threads', type=int, default=4)
249
+ parser.add_argument('--device', choices=['cpu', 'cuda', 'auto'], default='cpu',
250
+ help='training device (auto selects CUDA when available)')
224
251
  parser.add_argument('--context-tokens', type=int, default=1024)
225
252
  parser.add_argument('--token-budget', type=int, default=TOKEN_BUDGET,
226
253
  help='whole-forward-pass tokens per batch (prompt plus every option)')