Skip to content

Reject nonfinite Q updates before persistence - #14

Draft
Frankie-Xu wants to merge 2 commits into
MemTensor:mainfrom
Frankie-Xu:fix/reject-nonfinite-q-updates
Draft

Frankie-Xu wants to merge 2 commits into
MemTensor:mainfrom
Frankie-Xu:fix/reject-nonfinite-q-updates

Conversation

@Frankie-Xu

Copy link
Copy Markdown

QValueUpdater.update currently writes NaN/Infinity into memory metadata when a reward, bootstrap value, configuration value, or stored Q/EMA is nonfinite. Finite arithmetic can also overflow before persistence. For example, calling update with reward=float('nan') writes a NaN q_value and reward_ma.

Validate the numerical inputs and computed target, Q, and reward EMA before calling text_mem.update. Validate the optional floor before applying it, so it cannot conceal invalid arithmetic. Invalid values raise ValueError and perform no persistence write; valid scalar updates retain the existing formula and floor behavior.

Validation: python3 -m unittest discover -s tests -p test_q_value_finite.py -q passes 3 tests (24 invalid input/overflow cases plus repeated valid updates). These regressions produced 24 failures against main c1b322c. git diff --check passes. Tests load the actual service module and replace only its MemOS type import and persistence boundary; no external MemOS service or end-to-end suite was run.

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.

1 participant