Skip to content

[Triage] SFT formatting map spawns up to 8 worker processes for a trivial string-join and gives no measured gain (CR-A03-095) #82

Closed as not planned

Description

@cemililik

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.

Where.

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.

Activity

  1. added
    bugSomething isn't working
    needs-triageNot triaged yet: every new issue starts with it; only a maintainer removes it
    source: review-2026-10Found by the October 2026 code and documentation review
    on Oct 9, 2026
  2. cemililik commented on Oct 20, 2026

    @cemililik
    CollaboratorAuthor

    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.

  3. added
    wontfixThis will not be worked on
    and removed
    needs-triageNot triaged yet: every new issue starts with it; only a maintainer removes it
    bugSomething isn't working
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    source: review-2026-10Found by the October 2026 code and documentation reviewwontfixThis will not be worked on

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions