Skip to content

Fix #2364: [Bug] MIN_ADAPTIVE_BASELINE floor untuned for v2.0.7 normalized backprop reward - #2604

Open
syzsunshine219 wants to merge 1 commit into
MemTensor:mainfrom
Memtensor-AI:bugfix/autodev-2364-20260914203909369
Open

syzsunshine219 wants to merge 1 commit into
MemTensor:mainfrom
Memtensor-AI:bugfix/autodev-2364-20260914203909369

Conversation

@syzsunshine219

Copy link
Copy Markdown
Collaborator

Restores the proposal from #2367 as an open PR against main; its former base branch, dev-v2.0.34, is no longer available. This proposal requires maintainer review of the feature or design direction before merging.

Source head: 9dcb98a44346c9a02437fb6500af65ea73e30ef0. No new source-code changes are introduced by restoring this proposal. Earlier discussion and evidence remain in #2367; validation claims in the original description refer to the earlier snapshot.

Outstanding review scope

旧 PR 将 adaptiveBaseline 最低值从0.2调到0.005,依据是生产已经采用V≈R/N的归一化贡献值;当前main实际仍调用旧的右到左递推backprop,该前提不成立。不得把缺少0.005直接认定遗漏修复,需结合当前打分分布决定阈值。


Original proposal

Description

Retunes MIN_ADAPTIVE_BASELINE in apps/memos-local-plugin/core/memory/l2/gain.ts from 0.2 to 0.005, restoring the adaptive-baseline behavior that adaptiveBaseline() has always documented. Root cause: the v2.0.7 reward-backprop rewrite moved per-trace V values into a ~0.02–0.5 band (typical poolMean ~0.01–0.06), but the 0.2 floor was left over from the pre-v2.0.7 reward scale. Since Math.max(0.2, poolMean) pinned every real pool at 0.2, the adaptive branch became dead code — computeGain output was capped and shrinkTowardBaseline systematically penalized low-without-count candidate policies, stalling policy/skill promotion fleet-wide.

The retuned constant (0.005) matches the v2.0.7 minTraceValue floor already documented in core/config/defaults.ts, so poolMean values across the entire observed distribution now reach the adaptive branch. The MIN_ADAPTIVE_BASELINE guard only triggers for degenerate near-zero pools, which is the original design intent.

Verification: two new regression cases in tests/unit/memory/l2/gain.test.ts assert (a) the adaptive branch is reachable at typical v2.0.7 poolMean 0.03 and (b) MIN_ADAPTIVE_BASELINE ≤ config.minTraceValue. Full apps/memos-local-plugin unit suite green (1552 tests, 0 failures) and tsc --noEmit passes clean. gain.ts docstring plus the neighboring L2 README were updated to describe the v2.0.7 distribution and cross-link the shared floor with minTraceValue.

Files touched (3): apps/memos-local-plugin/core/memory/l2/gain.ts, apps/memos-local-plugin/core/memory/l2/README.md, apps/memos-local-plugin/tests/unit/memory/l2/gain.test.ts. Fix is minimal, reversible, and does not require a data migration — the change only affects gain computation for new promotion decisions. Refs #2364.

Related Issue (Required): Fixes #2364

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Not run; documentation-only change.

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have created related documentation issue/PR in MemOS-Docs (if applicable)
  • I have linked the issue to this PR (if applicable)
  • I have mentioned the person who will review this PR

@WeiminLee please review this PR.

Reviewer Checklist

adaptiveBaseline(poolMean) is documented as adaptive between
MIN_ADAPTIVE_BASELINE (0.2) and V7_NEUTRAL_BASELINE (0.5), but the
post-v2.0.7 normalized-credit backprop rewrite left per-trace V
values in a ~0.02-0.5 band. Since typical poolMean sits at ~0.01-0.06
(well below 0.2), Math.max(0.2, poolMean) pinned the baseline at a
stale 0.2 for effectively every pool, capping computeGain output and
skewing shrinkTowardBaseline against low-without-count candidate
policies. Policy/skill promotion stalled fleet-wide.

Retune MIN_ADAPTIVE_BASELINE to 0.005, matching the v2.0.7
minTraceValue floor in core/config/defaults.ts. The adaptive branch
of adaptiveBaseline is now reachable across the full observed V
distribution; the constant only kicks in for degenerate near-zero
pools.

- gain.ts: constant 0.2 -> 0.005, docstring rewritten to reference
  v2.0.7 backprop distribution and the issue's regression history
- README.md: replace stale "V_with ~ 0.7-0.85" description with the
  v2.0.7 0.02-0.5 range, cross-link MIN_ADAPTIVE_BASELINE + minTraceValue
- gain.test.ts: two new regression cases (adaptive branch reachable
  at typical poolMean 0.03; MIN_ADAPTIVE_BASELINE <= minTraceValue)

Refs: MemTensor#2364
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.

[Bug] MIN_ADAPTIVE_BASELINE floor untuned for v2.0.7 normalized backprop reward scale — policy/skill promotion gain capped near-permanently

1 participant