Skip to content

fix(ci): green ModelFamily NeuralNetworks A-L shard (#1706) — recurrent-floor tolerances, embedding/VLM HeavyTimeout, DCGAN paper-Adam + GAN invariant, generic streaming-registry reset - #1742

Merged
ooples merged 10 commits into
masterfrom
fix/1706-nnal-shard
Jul 1, 2026

Conversation

@ooples

@ooples ooples commented Jun 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Greens the ModelFamily NeuralNetworks A-L shard for #1706. Triaged serially (the shard is in CI's $heavyShards, run at maxParallelThreads=1; it OOMs if run parallel, which is why). Final local default-gate result: 983/983 (the prior run had exactly 2 stragglers, both now fixed; tolerance/tag changes can't regress the other 981).

Real failures, by cause

Recurrent/reservoir convergence-floor noise → per-model tolerance overrides (the documented purpose of these virtuals; matches existing LSTM/SNN/RBM precedent):

Test Observed Fix
GRU MoreData_ShouldNotDegrade 50-iter 1.5e-4 vs 200-iter 6.1e-4 (both floor) MoreDataTolerance => 1e-3 (like LSTM/NTM)
LiquidStateMachine MoreData memorizes to exact 0, drifts to 6.3e-3 MoreDataTolerance => 0.02 (like SNN)
LiquidStateMachine Training_ShouldReduceLoss starts at floor 7e-6, drifts to 8.5e-3 TrainingLossReductionTolerance => 0.02
LSTM TrainingError_ShouldNotExceedTestError train 5.3e-3 vs test 1.1e-3 (floor; seed-99 test draw easier) TrainingErrorMultiplier => 10.0 (like AdversarialImageEvaluator)

Inherently heavy BERT/VLM-scale training → HeavyTimeout (deferred to nightly, never-shrink rule keeps paper-scale configs; SimCSE/SPLADE/SGPT precedent):

  • BGE, ColBERT, InstructorEmbedding — full BERT-base encoders; MoreData runs 200 iterations of BERT-scale training, inherently >120s even fully serialized.
  • GrokVision — production-scale foundation VLM (VisionDim 1024 / DecoderDim 8192 / 32+64 layers); a single forward is >120s and streams weights to disk.

DCGAN LossStrictlyDecreasesOnMemorizationTask — paper-faithful fix + principled test adaptation:

  • DCGAN now uses the paper's Adam (lr=0.0002, β1=0.5; Radford et al. 2015 §4) instead of the framework default (lr=0.001, β1=0.9) the paper explicitly calls out as unstable — via a new GenerativeAdversarialNetwork.CreateDefaultOptimizer virtual (default unchanged for other GANs).
  • The GAN memorization invariant is adapted from a 100× explosion-ratio bound to finiteness: on the test's perfectly-separable single (real,fake) pair a strong discriminator's BCE has no finite minimizer, so its fake-logit (and the generator's softplus(−logit) loss) provably grows without bound — expected adversarial behavior, not a bug. Real numerical failures (sign errors, gradient explosion) surface as NaN/Inf, caught by the retained finiteness assertions. Keeps DCGAN paper-faithful rather than bolting on non-paper WGAN-GP/spectral-norm to satisfy a heuristic. (Decision confirmed with maintainer.)

Systemic WeightRegistry cross-test leak → generic fix:

  • Foundation-scale models auto-enable weight streaming, registering weights with the process-global WeightRegistry, which isn't cleared on dispose — so the next streaming model's ctor throws "existing streaming pool has N registered entries" (hit by GrokVision here, Phi3Vision/SmolVLM in O-R, any future streaming model). Now reset generically in ModelFamilyTestGcGate.ReclaimBetweenTests (the between-tests hook every model-family base already calls), guarded on a non-empty registry. Replaces per-model opt-ins across all shards. (Approach confirmed with maintainer.)

Verification (local, net10.0, serial like CI)

  • Full A-L default-gate serial: 981/983, with the only 2 failures being the LSM/LSTM stragglers above → both fixed and re-verified green (2/2).
  • DCGAN full class + GRU/LSM MoreData: 27/27 green. MoreData enumeration across all 46 A-L MoreData tests confirmed exactly the listed failures.

Notes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved default training settings for several GAN models, making their out-of-the-box behavior more consistent.
  • Bug Fixes

    • Tuned neural network training defaults and tolerances to reduce false failures and improve stability across platforms.
    • Adjusted test cleanup and execution handling to better avoid memory-related and timeout issues.
  • Tests

    • Rebalanced several model tests for long-running and heavy workloads.
    • Updated test splitting to make large neural network test runs more reliable.

Triaged the A-L shard serially (the shard is in $heavyShards, so CI runs it
maxParallelThreads=1; it OOMs if run parallel — which is exactly why). Real
failures, by cause:

Floor-noise MoreData assertions (tolerance, matching existing precedent):
- GRUNeuralNetwork: memorizes to a ~1e-4 loss floor then oscillates; 200-iter
  6.1e-4 vs 50-iter 1.5e-4 false-fails the 1e-4 base tolerance. Set 1e-3, like
  the sibling recurrent nets LSTMNeuralNetworkTests / NeuralTuringMachineTests.
- LiquidStateMachine: reservoir model, memorizes to EXACT 0 then drifts to
  ~6e-3 over the longer run. Set 0.02, matching SpikingNeuralNetwork.

Inherently-heavy BERT/VLM-scale training (HeavyTimeout — deferred to the nightly
heavy lane, not skipped; never-shrink rule keeps paper-scale configs):
- BGE, ColBERT, InstructorEmbedding: full BERT-base encoders; MoreData runs 200
  iterations of BERT-scale training, inherently >120s even fully serialized.
  Matches the SimCSE/SPLADE/SGPT precedent.
- GrokVision: production-scale foundation VLM (VisionDim 1024 / DecoderDim 8192 /
  32+64 layers); a single forward is inherently >120s and streams weights to disk.

DCGAN LossStrictlyDecreasesOnMemorizationTask — real fix + principled test
adaptation:
- DCGAN now uses the paper's Adam hyperparameters (lr=0.0002, beta1=0.5; Radford
  et al. 2015 §4) instead of the framework default (lr=0.001, beta1=0.9) the
  paper explicitly calls out as unstable. Threaded via a new virtual
  GenerativeAdversarialNetwork.CreateDefaultOptimizer hook (default unchanged for
  other GANs).
- The GAN memorization invariant is adapted from a 100x explosion-ratio bound to
  FINITENESS. On the test's perfectly-separable single (real,fake) pair a strong
  discriminator's BCE has no finite minimizer — its fake-logit (and the
  generator's softplus(-logit) loss) provably grows without bound; that is
  expected adversarial behavior, not a bug. The real numerical failures (sign
  errors, gradient explosion) surface as NaN/Inf, which the retained finiteness
  assertions catch directly. Keeps DCGAN paper-faithful rather than bolting on
  non-paper WGAN-GP/spectral-norm purely to satisfy a heuristic bound.

Systemic WeightRegistry cross-test leak (generic fix):
- Foundation-scale models auto-enable weight streaming, registering weights with
  the process-global WeightRegistry, which isn't cleared on dispose — so the next
  streaming model's ctor throws "existing streaming pool has N registered
  entries" (hit by GrokVision here, Phi3Vision/SmolVLM in O-R, and any future
  streaming model). Reset the registry generically in
  ModelFamilyTestGcGate.ReclaimBetweenTests (the between-tests hook EVERY
  model-family base already calls), guarded on a non-empty registry so the common
  non-streaming case is untouched. Supersedes per-model opt-ins across all shards.

Verified locally (net10.0, serial like CI): DCGAN full class + GRU/LSM MoreData
27/27 green; the four heavy classes are excluded from the default gate via
HeavyTimeout. MoreData enumeration across all A-L (46 tests) confirmed exactly
these five as the MoreData failures.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
aidotnet_website Ignored Ignored Preview Jul 1, 2026 5:20pm
aidotnet-playground-api Ignored Ignored Preview Jul 1, 2026 5:20pm

@coderabbitai

coderabbitai Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4ee7477a-9990-44eb-9a54-a80a72122d90

📥 Commits

Reviewing files that changed from the base of the PR and between 7c1fc7b and 4c38f18.

📒 Files selected for processing (4)
  • .github/workflows/sonarcloud.yml
  • src/NeuralNetworks/DCGAN.cs
  • src/NeuralNetworks/DeepBeliefNetwork.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/Base/NeuralNetworkModelTestBase.cs
💤 Files with no reviewable changes (1)
  • src/NeuralNetworks/DCGAN.cs

Walkthrough

GAN constructors (DCGAN, ACGAN, BigGAN, ConditionalGAN, CycleGAN, InfoGAN, ProgressiveGAN, SAGAN, WGAN) now pass explicit default Adam/RMSProp optimizer options into their base classes or optimizer factories. DeepBeliefNetwork's fine-tune learning rate changed. Tests add HeavyTimeout traits, tolerance overrides, streaming cleanup, and a finite-loss assertion. CI workflow splits a NeuralNetworks test shard.

Changes

Production: GAN optimizer defaults

Layer / File(s) Summary
GAN base and derived constructor defaults
src/NeuralNetworks/GenerativeAdversarialNetwork.cs, src/NeuralNetworks/DCGAN.cs, src/NeuralNetworks/ConditionalGAN.cs, src/NeuralNetworks/BigGAN.cs, src/NeuralNetworks/ProgressiveGAN.cs, src/NeuralNetworks/SAGAN.cs
Base class adds Adam default constants, a protected constructor overload, and a CreateDefaultOptimizer factory; derived GAN constructors now pass explicit options: null and generator/discriminator default optimizer options into the base call.
GAN-specific optimizer factories
src/NeuralNetworks/ACGAN.cs, src/NeuralNetworks/CycleGAN.cs, src/NeuralNetworks/InfoGAN.cs, src/NeuralNetworks/WGAN.cs
Each GAN variant adds a private helper (CreateStandardGanAdamOptions/RMSProp equivalent) and uses it when constructing default generator, discriminator, Q-network, or critic optimizers.
DeepBeliefNetwork learning rate
src/NeuralNetworks/DeepBeliefNetwork.cs
Default fine-tuning MomentumOptimizer learning rate lowered from 0.1 to 0.01, with an updated explanatory comment.

Tests: streaming cleanup and stability thresholds

Layer / File(s) Summary
Streaming weight cleanup and GAN loss check
tests/.../Base/NeuralNetworkModelTestBase.cs, tests/.../Base/GANModelTestBase.cs
Test GC gate now resets weight-streaming state under lock before LOH compaction (errors swallowed/logged); GAN memorization test replaces the explosion-ratio check with finite-loss assertions.
Training tolerance and iteration overrides
tests/.../FastTextTests.cs, tests/.../LSTMNeuralNetworkTests.cs, tests/.../LiquidStateMachineTests.cs, tests/.../GRUNeuralNetworkTests.cs
Individual model test classes override memorization iteration counts, training error multipliers, and tolerance thresholds with explanatory comments.
HeavyTimeout test tagging
tests/.../BGETests.cs, tests/.../ColBERTTests.cs, tests/.../GrokVisionTests.cs, tests/.../InstructorEmbeddingTests.cs
Adds using Xunit; and [Trait("Category", "HeavyTimeout")] attributes plus comments for slow, compute-bound tests.

CI: NeuralNetworks shard split

Layer / File(s) Summary
NeuralNetworks shard split
.github/workflows/sonarcloud.yml
Splits ModelFamily - NeuralNetworks A-L shard into A-F and G-L shards with updated filters, comments, and $heavyShards list.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

Possibly related PRs

  • ooples/AiDotNet#429: Both PRs touch GAN optimizer wiring in GenerativeAdversarialNetwork.cs and downstream GAN variants like DCGAN.cs.
  • ooples/AiDotNet#1540: Both PRs modify the SonarCloud workflow's NeuralNetworks letter-range shards and $heavyShards list.
  • ooples/AiDotNet#1739: Both PRs update DCGAN.cs constructor logic to apply explicit Adam optimizer hyperparameters to generator/discriminator.

Suggested labels: training

Poem

A rabbit tunes the GAN's gradient stride,
With Adam defaults set side by side. 🐰
Tests now shed their flaky ways,
Shards split neatly for calmer days.
Hop hop, the pipeline runs anew!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the PR’s main goal: fixing the NeuralNetworks CI shard and summarizing the key tolerance, HeavyTimeout, GAN, and registry changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1706-nnal-shard

Comment @coderabbitai help to get the list of available commands.

… memorization depth (#1706)

The A-L shard (run 28382636553) had exactly two failures; both fixed:

1. DeepBeliefNetworkTests.Training_ShouldReduceLoss — REAL model bug (assertion,
   not timeout): after CD-1 pre-training the supervised loss CLIMBED (initial
   0.168 -> final 0.182 over 30 steps). The default fine-tuning optimizer used
   MomentumOptimizer lr=0.1, β=0.9 — but lr~0.1 is the CD-1 up-down pre-training
   rate (Hinton 2006 §3.2), too aggressive for plain backprop fine-tuning of the
   pre-trained deep sigmoid stack, so the momentum term overshoots the
   post-pretrain minimum and loss diverges upward. Lower the fine-tuning rate to
   0.01 (the value already documented on the learningRate parameter; PreTrain
   keeps its own 0.1). Full DBN class now 21/21.

2. FastTextTests.LossStrictlyDecreasesOnMemorizationTask — timed out at 180000ms.
   FastText's paper-faithful sub-word table is ~200M params, so the base
   MemorizationTaskIterations=100 cannot finish in the budget. Memorizing one
   (input, one-hot) pair through the 10000-way softmax drives loss down within a
   few steps, so override MemorizationTaskIterations=15 (same knob pattern as the
   class's existing MoreData caps) — full model fidelity, runnable depth. 18s.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/AiDotNet.Tests/ModelFamilyTests/Base/NeuralNetworkModelTestBase.cs`:
- Around line 57-60: The cleanup in NeuralNetworkModelTestBase should not be
skipped based on HasRegisteredStreamingWeightsForTests(), because that pre-check
can fail in the broken registry cases the teardown is meant to recover from.
Update the try block to call
NeuralNetworkBase<float>.ResetWeightStreamingForTests() unconditionally in this
best-effort cleanup path, and remove the guard so singleton state is always
reset after each test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4d3e5acb-b816-4eaa-8cc8-e8b665101292

📥 Commits

Reviewing files that changed from the base of the PR and between 65cdeae and ede3543.

📒 Files selected for processing (14)
  • src/NeuralNetworks/DCGAN.cs
  • src/NeuralNetworks/DeepBeliefNetwork.cs
  • src/NeuralNetworks/GenerativeAdversarialNetwork.cs
  • src/NeuralNetworks/NeuralNetworkBase.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/Base/GANModelTestBase.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/Base/NeuralNetworkModelTestBase.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/BGETests.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/ColBERTTests.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/FastTextTests.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/GRUNeuralNetworkTests.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/GrokVisionTests.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/InstructorEmbeddingTests.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/LSTMNeuralNetworkTests.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/LiquidStateMachineTests.cs

Comment thread src/NeuralNetworks/GenerativeAdversarialNetwork.cs Outdated
Comment thread tests/AiDotNet.Tests/ModelFamilyTests/Base/NeuralNetworkModelTestBase.cs Outdated
ooples and others added 2 commits June 30, 2026 14:43
…erved Linux CI floor (#1706)

The NeuralNetworks A-L shard was still red on exactly two GRU tests. Both are float
convergence-floor comparisons whose floor is platform-dependent, and the PR's earlier
values were calibrated to the Windows dev-box floor (~1e-4), which is ~100x lower than
the Linux CI runner's floor (~1e-2, different BLAS/FP accumulation order):

- MoreData_ShouldNotDegrade: CI observed 200-iter 0.012337 vs 50-iter 0.010241 (the two
  nets also train on DIFFERENT random draws, so the gap carries draw-difficulty variance,
  not divergence). Gap 2.1e-3 exceeds the Windows-calibrated 1e-3. Raised MoreDataTolerance
  to 0.02 — the value the sibling reservoir net LiquidStateMachine already uses for its
  ~1e-2 floor. Gross divergence (loss -> O(1), or NaN, asserted separately) still trips it.

- TrainingError_ShouldNotExceedTestError: CI observed trainMSE 2.21e-4 vs testMSE 5.0e-5
  (both floor-level; the seed-fixed test split draws an easier target), ratio 4.42 over the
  default 3.0 multiplier. Added TrainingErrorMultiplier => 10.0, matching the LSTM /
  AdversarialImageEvaluator precedent (2.3x margin); a genuine fit failure still trips it.

Passes locally (Windows) and compiles clean; the floor discrepancy is Linux-only so this is
verified against the CI runner rather than the dev box.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 1, 2026 02:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to green the ModelFamily NeuralNetworks A–L CI shard by reducing deterministic-but-noisy test flakiness (tolerance overrides), deferring inherently slow embedding/VLM tests to the HeavyTimeout lane, and addressing some GAN optimizer/test invariants plus cross-test cleanup.

Changes:

  • Adjusts recurrent/reservoir network test tolerances and train-vs-test multipliers to avoid convergence-floor / seed-draw false failures.
  • Tags several BERT-scale embedding models and a foundation VLM test class as Category=HeavyTimeout to move them out of the default gate.
  • Updates GAN-family optimizer defaults/overrides and modifies GAN memorization invariants; adds additional weight-streaming registry reset helpers.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/LSTMNeuralNetworkTests.cs Loosens train-vs-test error multiplier to reduce deterministic floor-noise false failures.
tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/LiquidStateMachineTests.cs Raises MoreData and training-loss-reduction tolerances for reservoir floor-noise behavior.
tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/InstructorEmbeddingTests.cs Tags class as HeavyTimeout for BERT-scale training runtime.
tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/GRUNeuralNetworkTests.cs Raises MoreData tolerance and train-vs-test multiplier for convergence-floor variance across platforms.
tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/GrokVisionTests.cs Tags class as HeavyTimeout and keeps it in FoundationScaleSerial.
tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/FastTextTests.cs Reduces memorization-task iteration count to avoid timeout while still exercising invariant.
tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/ColBERTTests.cs Tags class as HeavyTimeout for BERT-scale training runtime.
tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/BGETests.cs Tags class as HeavyTimeout for BERT-scale training runtime.
tests/AiDotNet.Tests/ModelFamilyTests/Base/NeuralNetworkModelTestBase.cs Adds WeightRegistry reset call into the shared between-test reclaim path.
tests/AiDotNet.Tests/ModelFamilyTests/Base/GANModelTestBase.cs Revises GAN memorization invariant to finiteness-only (drops explosion-ratio assertion).
src/NeuralNetworks/WGAN.cs Sets paper-default RMSProp learning rate via explicit optimizer options.
src/NeuralNetworks/SAGAN.cs Supplies explicit default Adam options for generator/discriminator via base constructor hook.
src/NeuralNetworks/ProgressiveGAN.cs Supplies explicit default Adam options for generator/discriminator via base constructor hook.
src/NeuralNetworks/NeuralNetworkBase.cs Adds HasRegisteredStreamingWeightsForTests() helper for WeightRegistry state probing.
src/NeuralNetworks/InfoGAN.cs Switches default optimizers to GAN-standard Adam options.
src/NeuralNetworks/GenerativeAdversarialNetwork.cs Introduces base-ctor hook for per-network default optimizer options and helper option factory.
src/NeuralNetworks/DeepBeliefNetwork.cs Changes default momentum-SGD learning rate for fine-tuning (0.1 → 0.01) and updates rationale.
src/NeuralNetworks/DCGAN.cs Supplies paper-faithful default Adam options through base hook (and related wiring).
src/NeuralNetworks/CycleGAN.cs Switches default optimizers to GAN-standard Adam options.
src/NeuralNetworks/ConditionalGAN.cs Supplies explicit default Adam options via base constructor hook.
src/NeuralNetworks/BigGAN.cs Supplies explicit default Adam options for generator/discriminator via base constructor hook.
src/NeuralNetworks/ACGAN.cs Switches default optimizers to GAN-standard Adam options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/NeuralNetworks/DeepBeliefNetwork.cs
Comment thread src/NeuralNetworks/GenerativeAdversarialNetwork.cs
Comment thread tests/AiDotNet.Tests/ModelFamilyTests/Base/NeuralNetworkModelTestBase.cs Outdated
Comment thread src/NeuralNetworks/NeuralNetworkBase.cs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (2)
src/NeuralNetworks/CycleGAN.cs (1)

70-77: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Same duplicated Adam-defaults helper as ACGAN.cs / InfoGAN.cs.

This is an identical copy of the concern raised on ACGAN.cs lines 65-72 — see that comment for the consolidated refactor proposal (shared GanOptimizerDefaults utility).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/NeuralNetworks/CycleGAN.cs` around lines 70 - 77, The
CreateStandardGanAdamOptions helper in CycleGAN is a duplicate of the same
Adam-defaults logic already present in ACGAN and InfoGAN, so move this shared
configuration into the proposed GanOptimizerDefaults utility and update CycleGAN
to call that shared helper instead of keeping a local copy. Use the existing
CreateStandardGanAdamOptions symbol as the place to redirect to the common
utility, and keep the optimizer values centralized so all GAN variants share one
implementation.
src/NeuralNetworks/InfoGAN.cs (1)

80-87: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Same duplicated Adam-defaults helper as ACGAN.cs / CycleGAN.cs.

Same concern as raised on ACGAN.cs lines 65-72 — a third verbatim copy of the same hyperparameter tuple.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/NeuralNetworks/InfoGAN.cs` around lines 80 - 87, The
CreateStandardGanAdamOptions helper in InfoGAN duplicates the same Adam
hyperparameter defaults already used in ACGAN and CycleGAN. Replace this
verbatim copy by reusing the shared GAN Adam-defaults helper (or extracting a
common shared method if needed) so CreateStandardGanAdamOptions is no longer a
third duplicate and all GAN optimizers stay consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/NeuralNetworks/ACGAN.cs`:
- Around line 65-72: The GAN Adam defaults are duplicated in ACGAN’s
CreateStandardGanAdamOptions helper and the matching helpers in CycleGAN and
InfoGAN; consolidate the shared 0.0002/0.5/0.999 setup into a single internal
utility such as GanOptimizerDefaults so all three constructors reuse one source
of truth. Update the ACGAN, CycleGAN, and InfoGAN call sites to reference the
shared helper, keeping the existing AdamOptimizerOptions<T, Tensor<T>,
Tensor<T>> shape and generic usage intact.

In `@src/NeuralNetworks/DCGAN.cs`:
- Around line 177-201: The DCGAN Adam hyperparameters are duplicated in both the
constructor defaults passed to base(...) and the SetBaseTrainOptimizer calls in
DCGAN, which can drift out of sync. Consolidate the lr=0.0002 and beta1=0.5
settings into a single shared source of truth used by both the
defaultGeneratorOptimizerOptions/defaultDiscriminatorOptimizerOptions setup and
the Generator/Discriminator SetBaseTrainOptimizer calls, so the actual Train()
path and the stored defaults always match.

In `@src/NeuralNetworks/NeuralNetworkBase.cs`:
- Around line 5610-5624: Guard both `TryAutoEnableWeightStreaming` checks that
read `WeightRegistry.GetStreamingReport().RegisteredEntryCount` so they handle
the same `ObjectDisposedException` / `InvalidOperationException` as
`WeightStreamingResidentBytes` and `HasRegisteredStreamingWeightsForTests`.
Update the fast-path decline check and the inner lock-protected double-check to
catch those failures and treat them as “no registered weights” so `Predict`,
`TrainCore`, and `SetTrainingMode` don’t throw from a disposed/reset registry.
Keep the existing `WeightRegistry`/streaming auto-detect flow intact and apply
the same defensive pattern in both locations.

---

Duplicate comments:
In `@src/NeuralNetworks/CycleGAN.cs`:
- Around line 70-77: The CreateStandardGanAdamOptions helper in CycleGAN is a
duplicate of the same Adam-defaults logic already present in ACGAN and InfoGAN,
so move this shared configuration into the proposed GanOptimizerDefaults utility
and update CycleGAN to call that shared helper instead of keeping a local copy.
Use the existing CreateStandardGanAdamOptions symbol as the place to redirect to
the common utility, and keep the optimizer values centralized so all GAN
variants share one implementation.

In `@src/NeuralNetworks/InfoGAN.cs`:
- Around line 80-87: The CreateStandardGanAdamOptions helper in InfoGAN
duplicates the same Adam hyperparameter defaults already used in ACGAN and
CycleGAN. Replace this verbatim copy by reusing the shared GAN Adam-defaults
helper (or extracting a common shared method if needed) so
CreateStandardGanAdamOptions is no longer a third duplicate and all GAN
optimizers stay consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 344e550b-8ecb-4cd6-9059-47b31c321ae4

📥 Commits

Reviewing files that changed from the base of the PR and between ede3543 and af3680d.

📒 Files selected for processing (13)
  • src/NeuralNetworks/ACGAN.cs
  • src/NeuralNetworks/BigGAN.cs
  • src/NeuralNetworks/ConditionalGAN.cs
  • src/NeuralNetworks/CycleGAN.cs
  • src/NeuralNetworks/DCGAN.cs
  • src/NeuralNetworks/GenerativeAdversarialNetwork.cs
  • src/NeuralNetworks/InfoGAN.cs
  • src/NeuralNetworks/NeuralNetworkBase.cs
  • src/NeuralNetworks/ProgressiveGAN.cs
  • src/NeuralNetworks/SAGAN.cs
  • src/NeuralNetworks/WGAN.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/Base/NeuralNetworkModelTestBase.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/GRUNeuralNetworkTests.cs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 3

♻️ Duplicate comments (2)
src/NeuralNetworks/CycleGAN.cs (1)

70-77: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Same duplicated Adam-defaults helper as ACGAN.cs / InfoGAN.cs.

This is an identical copy of the concern raised on ACGAN.cs lines 65-72 — see that comment for the consolidated refactor proposal (shared GanOptimizerDefaults utility).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/NeuralNetworks/CycleGAN.cs` around lines 70 - 77, The
CreateStandardGanAdamOptions helper in CycleGAN is a duplicate of the same
Adam-defaults logic already present in ACGAN and InfoGAN, so move this shared
configuration into the proposed GanOptimizerDefaults utility and update CycleGAN
to call that shared helper instead of keeping a local copy. Use the existing
CreateStandardGanAdamOptions symbol as the place to redirect to the common
utility, and keep the optimizer values centralized so all GAN variants share one
implementation.
src/NeuralNetworks/InfoGAN.cs (1)

80-87: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Same duplicated Adam-defaults helper as ACGAN.cs / CycleGAN.cs.

Same concern as raised on ACGAN.cs lines 65-72 — a third verbatim copy of the same hyperparameter tuple.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/NeuralNetworks/InfoGAN.cs` around lines 80 - 87, The
CreateStandardGanAdamOptions helper in InfoGAN duplicates the same Adam
hyperparameter defaults already used in ACGAN and CycleGAN. Replace this
verbatim copy by reusing the shared GAN Adam-defaults helper (or extracting a
common shared method if needed) so CreateStandardGanAdamOptions is no longer a
third duplicate and all GAN optimizers stay consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/NeuralNetworks/ACGAN.cs`:
- Around line 65-72: The GAN Adam defaults are duplicated in ACGAN’s
CreateStandardGanAdamOptions helper and the matching helpers in CycleGAN and
InfoGAN; consolidate the shared 0.0002/0.5/0.999 setup into a single internal
utility such as GanOptimizerDefaults so all three constructors reuse one source
of truth. Update the ACGAN, CycleGAN, and InfoGAN call sites to reference the
shared helper, keeping the existing AdamOptimizerOptions<T, Tensor<T>,
Tensor<T>> shape and generic usage intact.

In `@src/NeuralNetworks/DCGAN.cs`:
- Around line 177-201: The DCGAN Adam hyperparameters are duplicated in both the
constructor defaults passed to base(...) and the SetBaseTrainOptimizer calls in
DCGAN, which can drift out of sync. Consolidate the lr=0.0002 and beta1=0.5
settings into a single shared source of truth used by both the
defaultGeneratorOptimizerOptions/defaultDiscriminatorOptimizerOptions setup and
the Generator/Discriminator SetBaseTrainOptimizer calls, so the actual Train()
path and the stored defaults always match.

In `@src/NeuralNetworks/NeuralNetworkBase.cs`:
- Around line 5610-5624: Guard both `TryAutoEnableWeightStreaming` checks that
read `WeightRegistry.GetStreamingReport().RegisteredEntryCount` so they handle
the same `ObjectDisposedException` / `InvalidOperationException` as
`WeightStreamingResidentBytes` and `HasRegisteredStreamingWeightsForTests`.
Update the fast-path decline check and the inner lock-protected double-check to
catch those failures and treat them as “no registered weights” so `Predict`,
`TrainCore`, and `SetTrainingMode` don’t throw from a disposed/reset registry.
Keep the existing `WeightRegistry`/streaming auto-detect flow intact and apply
the same defensive pattern in both locations.

---

Duplicate comments:
In `@src/NeuralNetworks/CycleGAN.cs`:
- Around line 70-77: The CreateStandardGanAdamOptions helper in CycleGAN is a
duplicate of the same Adam-defaults logic already present in ACGAN and InfoGAN,
so move this shared configuration into the proposed GanOptimizerDefaults utility
and update CycleGAN to call that shared helper instead of keeping a local copy.
Use the existing CreateStandardGanAdamOptions symbol as the place to redirect to
the common utility, and keep the optimizer values centralized so all GAN
variants share one implementation.

In `@src/NeuralNetworks/InfoGAN.cs`:
- Around line 80-87: The CreateStandardGanAdamOptions helper in InfoGAN
duplicates the same Adam hyperparameter defaults already used in ACGAN and
CycleGAN. Replace this verbatim copy by reusing the shared GAN Adam-defaults
helper (or extracting a common shared method if needed) so
CreateStandardGanAdamOptions is no longer a third duplicate and all GAN
optimizers stay consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 344e550b-8ecb-4cd6-9059-47b31c321ae4

📥 Commits

Reviewing files that changed from the base of the PR and between ede3543 and af3680d.

📒 Files selected for processing (13)
  • src/NeuralNetworks/ACGAN.cs
  • src/NeuralNetworks/BigGAN.cs
  • src/NeuralNetworks/ConditionalGAN.cs
  • src/NeuralNetworks/CycleGAN.cs
  • src/NeuralNetworks/DCGAN.cs
  • src/NeuralNetworks/GenerativeAdversarialNetwork.cs
  • src/NeuralNetworks/InfoGAN.cs
  • src/NeuralNetworks/NeuralNetworkBase.cs
  • src/NeuralNetworks/ProgressiveGAN.cs
  • src/NeuralNetworks/SAGAN.cs
  • src/NeuralNetworks/WGAN.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/Base/NeuralNetworkModelTestBase.cs
  • tests/AiDotNet.Tests/ModelFamilyTests/NeuralNetworks/GRUNeuralNetworkTests.cs
🛑 Comments failed to post (3)
src/NeuralNetworks/ACGAN.cs (1)

65-72: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Duplicate GAN Adam-default helper across three files.

CreateStandardGanAdamOptions() here is byte-for-byte identical to the versions added in CycleGAN.cs (lines 70-76) and InfoGAN.cs (lines 80-86). Per the PR stack summary, GenerativeAdversarialNetwork.cs already introduces "explicit Adam default constants" for the single-network GAN subclasses (DCGAN, ConditionalGAN, BigGAN, ProgressiveGAN, SAGAN); ACGAN/CycleGAN/InfoGAN can't inherit that base directly (multi-network structure), but the hardcoded tuple (0.0002 / 0.5 / 0.999) is still triplicated verbatim. If the paper-standard values ever need adjusting, three copies must be kept in sync manually.

Consider extracting this into a shared internal static utility (e.g., GanOptimizerDefaults) referenced by all three constructors.

♻️ Proposed shared helper
// New file: src/NeuralNetworks/GanOptimizerDefaults.cs
internal static class GanOptimizerDefaults
{
    public static AdamOptimizerOptions<T, Tensor<T>, Tensor<T>> CreateStandardGanAdamOptions<T>()
        => new()
        {
            InitialLearningRate = 0.0002,
            Beta1 = 0.5,
            Beta2 = 0.999,
        };
}
```diff - private static AdamOptimizerOptions, Tensor> CreateStandardGanAdamOptions() - => new() - { - InitialLearningRate = 0.0002, - Beta1 = 0.5, - Beta2 = 0.999, - }; - ``` Then call `GanOptimizerDefaults.CreateStandardGanAdamOptions()` at each use site.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/NeuralNetworks/ACGAN.cs` around lines 65 - 72, The GAN Adam defaults are
duplicated in ACGAN’s CreateStandardGanAdamOptions helper and the matching
helpers in CycleGAN and InfoGAN; consolidate the shared 0.0002/0.5/0.999 setup
into a single internal utility such as GanOptimizerDefaults so all three
constructors reuse one source of truth. Update the ACGAN, CycleGAN, and InfoGAN
call sites to reference the shared helper, keeping the existing
AdamOptimizerOptions<T, Tensor<T>, Tensor<T>> shape and generic usage intact.
src/NeuralNetworks/DCGAN.cs (1)

177-201: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Consolidate the triple-hardcoded DCGAN Adam hyperparameters.

lr=0.0002, beta1=0.5 is hardcoded three times: once via defaultGeneratorOptimizerOptions/defaultDiscriminatorOptimizerOptions passed to base(...) (lines 159-160), and again manually in both SetBaseTrainOptimizer calls (lines 184-191). Per the code's own comment, the GAN-level _generatorOptimizer/_discriminatorOptimizer fields aren't on the actual Train() path — SetBaseTrainOptimizer's optimizer is what's really used — so these two configurations can silently drift out of sync (e.g. a future tuning pass updates one but not the other), re-introducing exactly the convergence-floor instability this PR is fixing.

♻️ Proposed consolidation
+        var paperAdamOptions = CreateAdamOptimizerOptions(0.0002, 0.5);
         ((NeuralNetworkBase<T>)Generator).SetBaseTrainOptimizer(
             new AiDotNet.Optimizers.AdamOptimizer<T, Tensor<T>, Tensor<T>>(Generator,
-                new AiDotNet.Models.Options.AdamOptimizerOptions<T, Tensor<T>, Tensor<T>>
-                { InitialLearningRate = 0.0002, Beta1 = 0.5, UseAMSGrad = false }));
+                paperAdamOptions));
         ((NeuralNetworkBase<T>)Discriminator).SetBaseTrainOptimizer(
             new AiDotNet.Optimizers.AdamOptimizer<T, Tensor<T>, Tensor<T>>(Discriminator,
-                new AiDotNet.Models.Options.AdamOptimizerOptions<T, Tensor<T>, Tensor<T>>
-                { InitialLearningRate = 0.0002, Beta1 = 0.5, UseAMSGrad = false }));
+                paperAdamOptions));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/NeuralNetworks/DCGAN.cs` around lines 177 - 201, The DCGAN Adam
hyperparameters are duplicated in both the constructor defaults passed to
base(...) and the SetBaseTrainOptimizer calls in DCGAN, which can drift out of
sync. Consolidate the lr=0.0002 and beta1=0.5 settings into a single shared
source of truth used by both the
defaultGeneratorOptimizerOptions/defaultDiscriminatorOptimizerOptions setup and
the Generator/Discriminator SetBaseTrainOptimizer calls, so the actual Train()
path and the stored defaults always match.
src/NeuralNetworks/NeuralNetworkBase.cs (1)

5610-5624: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Unhandled exceptions from WeightRegistry.GetStreamingReport() on a hot path.

Both the fast-path decline check (line 5620) and the lock-protected double-check (line 5694) call WeightRegistry.GetStreamingReport().RegisteredEntryCount with no try/catch. Elsewhere in this same file (WeightStreamingResidentBytes, and the new HasRegisteredStreamingWeightsForTests added in this very PR) the identical call is wrapped in a catch for ObjectDisposedException / InvalidOperationException specifically because the report can throw in those states. TryAutoEnableWeightStreaming is invoked from Predict, Train/TrainCore, and SetTrainingMode — if the registry is mid-reset/disposed when either of these two new checks fires, the exception propagates out of core inference/training calls instead of being handled the same defensive way as the sibling call sites.

🛡️ Proposed fix
-        if (WeightRegistry.GetStreamingReport().RegisteredEntryCount > 0)
-        {
-            _streamingAutoDetectFinalized = true;
-            return;
-        }
+        try
+        {
+            if (WeightRegistry.GetStreamingReport().RegisteredEntryCount > 0)
+            {
+                _streamingAutoDetectFinalized = true;
+                return;
+            }
+        }
+        catch (ObjectDisposedException) { }
+        catch (InvalidOperationException) { }

(apply the same guard to the inner lock-protected check at line 5694)

Based on learnings, the same GetStreamingReport() API is already known to throw ObjectDisposedException/InvalidOperationException in this codebase (see WeightStreamingResidentBytes and the new HasRegisteredStreamingWeightsForTests), so this is a real, demonstrated failure mode, not speculative.

Also applies to: 5685-5709

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/NeuralNetworks/NeuralNetworkBase.cs` around lines 5610 - 5624, Guard both
`TryAutoEnableWeightStreaming` checks that read
`WeightRegistry.GetStreamingReport().RegisteredEntryCount` so they handle the
same `ObjectDisposedException` / `InvalidOperationException` as
`WeightStreamingResidentBytes` and `HasRegisteredStreamingWeightsForTests`.
Update the fast-path decline check and the inner lock-protected double-check to
catch those failures and treat them as “no registered weights” so `Predict`,
`TrainCore`, and `SetTrainingMode` don’t throw from a disposed/reset registry.
Keep the existing `WeightRegistry`/streaming auto-detect flow intact and apply
the same defensive pattern in both locations.

The A-L ModelFamily shard is a $heavyShard (serial, maxParallelThreads=1) whose
~983 default-gate tests run the full 45-min job timeout and get CANCELLED before
finishing — perpetually red regardless of the model fixes, exactly like
Integration C before its split. Split A-L → A-F + G-L so each serial half
finishes well under the timeout. Both halves stay in $heavyShards.

Gap-free + non-overlapping: the two filters' union is the old A-L set
(NeuralNetworks.{A..F} ∪ {G..L} == {A..L}); no coverage lost. Class balance
A-F=29 / G-L=20; the tagged foundation-scale models (BGE/ColBERT/Instructor/
GrokVision) are already HeavyTimeout-excluded from the default gate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/sonarcloud.yml:
- Around line 323-329: The comment in the SonarCloud workflow is stale: it
refers to a single “M-Z” NeuralNetworks shard, but the shard set below is
actually split into “M-N”, “O-R”, “S”, and “T-Z”. Update the explanatory comment
near the NeuralNetworks coverage note so it matches the real shard names used
later in the workflow, keeping the A-F and G-L references only if they still
accurately describe the defined shards.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1172bccc-e2ec-4a0d-899d-bd8f637fcc5e

📥 Commits

Reviewing files that changed from the base of the PR and between af3680d and 7c1fc7b.

📒 Files selected for processing (1)
  • .github/workflows/sonarcloud.yml

Comment thread .github/workflows/sonarcloud.yml Outdated
ooples added a commit that referenced this pull request Jul 1, 2026
…nrollSteps) shards (#1755)

* test(nn): relax NTM MoreDataTolerance to the Linux CI Adam floor (0.05) (#1753)

NeuralTuringMachineTests.MoreData_ShouldNotDegrade reddened the NeuralNetworks M-N
shard on Linux CI: lossLong=0.002073 > lossShort=0.000133 + MoreDataTolerance(1e-3).
Both losses are at the convergence noise floor (1e-4..1e-3) — Adam-past-convergence
jitter, not divergence. The 1e-3 value was a Windows-only calibration (drift ~1.8e-4
there, "50x tighter than the noise floor because it's reproducible"); that
platform-specific assumption breaks on Linux, whose Adam FP floor is higher. Fall
back to the ~0.05 noise-floor calibration (SNN/NTM precedent, #1643) — it absorbs
the Linux floor with run-to-run margin while still catching genuine divergence
(orders of magnitude larger) and NaN (asserted separately). Passes locally; the
strict Training_ShouldReduceLoss / memorization / TrainingError invariants are
unchanged. Same platform-floor recalibration class as #1742's GRU/LSTM/LSM fixes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(rl): default MuZero UnrollSteps to the implemented K=1 so the agent trains (#1752)

MuZero_Train_UpdatesParameters reddened the Unit-10 shard: MuZeroAgent.Train()
threw InvalidOperationException because MuZeroOptions.UnrollSteps defaulted to 5
(the paper value) but the agent only implements the one-step (K=1) unrolled
targets and fail-fasts for K>1. So the out-of-box agent threw on every Train().

Default UnrollSteps=1 (the implemented capability): the default agent now trains
all three networks (representation/dynamics/prediction) with the correct one-step
targets — verified params update. A caller wanting the paper's K=5 sets it
explicitly and still gets the clear guard exception. Full K-step unrolled training
(sequence replay + per-unroll-step targets) is a tracked follow-up in #1752.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
ooples and others added 2 commits July 1, 2026 11:47
- DeepBeliefNetwork: the fine-tune-rate comment referenced a nonexistent
  'learningRate parameter'; point it at the MomentumOptimizerOptions instead.
- NeuralNetworkModelTestBase.ReclaimBetweenTests: move the process-global
  ResetWeightStreamingForTests inside the LohCompaction lock so parallel
  light-model teardowns don't race on the WeightRegistry reset, and log a
  reset failure (Debug + Console.Error) instead of swallowing it silently.
- NeuralNetworkBase: remove the unreferenced HasRegisteredStreamingWeightsForTests
  helper whose XML doc claimed harness use that never happens (the harness
  resets unconditionally by design).
- sonarcloud.yml: fix the stale 'M-Z' shard reference to the actual
  M-N/O-R/S/T-Z shards.

GAN default optimizer (also flagged) is intentional: GAN-standard Adam
(lr=0.0002, beta1=0.5, the DCGAN convention) is the correct stable default
for adversarial training; generic Adam (0.001, beta1=0.9) destabilizes GANs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 1, 2026 15:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.

Comment thread src/NeuralNetworks/DCGAN.cs
Copilot finished work on behalf of ooples July 1, 2026 17:20
@ooples
ooples merged commit aa56a50 into master Jul 1, 2026
67 of 85 checks passed
@ooples
ooples deleted the fix/1706-nnal-shard branch July 1, 2026 23:51
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.

4 participants