-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforge-alloy.schema.json
More file actions
424 lines (398 loc) · 20.1 KB
/
Copy pathforge-alloy.schema.json
File metadata and controls
424 lines (398 loc) · 20.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/CambrianTech/forge-alloy/schema/forge-alloy.schema.json",
"title": "ForgeAlloy",
"description": "Portable pipeline specification for model forging",
"type": "object",
"required": ["name", "version", "source", "stages", "cycles"],
"properties": {
"name": { "type": "string", "description": "Alloy name (e.g., qwen3.5-4b-code-balanced)" },
"version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$", "description": "Semver version of this alloy spec" },
"description": { "type": "string" },
"author": { "type": "string" },
"tags": { "type": "array", "items": { "type": "string" } },
"license": { "type": "string", "default": "apache-2.0" },
"source": { "$ref": "#/$defs/AlloySource" },
"stages": { "type": "array", "items": { "$ref": "#/$defs/AlloyStage" }, "minItems": 1 },
"cycles": { "type": "integer", "minimum": 1, "default": 1 },
"hardware": { "$ref": "#/$defs/AlloyHardware" },
"outputs": { "$ref": "#/$defs/AlloyOutputs" },
"results": { "$ref": "#/$defs/AlloyResults", "description": "Populated after execution — benchmark scores, hardware verification, samples" },
"sourceAlloyId": { "type": "string", "description": "Parent alloy for re-forge lineage" },
"forgedModelIds": { "type": "array", "items": { "type": "string" }, "description": "HF model IDs produced" }
},
"$defs": {
"AlloySource": {
"type": "object",
"required": ["baseModel", "architecture"],
"properties": {
"baseModel": { "type": "string", "description": "HuggingFace model ID (e.g., Qwen/Qwen3.5-4B)" },
"architecture": { "type": "string", "enum": ["qwen3_5", "qwen3_5_moe", "qwen2", "llama", "mistral", "phi", "gemma", "deepseek"] },
"revision": { "type": "string" },
"isMoE": { "type": "boolean", "default": false },
"totalExperts": { "type": "integer" }
}
},
"AlloyResults": {
"type": "object",
"description": "Complete results from executing an alloy pipeline. Empty in recipe alloys, populated after forging.",
"properties": {
"completedAt": { "type": "string", "format": "date-time", "description": "When the forge completed" },
"durationMinutes": { "type": "number", "minimum": 0, "description": "Total forge wall-clock time" },
"baselinePerplexity": { "type": "number", "description": "Perplexity before forging" },
"finalPerplexity": { "type": "number", "description": "Perplexity after forging" },
"improvementPct": { "type": "number", "description": "Improvement percentage (positive = better)" },
"finalSizeGb": { "type": "number", "description": "Model size after forging in GB" },
"finalParams": { "type": "string", "description": "Parameter count after forging (e.g., '3.8B')" },
"benchmarks": {
"type": "array",
"items": { "$ref": "#/$defs/BenchmarkResult" },
"description": "Benchmark results — extensible, each defines its own metrics"
},
"hardwareVerified": {
"type": "array",
"items": { "$ref": "#/$defs/HardwareProfile" },
"description": "Verified hardware performance for model card device grid"
},
"samples": {
"type": "array",
"items": { "$ref": "#/$defs/GenerationSample" },
"description": "Raw model output — no cherry-picking"
},
"integrity": { "$ref": "#/$defs/IntegrityAttestation" }
}
},
"BenchmarkResult": {
"type": "object",
"required": ["name", "metrics"],
"description": "A single benchmark result. Metrics are open-ended — each benchmark reports whatever it wants.",
"properties": {
"name": { "type": "string", "description": "Benchmark name (e.g., humaneval, mmlu-pro, imo-proofbench-advanced)" },
"subset": { "type": "string", "description": "Optional benchmark subset" },
"metrics": {
"type": "object",
"additionalProperties": { "oneOf": [{ "type": "number" }, { "type": "string" }, { "type": "boolean" }] },
"description": "Open metric bag. Examples: { passing: 63, total: 85, score: 74.1 } for HumanEval, { proofScore: 42.0, difficulty: 'advanced' } for IMO-ProofBench"
},
"submittedToLeaderboard": { "type": "boolean", "default": false },
"resultHash": { "type": "string", "description": "Per-benchmark integrity hash" }
}
},
"HardwareProfile": {
"type": "object",
"required": ["device", "format"],
"description": "Verified performance on a specific device — generates model card device grid.",
"properties": {
"device": { "type": "string", "description": "Device name (e.g., MacBook Air 8GB, RTX 5090, iPhone 17)" },
"format": { "type": "string", "description": "Format used (e.g., Q4_K_M, fp16, mlx-4bit)" },
"sizeGb": { "type": "number", "description": "Model file size in GB for this format" },
"tokensPerSec": { "type": "number", "description": "Inference speed in tokens/second" },
"memoryUsageGb": { "type": "number", "description": "RAM/VRAM usage during inference" },
"verified": { "type": "boolean", "default": false, "description": "Actually tested (true) or estimated (false)" }
}
},
"GenerationSample": {
"type": "object",
"required": ["label", "prompt", "completion"],
"description": "Raw model output sample — no cherry-picking, no post-processing.",
"properties": {
"label": { "type": "string", "description": "Label (e.g., Merge Sort, Binary Search Tree)" },
"prompt": { "type": "string" },
"completion": { "type": "string" },
"baselineCompletion": { "type": "string", "description": "Base model output for comparison" }
}
},
"IntegrityAttestation": {
"type": "object",
"required": ["trustLevel", "code", "modelHash", "attestedAt"],
"description": "Cryptographic attestation modeled after FIDO2/WebAuthn. Self-attested prevents accidental corruption only. Enclave required for tamper-proof.",
"properties": {
"trustLevel": {
"type": "string",
"enum": ["self-attested", "verified", "enclave"],
"description": "Trust tier. Self-attested: signer vouches (NOT adversary-proof). Verified: third-party audited. Enclave: TEE hardware-bound."
},
"code": { "$ref": "#/$defs/CodeAttestation" },
"modelHash": { "type": "string", "description": "SHA-256 of FULL model weights (every byte, not partial)" },
"alloyHash": { "type": "string", "description": "SHA-256 of alloy pipeline (required when signed)" },
"datasets": {
"type": "array",
"items": { "$ref": "#/$defs/DatasetAttestation" },
"description": "Hashes of benchmark datasets (cover exactly the subset used)"
},
"nonce": { "type": "string", "description": "Verifier-provided challenge for replay prevention (like WebAuthn challenge)" },
"audience": { "type": "string", "description": "Audience binding — prevents cross-marketplace replay" },
"signature": { "$ref": "#/$defs/AttestationSignature" },
"certifications": {
"type": "array",
"items": { "$ref": "#/$defs/AdapterAttestation" },
"description": "Third-party adapter attestations — independent certifications from approved adapters. Each adapter signs with its own key."
},
"attestedAt": { "type": "string", "format": "date-time" }
}
},
"AdapterAttestation": {
"type": "object",
"required": ["adapter", "version", "domain", "attestedAt"],
"description": "Third-party adapter certification. Like UL: independent authority tests one aspect, signs with own key.",
"properties": {
"adapter": { "type": "string", "description": "Adapter identifier (e.g., forge-alloy/humaneval, ul/safety-audit, nvidia/perf-cert)" },
"version": { "type": "string", "description": "Adapter version (semver)" },
"domain": { "type": "string", "description": "What this adapter certifies (e.g., benchmark:humaneval, safety:toxicity, hardware:inference)" },
"result": {
"type": "object",
"additionalProperties": true,
"description": "Adapter-specific results — open-ended metrics"
},
"adapterHash": { "type": "string", "description": "SHA-256 of adapter binary/script" },
"signature": { "$ref": "#/$defs/AttestationSignature" },
"nonce": { "type": "string", "description": "API-provided nonce for this adapter run" },
"sourceRepo": { "type": "string", "description": "GitHub URL — open source adapters get higher trust" },
"commit": { "type": "string", "description": "Git commit of adapter at execution time" },
"attestedAt": { "type": "string", "format": "date-time" }
}
},
"CodeAttestation": {
"type": "object",
"required": ["runner", "version", "binaryHash"],
"description": "Attestation of the code that produced results — proves the forge runner is genuine.",
"properties": {
"runner": { "type": "string", "description": "Runner identifier (e.g., sentinel-ai/forge_model)" },
"version": { "type": "string", "description": "Runner version (semver)" },
"binaryHash": { "type": "string", "description": "SHA-256 of the runner binary or entry script" },
"sourceHash": { "type": "string", "description": "SHA-256 of the source repository at build time" },
"commit": { "type": "string", "description": "Git commit hash of the runner source" },
"environment": { "type": "string", "description": "Execution environment description" },
"environmentHash": { "type": "string", "description": "SHA-256 of the container image or environment" }
}
},
"DatasetAttestation": {
"type": "object",
"required": ["name", "hash"],
"description": "Attestation of a benchmark dataset — proves eval used unmodified data.",
"properties": {
"name": { "type": "string", "description": "Dataset name (e.g., humaneval, mmlu-pro)" },
"version": { "type": "string", "description": "Dataset version or commit hash" },
"hash": { "type": "string", "description": "SHA-256 of the dataset files" },
"source": { "type": "string", "description": "Source URL or repository" }
}
},
"AttestationSignature": {
"type": "object",
"required": ["algorithm", "publicKey", "value"],
"description": "Signature over RFC 8785 JCS-canonical attestation payload. Extensible to post-quantum.",
"properties": {
"algorithm": {
"type": "string",
"enum": ["ES256", "ES384", "EdDSA", "ML-DSA-65", "ML-DSA-87", "SLH-DSA-128s"],
"description": "Signing algorithm. ES256 default. PQC variants for quantum-safe migration."
},
"publicKey": { "type": "string", "description": "Base64url public key — verifiers MUST check against registry" },
"value": { "type": "string", "description": "Base64url signature over SHA-256(JCS payload)" },
"keyId": { "type": "string", "description": "Key ID in registry for lookup and revocation" },
"credentialId": { "type": "string", "description": "WebAuthn credential ID (see passkey signing gap in docs)" },
"certificateChain": {
"type": "array",
"items": { "type": "string" },
"description": "PEM-encoded certificate chain (leaf first) for verified tier"
},
"keyRegistry": { "type": "string", "format": "uri", "description": "Registry URL for key verification and revocation" }
}
},
"AlloyStage": {
"type": "object",
"required": ["type"],
"discriminator": { "propertyName": "type" },
"oneOf": [
{ "$ref": "#/$defs/PruneStage" },
{ "$ref": "#/$defs/TrainStage" },
{ "$ref": "#/$defs/LoRAStage" },
{ "$ref": "#/$defs/CompactStage" },
{ "$ref": "#/$defs/QuantStage" },
{ "$ref": "#/$defs/EvalStage" },
{ "$ref": "#/$defs/PublishStage" },
{ "$ref": "#/$defs/ExpertPruneStage" },
{ "$ref": "#/$defs/ContextExtendStage" },
{ "$ref": "#/$defs/ModalityStage" }
]
},
"PruneStage": {
"type": "object",
"required": ["type", "strategy", "level"],
"properties": {
"type": { "const": "prune" },
"strategy": { "type": "string", "enum": ["entropy", "magnitude", "gradient", "random"] },
"level": { "type": "number", "minimum": 0.0, "maximum": 0.9 },
"minHeadsPerLayer": { "type": "integer", "minimum": 1, "default": 4 },
"minKvHeadsPerLayer": { "type": "integer", "minimum": 1, "default": 2 },
"analysisSteps": { "type": "integer", "minimum": 10, "default": 200 }
}
},
"TrainStage": {
"type": "object",
"required": ["type", "domain", "steps", "learningRate"],
"properties": {
"type": { "const": "train" },
"domain": { "type": "string" },
"dataset": { "type": "string" },
"steps": { "type": "integer", "minimum": 1 },
"learningRate": { "type": "string" },
"batchSize": { "type": "integer", "minimum": 1, "maximum": 64, "default": 4 },
"gradientAccumulation": { "type": "integer", "minimum": 1, "maximum": 16, "default": 1 },
"scheduler": { "type": "string", "enum": ["cosine", "linear", "constant", "constant_with_warmup", "polynomial"], "default": "cosine" },
"warmupRatio": { "type": "number", "minimum": 0.0, "maximum": 1.0, "default": 0.03 },
"weightDecay": { "type": "number", "minimum": 0.0, "maximum": 1.0, "default": 0.01 },
"maxGradientNorm": { "type": "number", "minimum": 0.0, "maximum": 10.0, "default": 1.0 },
"precision": { "type": "string", "enum": ["bf16", "fp16", "fp32"], "default": "bf16" },
"sequenceLength": { "type": "integer", "minimum": 128, "maximum": 131072, "default": 2048 },
"optimizations": {
"type": "array",
"items": { "type": "string", "enum": ["flash_attention", "gradient_checkpointing", "optimizer_8bit", "paged_optimizer", "fused_kernels", "sequence_packing", "dynamic_padding", "activation_offloading"] }
}
}
},
"LoRAStage": {
"type": "object",
"required": ["type", "rank"],
"properties": {
"type": { "const": "lora" },
"rank": { "type": "integer", "minimum": 1, "maximum": 256, "default": 32 },
"alpha": { "type": "integer", "minimum": 1, "maximum": 512 },
"dropout": { "type": "number", "minimum": 0.0, "maximum": 1.0, "default": 0.05 },
"targetModules": { "type": "array", "items": { "type": "string" }, "default": ["q_proj", "k_proj", "v_proj", "o_proj"] },
"quantize": { "type": "boolean", "default": true },
"quantizeBits": { "type": "integer", "enum": [4, 8], "default": 4 },
"dataset": { "type": "string" },
"epochs": { "type": "integer", "minimum": 1, "maximum": 20, "default": 3 },
"learningRate": { "type": "string", "default": "1e-4" },
"batchSize": { "type": "integer", "minimum": 1, "maximum": 64, "default": 4 },
"mergeAfter": { "type": "boolean", "default": false }
}
},
"CompactStage": {
"type": "object",
"required": ["type"],
"properties": {
"type": { "const": "compact" },
"deadThreshold": { "type": "number", "minimum": 0.0, "maximum": 1.0, "default": 0.1 },
"dormantThreshold": { "type": "number", "minimum": 0.0, "maximum": 1.0, "default": 0.2 },
"lowThreshold": { "type": "number", "minimum": 0.0, "maximum": 1.0, "default": 0.3 },
"mediumThreshold": { "type": "number", "minimum": 0.0, "maximum": 1.0, "default": 0.5 },
"highThreshold": { "type": "number", "minimum": 0.0, "maximum": 1.0, "default": 0.7 },
"targetSizeGb": { "type": "number", "minimum": 0.1 },
"enableQuantization": { "type": "boolean", "default": true }
}
},
"QuantStage": {
"type": "object",
"required": ["type", "format", "quantTypes"],
"properties": {
"type": { "const": "quant" },
"format": { "type": "string", "enum": ["gguf", "mlx", "safetensors", "onnx"] },
"quantTypes": {
"type": "array",
"items": { "type": "string", "enum": ["Q2_K", "Q3_K_S", "Q3_K_M", "Q3_K_L", "IQ4_XS", "Q4_K_S", "Q4_K_M", "Q5_K_S", "Q5_K_M", "Q6_K", "Q8_0", "F16", "F32"] }
},
"deviceTargets": { "type": "array", "items": { "type": "string" } }
}
},
"EvalStage": {
"type": "object",
"required": ["type", "benchmarks"],
"properties": {
"type": { "const": "eval" },
"benchmarks": {
"type": "array",
"items": {
"type": "object",
"required": ["name"],
"properties": {
"name": { "type": "string" },
"subset": { "type": "string" },
"nShot": { "type": "integer", "minimum": 0 },
"submitToLeaderboard": { "type": "boolean", "default": false }
}
}
},
"passingThreshold": { "type": "number", "minimum": 0, "maximum": 100 },
"compareToBase": { "type": "boolean", "default": true }
}
},
"PublishStage": {
"type": "object",
"required": ["type", "org"],
"properties": {
"type": { "const": "publish" },
"org": { "type": "string" },
"repoNameTemplate": { "type": "string", "default": "{base}-{domain}-forged" },
"includeAlloy": { "type": "boolean", "default": true },
"cardFromBenchmarks": { "type": "boolean", "default": true },
"tags": { "type": "array", "items": { "type": "string" } },
"private": { "type": "boolean", "default": false }
}
},
"ExpertPruneStage": {
"type": "object",
"required": ["type", "keepExperts"],
"properties": {
"type": { "const": "expert-prune" },
"keepExperts": { "type": "integer", "minimum": 1 },
"selectionStrategy": { "type": "string", "enum": ["activation", "gradient", "random"], "default": "activation" },
"profileDataset": { "type": "string" },
"profileSteps": { "type": "integer", "minimum": 1, "default": 100 }
}
},
"ContextExtendStage": {
"type": "object",
"required": ["type", "targetLength", "method"],
"properties": {
"type": { "const": "context-extend" },
"targetLength": { "type": "integer", "minimum": 1024 },
"method": { "type": "string", "enum": ["yarn", "ntk", "linear", "dynamic-ntk"] },
"trainingDataset": { "type": "string" },
"trainingSteps": { "type": "integer", "minimum": 1 }
}
},
"ModalityStage": {
"type": "object",
"required": ["type", "modality", "encoderModel"],
"properties": {
"type": { "const": "modality" },
"modality": { "type": "string", "enum": ["vision", "audio", "multimodal"] },
"encoderModel": { "type": "string" },
"projectionArch": { "type": "string", "enum": ["mlp", "cross-attention", "linear"], "default": "mlp" },
"freezeBase": { "type": "boolean", "default": true },
"freezeEncoder": { "type": "boolean", "default": true },
"trainingDataset": { "type": "string" },
"trainingSteps": { "type": "integer", "minimum": 1 },
"projectionDim": { "type": "integer" }
}
},
"AlloyHardware": {
"type": "object",
"properties": {
"minVramGb": { "type": "number", "minimum": 0 },
"recommendedVramGb": { "type": "number", "minimum": 0 },
"estimatedDurationMinutes": { "type": "number", "minimum": 0 },
"supportsCPU": { "type": "boolean", "default": false },
"testedOn": { "type": "array", "items": { "type": "string" } }
}
},
"AlloyOutputs": {
"type": "object",
"properties": {
"produces": {
"type": "array",
"items": {
"type": "object",
"required": ["type"],
"properties": {
"type": { "type": "string", "enum": ["safetensors", "gguf", "mlx", "lora-adapter", "model-card", "alloy"] },
"description": { "type": "string" }
}
}
}
}
}
}
}