infixspeed-cli 0.0.16__py3-none-any.whl
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.
- infix_cli/__init__.py +5 -0
- infix_cli/__main__.py +6 -0
- infix_cli/agent-guide.txt +71 -0
- infix_cli/cli_framework.py +96 -0
- infix_cli/command_contract.py +157 -0
- infix_cli/commands/__init__.py +1 -0
- infix_cli/commands/_artifacts.py +142 -0
- infix_cli/commands/_comparison.py +443 -0
- infix_cli/commands/_confirm.py +26 -0
- infix_cli/commands/_control.py +290 -0
- infix_cli/commands/_create.py +351 -0
- infix_cli/commands/_create_output.py +139 -0
- infix_cli/commands/_delete.py +288 -0
- infix_cli/commands/_download.py +459 -0
- infix_cli/commands/_fusion_common.py +191 -0
- infix_cli/commands/_fusion_config.py +394 -0
- infix_cli/commands/_fusion_feedback.py +319 -0
- infix_cli/commands/_fusion_tasks.py +507 -0
- infix_cli/commands/_fusion_tensorboard.py +132 -0
- infix_cli/commands/_jobs.py +312 -0
- infix_cli/commands/_logs.py +210 -0
- infix_cli/commands/_publish.py +123 -0
- infix_cli/commands/_register.py +600 -0
- infix_cli/commands/_register_output.py +231 -0
- infix_cli/commands/_storage_tree.py +62 -0
- infix_cli/commands/admin.py +668 -0
- infix_cli/commands/asset.py +2012 -0
- infix_cli/commands/auth.py +246 -0
- infix_cli/commands/deploy.py +850 -0
- infix_cli/commands/evaluation.py +360 -0
- infix_cli/commands/examples.py +138 -0
- infix_cli/commands/fusion.py +1842 -0
- infix_cli/commands/merge.py +709 -0
- infix_cli/commands/resource.py +127 -0
- infix_cli/commands/spark.py +347 -0
- infix_cli/commands/storage.py +329 -0
- infix_cli/commands/training.py +748 -0
- infix_cli/config.py +311 -0
- infix_cli/config_input.py +217 -0
- infix_cli/context.py +84 -0
- infix_cli/discovery.py +459 -0
- infix_cli/domain/__init__.py +1 -0
- infix_cli/domain/dto/__init__.py +6 -0
- infix_cli/domain/dto/admin.py +413 -0
- infix_cli/domain/dto/asset.py +390 -0
- infix_cli/domain/dto/common.py +136 -0
- infix_cli/domain/dto/evaluation.py +296 -0
- infix_cli/domain/dto/logs.py +98 -0
- infix_cli/domain/dto/resource.py +108 -0
- infix_cli/domain/dto/serving.py +156 -0
- infix_cli/domain/dto/spark.py +241 -0
- infix_cli/domain/dto/storage.py +75 -0
- infix_cli/domain/dto/training.py +272 -0
- infix_cli/domain/enums.py +359 -0
- infix_cli/domain/hyperparams.py +190 -0
- infix_cli/domain/refs.py +108 -0
- infix_cli/domain/resolve.py +619 -0
- infix_cli/errors.py +158 -0
- infix_cli/example_data/__init__.py +1 -0
- infix_cli/example_data/fusion/README.md +128 -0
- infix_cli/example_data/fusion/fusion.json +149 -0
- infix_cli/example_data/fusion/prompts/code.jsonl +16 -0
- infix_cli/example_data/fusion/prompts/math.jsonl +16 -0
- infix_cli/example_data/fusion.zip +0 -0
- infix_cli/example_data/merge/README.md +89 -0
- infix_cli/example_data/merge/merge.json +26 -0
- infix_cli/example_data/merge.zip +0 -0
- infix_cli/http/__init__.py +1 -0
- infix_cli/http/browser_auth.py +160 -0
- infix_cli/http/client.py +575 -0
- infix_cli/http/pagination.py +84 -0
- infix_cli/http/upload.py +254 -0
- infix_cli/main.py +432 -0
- infix_cli/pipeline_config_schema.py +122 -0
- infix_cli/render/__init__.py +79 -0
- infix_cli/render/json_out.py +123 -0
- infix_cli/render/progress.py +62 -0
- infix_cli/render/text.py +233 -0
- infix_cli/update_check.py +177 -0
- infix_cli/waiter.py +93 -0
- infix_cli/workspace.py +158 -0
- infixspeed_cli-0.0.16.dist-info/METADATA +58 -0
- infixspeed_cli-0.0.16.dist-info/RECORD +85 -0
- infixspeed_cli-0.0.16.dist-info/WHEEL +4 -0
- infixspeed_cli-0.0.16.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
"""PRD JSON/命令行引用转换为平台版本化配置;不推测未交付的算法默认值。"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from copy import deepcopy
|
|
6
|
+
import math
|
|
7
|
+
import json
|
|
8
|
+
|
|
9
|
+
from infix_cli.commands._fusion_common import reference
|
|
10
|
+
from infix_cli.commands.merge import hardware
|
|
11
|
+
from infix_cli.errors import UsageError
|
|
12
|
+
|
|
13
|
+
ALIASES = {"distill": "generate", "clean": "filter", "warmup": "sft"}
|
|
14
|
+
ORDER = ("split", "generate", "filter", "sft", "opd")
|
|
15
|
+
METADATA = {"name", "visibility", "description", "output_name"}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def stage_name(value):
|
|
19
|
+
if not isinstance(value, str):
|
|
20
|
+
raise UsageError("Stage must be a string.")
|
|
21
|
+
value = ALIASES.get(value, value)
|
|
22
|
+
if value not in ORDER:
|
|
23
|
+
raise UsageError("Stage must be split/distill/clean/warmup/opd.")
|
|
24
|
+
return value
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def teacher_value(text):
|
|
28
|
+
result = {}
|
|
29
|
+
for item in text.split(","):
|
|
30
|
+
key, separator, value = item.partition("=")
|
|
31
|
+
if (
|
|
32
|
+
not separator
|
|
33
|
+
or key not in {"model", "domain", "prompt", "weight", "preset"}
|
|
34
|
+
or key in result
|
|
35
|
+
or not value
|
|
36
|
+
):
|
|
37
|
+
raise UsageError(
|
|
38
|
+
"Teacher format: model=reference[,domain=name][,prompt=reference][,weight=positive-number]."
|
|
39
|
+
)
|
|
40
|
+
result[key] = value
|
|
41
|
+
if "model" not in result and "preset" not in result:
|
|
42
|
+
raise UsageError("Teacher requires model or preset.")
|
|
43
|
+
if "weight" in result:
|
|
44
|
+
try:
|
|
45
|
+
result["weight"] = float(result["weight"])
|
|
46
|
+
except ValueError as exc:
|
|
47
|
+
raise UsageError("Teacher weight must be positive.") from exc
|
|
48
|
+
if not math.isfinite(result["weight"]) or result["weight"] <= 0:
|
|
49
|
+
raise UsageError("Teacher weight must be finite and positive.")
|
|
50
|
+
return result
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def teachers(client, values, *, student=None):
|
|
54
|
+
if isinstance(values, dict):
|
|
55
|
+
if any(
|
|
56
|
+
not isinstance(row, dict) or "model" not in row for row in values.values()
|
|
57
|
+
):
|
|
58
|
+
raise UsageError(
|
|
59
|
+
"Each Teacher domain requires an object with a model reference."
|
|
60
|
+
)
|
|
61
|
+
return {
|
|
62
|
+
key: {
|
|
63
|
+
**row,
|
|
64
|
+
"model": reference(client, row["model"]),
|
|
65
|
+
**(
|
|
66
|
+
{"prompt": reference(client, row["prompt"], kind="dataset")}
|
|
67
|
+
if row.get("prompt") is not None
|
|
68
|
+
else {}
|
|
69
|
+
),
|
|
70
|
+
}
|
|
71
|
+
for key, row in values.items()
|
|
72
|
+
}
|
|
73
|
+
if not isinstance(values, list) or not values:
|
|
74
|
+
raise UsageError("Provide at least one Teacher.")
|
|
75
|
+
selections = []
|
|
76
|
+
overrides = {}
|
|
77
|
+
direct = {}
|
|
78
|
+
for raw in values:
|
|
79
|
+
row = teacher_value(raw) if isinstance(raw, str) else deepcopy(raw)
|
|
80
|
+
if not isinstance(row, dict) or set(row) - {
|
|
81
|
+
"model",
|
|
82
|
+
"preset",
|
|
83
|
+
"domain",
|
|
84
|
+
"prompt",
|
|
85
|
+
"weight",
|
|
86
|
+
}:
|
|
87
|
+
raise UsageError("Teacher object contains unknown fields.")
|
|
88
|
+
if row.get("model"):
|
|
89
|
+
row["model"] = reference(client, row["model"])
|
|
90
|
+
if row.get("prompt"):
|
|
91
|
+
prompt = reference(client, row["prompt"], kind="dataset")
|
|
92
|
+
if "path" in prompt:
|
|
93
|
+
overrides[len(selections)] = prompt
|
|
94
|
+
row.pop("prompt")
|
|
95
|
+
else:
|
|
96
|
+
row["prompt"] = prompt
|
|
97
|
+
if "path" in (row.get("model") or {}):
|
|
98
|
+
domain = row.get("domain")
|
|
99
|
+
if not isinstance(domain, str) or not domain or domain in direct:
|
|
100
|
+
raise UsageError("Each Storage Teacher requires a unique domain.")
|
|
101
|
+
direct[domain] = {
|
|
102
|
+
key: value for key, value in row.items() if key != "domain"
|
|
103
|
+
}
|
|
104
|
+
if len(selections) in overrides:
|
|
105
|
+
direct[domain]["prompt"] = overrides.pop(len(selections))
|
|
106
|
+
else:
|
|
107
|
+
selections.append(row)
|
|
108
|
+
result = {}
|
|
109
|
+
if selections:
|
|
110
|
+
payload = {"teachers": selections}
|
|
111
|
+
if student and set(student) & {"asset", "snapshot"}:
|
|
112
|
+
payload["student"] = student
|
|
113
|
+
response = client.post("/fusion/teachers/resolve", json=payload)
|
|
114
|
+
result = response["configuration"]["teachers"]
|
|
115
|
+
for index, prompt in overrides.items():
|
|
116
|
+
result[response["selections"][index]["domain"]]["prompt"] = prompt
|
|
117
|
+
if set(result) & set(direct):
|
|
118
|
+
raise UsageError("Teacher domains must be unique.")
|
|
119
|
+
return {**result, **direct}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def port_reference(client, value, *, kind):
|
|
123
|
+
if isinstance(value, str):
|
|
124
|
+
return reference(client, value, kind=kind)
|
|
125
|
+
if not isinstance(value, dict):
|
|
126
|
+
raise UsageError(
|
|
127
|
+
"Input must be an asset/Storage reference or a domain reference object."
|
|
128
|
+
)
|
|
129
|
+
if set(value) & {"asset", "snapshot", "path", "from"}:
|
|
130
|
+
return deepcopy(value)
|
|
131
|
+
if "domains" in value:
|
|
132
|
+
if not isinstance(value["domains"], dict):
|
|
133
|
+
raise UsageError("domains must be a domain-to-reference object.")
|
|
134
|
+
return {
|
|
135
|
+
"domains": {
|
|
136
|
+
key: port_reference(client, row, kind=kind)
|
|
137
|
+
for key, row in value["domains"].items()
|
|
138
|
+
},
|
|
139
|
+
**(
|
|
140
|
+
{"base": port_reference(client, value["base"], kind=kind)}
|
|
141
|
+
if "base" in value
|
|
142
|
+
else {}
|
|
143
|
+
),
|
|
144
|
+
}
|
|
145
|
+
return {key: port_reference(client, row, kind=kind) for key, row in value.items()}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def stage_params(raw, *, stage=None):
|
|
149
|
+
if not isinstance(raw, dict):
|
|
150
|
+
raise UsageError("set/params must be a parameter object.")
|
|
151
|
+
values = normalized_keys(raw)
|
|
152
|
+
aliases = {
|
|
153
|
+
"num_epoch": "epochs", "global_batch_size": "batch_size", "max_steps": "updates",
|
|
154
|
+
"checkpoint_interval": "save_interval", "rollout_temperature": "temperature",
|
|
155
|
+
} if stage in {"sft", "opd"} else {}
|
|
156
|
+
result = {}
|
|
157
|
+
for key, value in values.items():
|
|
158
|
+
key = aliases.get(key, key)
|
|
159
|
+
if stage == "sft" and key == "method":
|
|
160
|
+
key = "training_precision"
|
|
161
|
+
if key in result:
|
|
162
|
+
raise UsageError("Duplicate parameter alias: " + key)
|
|
163
|
+
if key == "distill_divergence" and isinstance(value, str):
|
|
164
|
+
value = {"reverse-kl": "reverse_kl", "forward-kl": "forward_kl"}.get(value, value)
|
|
165
|
+
result[key] = value
|
|
166
|
+
try:
|
|
167
|
+
json.dumps(result, allow_nan=False)
|
|
168
|
+
except (TypeError, ValueError) as exc:
|
|
169
|
+
raise UsageError("Parameters must contain finite JSON values.") from exc
|
|
170
|
+
for name in ("domain_mix_ratio", "teacher_weights"):
|
|
171
|
+
if isinstance(result.get(name), str):
|
|
172
|
+
mapping = {}
|
|
173
|
+
for item in result[name].split(","):
|
|
174
|
+
key, separator, value = item.partition(":")
|
|
175
|
+
if not separator or not key or key in mapping:
|
|
176
|
+
raise UsageError(f"{name} requires unique domain:weight values.")
|
|
177
|
+
try:
|
|
178
|
+
mapping[key] = float(value)
|
|
179
|
+
except ValueError as exc:
|
|
180
|
+
raise UsageError(f"{name} weights must be numeric.") from exc
|
|
181
|
+
if not math.isfinite(mapping[key]):
|
|
182
|
+
raise UsageError(f"{name} weights must be finite numbers.")
|
|
183
|
+
result[name] = mapping
|
|
184
|
+
return result
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def normalized_keys(raw):
|
|
188
|
+
result = {}
|
|
189
|
+
for key, value in raw.items():
|
|
190
|
+
if not isinstance(key, str):
|
|
191
|
+
raise UsageError("Configuration keys must be strings.")
|
|
192
|
+
normalized = key.replace("-", "_")
|
|
193
|
+
if normalized in result:
|
|
194
|
+
raise UsageError("Duplicate configuration key: " + normalized)
|
|
195
|
+
result[normalized] = deepcopy(value)
|
|
196
|
+
return result
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def merge_params(previous, changes, *, stage):
|
|
200
|
+
result = stage_params(previous, stage=stage)
|
|
201
|
+
for name, value in stage_params(changes, stage=stage).items():
|
|
202
|
+
if stage == "split" and name == "ratio":
|
|
203
|
+
result.pop("sft_ratio", None)
|
|
204
|
+
result[name] = value
|
|
205
|
+
return result
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def input_override(client, stage, values, previous=None):
|
|
209
|
+
if not values:
|
|
210
|
+
return None
|
|
211
|
+
if stage in {"split", "generate", "opd"}:
|
|
212
|
+
supplied = {}
|
|
213
|
+
for item in values:
|
|
214
|
+
key, separator, value = item.partition("=")
|
|
215
|
+
if not separator or not key or key in supplied:
|
|
216
|
+
raise UsageError("Use unique domain=reference values for input.")
|
|
217
|
+
supplied[key] = reference(client, value, kind="dataset")
|
|
218
|
+
if stage == "split":
|
|
219
|
+
return {**(previous or {}), **supplied}
|
|
220
|
+
result = {"domains": {**(previous or {}).get("domains", {}), **supplied}}
|
|
221
|
+
if previous:
|
|
222
|
+
result["base"] = (
|
|
223
|
+
previous.get("base") if "domains" in previous else deepcopy(previous)
|
|
224
|
+
)
|
|
225
|
+
if result["base"] is None:
|
|
226
|
+
result.pop("base")
|
|
227
|
+
return result
|
|
228
|
+
if len(values) != 1:
|
|
229
|
+
raise UsageError("clean/warmup requires a single dataset reference.")
|
|
230
|
+
value = reference(client, values[0], kind="dataset")
|
|
231
|
+
return {"external": value} if stage == "filter" else value
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def convert(run, cfg, *, start=None, end=None):
|
|
235
|
+
client = run.client()
|
|
236
|
+
cfg = normalized_keys(cfg)
|
|
237
|
+
# 平台共用配置模型导出时会附带另一任务类型的空默认字段。
|
|
238
|
+
if cfg.get("experts") == {}:
|
|
239
|
+
cfg.pop("experts")
|
|
240
|
+
if "base" in cfg and cfg["base"] is None:
|
|
241
|
+
cfg.pop("base")
|
|
242
|
+
known = METADATA | {
|
|
243
|
+
"schema_version",
|
|
244
|
+
"parameter_contract",
|
|
245
|
+
"from",
|
|
246
|
+
"to",
|
|
247
|
+
"student",
|
|
248
|
+
"teachers",
|
|
249
|
+
"stages",
|
|
250
|
+
*ORDER,
|
|
251
|
+
*ALIASES,
|
|
252
|
+
}
|
|
253
|
+
if set(cfg) - known:
|
|
254
|
+
raise UsageError(
|
|
255
|
+
"Unknown Fusion configuration fields: "
|
|
256
|
+
+ ", ".join(sorted(set(cfg) - known))
|
|
257
|
+
)
|
|
258
|
+
document = {
|
|
259
|
+
key: deepcopy(cfg[key])
|
|
260
|
+
for key in ("schema_version", "parameter_contract")
|
|
261
|
+
if key in cfg
|
|
262
|
+
}
|
|
263
|
+
document.update(
|
|
264
|
+
{
|
|
265
|
+
"from": stage_name(start or cfg.get("from", "split")),
|
|
266
|
+
"to": stage_name(end or cfg.get("to", "opd")),
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
if ORDER.index(document["from"]) > ORDER.index(document["to"]):
|
|
270
|
+
raise UsageError("from must not be later than to.")
|
|
271
|
+
if cfg.get("student") is not None:
|
|
272
|
+
document["student"] = reference(client, cfg["student"])
|
|
273
|
+
if cfg.get("teachers"):
|
|
274
|
+
document["teachers"] = teachers(
|
|
275
|
+
client, cfg["teachers"], student=document.get("student")
|
|
276
|
+
)
|
|
277
|
+
document["stages"] = {}
|
|
278
|
+
raw_stages = deepcopy(cfg.get("stages", {}))
|
|
279
|
+
if not isinstance(raw_stages, dict):
|
|
280
|
+
raise UsageError("stages must be an object.")
|
|
281
|
+
for name in (*ORDER, *ALIASES):
|
|
282
|
+
if name in cfg:
|
|
283
|
+
if name in raw_stages:
|
|
284
|
+
raise UsageError("Duplicate stage configuration: " + name)
|
|
285
|
+
raw_stages[name] = cfg[name]
|
|
286
|
+
for original, raw in raw_stages.items():
|
|
287
|
+
name = stage_name(original)
|
|
288
|
+
if name in document["stages"] or not isinstance(raw, dict):
|
|
289
|
+
raise UsageError(
|
|
290
|
+
"Duplicate stage/alias or invalid stage object: " + original
|
|
291
|
+
)
|
|
292
|
+
raw = normalized_keys(raw)
|
|
293
|
+
advanced = bool(set(raw) & {"inputs", "params", "resources"})
|
|
294
|
+
if "set" in raw and "params" in raw:
|
|
295
|
+
raise UsageError("Specify either set or params.")
|
|
296
|
+
params = stage_params(raw.get("params", raw.get("set", {})), stage=name)
|
|
297
|
+
controls = {
|
|
298
|
+
"inputs",
|
|
299
|
+
"params",
|
|
300
|
+
"set",
|
|
301
|
+
"resources",
|
|
302
|
+
"hardware",
|
|
303
|
+
"workers",
|
|
304
|
+
"input",
|
|
305
|
+
"student",
|
|
306
|
+
"teacher_hardware",
|
|
307
|
+
"checkpoint_precision",
|
|
308
|
+
}
|
|
309
|
+
for key, value in raw.items():
|
|
310
|
+
if key not in controls:
|
|
311
|
+
if key in params:
|
|
312
|
+
raise UsageError("Duplicate stage parameter: " + key)
|
|
313
|
+
params[key] = value
|
|
314
|
+
if not isinstance(raw.get("inputs", {}), dict):
|
|
315
|
+
raise UsageError("Stage inputs must be an object.")
|
|
316
|
+
inputs = {
|
|
317
|
+
port: port_reference(
|
|
318
|
+
client,
|
|
319
|
+
value,
|
|
320
|
+
kind="model" if port in {"student", "teacher"} else "dataset",
|
|
321
|
+
)
|
|
322
|
+
for port, value in raw.get("inputs", {}).items()
|
|
323
|
+
}
|
|
324
|
+
if "input" in raw:
|
|
325
|
+
if inputs:
|
|
326
|
+
raise UsageError("Specify either input or inputs.")
|
|
327
|
+
port = {
|
|
328
|
+
"split": "prompt_set",
|
|
329
|
+
"generate": "prompt_a",
|
|
330
|
+
"filter": "distill_data",
|
|
331
|
+
"sft": "sft_dataset",
|
|
332
|
+
"opd": "prompt_b",
|
|
333
|
+
}[name]
|
|
334
|
+
value = port_reference(client, raw["input"], kind="dataset")
|
|
335
|
+
if name in {"generate", "opd"} and not set(value) & {
|
|
336
|
+
"asset",
|
|
337
|
+
"path",
|
|
338
|
+
"from",
|
|
339
|
+
"snapshot",
|
|
340
|
+
"domains",
|
|
341
|
+
}:
|
|
342
|
+
value = {"domains": value}
|
|
343
|
+
if (
|
|
344
|
+
name == "filter"
|
|
345
|
+
and set(value) & {"asset", "path", "from", "snapshot"}
|
|
346
|
+
and "from" not in value
|
|
347
|
+
):
|
|
348
|
+
value = {"external": value}
|
|
349
|
+
inputs[port] = value
|
|
350
|
+
if "student" in raw:
|
|
351
|
+
inputs["student"] = reference(client, raw["student"])
|
|
352
|
+
if raw.get("checkpoint_precision") is not None:
|
|
353
|
+
params["checkpoint_precision"] = raw["checkpoint_precision"]
|
|
354
|
+
if "workers" in raw:
|
|
355
|
+
if type(raw["workers"]) is not int or raw["workers"] < 1:
|
|
356
|
+
raise UsageError("workers must be a positive integer.")
|
|
357
|
+
if name == "generate":
|
|
358
|
+
params["workers"] = raw["workers"]
|
|
359
|
+
elif name in {"sft", "opd"}:
|
|
360
|
+
topology = params.setdefault("topology", {})
|
|
361
|
+
if not isinstance(topology, dict):
|
|
362
|
+
raise UsageError("topology must be an object.")
|
|
363
|
+
if "actor_nodes" in topology:
|
|
364
|
+
raise UsageError("Specify either workers or topology.actor_nodes.")
|
|
365
|
+
topology["actor_nodes"] = raw["workers"]
|
|
366
|
+
else:
|
|
367
|
+
raise UsageError("This stage does not accept workers.")
|
|
368
|
+
resources = raw.get("resources")
|
|
369
|
+
if raw.get("hardware"):
|
|
370
|
+
if resources is not None:
|
|
371
|
+
raise UsageError("Specify either hardware or resources.")
|
|
372
|
+
resources = hardware(client, raw["hardware"])
|
|
373
|
+
if raw.get("teacher_hardware"):
|
|
374
|
+
if name != "opd":
|
|
375
|
+
raise UsageError("teacher-hardware is only available for OPD.")
|
|
376
|
+
if "teacher_resources" in params:
|
|
377
|
+
raise UsageError(
|
|
378
|
+
"Specify either teacher-hardware or teacher_resources."
|
|
379
|
+
)
|
|
380
|
+
params["teacher_resources"] = hardware(client, raw["teacher_hardware"])
|
|
381
|
+
elif name == "opd" and resources is not None and "teacher_resources" not in params and (not advanced or raw.get("hardware")):
|
|
382
|
+
# 新 PRD 的硬件写法默认逐 Teacher 使用 Student 单 Worker 规格;历史原生配置不改默认值。
|
|
383
|
+
params["teacher_resources"] = deepcopy(resources)
|
|
384
|
+
if not advanced and name == "opd":
|
|
385
|
+
params.setdefault("distill_divergence", "jsd")
|
|
386
|
+
if not advanced and name == "sft":
|
|
387
|
+
params.setdefault("training_precision", "fp8")
|
|
388
|
+
if params["training_precision"] == "fp8":
|
|
389
|
+
params.setdefault("training_backend", "main_training")
|
|
390
|
+
stage = {"inputs": inputs, "params": stage_params(params, stage=name)}
|
|
391
|
+
if resources is not None:
|
|
392
|
+
stage["resources"] = resources
|
|
393
|
+
document["stages"][name] = stage
|
|
394
|
+
return document
|