Skip to content

feat(training): wire additional WGAN-GP + diffusion consumers#1848

Merged
ooples merged 1 commit into
feat/gpu-resident-nontsfrom
feat/wgan-diffusion-additional-consumers
Jul 10, 2026
Merged

feat(training): wire additional WGAN-GP + diffusion consumers#1848
ooples merged 1 commit into
feat/gpu-resident-nontsfrom
feat/wgan-diffusion-additional-consumers

Conversation

@ooples

@ooples ooples commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Follow-up to PR #1847. A comprehensive audit surfaced additional WGAN-GP and diffusion consumers beyond the four named in issues #1845/#1846. This PR wires the ones that fit the primitives cleanly and documents the ones that need TFC/CSDI-scale rework first.

Summary

Wired (3 new consumers):

  • src/NeuralNetworks/WGANGP.cs — standalone WGAN-GP class. Was using the legacy flat-vector round-trip (GetParameterGradients + host-side combine + UpdateCriticWithOptimizer). Now attempts WganGpFusedStep.TryStep first with Critic.Layers as the parameter source.
  • src/NeuralNetworks/SyntheticData/FinDiffGenerator.cs — per-row DDPM training (Sattarov et al. 2023). TrainBatch now caches a MultiSlotFusedStep across rows.
  • src/NeuralNetworks/SyntheticData/AutoDiffTabGenerator.cs — same per-row pattern as FinDiff. TrainBatch caches MultiSlotFusedStep slots (denoiserInput, targetNoise).

Explicitly not wired (documented in commit message):

  • GenerativeAdversarialNetwork.cs — uses BCE + optional GP regularization, NOT Wasserstein + GP. Wiring WganGpFusedStep would change training semantics.
  • Finance/Forecasting/Foundation: CCDM, MGTSD, TSDiff, TimeDiff, TimeGrad, DiffusionTS — each has .Data.Span host-side packs (same trace-freeze issue TFC/CSDI had in feat(training): GPU-resident fused step for non-TS single-net models #1843). Each needs a TFC/CSDI-scale traceable rewrite BEFORE fused wiring is safe.
  • MetaLearning: MetaDDPMAlgorithm, MetaDMAlgorithm, MetaDiffAlgorithm — hand-rolled Vector<T> params with index arithmetic, not ILayer/Engine/tape.
  • DiffusionModelBase subclasses (DDPMModel, DiffWaveModel, LatentDiffusionModelBase) — the SupportsFusedDenoising opt-in hook from feat(training): centralize WGAN-GP + diffusion consumers through fused primitives #1847 is available; flipping it requires per-class audit of PredictNoise → UNet traceability.

Test plan

Base branch

Targets feat/gpu-resident-nonts (PR #1843's branch, which already contains #1847's merge). Once #1843 merges to master, this PR will retarget to master.

🤖 Generated with Claude Code

… fused primitives

Extends PR #1847 with three additional consumer wire-ups discovered during a
comprehensive audit against the primitives added in PR #1843. Each consumer
attempts the fused path first via the existing IFusedOptimizerSpec /
TryMapToFusedOptimizerConfig plumbing and falls back to eager tape training
when the fused path can't engage.

## WGAN-GP consumers (additional beyond #1845)

* NeuralNetworks/WGANGP.cs — standalone WGAN-GP class. Previously used the
  legacy flat-vector round-trip (three Critic.Predict calls per step,
  GetParameterGradients + host-side vector combine + UpdateCriticWithOptimizer).
  TrainCriticBatchWithGP now attempts WganGpFusedStep.TryStep first, using
  Critic.Layers as the parameter source and a per-batch ε ~ U(0, 1) sampler
  matching each critic's local ComputeGradientPenalty behavior. Falls back to
  the legacy path when the critic's optimizer has no fused-kernel mapping.

## Diffusion consumers (additional beyond #1846)

* NeuralNetworks/SyntheticData/FinDiffGenerator.cs — per-row DDPM training
  (Sattarov et al. 2023). TrainBatch caches a MultiSlotFusedStep across rows
  so the compiled plan is built once and replayed via slot-data refresh for
  subsequent rows. Slots: (packedDenoiserInput, targetNoise). Falls back to
  the existing Train(input, targetNoise) call on miss.

* NeuralNetworks/SyntheticData/AutoDiffTabGenerator.cs — per-row DDPM training
  with a custom TapeStepOver optimizer step. Same MultiSlotFusedStep caching
  pattern as FinDiff. Slots: (denoiserInput, targetNoise). Falls back to the
  existing tape-based TapeStepOver path on miss.

## Explicitly not wired in this PR (documented)

* NeuralNetworks/GenerativeAdversarialNetwork.cs — uses BCE loss with optional
  GP regularization (a separate auxiliary optimizer step), NOT Wasserstein +
  GP. Wiring WganGpFusedStep would change training semantics from BCE to
  Wasserstein. Requires a separate design decision.

* Finance/Forecasting/Foundation/{CCDM,MGTSD,TSDiff,TimeDiff,TimeGrad}.cs and
  Finance/Probabilistic/DiffusionTS.cs — each uses .Data.Span host-side packs
  for the denoising input (same trace-freeze issue TFC/CSDI hit in PR #1843).
  Each needs a TFC/CSDI-scale traceable rewrite BEFORE fused wiring is safe.
  Deferred to individual per-consumer PRs.

* MetaLearning/Algorithms/{MetaDDPMAlgorithm,MetaDMAlgorithm,MetaDiffAlgorithm}.cs
  — hand-rolled Vector&lt;T&gt; params with index arithmetic, NOT the
  ILayer/Engine/tape infrastructure. Would need full rewrite to fit MultiSlotFusedStep.

* DiffusionModelBase subclasses (DDPMModel, DiffWaveModel, LatentDiffusionModelBase)
  — the SupportsFusedDenoising opt-in hook (added in PR #1847) is available,
  but flipping it safely requires per-class audit of PredictNoise → UNet
  traceability. Left as follow-up work; the mechanism is in place.

## Verification

* net8.0, net471, net10.0 all build clean.
* No API surface changes.

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

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bcd27482-c64e-47d8-85cc-27f0dd47a9b4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/wgan-diffusion-additional-consumers

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

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
aidotnet_website Ready Ready Preview, Comment Jul 10, 2026 11:55pm
aidotnet-playground-api Ready Ready Preview, Comment Jul 10, 2026 11:55pm

@ooples ooples merged commit 618795d into feat/gpu-resident-nonts Jul 10, 2026
7 of 13 checks passed
@ooples ooples deleted the feat/wgan-diffusion-additional-consumers branch July 10, 2026 23:55
ooples added a commit that referenced this pull request Jul 11, 2026
…for fused paths)

0.113.0 publishes Tensors PR #763 — this branch's gating dependency. #763's key fix
(4C): the compiled/persistent backward now honors createGraph=true (GradientTape.
ComputeGradients previously gated the compiled path on !createGraph), so the WGAN-GP
gradient penalty's inner backward differentiates into the disc weights through the
fused compiled plan instead of silently returning zeros (issue #1844). Against 0.111.2
the fused GPU-resident WGAN-GP path would have silently degraded to plain WGAN.

The src/Training fused-primitive mirrors (WganGpFusedStep, MultiSlotFusedStep,
DpSgdFusedStep) stay as the consumer-side primitives that #1847/#1848 centralize every
consumer through; they call the public engine API, so the bump alone routes them onto
#763's fixed compiled backward. Also picks up #765 (compiled ReduceMax axis fill) and
#764 (resident-param fused-Adam fix). Native OneDNN/OpenBLAS/CLBlast bumped in lockstep
(all published). Builds green on net8.0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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