Skip to content

Fix parse_args split crash and add NaN guard to get_normalizer - #56

Merged
Randomizez merged 2 commits into
stepfun-ai:devfrom
WangXukang-cypher:fix/parse-args-split-equals
Sep 4, 2026
Merged

Randomizez merged 2 commits into
stepfun-ai:devfrom
WangXukang-cypher:fix/parse-args-split-equals

Conversation

@WangXukang-cypher

Copy link
Copy Markdown
Contributor

Summary

  • parse_args: o.split("=") splits on every = character. Config values containing = (e.g. load_path=s3://bucket/path?key=val) produce more than two parts, causing ValueError: too many values to unpack. Fixed by using o.split("=", 1).
  • get_normalizer: When any advantage element is NaN/inf, mean and std both become NaN. The downstream std.clip_(0.01) does not help because clamp(NaN) returns NaN per IEEE 754. All advantages silently become NaN, corrupting the training step. Added a ValueError check after computing mean and std.

Test plan

  • tests/test_arguments.py — 7 tests covering: normal key=value, values with =, Python literals, "false"/"null" edge cases
  • tests/test_get_normalizer.py — 4 tests covering: normal input, NaN input, inf input, constant input (std=0)
  • pytest tests/test_arguments.py tests/test_get_normalizer.py -v — all 11 tests pass
  • ruff check and ruff format pass on all changed files
  • Existing tests unaffected: pytest tests/exp/test_base_exp.py -v passes

`o.split("=")` splits on every `=` character, so values like
`load_path=s3://bucket/path?key=val` produce more than two parts
and the tuple-unpacking raises `ValueError: too many values to
unpack`.

Use `o.split("=", 1)` to limit the split to the first occurrence.
get_normalizer computes mean and std via all_reduce without checking
for non-finite values. If any advantage element is NaN (e.g. from a
degenerate reward or GAE), mean and std both become NaN. The caller's
`std.clip_(0.01)` does not help because `clamp(NaN)` returns NaN
per IEEE 754. All advantages silently become NaN, corrupting the
entire training step with no error raised.

Add a ValueError check after computing mean and std so the failure
is caught immediately at the source.
@WangXukang-cypher
WangXukang-cypher requested a review from a team September 4, 2026 02:57

@Randomizez Randomizez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Randomizez
Randomizez merged commit 5169489 into stepfun-ai:dev Sep 4, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants