test: add comprehensive InferenceOptimization integration tests#768
test: add comprehensive InferenceOptimization integration tests#768
Conversation
Add 284 integration tests for the InferenceOptimization module covering: - OptimizationNode<T>: constructor, input/output management, clone, properties - OptimizationGraph<T>: node management, topological sort, validation, statistics - OptimizationLevel enum: all levels from None to Maximum - OptimizationOptions: configuration for each optimization level - IR types: IRDataType, MemoryLayout, DeviceType, TensorType, QuantizationParams - Optimization passes: DeadCodeElimination, ConstantFolding, AlgebraicSimplification, CommonSubexpressionElimination, StrengthReduction, InPlace, MemoryReuse, Layout, ElementwiseFusion, ConvBatchNormFusion, MatMulBiasFusion, MultiHeadAttentionFusion Closes #658 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughAdds a large integration test suite for the InferenceOptimization module and updates CommonSubexpressionEliminationPass to compute commutativity-aware signatures for detecting identical subexpressions. Changes
Sequence Diagram(s)(omitted — changes are tests and a localized signature logic update; no multi-component sequential flow requiring visualization) Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
BUG FIX: CommonSubexpressionEliminationPass incorrectly sorted input IDs for all operations, which caused non-commutative operations like Subtract and Divide to be incorrectly merged when operands were reversed. IMPACT: a-b would be merged with b-a (WRONG - they produce different results!) CHANGES: - Added IsCommutativeOperation() helper to distinguish between: - Commutative ops (Add, Multiply): a+b == b+a, so input IDs can be sorted - Non-commutative ops (Subtract, Divide, etc.): a-b != b-a, order preserved - ComputeSignature() now only sorts input IDs for commutative operations - Added 5 new CSE tests including bug detection tests for non-commutative ops All 86 tests pass on both .NET 10.0 and .NET Framework 4.7.1. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
… and node methods PR #768 production-readiness fixes: - OptimizationNode.AddInput: add null check for inputNode - OptimizationNode.RemoveInput: add null check for inputNode - OptimizationNode.ReplaceInput: add null checks for oldInput/newInput - OptimizationGraph.FindNodeById: add null check for id - OptimizationGraph.FindNodesByName: add null check for name - IRDataTypeExtensions.FromSystemType: add null check for type - TensorType.IsBroadcastCompatible: add null check for other - GraphOptimizer.Optimize: add null check for graph - GraphOptimizer.AddPass: add null check for pass Added 14 tests covering all 9 bug fixes and valid input scenarios. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: production bugs in recently merged PRs Fixed critical bugs found during production-readiness review: 1. PredictionTypeInference (PR #765): Integer overflow when calculating class label range. maxClass - minClass overflows for extreme values. Fixed by using long for range calculation. 2. GeneticOptimizer (PR #762): IndexOf bug in tournament selection. When population contains duplicate prompts, IndexOf returns first occurrence index, causing wrong fitness selection. Fixed by tracking index directly. 3. NeuralProgramSynthesizer (PR #763): Absolute error comparison fails for large numbers. 1e12 + 0.5 vs 1e12 incorrectly fails with 1e-6 absolute tolerance. Fixed with relative error comparison for large numbers and absolute for small. 4. TrainingMonitor (PR #755): CSV export shows "0" for missing metrics instead of empty string. FirstOrDefault returns default(T) which is 0 for numerics, not null. Fixed by checking if match exists. Added comprehensive tests that expose all bugs and verify fixes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: critical FineTuning bugs - log probability and SFT constructor FineTuningBase.cs: - Implemented ComputeLogProbabilityFromPrediction that was returning 0.0 - Added proper handling for probability distributions (cross-entropy) - Added cosine similarity for embeddings - Added scalar comparison for numeric values - Added string similarity using Levenshtein distance - Fixed single-element array bug (cosine similarity is always 1.0) SupervisedFineTuning.cs: - Added single-parameter constructor for Activator.CreateInstance compatibility - This enables reflection-based instantiation used by test frameworks MergedPRBugFixTests.cs: - Added tests for log probability computation - Added test verifying SFT can be instantiated with single-parameter constructor - All 14 tests passing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: critical Diagnostics bugs - memory leak, thread safety, variance MemoryTracker.cs: - Added MaxHistorySize property with default of 10000 - Enforces limit to prevent unbounded memory growth in long-running apps - Removes oldest snapshots when limit is reached (FIFO) ProfilerSession.cs: - Fixed thread-unsafe System.Random by using RandomHelper.ThreadSafeRandom - System.Random is NOT thread-safe; concurrent access corrupts internal state - Fixed variance calculation: was population (_m2/_count), now sample (_m2/(_count-1)) - Fixed call stack cleanup: handles out-of-order Stop() calls (e.g., due to exceptions) - Now searches stack for timer instead of only checking top, prevents memory leak MergedPRBugFixTests.cs: - Added 5 tests for Diagnostics bug fixes - All 19 tests passing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: ModelRegistry production bugs (PR #774) Fixed 5 critical production-readiness bugs: 1. Mutable internal state returned: GetModel, GetModelByStage, and SearchModels now return clones to prevent external modification of internal state 2. Console.WriteLine in library code: Replaced with LoadErrors property for proper diagnostic exposure without polluting stdout 3. TOCTOU race conditions: Fixed file operations in DeleteModelVersion and GetModelCard to use try-catch pattern instead of File.Exists checks 4. DeleteModelVersion didn't validate modelName: Added ValidateModelName call for consistency with other methods 5. Lineage tracking didn't work: _lineage dictionary is now populated when model versions are created via RegisterModel and CreateModelVersion Also added GetInternalModel helper method for internal mutation operations. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: PR #773 Metrics - add null checks, empty tensor handling, and validation Bugs fixed in Metrics module: - PSNR.ComputeBatch: Added null argument validation - STOI.Compute: Added null argument validation - STOI.ComputeNormalizedCorrelation: Fixed bounds check to include both arrays - SI-SDR.Compute: Added null validation and empty tensor handling - SNR.Compute: Added null argument validation - IoU3D.ComputeBoxIoU: Added null validation and coordinate validation (min <= max) - ChamferDistance.ComputeOneWay: Throws for empty target with non-empty source Added 9 new tests to verify fixes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: PR #772 Logging - add null checks, validation, and TOCTOU fix Bugs fixed in Logging module: - SummaryWriter.AddScalars: Added null check for tagScalarDict - SummaryWriter.AddHistogram: Added null check for values arrays - SummaryWriter.AddImage: Validate dataformats parameter (must be CHW or HWC) - SummaryWriter.AddImages: Added null check and parameter validation - SummaryWriter.AddPrCurve: Added null checks, length validation - SummaryWriter.LogWeights: Added null check, handle empty weights array - TensorBoardWriter.WriteEmbedding: Added null check, metadata length validation - TensorBoardWriter.EncodePng: Validate pixels array length - TensorBoardWriter.WriteProjectorConfig: Fixed TOCTOU race condition Added 7 new tests to verify fixes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(LanguageModels): add null/empty validation for model names and API version Bug fixes for PR #771 LanguageModels: - OpenAIChatModel: Validate modelName not null/empty (was NullReferenceException) - OpenAIChatModel: Validate maxTokens > 0 early with clear error message - AnthropicChatModel: Validate modelName not null/empty (was NullReferenceException) - AzureOpenAIChatModel: Validate apiVersion not null/empty (caused invalid URL) - AzureOpenAIChatModel: Validate maxTokens > 0 early with clear error message Added 12 tests covering these validation scenarios. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(JitCompiler): add null checks and remove side effect from Validate Bug fixes for PR #770 JitCompiler: - IRGraph.Validate(): Remove side effect that modified TensorShapes (validation should be read-only) - TensorShapeExtensions.GetElementCount(): Add null check - TensorShapeExtensions.ShapeToString(): Add null check - TensorShapeExtensions.GetShapeHashCode(): Add null check - TensorShapeExtensions.GetShape(): Add null tensor check - IRTypeExtensions.FromSystemType(): Add null Type check Added 10 tests covering these validation scenarios. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(Interpretability): add null argument validation to helper methods Bug fixes for PR #769 Interpretability: - InterpretabilityMetricsHelper.GetUniqueGroups: Add null check for sensitiveFeature - InterpretabilityMetricsHelper.GetGroupIndices: Add null check for sensitiveFeature - InterpretabilityMetricsHelper.GetSubset: Add null checks for vector and indices - InterpretabilityMetricsHelper.ComputePositiveRate: Add null check for predictions - InterpretabilityMetricsHelper.ComputeTruePositiveRate: Add null checks for predictions and actualLabels - InterpretabilityMetricsHelper.ComputeFalsePositiveRate: Add null checks for predictions and actualLabels - InterpretabilityMetricsHelper.ComputePrecision: Add null checks for predictions and actualLabels - InterpretableModelHelper: Add null checks for model, enabledMethods, and input parameters across all async methods (GetGlobalFeatureImportanceAsync, GetLocalFeatureImportanceAsync, GetShapValuesAsync, GetLimeExplanationAsync, GetPartialDependenceAsync, GetCounterfactualAsync, GetModelSpecificInterpretabilityAsync, GenerateTextExplanationAsync, GetFeatureInteractionAsync, ValidateFairnessAsync, GetAnchorExplanationAsync) Added 10 tests covering null argument validation scenarios. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(InferenceOptimization): add null validation to optimization graph and node methods PR #768 production-readiness fixes: - OptimizationNode.AddInput: add null check for inputNode - OptimizationNode.RemoveInput: add null check for inputNode - OptimizationNode.ReplaceInput: add null checks for oldInput/newInput - OptimizationGraph.FindNodeById: add null check for id - OptimizationGraph.FindNodesByName: add null check for name - IRDataTypeExtensions.FromSystemType: add null check for type - TensorType.IsBroadcastCompatible: add null check for other - GraphOptimizer.Optimize: add null check for graph - GraphOptimizer.AddPass: add null check for pass Added 14 tests covering all 9 bug fixes and valid input scenarios. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(HyperparameterOptimization): add null validation to trial pruner and distributions PR #767 production-readiness fixes: - TrialPruner.ReportAndCheckPrune(trial): add null check for trial - TrialPruner.ReportAndCheckPrune(trialId): add null check for trialId - TrialPruner.MarkComplete: add null check for trialId - ContinuousDistribution.Sample: add null check for random - IntegerDistribution.Sample: add null check for random - CategoricalDistribution.Sample: add null check for random - HyperparameterOptimizerBase.FindBestTrial: add null check for completedTrials - HyperparameterOptimizerBase.EvaluateTrialSafely: add null checks for trial, objectiveFunction, parameters Added 13 tests covering all 8 bug fixes and valid input scenarios. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(ExperimentTracking): fix production bugs in experiment tracking Bug fixes: - StartRun: persist experiment timestamp after Touch() to maintain disk consistency - SearchRuns: validate maxResults > 0 to prevent invalid queries - GetRunDirectory: use TryGetValue with descriptive InvalidOperationException - DeleteExperiment/DeleteRun: handle IOException gracefully when directory deletion fails - LogArtifact: validate extracted filename isn't empty for root paths - LogArtifacts: wrap UnauthorizedAccessException with descriptive message - Add null validation to GetExperiment, GetRun, ListRuns, DeleteExperiment, DeleteRun - Add null validation to SerializeToJson, DeserializeFromJson, GetLatestMetric Added 11 tests covering: - Null argument validation - MaxResults validation - Timestamp persistence verification - Thread safety for concurrent metric logging - Graceful error handling for directory operations Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(DistributedTraining): fix production bugs in distributed communication Bug fixes: - CommunicationManager.Broadcast: add root range validation to prevent invalid operations - CommunicationManager.Scatter: add root range validation to prevent invalid operations - CommunicationManager.ReduceScatter: add null validation for data parameter - ParameterAnalyzer.CalculateDistributionStats: throw for null/empty groups (consistent API) - InMemoryCommunicationBackend.PerformReduction: validate all vectors have same length - InMemoryCommunicationBackend.Receive: validate message size BEFORE dequeuing (prevents data loss) - ShardingConfiguration factory methods: add null validation for better error messages Added 10 tests covering: - Root validation in Broadcast/Scatter - Null data validation in ReduceScatter - Null/empty groups in ParameterAnalyzer - Null backend in ShardingConfiguration factory methods - Single-process AllReduce optimization path Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(Reasoning): fix production bugs in reasoning module Bug fixes: - ReasoningChain.AddStep: add null validation for step parameter - DepthFirstSearch.SearchAsync: add null validation for generator, evaluator, config (consistent with other search algorithms) - MonteCarloTreeSearch constructor: validate numSimulations >= 1 and explorationConstant >= 0 - BreadthFirstSearch.CollectAllNodes: use iterative approach instead of recursion to prevent StackOverflow on deep trees Added 9 tests covering: - Null step validation in ReasoningChain - Step number auto-increment - MCTS constructor parameter validation - ThoughtNode path reconstruction - ThoughtNode leaf/root detection - ReasoningConfig default values Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(Serialization): add validation for negative dimensions in JSON converters - VectorJsonConverter: validate that length is non-negative - TensorJsonConverter: validate that shape array is not empty - TensorJsonConverter: validate that all shape dimensions are non-negative - Added 8 tests for serialization validation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(Serving): add parameter validation to batching strategies and padding Add production bug fixes for PR #758 (Serving module): Batching Strategies: - ContinuousBatchingStrategy: validate maxConcurrency >= 1, minWaitMs >= 0, targetLatencyMs > 0 - TimeoutBatchingStrategy: validate timeoutMs >= 0, maxBatchSize >= 1 - AdaptiveBatchingStrategy: validate minBatchSize >= 1, maxBatchSize >= minBatchSize, maxWaitMs >= 0, targetLatencyMs > 0, latencyToleranceFactor > 0 - SizeBatchingStrategy: validate batchSize >= 1, maxWaitMs >= 0 - BucketBatchingStrategy: validate maxBatchSize >= 1, maxWaitMs >= 0, bucket values > 0 Monitoring: - PerformanceMetrics: validate maxSamples >= 1, maxQueueDepthSamples >= 1 Padding Strategies (MinimalPaddingStrategy, BucketPaddingStrategy, FixedSizePaddingStrategy): - PadBatch: validate no null vectors in input array - UnpadBatch: validate originalLengths are non-negative - FixedSizePaddingStrategy: validate fixedLength > 0 - BucketPaddingStrategy: validate bucketSizes not null/empty Added 25 validation tests across BatchingStrategyTests, PaddingStrategyTests, and PerformanceMetricsTests. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(Tokenization): add parameter validation to tokenizers and vocabulary Add production bug fixes for PR #757 (Tokenization module): Vocabulary: - AddTokens: validate tokens parameter is not null - Constructor(Dictionary): validate tokenToId parameter is not null Tokenizers: - BpeTokenizer.Train: validate corpus not null, vocabSize >= 1 - WordPieceTokenizer.Train: validate corpus not null, vocabSize >= 1 - WordPieceTokenizer constructor: validate maxInputCharsPerWord >= 1 - CharacterTokenizer.Train: validate corpus not null, minFrequency >= 1 MidiTokenizer: - Constructor: validate ticksPerBeat >= 1, numVelocityBins >= 1 - CreateREMI: validate ticksPerBeat >= 1, numVelocityBins >= 1 - CreateCPWord: validate ticksPerBeat >= 1, numVelocityBins >= 1 - CreateSimpleNote: validate ticksPerBeat >= 1 TokenizationConfig: - ParallelBatchThreshold: validate value >= 1 via property setter Added 17 validation tests across BpeTokenizerTests, CharacterTokenizerTests, WordPieceTokenizerTests, SpecializedTokenizerTests, and VocabularyTests. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(Tools): add parameter validation and robust type conversion - Add upper bound validation (100) for topK in VectorSearchTool and RAGTool - Add validation that topKAfterRerank cannot exceed topK in RAGTool - Make ToolBase TryGetInt/TryGetDouble/TryGetBool handle type conversion errors gracefully - Add 34 unit tests covering parameter validation and edge cases PR #756 bug fixes - prevent performance issues from excessive topK values and improve robustness when receiving invalid JSON property types. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(DistributedTraining): fix initialization order and add parameter validation Bugs fixed: 1. Initialization order bug in derived classes (DivideByZeroException): - Base class was calling InitializeSharding() before derived class fields were set - Fix: Remove InitializeSharding() from base constructor, each derived class now calls it explicitly at the end of their constructor 2. ShardingConfiguration missing learningRate validation: - Added validation that learningRate > 0 3. PipelineParallelModel missing microBatchSize validation: - Added validation that microBatchSize >= 1 4. HybridShardedModel missing parallelism size validation: - Added validation that pipelineParallelSize >= 1 - Added validation that tensorParallelSize >= 1 5. Inconsistent learning rate usage: - DDPModel, FSDPModel, PipelineParallelModel, HybridShardedModel were using hardcoded 0.01 instead of Config.LearningRate - Fixed to use Config.LearningRate consistently Affected files: - ShardedModelBase.cs - removed InitializeSharding() call from constructor - DDPModel.cs, FSDPModel.cs, ZeRO1Model.cs, ZeRO2Model.cs - added InitializeSharding() call - TensorParallelModel.cs, PipelineParallelModel.cs, HybridShardedModel.cs - same + validation - ShardingConfiguration.cs - added learningRate validation Tests: Added 26 validation tests in DistributedTrainingValidationTests.cs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(LoRA): fix matrix indexing bugs and initialization order issues - Add input/output size validation in LoRALayer constructor - Add pruningInterval validation in AdaLoRAAdapter to prevent division by zero - Fix matrix indexing in MergeWeights (returns [inputSize, outputSize]): - LoRAAdapterBase.MergeToDenseOrFullyConnected - StandardLoRAAdapter.MergeToOriginalLayer - QLoRAAdapter.MergeToOriginalLayer - DoRAAdapter.Forward() and MergeToOriginalLayer - Fix DefaultLoRAConfiguration.CreateAdapter to handle different constructor signatures - Fix VeRAAdapter initialization order bug: - Move scaling vector init to CreateLoRALayer (called before ParameterCount) - Add UpdateParametersFromLayers override for VeRA-specific parameter sync - Add 22 validation tests covering all bug fixes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(Autodiff): add numerical stability validation to tensor operations - Add division by zero validation in TensorOperations.Divide - Add non-positive value validation in TensorOperations.Log - Add negative value validation in TensorOperations.Sqrt - Handle sqrt(0) edge case in backward pass (use 0 instead of infinity) - Fix null axes handling in TensorOperations.Sum OperationParams - Add segmentSize validation in GradientCheckpointing.SequentialCheckpoint - Add 19 validation tests covering all bug fixes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: address pr review comments and code scanning alerts - ExperimentTracker: add logging to IOException catch block as comment indicated - MonteCarloTreeSearch: add NaN/Infinity guards to explorationConstant validation - TensorJsonConverter: remove validation rejecting empty shapes (scalars are valid) - BucketBatchingStrategy: add validation for empty bucket boundaries array - ToolBase: update exception handling to catch JsonSerializationException - LoRALayer: update XML docs to reflect actual exception types thrown - MergedPRBugFixTests: update size-mismatch test to actually verify behavior - FineTuningBase: fix generic catch clauses and collection equality check - ShardedModelBase: use lazy initialization to avoid virtual calls in constructor Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: correct misleading comment and tighten assertion in sum operation - Update comment in TensorOperations.cs to accurately describe OperationParams behavior - Tighten Sum_NullAxes_OperationParamsHandledCorrectly test assertion to properly verify that Axes key is NOT present when axes parameter is null Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: remove virtual calls from distributed training model constructors - Remove direct InitializeSharding() calls from DDPModel, FSDPModel, ZeRO1Model, and ZeRO2Model constructors - Remove redundant InitializeSharding() call from TensorParallelModel's OnBeforeInitializeSharding() method - All models now rely on lazy initialization via EnsureShardingInitialized() in the base class to avoid virtual calls in constructors Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: address coderabbit review comments for pr #783 - TensorOperations.cs: convert if/else to ternary for operationparams assignment - HybridShardedModel.cs: move pendingconfig.value = null to onbeforeinitializesharding where it is consumed (lazy init compatibility) - FineTuningBase.cs: move string check before ienumerable check since strings implement ienumerable<char> Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: address additional coderabbit review comments - TensorOperations.cs: only emit "Axes" metadata when non-null AND non-empty (empty array means sum-all like null) - FineTuningBase.cs: treat null-null elements as matches in sequence matching fallback Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: guard numeric conversion against mixed runtime types Check both prediction and target are numeric before calling Convert.ToDouble to avoid throwing when TOutput is object and types don't match. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove accidentally committed _playground_publish folder Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add comprehensive ActiveLearning integration tests Add 62 integration tests covering: - EntropySampling (8 tests) - UncertaintySampling (5 tests) - BALD (4 tests) - RandomSampling (3 tests) - MarginSampling (2 tests) - LeastConfidenceSampling (2 tests) - VariationRatios (2 tests) - DiversitySampling (5 tests with all methods/metrics) - CoreSetSelection (2 tests) - HybridSampling (3 tests with all combination methods) - InformationDensity (2 tests) - DensityWeightedSampling (1 test) - ExpectedModelChange (2 tests) - BatchBALD (2 tests) - QueryByCommittee (2 tests) - Edge cases and mathematical validation (6 tests) Tests include: - Correct batch size validation - Null argument handling - Score range validation - Mathematical properties (entropy of uniform/certain distributions) - Diversity selection across clusters Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add comprehensive ContinualLearning integration tests Add 53 integration tests covering: - ElasticWeightConsolidation (EWC): 12 tests - SynapticIntelligence (SI): 5 tests - MemoryAwareSynapses (MAS): 4 tests - GradientEpisodicMemory (GEM): 4 tests - LearningWithoutForgetting (LwF): 4 tests - OnlineEWC: 3 tests - ExperienceReplay: 3 tests - PackNet: 3 tests - ProgressiveNeuralNetworks: 2 tests - GenerativeReplay: 2 tests - AveragedGEM (A-GEM): 3 tests - Edge cases and cross-strategy validation: 8 tests Tests verify: - Constructor initialization - BeforeTask/AfterTask lifecycle - ComputeLoss returns non-negative values - ModifyGradients produces valid output - Reset clears stored data - Multiple sequential tasks work correctly - Lambda property can be modified - Null argument handling Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add comprehensive curriculum learning integration tests - Add 35 integration tests for CurriculumLearning components - Test schedulers: LinearScheduler, SelfPacedScheduler, CompetenceBasedScheduler - Test difficulty estimators: LossBased, ConfidenceBased, TransferBased, ExpertDefined, Ensemble - Test edge cases: empty arrays, zero epochs, reset behavior - Fix bug in CurriculumSchedulerBase.GetIndicesAtPhase that crashed on empty arrays Note: Tests document a bug with generic T? default values - for unconstrained generics, T? with default value is 0.0 for value types, not null. Tests work around this by providing explicit values for optional parameters. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive selfsupervisedlearning integration tests Add 52 integration tests covering the SelfSupervisedLearning module: - NT-Xent Loss tests (4 tests): temperature effects, gradient computation - InfoNCE Loss tests (5 tests): memory bank integration, accuracy metrics - BYOL Loss tests (5 tests): cosine similarity, symmetric loss computation - Linear Projector tests (6 tests): shape validation, gradient backprop - MLP Projector tests (5 tests): batch norm, training mode, backward pass - Symmetric Projector tests (6 tests): predictor head, combined operations - Memory Bank tests (11 tests): FIFO queue, momentum updates, sampling - Momentum Encoder static method tests (3 tests): cosine schedule - Edge cases and error handling tests (6 tests) Uses RandomHelper for secure random number generation and proper Tensor API patterns for cross-framework compatibility. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add nestedlearning integration tests for associativememory and contextflow Add 30 integration tests covering the NestedLearning module: AssociativeMemory tests (12 tests): - Constructor validation and initialization - Associate/Retrieve with dimension validation - Capacity limit enforcement (FIFO) - Association matrix updates with Hebbian learning - Clear/Reset functionality - Multiple associations and large capacity handling ContextFlow tests (15 tests): - Constructor and matrix initialization - PropagateContext with level validation - ComputeContextGradients backpropagation - UpdateFlow transformation matrix updates - GetContextState and CompressContext operations - Reset clears all context states - Independent states across multiple levels Integration tests (3 tests): - Combined AssociativeMemory + ContextFlow workflow - Large capacity stress testing - Sequential propagation state accumulation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add mixedprecision integration tests (39 tests) Adds comprehensive integration tests for MixedPrecision module: - LossScaler: scaling, unscaling, overflow detection, dynamic scaling - MixedPrecisionConfig: defaults follow NVIDIA recommendations - MixedPrecisionContext: FP32/FP16 weight management, gradient preparation - Full workflow tests: training iterations, overflow recovery Closes #642 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive integration tests for adversarial robustness module - Add 83 integration tests for AdversarialRobustness module: - FGSM attack tests (8 tests) - PGD attack tests (4 tests) - CW attack tests (3 tests) - AutoAttack tests (2 tests) - Adversarial training defense tests (7 tests) - Randomized smoothing certification tests (8 tests) - Interval bound propagation tests (7 tests) - CROWN verification tests (6 tests) - Safety filter tests (11 tests) - Rule-based content classifier tests (11 tests) - Integration scenarios (6 tests) - Edge cases and error handling (10 tests) - Fix bug in FGSMAttack: add null check for trueLabel parameter to throw ArgumentNullException instead of InvalidOperationException Closes #631 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: fix randomhelper usage in finetuning integration tests Replace new Random(42) with RandomHelper.CreateSeededRandom(42) to follow project security standards for random number generation. Closes #640 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: fix lora integration tests and loralayer exception consistency - Fix LoRALayer to throw ArgumentOutOfRangeException consistently for all invalid rank values (was throwing ArgumentException for rank > min(in, out)) - Update test to expect ArgumentOutOfRangeException - Replace new Random(42) with RandomHelper.CreateSeededRandom(42) Closes #641 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add knowledgedistillation integration tests Comprehensive integration tests covering: - DistillationLoss: constructor, compute loss/gradient, edge cases - All distillation strategies: Feature, Attention, Contrastive, Probabilistic, Hybrid, Curriculum, Adaptive, Variational, NeuronSelectivity, Relational, SimilarityPreserving, FlowBased, FactorTransfer - DistillationStrategyFactory: all strategy types - DistillationForwardResult and DistillationCheckpointConfig - IntermediateActivations: add/get/count - Numerical stability and edge case testing Total: 85 tests, 0 bugs found Closes #636 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive physicsinformed integration tests Add 94 integration tests covering the PhysicsInformed module: - PhysicsInformedLoss tests (loss computation, gradients, edge cases) - PDE tests (HeatEquation, WaveEquation, PoissonEquation, BurgersEquation, AllenCahnEquation, KdV, AdvectionDiffusion) - PINN tests (PhysicsInformedNeuralNetwork, VariationalPINN, DeepRitzMethod) - Neural Operator tests (FourierNeuralOperator, FourierLayer) - ScientificML tests (HamiltonianNeuralNetwork) - TrainingHistory, PDEDerivatives, PDEResidualGradient tests - Edge cases and numerical stability tests - Integration workflow tests - Serialization tests Closes #637 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: move tensor type check before text fullname check in datamodalitydetector The Tensor check was happening after the fullName-based Text check, which caused Tensor<T> types to be incorrectly detected as Text modality since the fullName could contain substrings matching other checks. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive augmentation integration tests with 106 tests Coverage includes: - Image augmentations (GaussianNoise, Brightness, Contrast, Cutout, RandomCrop, etc.) - Audio augmentations (AudioNoise, TimeStretch, PitchShift, etc.) - Video augmentations (TemporalFlip, FrameDropout, SpeedChange) - Text augmentations (RandomDeletion, RandomInsertion, SynonymReplacement, etc.) - Object detection augmentations (BoundingBox, Keypoint transformations) - Compose and auto-augment pipelines - DataModalityDetector type detection Tests verify correct behavior for each augmentation category including: - Apply with probability, deterministic behavior, edge cases - Parameter validation, composition, and context management Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive federated learning integration tests Adds 64 integration tests for the FederatedLearning module covering: - Aggregation strategies: FedAvg, FedProx, FedBN with weighted averaging - Byzantine-robust aggregators: Krum, MultiKrum, Bulyan, TrimmedMean, WinsorizedMean, GeometricMedian, RFA - Client selection strategies: UniformRandom, WeightedRandom, Stratified, AvailabilityAware, PerformanceAware, Clustered - Privacy mechanisms: GaussianDifferentialPrivacy with clipping and noise - Privacy accounting: BasicComposition and RDP privacy accountants - Cryptography: HKDF key derivation - Server optimizers: FedAdam, FedAdagrad, FedYogi, FedAvgM - Heterogeneity corrections: SCAFFOLD, FedNova, FedDyn - Secure aggregation: SecureAggregationVector, ThresholdSecureAggregationVector - Additional tests: GaussianDifferentialPrivacyVector Tests verify mathematical correctness and proper API behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add checkpoint management integration tests Adds 38 integration tests for the CheckpointManagement module covering: - CheckpointManager construction and directory creation - Auto-checkpointing configuration (save frequency, keep last, save on improvement) - ShouldAutoSaveCheckpoint logic (frequency-based and improvement-based triggers) - UpdateAutoSaveState for tracking last save step and best metric values - AutoCheckpointState properties and ToString formatting - Thread-safe concurrent configuration updates and state reads - ListCheckpoints, LoadLatestCheckpoint, LoadBestCheckpoint edge cases - CleanupOldCheckpoints and CleanupKeepBest cleanup strategies - MetricOptimizationDirection enum values - Path validation and nested directory support Tests verify proper state tracking for minimization and maximization scenarios. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add 64 integration tests for Configuration module - AutoMLBudgetOptions: default values, property setting, all presets - RLTrainingOptions: default values, property setting, callbacks - RLCheckpointConfig: default values, property setting - RLEarlyStoppingConfig: default values, generic type support - ExplorationScheduleConfig: default values, all decay types - InferenceOptimizationConfig: default values, validation, all enum values - ResNetConfiguration: variants, block counts, expansion, factory methods - BenchmarkingOptions: default values, federated configs - CurriculumLearningOptions: schedule types, difficulty estimators - Supporting options classes: SelfPacedOptions, CompetenceBasedOptions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add dataprocessor integration tests and fix empty matrix bug - Add 24 comprehensive integration tests for DataProcessor module - Tests cover DefaultDataPreprocessor, DataProcessorOptions, SplitData - Tests validate preprocessing pipeline with Matrix, Vector, and Tensor types - Fix DivideByZeroException in FeatureSelectorHelper.CreateFilteredData when handling empty matrices (0 rows) - The fix returns a properly dimensioned empty matrix instead of attempting to call FromColumns on empty column vectors Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add dataversioncontrol integration tests (62 tests) - Add comprehensive integration tests for DataVersionControl module - Tests cover versioning, hashing, integrity verification, run linking - Tests cover tagging, lineage tracking, snapshots, and persistence - Tests verify thread safety with concurrent version creation - Tests model classes: DatasetVersion, DatasetLineage, DatasetStatistics, etc. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add 65 integration tests for dataversioning module Tests cover: - Constructor and directory structure creation - CreateDataset with validation, metadata, and duplicate handling - AddVersion with files, directories, and deduplication - GetVersion by ID, version number, and "latest" - ListVersions and ListDatasets with ordering - GetDataPath with directory structure preservation - CompareVersions detecting additions, removals, modifications - DeleteVersion and DeleteDataset with file cleanup - RecordLineage and GetLineage with recursive upstream resolution - Persistence across instance restarts - Model classes (DatasetInfo, DataVersion, DataFileInfo, DataVersionDiff, DataLineage) - Thread safety for concurrent operations - Edge cases (large file count, empty directories, special characters) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: correct json parsing bug in agent response extraction The ExtractJsonFromResponse method in all agent classes used a non-greedy regex pattern that incorrectly matched nested JSON objects. For example, with input: {"reasoning_steps": [...], "tool_calls": [{"tool_name": "X"}]} The regex would match up to the first "}" (end of tool_calls inner object) instead of the outer closing brace. Fixed by implementing proper brace-balancing algorithm that: - Tracks brace count while respecting string boundaries - Handles escape sequences within strings - Returns the complete outermost JSON object Also added comprehensive integration tests for all agent types: - Agent (ReAct pattern): 15 tests - ChainOfThoughtAgent: 8 tests - PlanAndExecuteAgent: 7 tests - RAGAgent: 12 tests - AgentBase: 3 tests - JSON parsing edge cases: 4 tests - Thread safety: 1 test Total: 50 new tests for the Agents module Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: correct training data dimensions in vision and tabular benchmarking tests The tests were training KNN models on 1-feature data but then running benchmarks that generate test data with different feature dimensions: - CIFAR10/CIFAR100: 3072 features (32x32x3 pixels flattened) - TabularNonIID: FeatureCount features (3 in this test) Fixed by providing training data that matches the benchmark feature dimensions: - CIFAR tests: 2 samples with 3072 features each (normalized pixel values) - TabularNonIID test: 3 samples with 3 features each Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive benchmarking integration tests Add 98 integration tests for the Benchmarking module covering: - BenchmarkSuiteRegistry: display names, suite categories, mappings - BenchmarkReport: construction, serialization, aggregation, statistics - BenchmarkMetricValue: creation, edge cases, formatting - BenchmarkExecutionStatus: all status values and transitions - BenchmarkSuite enum: all 23 benchmark suites - BenchmarkMetric enum: all 8 metric types - BenchmarkSuiteKind enum: all 3 suite kinds - Model classes: BenchmarkSuiteReport, BenchmarkDataSelectionSummary Tests verify behavior for: - Enum value coverage for all benchmark-related enums - Display name generation and formatting - Report creation and metric aggregation - Suite category classification (ReasoningSuite vs DatasetSuite) - Edge cases like empty reports and default values Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: add comprehensive computervision integration tests (66 tests) Tests cover: - BoundingBox format conversions (XYXY, XYWH, CXCYWH, YOLO) - BoundingBox IoU, Area, Clip, IsValid operations - Detection and DetectionResult classes - DetectionStatistics and BatchDetectionResult - NMS (standard, class-aware, batched) - IoU variants (IoU, GIoU, DIoU, CIoU) - GIoULoss for bounding box regression - SORT tracker with Kalman filtering - Track, TrackingOptions, TrackingResult classes - End-to-end integration scenarios Closes #647 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: net471 compatibility for string.split and enum.getvalues - Use char array overload for string.Split with StringSplitOptions - Use typeof() overload for Enum.GetValues instead of generic version Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: address pr review comments for integration tests - Fix divide-by-zero guard in ActiveLearning CreatePoolWithKnownUncertainty - Add missing assertion in RandomSampling_InformativenessScores test - Add meaningful assertion in Rotation_ApplyWithTargets test - Rename AllRegularizationStrategies to CoreRegularizationStrategies for accuracy - Fix reflection test to assert if type exists but methods don't - Fix greedy regex in ChainOfThoughtAgent JSON extraction - Add BindingFlags for non-public property reflection in Benchmarking - Add cleanup for default checkpoints directory - Fix culture-invariant decimal comparison in AutoCheckpointState test Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: address additional pr review comments - Rename misleading test names in DataVersionControl - Make MockChatModel thread-safe with Interlocked and ConcurrentBag - Guard against deleting pre-existing default directories in DataVersioning - Add delays to prevent timestamp-tie flakes in ordered tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: replace generic catch clauses with specific exception types in finetuning - Replace `catch (Exception ex) when (...)` patterns with specific exception type catches (InvalidCastException, FormatException, OverflowException) - Extract ComputeSequenceMatchLogProbability helper to reduce code duplication - Fix Equals on collections issue by using EqualityComparer<TOutput>.Default Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: replace generic catch clause with specific exception types in ssl tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: guard against single-class divide-by-zero in mock model Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update lora tests to expect argumentoutofrangeexception The code correctly throws ArgumentOutOfRangeException (more specific than ArgumentException) for invalid rank values. Tests now expect the correct exception type. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update vblora test to expect argumentoutofrangeexception The test Constructor_WithRankExceedingBankSizeA_ThrowsArgumentException was expecting ArgumentException but the code correctly throws ArgumentOutOfRangeException which is more specific for range validation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: franklinic <franklin@ivorycloud.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
The src/InferenceOptimization/ directory (16 .cs files + Core/IR/Kernels/Passes subdirs + README + ARCHITECTURE) was orphaned JIT IR/optimization-pass scaffolding from a compilation model that no longer exists. Zero production code in src/ referenced it — only tests and benchmarks did. The AiDotNet.Tensors compilation system (AutoTracer + CompiledInferencePlan + CompiledTrainingPlan, auto-enabled) is the replacement. Removed: - src/InferenceOptimization/ (full tree, 36 .cs files) - tests/AiDotNet.Tests/InferenceOptimization/ + IntegrationTests/InferenceOptimization/ - AiDotNetBenchmarkTests/InferenceOptimization/ - The InferenceOptimization PR #768 regression-tests region in MergedPRBugFixTests.cs - global using MemoryLayout / QuantizationParams aliases in src/Helpers/UsingsHelper.cs and tests/AiDotNet.Tests/GlobalUsings.cs (nothing else in either project uses either of those short names) - src/NeuralNetworks/SyntheticData/TapeLayerBridge.cs — public method ExportMLPGeneratorGraph had zero callers; xmldoc falsely claimed WGAN-GP use but WGANGP.cs:450-456 already uses GradientTape<T> directly - SyntheticTabularGeneratorBase.ExportMLPGeneratorGraph wrapper (dead) - SyntheticTabularGeneratorBase.SupportsJitCompilation + ExportComputationGraph stubs (both threw NotSupportedException) Scrubbed TapeLayerBridge mentions from MedSynthGenerator, MisGANGenerator, TimeGANGenerator private helper xmldoc (the helpers themselves remain — they're still used by in-progress gradient-penalty code or kept for analysis). Cosmetic: the "// InferenceOptimization Operations" and "// Fused Operations for InferenceOptimization" comment labels in src/Enums/OperationType.cs are replaced with generic labels. The enum values themselves are public API and left in place. LIVE and untouched (different systems that share a prefix): - src/Inference/InferenceOptimizer.cs (KV-cache, speculative decoding) - src/Configuration/InferenceOptimizationConfig.cs (quantization config) Build: net10.0 + net471 both green, 0 errors. Tests build green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…loses #1015) (#1155) * chore(deps): bump AiDotNet.Tensors 0.38.0 → 0.42.3 Also bumps AiDotNet.Native.OneDNN in lockstep. Picks up the recent perf work (backward-op primitive fast paths, net471 SIMD gap fix, memory planning / tile scheduling / operator reordering, plan serialization + stitching audit fixes) and is the baseline for the dead-JIT-scaffolding cleanup in issue #1015. Both net10.0 and net471 build with 0 errors. No source changes needed — the Tensors API is backward-compatible across 0.38 → 0.42. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: remove dead src/InferenceOptimization/ tree and TapeLayerBridge The src/InferenceOptimization/ directory (16 .cs files + Core/IR/Kernels/Passes subdirs + README + ARCHITECTURE) was orphaned JIT IR/optimization-pass scaffolding from a compilation model that no longer exists. Zero production code in src/ referenced it — only tests and benchmarks did. The AiDotNet.Tensors compilation system (AutoTracer + CompiledInferencePlan + CompiledTrainingPlan, auto-enabled) is the replacement. Removed: - src/InferenceOptimization/ (full tree, 36 .cs files) - tests/AiDotNet.Tests/InferenceOptimization/ + IntegrationTests/InferenceOptimization/ - AiDotNetBenchmarkTests/InferenceOptimization/ - The InferenceOptimization PR #768 regression-tests region in MergedPRBugFixTests.cs - global using MemoryLayout / QuantizationParams aliases in src/Helpers/UsingsHelper.cs and tests/AiDotNet.Tests/GlobalUsings.cs (nothing else in either project uses either of those short names) - src/NeuralNetworks/SyntheticData/TapeLayerBridge.cs — public method ExportMLPGeneratorGraph had zero callers; xmldoc falsely claimed WGAN-GP use but WGANGP.cs:450-456 already uses GradientTape<T> directly - SyntheticTabularGeneratorBase.ExportMLPGeneratorGraph wrapper (dead) - SyntheticTabularGeneratorBase.SupportsJitCompilation + ExportComputationGraph stubs (both threw NotSupportedException) Scrubbed TapeLayerBridge mentions from MedSynthGenerator, MisGANGenerator, TimeGANGenerator private helper xmldoc (the helpers themselves remain — they're still used by in-progress gradient-penalty code or kept for analysis). Cosmetic: the "// InferenceOptimization Operations" and "// Fused Operations for InferenceOptimization" comment labels in src/Enums/OperationType.cs are replaced with generic labels. The enum values themselves are public API and left in place. LIVE and untouched (different systems that share a prefix): - src/Inference/InferenceOptimizer.cs (KV-cache, speculative decoding) - src/Configuration/InferenceOptimizationConfig.cs (quantization config) Build: net10.0 + net471 both green, 0 errors. Tests build green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor: remove dead AiDotNet-side ExportComputationGraph scaffolding The removed AiDotNet JitCompiler left behind a graveyard of stub methods and now-unreachable graph-building helpers. All of them either threw NotSupportedException or built ComputationNode<T> trees for a compiler that no longer exists. Deleted: - ExportComputationGraph method on: LayerBase, NeuralNetworkBase, ClassifierBase, MultiLabelClassifierBase, RegressionBase, NonLinearRegressionBase, DecisionTreeRegressionBase, DecisionTreeAsyncRegressionBase, DiffusionModelBase, VAEModelBase, NoisePredictorBase, AutoMLModelBase, ShardedModelBase, CausalModelBase, OnlineLearningModelBase, TimeSeriesModelBase, ReinforcementLearningAgentBase, SurvivalModelBase, NBEATSBlock, AiModelResult, MCDropoutLayer, BayesianDenseLayer. - ConvertLayerToGraph helper on NeuralNetworkBase. - SupportsJitCompilation property on LayerBase + same accompanying bases (kept on IActivationFunction / IVectorActivationFunction interfaces and their implementations since those are still consumed by LoRA / SE / Hyperbolic layer fallback paths). - Layer-internal graph helpers: LayerBase.ApplyActivationToGraph, CanActivationBeJitted, SparseLinearLayer.ApplyActivationToComputationNode, SqueezeAndExcitationLayer.ApplyActivationToGraphNode, SpyNetLayer.{BuildComputationGraph,BuildPyramidGraph,CreateGridFromFlowGraph, CreateIdentityGrid,CreateScaleTensor}, DeformableConvolutionalLayer.BuildComputationGraph. - NonLinearRegressionBase kernel-graph helpers: ComputeLinearKernel, ComputeRBFKernel, ComputeSigmoidKernel, ComputePolynomialKernel, ComputeLaplacianKernel, CreateFilledTensorLike. - DecisionTreeRegressionBase / DecisionTreeAsyncRegressionBase ExportNodeAsComputationGraph + GetMaxFeatureIndexFromTree helpers. - NBEATSBlock.ApplyBasisExpansionGraph helper. - TestScaffoldGenerator emitting the SupportsJitCompilation / ExportComputationGraph stubs into generated test fixtures. Stale xmldoc bullets "JIT compilation support via ExportComputationGraph()" removed from GraphAttentionLayer, GraphIsomorphismLayer, GraphSAGELayer, PrincipalNeighbourhoodAggregationLayer. Tests: removed obsolete *_JitRemoved_SupportsJitIsFalse* assertions from BaseClassesIntegrationTests and the LoRA/KNN/LWR/RotaryPE/QuantizedAttention SupportsJitCompilation checks. Removed MixedPrecisionIntegrationTests' TestLayer override of SupportsJitCompilation / ExportComputationGraph. Compilation is transparent via AiDotNet.Tensors' AutoTracer (auto-enabled, hot paths compile to CompiledInferencePlan after the 2nd call). Opt out via TensorCodecOptions.Current.EnableCompilation or the still-supported AiModelBuilder.ConfigureJitCompilation() builder API (which projects config onto the live TensorCodecOptions under the hood). Build: net10.0 + net471 + tests all green, 0 errors. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(deps): bump AiDotNet.Tensors 0.42.3 → 0.46.0 Newer Tensors release while this PR was in flight. Brings the work after 0.42.x (0.43, 0.44, 0.45, 0.46). Backward-compatible API — no source changes required. Build: net10.0 + net471 both green, 0 errors. Auto-compile regression tests (CompileForwardTests + CompiledModelHostTests, 14 total): all pass on both TFMs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: address PR #1155 review comments on NBEATSBlock Three review comments from CodeRabbit, all on src/TimeSeries/NBEATSBlock.cs: 1. (Major) ParameterCount / GetParameters / SetParameters ignored the trainable V_b / V_f bases in generic mode — only fc weights + biases were exported/imported. That made parameter round-trips drop learned basis state. Fixed: include the bases in all three APIs when _useInterpretableBasis == false, and also re-register them in ReRegisterParameters so the SetParameters tensor swap doesn't drop them from the trainable registry. 2. (Major) Constructor validated lookbackWindow / forecastHorizon / hiddenLayerSize / numHiddenLayers but accepted thetaSizeBackcast, thetaSizeForecast, and polynomialDegree without validation. Invalid values deferred failure to tensor allocation/math paths where diagnosis is much harder. Added explicit checks: both theta sizes must be positive; polynomialDegree must be non-negative when useInterpretableBasis is true. 3. (Critical) UpdateParameters(T learningRate) was an empty override that silently ignored update calls — the kind of silent no-op that becomes an accuracy regression you can only find by bisecting. Replaced with a fail-fast InvalidOperationException pointing callers at the tape-based training path (CompiledTapeTrainingStep), so misuse is caught at the training boundary instead of producing silently-undertrained models. Build: net10.0 + net471 + tests all green, 0 errors. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: two more PR #1155 review comments on NBEATSBlock 1. (Major) Interpretable theta sizes weren't validated against polynomialDegree + 1. ComputeBasisTensor + ApplyBasisExpansion both cap usable rows at polynomialDegree + 1, so oversized thetaSizeBackcast / thetaSizeForecast silently allocated dead trainable weights that couldn't influence the output. Added explicit checks for interpretable mode. 2. (Critical) ForwardInternal's generic branch in ApplyBasisExpansion returned theta directly instead of multiplying by the learned V_b / V_f basis tensors. With the Phase 1 fix that made those bases round-trip through GetParameters/SetParameters, PredictSingle would diverge from both Forward() (which uses _basisBackcast/_basisForecast via matmul) and from loaded-model state. Changed ApplyBasisExpansion to take a basis tensor argument and multiply by it in the generic branch, matching training and tape paths per Oreshkin et al. 2020 §3.2. Build: net10.0 clean, 0 errors. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor: audit pass — remove dead SupportsJitCompilation properties + empty IJitCompilable regions Sweep #1 of the end-to-end JIT audit. The IJitCompilable interface no longer exists (removed with the JitCompiler). Every remaining reference was either a stale region marker with no content, or a vestigial SupportsJitCompilation property that nothing reads. Removed: - SupportsJitCompilation property on 11 model base classes (AutoML, CausalInference, Classification, MultiLabelClassification, Diffusion, NoisePredictor, VAE, DistributedTraining/ShardedModelBase, NeuralNetworkBase, OnlineLearning, Survival). Kept on IActivationFunction / IVectorActivationFunction implementations since LoRA / SqueezeAndExcitation / HyperbolicLinear / SparseLinear still consult those for activation-graph fallback (live code path). - 21 empty #region IJitCompilable Override markers across the SyntheticData generators (AutoDiffTab, CausalGAN, CopulaGAN, CTABGANPlus, CTGAN, DPCTGAN, FinDiff, GOGGLE, MedSynth, MisGAN, OCTGAN, PATEGAN, REaLTabFormer, TabDDPM, TabFlow, TableGAN, TabLLMGen, TabSyn, TabTransformerGen, TimeGAN, TVAE). - 4 empty #region IJitCompilable Implementation Override markers in Regression (AdaBoostR2, ExtremelyRandomizedTrees, GradientBoosting, RandomForest) and TransferLearning (TransferRandomForest). - ExpressionTree.BuildComputationGraph (private method with only recursive self-calls; nothing external called it after JitCompiler removal). - VectorModel.VectorToTensor (private method inside #region IJitCompilable Implementation; only defined, never referenced inside or outside the file). - SuperNet.ExportOperationGraph + SuperNet.Forward (both dead, only existed to satisfy the removed IJitCompilable interface). Build: net10.0 + net471 both green, 0 errors. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(jit-audit): remove dead BuildComputationGraph chain + IJitCompilable xmldoc Audit A: continues the dead JIT-scaffolding sweep from 010bc09 / fb9ebb2. After removal in prior commits of the JitCompiler / InferenceOptimization IR / ExportComputationGraph surface, these eight layer files still carried a closed chain of private BuildComputationGraph() methods that only called each other (zero external callers), plus xmldoc remarks referencing IJitCompilable on interfaces that were removed. All of it is dead. - 8 neural-network layers: remove private BuildComputationGraph chain (DenseBlock, InvertedResidual, RRDB, RRDBNetGenerator, ResidualDense, SqueezeAndExcitation, Transition, UNetDiscriminator) - 5 KnowledgeDistillation teacher-model xmldocs: strip IJitCompilable references; note Tensors' AutoTracer handles auto-compile transparently - DeepReinforcementLearningAgentBase: same xmldoc fix + point to TensorCodecOptions.Current.EnableCompilation for opt-out - InterfaceGuard / IFullModel: scrub IJitCompilable from the remarks list Build: net10.0 + net471 clean (0 errors). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(jit-audit): remove orphan IJitCompilable stubs from tests & docs After the production-side IJitCompilable removal in prior commits, test mocks, testconsole examples, the benchmark harness, and the golden-standard pattern doc still carried SupportsJitCompilation + ExportComputationGraph stubs for a removed interface — purely orphan code that compiled only because no interface required those members. This sweep removes all of them (29 test files + 3 testconsole examples + 1 benchmark helper + GOLDEN_STANDARD_PATTERNS.md). The only remaining SupportsJitCompilation references are on IActivationFunction / IVectorActivationFunction, which are part of the live ComputationNode graph-mode autodiff path (distinct from the removed JIT compiler). Build: net10.0 + net471 clean across src/, tests/, testconsole/, and AiDotNetBenchmarkTests/. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(jit-audit): remove stale JitCompiler/InferenceOptimization filters from CI Deep Audit A found 5 dangling references to deleted test namespaces in CI and test-sharding configs. These filters targeted tests that were deleted in the JIT/InferenceOptimization sweep — now no-ops that confuse CI dashboards. - .github/workflows/sonarcloud.yml: - Unit-06 shard: drop UnitTests.JitCompiler (deleted); rename "JIT/KD/..." -> "KD/..." - Exclusion filter: drop UnitTests.JitCompiler (no longer emits tests) - Drop "Other - InferenceOptimization" shard entirely (namespace deleted) - scripts/run-tests-sharded.ps1: - Drop "JitCompiler" from unitNamespaceRoots - Rename Unit-07 shard "Interpretability/JIT/KD" -> "Interpretability/KD" - Drop shard 13 "InferenceOptimization" (namespace deleted); renumber PromptEngineering -> 13 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(tensors-parity): acceleration diagnostics + SymbolicShape dynamic-batch compile (gaps 2+5) Part of the Tensors-0.46.0 parity work (closes 2 of 14 gaps; see Tensors issues #197 + #198 for the two gaps that need upstream Tensors features). ## Gap 5 — acceleration diagnostics (PlatformDetector + NativeLibraryDetector) Tensors already ships PlatformDetector (SIMD level, cache sizes, GPU support flags) and NativeLibraryDetector (OpenBLAS / CLBlast / cuDNN / MKL availability). AiDotNet was ignoring both — users had no visibility into which acceleration path was actually engaged. - src/Diagnostics/AccelerationDiagnostics.cs — new facade wrapping both detectors. GetReport() returns a human-readable summary; GetSnapshot() returns a structured AccelerationSnapshot for programmatic assertions. - AiModelBuilder.ReportAccelerationStatus(Action<string>? logger) — opt-in builder method. Runs after ApplyGpuConfiguration so the snapshot reflects the engine state the built model will actually see. - AiModelResult.AccelerationSnapshot — new property on every AiModelResult. 7 construction sites updated via AttachDiagnostics() helper. ## Gap 2 — SymbolicShape for dynamic batch/seq-len compile keys CompiledModelHost keyed the compile cache on concrete shape via GetOrCompileInference(shape, forward). Every batch-size change forced a fresh trace+compile — wasteful for real inference traffic where request batches vary. Tensors exposes SymbolicShape.BatchDynamic / BatchAndSeqDynamic / AllDynamic + a 3-arg GetOrCompileInference overload for exactly this case. - src/NeuralNetworks/CompiledModelHost.cs: new SymbolicShapeMode enum (Static / BatchDynamic / BatchAndSeqDynamic / AllDynamic). Default = BatchDynamic (matches PyTorch torch.compile(dynamic=True) default). - Predict() builds a SymbolicShape from mode + concrete shape and calls the 3-arg overload, falling back to the 2-arg concrete overload when rank is too small (e.g. 1-D scalar input with BatchDynamic requested). ## Verify dotnet build -f net10.0 — clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(tensors-parity): disk-backed plan caching via CompiledPlanLoader (gap 1) PyTorch-parity equivalent: torch.jit.save + torch.jit.load. Before this change AiDotNet recompiled every forward-pass plan on every process start — wasteful for production serving where warm inference latency matters. Tensors 0.46.0 already ships everything needed: ICompiledPlan.SaveAsync, CompiledPlanLoader.LoadInferenceAsync, PlanCompatibilityInfo for hardware- fingerprint gating. We just weren't wiring it. ## Public API await new PredictionModelBuilder<float, Tensor<float>, Tensor<float>>() .ConfigureModel(myNet) .ConfigurePlanCaching(@"C:\PlanCache") // NEW .BuildAsync(); Plans are saved under modelTypeName_T_v{structureVersion}_s{shapeHash}.plan. Per-(model, T, version, shape) — one directory can host multiple models without collision. Loads that fail PlanCompatibilityInfo fall through to a fresh compile silently. ## Files - src/NeuralNetworks/PlanCache.cs: new. Static Current, directory-based storage, atomic writes (tmp + rename). Shape hash = SHA256 of int32[]. - src/NeuralNetworks/CompiledModelHost.cs: - ctor now accepts optional modelIdentity — null = disk caching off - new fields: _diskCheckedShapes (one load attempt per shape-version), _preloadedPlans (in-memory cache of disk-loaded plans) - Predict(): before GetOrCompileInference, call TryUseDiskCachedPlan. If hit, skip compile entirely. - After fresh compile, fire-and-forget save via Task.Run so Predict doesn't block on IO. - src/NeuralNetworks/NeuralNetworkBase.cs: _compileHost is now assigned in the ctor so GetType().FullName reflects the concrete subclass — different model types don't collide on disk keys. - src/Diffusion/NoisePredictors/NoisePredictorBase.cs: same change. - src/AiModelBuilder.cs + src/Interfaces/IAiModelBuilder.cs: new ConfigurePlanCaching(directory) fluent method. ## Verify dotnet build -f net10.0 — clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(tensors-parity): add FusedLinear in FeedForward + Tensors op profiling (gaps 6/7/12) ## Gap 12 — Fused GEMM+Bias+Activation (already mostly wired; completing) Audit confirmed the major linear layers (DenseLayer, FullyConnectedLayer, and several others) already dispatch through Engine.FusedLinear / FusedLinearGpu for CPU + GPU paths. The notable miss was FeedForwardLayer.Forward, which was doing separate TensorMatMul + Reshape + TensorBroadcastAdd + ApplyActivation calls (4 kernel launches per forward). Refactored to use Engine.FusedLinear(input, weights, biases, fusedActivation) with the standard pre-activation tape-safe fallback for training. - src/NeuralNetworks/Layers/FeedForwardLayer.cs: Forward() rewritten. Mirror of DenseLayer's fused-inference path. ## Gap 7 — Tensors per-op profiling (orthogonal to existing AiDotNet ProfilerSession) AiDotNet already has its own ProfilerSession / ProfileReport / AiModelResult. ProfilingReport surfacing HIGHER-level workflow timings (Welford stats, hierarchical call trees, reservoir percentiles, memory tracking — richer than Tensors' simpler per-op profiler). Tensors has no parity with that feature set, so we keep it. What was missing: visibility into LOWER-level tensor-op kernel timings. Tensors ships PerformanceProfiler.Instance which wraps every engine op in an IDisposable scope — useful for finding which kernel (MatMul, Softmax, LayerNorm) is the actual bottleneck. - src/Diagnostics/ProfilingReport.cs: new. TensorsOperationProfile wraps PerformanceProfiler output. FormatSummary formats top-N ops. - src/AiModelBuilder.cs + src/Interfaces/IAiModelBuilder.cs: new EnableTensorsOpProfiling() fluent method. - src/Models/Results/AiModelResult.Diagnostics.cs: new TensorsOperationProfile property. Sits alongside existing ProfilingReport (not replacing it). ## Verify dotnet build -f net10.0 — clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(tensors-parity): diagnostics surface + subclass PredictEager routing (gaps 9+14) ## Gap 9 — autotune cache diagnostics Tensors ships AutotuneCache (Helpers.Autotune namespace) with per-kernel autotune storage. Users couldn't see whether it was active. Filed Tensors issue #200 for the WarmupCommonKernelsAsync convenience; added diagnostics surface here so users at least see the cache path + hardware fingerprint. - src/Diagnostics/AccelerationDiagnostics.cs: GetReport now emits AutotuneCache.DefaultCachePath + CurrentHardwareFingerprint. AccelerationSnapshot carries both as AutotuneCachePath / AutotuneHardwareFingerprint. ## Gap 14 — subclass Predict() routing through PredictCompiled 11 NeuralNetwork subclasses overrode Predict as literally `return Forward(input);`, bypassing the base's PredictCompiled auto-compile path. Refactored each to override PredictEager (the base's compile-lambda eager fallback) instead, keeping Forward as the implementation but routing through CompiledModelHost. After: every Predict on these 11 models goes through _compileHost.Predict, which traces → compiles → replays (and triggers disk caching via PlanCache when configured, from Gap 1). Files touched: - src/NeuralNetworks/ConvolutionalNeuralNetwork.cs - src/NeuralNetworks/EfficientNetNetwork.cs - src/NeuralNetworks/FastText.cs - src/NeuralNetworks/GloVe.cs - src/NeuralNetworks/MobileNetV2Network.cs - src/NeuralNetworks/ResNetNetwork.cs - src/NeuralNetworks/SiameseNeuralNetwork.cs - src/NeuralNetworks/UNet3D.cs - src/NeuralNetworks/VGGNetwork.cs - src/NeuralNetworks/VoxelCNN.cs - src/NeuralNetworks/Word2Vec.cs Forward methods unchanged — they still have their GPU-resident fast path (TryForwardGpuOptimized etc.) and shape-validation logic. The base's PredictCompiled treats Forward as the eager fallback but AutoTracer fires on first call regardless. ## Verify - dotnet build -f net10.0 — clean - dotnet build -f net471 — clean - dotnet test CompiledTapeTrainingStep + FusedOptimizer — 9/9 passing Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: address 5 CodeRabbit review comments on PR #1155 - NBEATSBlock ctor: extract CreateInputShape / CreateOutputShape static factories that validate lookbackWindow / forecastHorizon BEFORE the base(...) call. Invalid values now surface as ArgumentException with the right nameof(...) tag instead of a downstream LayerBase<T> shape error. - InterfaceGuard: class visibility reduced from public to internal to match the AiDotNet facade pattern. InternalsVisibleTo on src/AiDotNet.csproj already grants access to AiDotNetTests / AiDotNetTestConsole / AiDotNet.Serving / AiDotNetBenchmarkTests, so the 58 existing test call sites still compile. Doc remark added explaining the visibility choice. - PretrainedTeacherModel + TransformerTeacherModel: reworded "auto-compiles via Tensors' AutoTracer" remarks. The wrapper only invokes the delegate; whether auto-compile actually happens depends entirely on what's inside the delegate. Removed the unconditional guarantee and added a note that external paths (ONNX, REST, etc.) won't pick up engine optimizations. - SelfTeacherModel.GetLogits: rewrote XML-doc so summary/returns/exception match the throw-only behavior (method has no underlying model to run and always throws InvalidOperationException). Previous summary said "Gets logits from the underlying model" which was misleading. Verify: dotnet build net10.0 + net471 — 0 errors. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: franklinic <franklin@ivorycloud.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>


Summary
Test Coverage
Test Results
Closes #658
🤖 Generated with Claude Code