Skip to content

Pin batch-size invariance of safety and judge generation in fp32 (batch_size 1 / 2 / 4 / 8) #922

Open

Description

@cemililik

Deferred work · F-PR29-A8-10 · severity Low · cost ~1-2 h · recorded in docs/roadmap/risks-and-decisions.md:91

Summary

Both gates generate the answers they score with left-padded, batched greedy decoding (forgelm/safety/_generate.py, forgelm/judge.py), but every test stubs the batched helpers, so a change that made results depend on batch_size would ship without a failing test. The PR #29 review deferred the determinism test. #677 shows bf16 output legitimately varies with batch size, so the contract to pin is fp32.

Condition or budget

None recorded (the row still names v0.6.x).

State today (re-checked 2026-10-09)

No determinism test exists; the only batch_size tests check input validation.

Related

#676 asks for a safety-side batched-versus-single test (and accepts a weaker padding-side fix for the judge); #677 documents the bf16 variance.

Acceptance criteria

  • A tiny-model fp32 test runs safety generation and judge generation at batch_size 1, 2, 4 and 8 and asserts identical outputs.
  • The row is removed from the deferral table and the CHANGELOG names its ID (the table's removal contract).

Recorded in docs/roadmap/risks-and-decisions.md (read at f94595f) and re-checked against the code on 2026-10-09. The row leaves that table only when the fix is on main, the CHANGELOG names its ID and any promised guard exists.

Activity

  1. added
    severity: lowMinor defect, inaccuracy or rough edge
    wave: 4Roadmap wave 4: low / info / watch, when touching the module
    source: roadmapPlanned or deferred work recorded in docs/roadmap/
    on Oct 9, 2026
  2. cemililik commented on Oct 11, 2026

    @cemililik
    CollaboratorAuthor

    Where to start

    Thanks for taking a look. Please confirm the issue is unassigned and comment before starting so work does not overlap.

    Start with these files on development:

    Construct a tiny seeded causal model and tokenizer locally in fp32/eval mode, with short prompts of differing lengths and left padding. Assert identical decoded outputs for batch sizes 1, 2, 4 and 8 through both real helpers; do not mock the generation helper or download a Hub model. Include a case sensitive to padding errors. Follow the deferral table's removal contract: reference the implementation now and remove the row only when the fix is on main; name F-PR29-A8-10 in the changelog.

    Test-only task, no bf16 determinism claim or production model benchmark. Needs familiarity with a tiny local Transformers fixture; allow ~2 h, subject to maintainer review of that estimate.

    Run the focused tests:

    pytest tests/test_safety_advanced.py tests/test_judge_functions.py --no-cov

    Run these guards/checks as applicable to the changed files:

    ruff format --check forgelm/safety/_generate.py forgelm/judge.py tests/test_safety_advanced.py tests/test_judge_functions.py
    ruff check forgelm/safety/_generate.py forgelm/judge.py tests/test_safety_advanced.py tests/test_judge_functions.py
    python3 tools/check_bilingual_parity.py --strict
    python3 tools/check_bilingual_code_blocks.py --strict
    python3 tools/check_anchor_resolution.py --strict
    python3 tools/check_tr_links_prefer_mirror.py --strict
    python3 tools/check_usermanual_self_contained.py --strict
    python3 tools/check_usermanual_schema_drift.py --strict

    If user-facing documentation changes, update the existing Turkish mirror in the same PR; keep commands, code and terminal output in English and structurally aligned. English-only contributor standards need no new mirror.

    Open the PR against development with Fixes #922 once every finding is resolved or explicitly closed with a reason; use Refs #922 for partial work and list the resolved finding IDs.

  3. added
    help wantedExtra attention is needed
    and removed on Oct 11, 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

    area: eval-gatesCode area: eval-gateshelp wantedExtra attention is neededseverity: lowMinor defect, inaccuracy or rough edgesource: roadmapPlanned or deferred work recorded in docs/roadmap/wave: 4Roadmap wave 4: low / info / watch, when touching the module

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions