feat(data): add degenerate sample detection and governance (#217) - #307
Open
HDM-xymm wants to merge 5 commits into
Open
feat(data): add degenerate sample detection and governance (#217)#307HDM-xymm wants to merge 5 commits into
HDM-xymm wants to merge 5 commits into
Conversation
HDM-xymm
force-pushed
the
feat/issue-217-degenerate-sample-governance
branch
from
July 28, 2026 08:44
a6e7a97 to
7f0eb23
Compare
…AI#217) Add degenerate sample detection utilities in areno.api.data that identify empty, whitespace-only, special-token-only, no-trainable-token, and identical DPO preference branch samples. Integrate detection into the SFT, DPO, and policy rollout paths with configurable SKIP/ERROR policy. - Add DegenerateReason, DegeneratePolicy, DegenerateFilterConfig, SampleQualityReport dataclasses and 6 check_* detection functions - Integrate into Trainer.load_prompt_batches, SFT, DPO, and PolicyOnly paths - Add --degenerate-policy CLI flag and trainer_config field - Add PromptBatch counters for skipped_degenerate and degenerate_reasons - Add 23 CPU-only unit tests (no GPU/tokenizer dependency) - Add user docs and design doc for issue inclusionAI#217
- Remove unused check_response_text import from DPO trainer - Simplify _make_sequence trainable token check to avoid redundant any() call - Add comment explaining backward-compatible empty response check in SFT - Fix missing trailing newline in cli/train.py - Collapse record_degenerate_reason signature to single line
- Rebase onto latest main (4f908e7) with proper conflict resolution - Fix indentation errors in trainer_config.py from merge - Add degenerate_policy='skip' to test SimpleNamespace mocks - Add degenerate_filter_config() to SFT test config mock - Remove unused skipped_degenerate variable in sft.py - Fix missing trailing newline in __init__.py - Preserve main's backend_config/cuda_config/mlx_config API alongside degenerate_filter_config
HDM-xymm
force-pushed
the
feat/issue-217-degenerate-sample-governance
branch
from
August 24, 2026 03:30
60b2693 to
ade342d
Compare
HDM-xymm
pushed a commit
to HDM-xymm/AReno
that referenced
this pull request
Aug 28, 2026
Merge upstream/main into feat/issue-217-degenerate-sample-governance. Conflict resolutions (3 files, 8 conflicts): - areno/api/__init__.py: keep both LoraConfig (upstream) and DegenerateFilterConfig/DegeneratePolicy/DegenerateReason (PR) - areno/api/trainer_config.py: keep both degenerate_policy field (PR) and lora/reference_mode fields (upstream) - areno/cli/train.py: keep both degenerate_policy CLI option (PR) and lora/reference_mode CLI options (upstream); restore missing optimizer_state_offload getattr defaults
Merge upstream/main into feat/issue-217-degenerate-sample-governance. Conflict resolutions (3 files, 8 conflicts): - areno/api/__init__.py: keep both LoraConfig (upstream) and DegenerateFilterConfig/DegeneratePolicy/DegenerateReason (PR) - areno/api/trainer_config.py: keep both degenerate_policy field (PR) and lora/reference_mode fields (upstream) - areno/cli/train.py: keep both degenerate_policy CLI option (PR) and lora/reference_mode CLI options (upstream); restore missing optimizer_state_offload getattr defaults
HDM-xymm
force-pushed
the
feat/issue-217-degenerate-sample-governance
branch
from
August 28, 2026 08:38
a5b14db to
baaad9e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Add degenerate sample detection utilities in
areno.api.datathat identify empty, whitespace-only, special-token-only, no-trainable-token, and identical DPO preference branch samples. The detection is integrated into the SFT, DPO, and policy rollout paths with configurable SKIP/ERROR policy.Key changes:
DegenerateReason,DegeneratePolicy,DegenerateFilterConfig,SampleQualityReportdataclasses and 6check_*detection functionsTrainer.load_prompt_batches, SFT, DPO, andPolicyOnlypaths--degenerate-policyCLI flag andtrainer_configfieldPromptBatchcounters forskipped_degenerateanddegenerate_reasonsUsage
Control degenerate sample handling via CLI:
Detection covers 5 categories across pre- and post-tokenization stages:
Example output
With --degenerate-policy skip (default), degenerate rows are filtered and counted:
With --degenerate-policy error, the first degenerate sample raises:
ValueError: degenerate sample detected (pre_tokenization): prompt is an empty string
Related issue
Fixes #217
Type of change
How was it tested?
23 CPU-only unit tests covering:
check_prompt_text — empty and whitespace-only prompt detection
check_response_text — empty and whitespace-only response detection
check_tokenized_prompt — zero-length and all-special-token detection
check_trainable_tokens — all-prompt-mask (no trainable token) detection
check_preference_pair — identical DPO chosen/rejected branch detection
apply_degenerate_policy — SKIP returns True, ERROR raises ValueError, disabled config passes through
record_degenerate_reason / format_degenerate_reasons — reason counting and formatting
No GPU or tokenizer dependency. Existing tests pass with default skip policy (backward-compatible).
Checklist
pytest tests/ -k cpu).##Update
-Update (2026-08-24): Rebased onto latest main to resolve merge conflicts with the MLX backend and multimodal optimizer features. Fixed lint errors (unused variable, import ordering, formatting) and
updated test mocks to include the new degenerate_policy field and degenerate_filter_config() method.