You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Triage] SFT formatting map spawns up to 8 worker processes for a trivial string-join and gives no measured gain (CR-A03-095) #82
Needs triage. Reviewers disagreed on this finding, so it is not counted in the backlog. Decide whether it is a real defect: if yes, set severity and wave; if not, close it with the reason.
CR-A03-095 — SFT formatting map spawns up to 8 worker processes for a trivial string-join and gives no measured gain
severity Info · confidence disputed · single reviewer · reproduced end to end
What happens. _format_sft_dataset runs .map(processor, batched=True, num_proc=min(os.cpu_count() or 1, 8)) (data.py:681-687) for every split. The processor is pure-Python string concatenation; tokenisation happens later in TRL. Measured on this 18-core macOS host (datasets 5.0, caching disabled, JSONL of messages rows): N=200: 0.30 s with 8 procs vs 0.17 s with 1; N=20k: 0.48 s vs 0.28 s; N=200k: 1.15 s vs 1.34 s. Break-even is about 200k rows, and the absolute difference is under a second. The cost is a fixed per-split pool start/dill pickling of the closure (a larger relative cost on spawn platforms, where each worker re-imports forgelm). On Linux (fork) the cost is likely lower; not measured.
Recommended fix. Use num_proc=None below a row threshold (say 100k) or drop it. Gain: 0.1-0.2 s per split plus fewer pool failures; negligible at the documented scale.
Found by the October 2026 ForgeLM code and documentation review against commit cab2947. Code links point at that commit; line numbers may have moved since. Finding IDs (CR-…, DOC-…, TECH-…) are stable references for this backlog.
We re-measured on datasets 5.0 with the real processor and JSONL-backed data (macOS, spawn start method). With 8 workers the fixed cost is about 0.15 s per split on tiny sets (0.01 s without), break-even is around 30-40k rows, and at 100k and 200k rows 8 workers are 2.4x and 3.5x faster (0.19 s vs 0.45 s, 0.26 s vs 0.92 s). We could not reproduce the slowdown at 200k rows, and the processor also validates every row and cleans text, so it is more than a join. Linux fork was not measured; its worker start-up is cheaper than spawn, so the small-data cost can only be lower.
The cost on small data is a fraction of a second and the gain on large corpora is real, so this is closed as not worth changing. If someone wants a small-dataset threshold, a separate enhancement issue is welcome.
Triage round 1, checked against development on 2026-10-20.
Activity
cemililik commentedon Oct 20, 2026
We re-measured on datasets 5.0 with the real processor and JSONL-backed data (macOS, spawn start method). With 8 workers the fixed cost is about 0.15 s per split on tiny sets (0.01 s without), break-even is around 30-40k rows, and at 100k and 200k rows 8 workers are 2.4x and 3.5x faster (0.19 s vs 0.45 s, 0.26 s vs 0.92 s). We could not reproduce the slowdown at 200k rows, and the processor also validates every row and cleans text, so it is more than a join. Linux fork was not measured; its worker start-up is cheaper than spawn, so the small-data cost can only be lower.
The cost on small data is a fraction of a second and the gain on large corpora is real, so this is closed as not worth changing. If someone wants a small-dataset threshold, a separate enhancement issue is welcome.
Triage round 1, checked against
developmenton 2026-10-20.