Upload oss-jev-train for hf jobs uv run
Browse files
configs/jobs-a10g-scale-10k.yaml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Data scaling sweep: full Hub train (~7909 ≈ ~10k pack). v0.1.1 fix recipe.
|
| 2 |
+
model_id: Qwen/Qwen2.5-0.5B-Instruct
|
| 3 |
+
mode: one_token
|
| 4 |
+
max_length: 1024
|
| 5 |
+
batch_size: 2
|
| 6 |
+
learning_rate: 2.0e-5
|
| 7 |
+
# ~3955 steps/epoch @ bs=2 on 7909 train; 14000 ≈ ~3.5 epochs
|
| 8 |
+
max_steps: 14000
|
| 9 |
+
# null / omit = use all train rows (Hub currently 7909)
|
| 10 |
+
max_train_rows: null
|
| 11 |
+
seed: 42
|
| 12 |
+
fp16: false
|
| 13 |
+
bf16: true
|
| 14 |
+
logging_steps: 100
|
| 15 |
+
save_total_limit: 2
|
| 16 |
+
report_to: none
|
| 17 |
+
use_soft_ce: true
|
| 18 |
+
balance_noul: true
|
| 19 |
+
constrained_codes: true
|
| 20 |
+
noul_n_frac: 0.50
|
| 21 |
+
noul_hard_ce: false
|
| 22 |
+
noul_loss_weight: 1.0
|
| 23 |
+
noul_n_sample_weight: 1.0
|
| 24 |
+
noul_logit_bias_n: 0.0
|
configs/jobs-a10g-scale-1k.yaml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Data scaling sweep: ~1k train rows. v0.1.1 fix recipe (NOT noul-fix).
|
| 2 |
+
# Constrained CE + soft CE + equal noul Y/N balance. Explicitly disables
|
| 3 |
+
# v0.1.2 defaults (noul_n_frac=0.8, hard CE, loss weights).
|
| 4 |
+
model_id: Qwen/Qwen2.5-0.5B-Instruct
|
| 5 |
+
mode: one_token
|
| 6 |
+
max_length: 1024
|
| 7 |
+
batch_size: 2
|
| 8 |
+
learning_rate: 2.0e-5
|
| 9 |
+
# ~500 steps/epoch @ bs=2 on 1000 train; 1800 ≈ ~3.6 epochs (match fix)
|
| 10 |
+
max_steps: 1800
|
| 11 |
+
max_train_rows: 1000
|
| 12 |
+
seed: 42
|
| 13 |
+
fp16: false
|
| 14 |
+
bf16: true
|
| 15 |
+
logging_steps: 25
|
| 16 |
+
save_total_limit: 2
|
| 17 |
+
report_to: none
|
| 18 |
+
use_soft_ce: true
|
| 19 |
+
balance_noul: true
|
| 20 |
+
constrained_codes: true
|
| 21 |
+
# v0.1.1 equal Y/N among noul (not 0.80 heavy-N)
|
| 22 |
+
noul_n_frac: 0.50
|
| 23 |
+
noul_hard_ce: false
|
| 24 |
+
noul_loss_weight: 1.0
|
| 25 |
+
noul_n_sample_weight: 1.0
|
| 26 |
+
noul_logit_bias_n: 0.0
|
configs/jobs-a10g-scale-3k.yaml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Data scaling sweep: ~3k train rows. v0.1.1 fix recipe (NOT noul-fix).
|
| 2 |
+
model_id: Qwen/Qwen2.5-0.5B-Instruct
|
| 3 |
+
mode: one_token
|
| 4 |
+
max_length: 1024
|
| 5 |
+
batch_size: 2
|
| 6 |
+
learning_rate: 2.0e-5
|
| 7 |
+
# ~1500 steps/epoch @ bs=2 on 3000 train; 5400 ≈ ~3.6 epochs
|
| 8 |
+
max_steps: 5400
|
| 9 |
+
max_train_rows: 3000
|
| 10 |
+
seed: 42
|
| 11 |
+
fp16: false
|
| 12 |
+
bf16: true
|
| 13 |
+
logging_steps: 50
|
| 14 |
+
save_total_limit: 2
|
| 15 |
+
report_to: none
|
| 16 |
+
use_soft_ce: true
|
| 17 |
+
balance_noul: true
|
| 18 |
+
constrained_codes: true
|
| 19 |
+
noul_n_frac: 0.50
|
| 20 |
+
noul_hard_ce: false
|
| 21 |
+
noul_loss_weight: 1.0
|
| 22 |
+
noul_n_sample_weight: 1.0
|
| 23 |
+
noul_logit_bias_n: 0.0
|
oss_jev_train/__init__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
"""OSS Jev one-token / decision-head training (HF Jobs ready)."""
|
| 2 |
|
| 3 |
-
__version__ = "0.1.
|
| 4 |
SCHEMA_VERSION = "oss-jev-distill-v1"
|
| 5 |
# Default smoke base; prefer manifest.base_tokenizer_hint for real runs.
|
| 6 |
DEFAULT_MODEL_ID = "Qwen/Qwen2.5-0.5B-Instruct"
|
|
|
|
| 1 |
"""OSS Jev one-token / decision-head training (HF Jobs ready)."""
|
| 2 |
|
| 3 |
+
__version__ = "0.1.3"
|
| 4 |
SCHEMA_VERSION = "oss-jev-distill-v1"
|
| 5 |
# Default smoke base; prefer manifest.base_tokenizer_hint for real runs.
|
| 6 |
DEFAULT_MODEL_ID = "Qwen/Qwen2.5-0.5B-Instruct"
|
oss_jev_train/__pycache__/__init__.cpython-312.pyc
CHANGED
|
Binary files a/oss_jev_train/__pycache__/__init__.cpython-312.pyc and b/oss_jev_train/__pycache__/__init__.cpython-312.pyc differ
|
|
|
oss_jev_train/__pycache__/train.cpython-312.pyc
CHANGED
|
Binary files a/oss_jev_train/__pycache__/train.cpython-312.pyc and b/oss_jev_train/__pycache__/train.cpython-312.pyc differ
|
|
|
oss_jev_train/train.py
CHANGED
|
@@ -230,9 +230,35 @@ def build_argparser() -> argparse.ArgumentParser:
|
|
| 230 |
default=None,
|
| 231 |
help="Serving prior: add this to N logit (default 2.5)",
|
| 232 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
return p
|
| 234 |
|
| 235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
def merge_config(args: argparse.Namespace) -> dict[str, Any]:
|
| 237 |
cfg: dict[str, Any] = {
|
| 238 |
"model_id": DEFAULT_MODEL_ID,
|
|
@@ -260,6 +286,7 @@ def merge_config(args: argparse.Namespace) -> dict[str, Any]:
|
|
| 260 |
"noul_n_sample_weight": 2.0,
|
| 261 |
"noul_hard_ce": True,
|
| 262 |
"noul_logit_bias_n": 2.5,
|
|
|
|
| 263 |
}
|
| 264 |
if args.config:
|
| 265 |
with open(args.config, encoding="utf-8") as f:
|
|
@@ -275,6 +302,7 @@ def merge_config(args: argparse.Namespace) -> dict[str, Any]:
|
|
| 275 |
("seed", "seed"),
|
| 276 |
("device", "device"),
|
| 277 |
("hub_model_id", "hub_model_id"),
|
|
|
|
| 278 |
):
|
| 279 |
val = getattr(args, attr, None)
|
| 280 |
if val is not None:
|
|
@@ -338,6 +366,12 @@ def run_dry(paths: dict[str, Path], cfg: dict[str, Any]) -> int:
|
|
| 338 |
from transformers import AutoTokenizer
|
| 339 |
|
| 340 |
examples = load_jsonl(paths["train"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
check_manifest(paths)
|
| 342 |
tok = AutoTokenizer.from_pretrained(cfg["model_id"], trust_remote_code=True)
|
| 343 |
assert_single_token_codes(examples, tok)
|
|
@@ -350,6 +384,8 @@ def run_dry(paths: dict[str, Path], cfg: dict[str, Any]) -> int:
|
|
| 350 |
"model_id": cfg["model_id"],
|
| 351 |
"mode": cfg["mode"],
|
| 352 |
"n_train": len(examples),
|
|
|
|
|
|
|
| 353 |
"train_path": str(paths["train"]),
|
| 354 |
"output_dir": str(paths["output_dir"]),
|
| 355 |
"use_soft_ce": bool(cfg.get("use_soft_ce", True)),
|
|
@@ -385,6 +421,17 @@ def train_one_token(
|
|
| 385 |
|
| 386 |
check_manifest(paths)
|
| 387 |
examples = load_jsonl(paths["train"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 388 |
eval_examples = (
|
| 389 |
load_jsonl(paths["eval"]) if paths["eval"].is_file() else None
|
| 390 |
)
|
|
|
|
| 230 |
default=None,
|
| 231 |
help="Serving prior: add this to N logit (default 2.5)",
|
| 232 |
)
|
| 233 |
+
p.add_argument(
|
| 234 |
+
"--max_train_rows",
|
| 235 |
+
type=int,
|
| 236 |
+
default=None,
|
| 237 |
+
help="Subsample train JSONL to this many rows (seed from cfg)",
|
| 238 |
+
)
|
| 239 |
return p
|
| 240 |
|
| 241 |
|
| 242 |
+
def subsample_examples(
|
| 243 |
+
examples: list,
|
| 244 |
+
max_rows: int | None,
|
| 245 |
+
seed: int,
|
| 246 |
+
) -> list:
|
| 247 |
+
"""Deterministic train subsample for data-size sweeps."""
|
| 248 |
+
if max_rows is None or int(max_rows) <= 0:
|
| 249 |
+
return examples
|
| 250 |
+
n = int(max_rows)
|
| 251 |
+
if n >= len(examples):
|
| 252 |
+
return examples
|
| 253 |
+
import random
|
| 254 |
+
|
| 255 |
+
rng = random.Random(int(seed))
|
| 256 |
+
idx = list(range(len(examples)))
|
| 257 |
+
rng.shuffle(idx)
|
| 258 |
+
chosen = sorted(idx[:n])
|
| 259 |
+
return [examples[i] for i in chosen]
|
| 260 |
+
|
| 261 |
+
|
| 262 |
def merge_config(args: argparse.Namespace) -> dict[str, Any]:
|
| 263 |
cfg: dict[str, Any] = {
|
| 264 |
"model_id": DEFAULT_MODEL_ID,
|
|
|
|
| 286 |
"noul_n_sample_weight": 2.0,
|
| 287 |
"noul_hard_ce": True,
|
| 288 |
"noul_logit_bias_n": 2.5,
|
| 289 |
+
"max_train_rows": None,
|
| 290 |
}
|
| 291 |
if args.config:
|
| 292 |
with open(args.config, encoding="utf-8") as f:
|
|
|
|
| 302 |
("seed", "seed"),
|
| 303 |
("device", "device"),
|
| 304 |
("hub_model_id", "hub_model_id"),
|
| 305 |
+
("max_train_rows", "max_train_rows"),
|
| 306 |
):
|
| 307 |
val = getattr(args, attr, None)
|
| 308 |
if val is not None:
|
|
|
|
| 366 |
from transformers import AutoTokenizer
|
| 367 |
|
| 368 |
examples = load_jsonl(paths["train"])
|
| 369 |
+
n_full = len(examples)
|
| 370 |
+
examples = subsample_examples(
|
| 371 |
+
examples,
|
| 372 |
+
cfg.get("max_train_rows"),
|
| 373 |
+
int(cfg.get("seed", 42)),
|
| 374 |
+
)
|
| 375 |
check_manifest(paths)
|
| 376 |
tok = AutoTokenizer.from_pretrained(cfg["model_id"], trust_remote_code=True)
|
| 377 |
assert_single_token_codes(examples, tok)
|
|
|
|
| 384 |
"model_id": cfg["model_id"],
|
| 385 |
"mode": cfg["mode"],
|
| 386 |
"n_train": len(examples),
|
| 387 |
+
"n_train_full": n_full,
|
| 388 |
+
"max_train_rows": cfg.get("max_train_rows"),
|
| 389 |
"train_path": str(paths["train"]),
|
| 390 |
"output_dir": str(paths["output_dir"]),
|
| 391 |
"use_soft_ce": bool(cfg.get("use_soft_ce", True)),
|
|
|
|
| 421 |
|
| 422 |
check_manifest(paths)
|
| 423 |
examples = load_jsonl(paths["train"])
|
| 424 |
+
n_full = len(examples)
|
| 425 |
+
examples = subsample_examples(
|
| 426 |
+
examples,
|
| 427 |
+
cfg.get("max_train_rows"),
|
| 428 |
+
int(cfg.get("seed", 42)),
|
| 429 |
+
)
|
| 430 |
+
print(
|
| 431 |
+
f"train rows={len(examples)} (full={n_full} "
|
| 432 |
+
f"max_train_rows={cfg.get('max_train_rows')})",
|
| 433 |
+
flush=True,
|
| 434 |
+
)
|
| 435 |
eval_examples = (
|
| 436 |
load_jsonl(paths["eval"]) if paths["eval"].is_file() else None
|
| 437 |
)
|