neural: shared CPU training substrate + NeuralFunctionApproximator#498
Merged
Conversation
Adds CpuNeuralTraining (backward pass + Adam/SGD + MSE/L1/Huber) and the
NeuralFunctionApproximator facade so any CPU-heavy subsystem can opt in to
a learned approximation. Refactors NeuralTextureCompressor off its inline
SGD/backprop loop and replaces NeuralRadianceCache::Update's finite-diff
MLP search with real analytical backprop + hash-grid input-gradient flow.
- CpuNeuralTraining.{h,cpp}: Trainer class, gradient check, losses
- NeuralFunctionApproximator.{h,cpp}: Configure/TrainOffline/TrainIncremental
- NeuralWeights: .nnw bumped to v2 with optional Adam/SGD-momentum trailer
(v1 files still load as optimizer.kind == None)
- NRC: persistent Adam state across frames, one upload per batch instead
of one per weight perturbation; ~100x faster training loop
- NTC: TrainBlock reduced from ~130 LOC of inline backprop to ~40 LOC
using the shared core + Adam
- 13 new tests covering analytical-vs-numerical gradient check, Adam +
SGD+momentum convergence on XOR, sine fit, NFA save/load round-trip,
.nnw v1/v2 compat, NRC loss decreases
Contributor
Code Coverage (GCC + lcov)Per-Subsystem Coverage
Total: 50.8% (28172/55466 lines) |
Contributor
❌ CI Error ReportFailed jobs: clang-tidy, macos-Debug-OpenGL, macos-Release-Metal, macos-Release-OpenGL, windows-vs2022-Release Build ErrorsOther errors (1)Test Failures
|
| Test | Jobs |
|---|---|
| [17:33:26.008] [TID:3288] [WARN ] [Network ] RCON unknown command: nonexistent_cmd (DedicatedServer.cpp:573) | windows-vs2022-Release |
| [17:33:26.023] [TID:3288] [WARN ] [Network ] NetBuffer::ReadUint8 — buffer overrun at pos 1 (size=1) (NetworkBuffer.c... | windows-vs2022-Release |
| [17:33:26.043] [TID:3288] [WARN ] [AI ] BuildNavMeshWithRecast: empty geometry (RecastDetourBackend.cpp:35) | windows-vs2022-Release |
| [17:33:26.043] [TID:3288] [WARN ] [AI ] NavMeshBuilder: Recast build failed, falling back to triangle-soup builder (N... | windows-vs2022-Release |
| [17:33:26.043] [TID:3288] [WARN ] [Audio ] XAudio2 backend requested but no AudioEngine provided, falling back to Nul... | windows-vs2022-Release |
| [ OK ] MaterialHandle_FindByN[17:33:26.061] [TID:3288] [WARN ] [Graphics ] No graphics backend available — falling ba... | windows-vs2022-Release |
| [17:33:26.061] [TID:3288] [WARN ] [Graphics ] No graphics backend available — falling back to NullRHIDevice (headless... | windows-vs2022-Release |
| [17:33:26.065] [TID:3288] [WARN ] [Editor ] Cannot host: userName is empty. (CollaborativeEditSession.cpp:454) | windows-vs2022-Release |
| [17:33:26.065] [TID:3288] [WARN ] [Editor ] Already connected. (CollaborativeEditSession.cpp:459) | windows-vs2022-Release |
| [17:33:26.068] [TID:3288] [WARN ] [Editor ] BroadcastEdit rejected: nodeId is empty. (CollaborativeEditSession.cpp:1108) | windows-vs2022-Release |
| [17:33:26.068] [TID:3288] [WARN ] [Editor ] BroadcastEdit rejected: sourceEditor is not set. (CollaborativeEditSessio... | windows-vs2022-Release |
| [17:33:26.069] [TID:3288] [WARN ] [Editor ] SetLocalSelection rejected: nodeId exceeds 255 chars (length=300). (Colla... | windows-vs2022-Release |
| [17:33:31.637] [TID:3288] [WARN ] [Network ] Connection rejected for pending client 5: server full (4/4) (NetworkConn... | windows-vs2022-Release |
| [17:33:31.638] [TID:3288] [WARN ] [Network ] Connection rejected for pending client 5: server full (4/4) (NetworkConn... | windows-vs2022-Release |
| [17:33:31.639] [TID:3288] [WARN ] [Network ] Invalid packet magic 0x6A0E5CB3 (expected 0x5350524B) (NetworkManager.cp... | windows-vs2022-Release |
Updated: 2026-04-18T17:34:31Z — this comment is updated in-place, not duplicated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds CpuNeuralTraining (backward pass + Adam/SGD + MSE/L1/Huber) and the NeuralFunctionApproximator facade so any CPU-heavy subsystem can opt in to a learned approximation. Refactors NeuralTextureCompressor off its inline SGD/backprop loop and replaces NeuralRadianceCache::Update's finite-diff MLP search with real analytical backprop + hash-grid input-gradient flow.