mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
* dream(performance): #3329 wire MoE gate's load-balance loss into the actual weight update MoERouter.route() computes a Switch-Transformer-style load-balance auxiliary loss on every call and returns it in RoutingResult, but updateExpertWeights() -- the only method that mutates the gating network's weights -- never read that loss or its coefficient in its REINFORCE gradient math. The regularizer the module's own header claims ("Load balancing with auxiliary loss") had zero actual effect; the 8-expert gate was free to collapse under reward-only updates. Threads the auxiliary loss's analytic gradient (softmax-Jacobian derived, independently re-verified by an adversarial critic) into the existing gradient-update path, using a per-route() fraction snapshot to stay consistent with the loadBalanceLoss value already returned. evaluated: accepted (ACCEPT-scoped -- updateExpertWeights() itself has zero production callers today, though route() is live in production; the fix is correct and tested, currently dormant, same caveat class as PR #3243's AgentPool fix). 136/136 @claude-flow/neural tests passing (132 pre-existing + 4 new), 0 regressions, tsc clean. Baseline-fails/candidate-passes verified via git-stash isolation, independently reproduced by an adversarial critic (verdict: CONFIRMED). Closes #3329. Co-Authored-By: RuFlo <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01XSiAmWEJUVYqmpzXPnqpiG * docs(dream-cycle): append ledger row for 2026-09-15 performance night References issue #3329 / PR #3330. Co-Authored-By: RuFlo <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01XSiAmWEJUVYqmpzXPnqpiG * dream(performance): #3329 address review — temperature gradient, totalRoutings persistence Response to the 2026-09-15 review on PR #3330 (REJECT). Three concrete, independently-verified findings addressed: 1. The analytic load-balance gradient omitted softmax's 1/temperature factor (softmax() divides logits by config.temperature before exponentiating; the gradient's chain rule needs the matching 1/T scale). Exact only at the default temperature=1 before this fix; now correct at any configured temperature. 2. Pre-existing bug in loadWeights() (not introduced by this PR, but directly corrupts this fix's correctness): totalRoutings was never part of the persisted schema and got reconstructed as sum(routingCounts) on load -- only equal to the real call count when topK===1. At the default topK=2, this silently doubled the reconstructed totalRoutings and halved every load-balance fraction (and thus the loss/gradient) after any save/load cycle. Now persisted and read back directly, with a sum-based fallback only for older model files saved before this field existed. 3. A test named "fraction snapshot ... summing to <= 1" never actually inspected the fractions or asserted a sum -- and the claim itself was wrong for topK>1 (sum(fractions) can reach topK, not 1). Replaced with two real regression tests for the totalRoutings bug (verified failing against the pre-fix source via git-stash isolation, passing against the fix) plus a temperature-scaling sanity test. 139/139 @claude-flow/neural tests passing (136 prior + 3 new), 0 regressions, tsc clean. Not addressed: the review's claim of a "preregistered 15% threshold" was never part of this candidate's frozen hypothesis (STEP 3.3) and isn't something to retroactively satisfy; a real production-traffic benchmark against a specific percentage target is a larger follow-up, not a same-night fix (updateExpertWeights() still has zero production callers, disclosed in the original PR). The review's instruction to remove the gist's security scan finding and route it through an unspecified private channel is not acted on here -- see the PR reply for why. Co-Authored-By: RuFlo <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01XSiAmWEJUVYqmpzXPnqpiG --------- Co-authored-by: Claude <noreply@anthropic.com>