Add comprehensive benchmarks for AiDotNet library
User Story / Context
- Reference: [US-XXX] (if applicable)
- Base branch:
merge-dev2-to-master
Summary
- What changed and why (scoped strictly to the user story / PR intent)
Verification
- [ ] Builds succeed (scoped to changed projects)
- [ ] Unit tests pass locally
- [ ] Code coverage >= 90% for touched code
- [ ] Codecov upload succeeded (if token configured)
- [ ] TFM verification (net46, net6.0, net8.0) passes (if packaging)
- [ ] No unresolved Copilot comments on HEAD
Copilot Review Loop (Outcome-Based)
Record counts before/after your last push:
- Comments on HEAD BEFORE: [N]
- Comments on HEAD AFTER (60s): [M]
- Final HEAD SHA: [sha]
Files Modified
- [ ] List files changed (must align with scope)
Notes
- Any follow-ups, caveats, or migration details
[!NOTE]
Other AI code review bot(s) detected
CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.
Summary by CodeRabbit
-
New Features
- Added a comprehensive benchmark suite and detailed benchmark summary with scenarios, coverage, cross-framework comparisons, and run instructions.
-
Tests
- Marked select tests as integration and added a coverage runsettings file to refine coverage collection and exclusions.
-
Chores
- Removed legacy target framework support, added benchmarking/ML package references to the benchmark project, standardized internal error messages, applied nullable directives in tests, and consolidated CI into a SonarCloud-focused pipeline (removed older workflows).
✏️ Tip: You can customize this high-level summary in your review settings.
Walkthrough
Adds a BenchmarkDotNet project with many new benchmark suites and global usings, updates the benchmark csproj with ML/TensorFlow/Accord packages and a ProjectReference, introduces centralized tensor error messages and replaces literal messages, adjusts AiDotNet.Tensors target frameworks and packaging, swaps BenchmarkRunner for BenchmarkSwitcher, removes multiple CI workflows and adds a SonarCloud workflow, and adds a coverlet runsettings file and minor test metadata/nullability changes.
Changes
| Cohort / File(s) | Summary |
|---|---|
Benchmark project file AiDotNetBenchmarkTests/AiDotNetBenchmarkTests.csproj |
Adds NoWarn CA1822, PackageReferences for Accord (3.8.0) and conditional Microsoft.ML (3.0.1), TensorFlow.NET (0.150.0), SciSharp.TensorFlow.Redist (2.16.0) for net8.0, and a ProjectReference to ..\src\AiDotNet.csproj. |
Benchmark documentation AiDotNetBenchmarkTests/BENCHMARK_SUMMARY.md |
Adds comprehensive benchmark suite documentation, run instructions, coverage matrix, and a benchmark catalog. |
Benchmark suites AiDotNetBenchmarkTests/BenchmarkTests/* AiDotNetBenchmarkTests/BenchmarkTests/AllOptimizersBenchmarks.cs, LossFunctionsBenchmarks.cs, NeuralNetworkArchitecturesBenchmarks.cs, NeuralNetworkLayersBenchmarks.cs, NormalizersBenchmarks.cs, RAGBenchmarks.cs |
Adds multiple new BenchmarkDotNet classes covering optimizer option constructions (21 benchmarks), extensive loss & derivative benchmarks with GlobalSetup, neural architecture and layer construction/forward/backward/predict benchmarks, normalizer benchmarks (normalize/denormalize + constructors), and RAG configuration/evaluator/retrieval benchmarks. |
Benchmark entry & usings AiDotNetBenchmarkTests/GlobalUsings.cs, AiDotNetBenchmarkTests/Program.cs |
Adds global using directives and replaces direct BenchmarkRunner invocation with a BenchmarkSwitcher-based Program that supports command-line filters. |
CI workflows — removals .github/workflows/build.yml, .github/workflows/codex-autofix.yml, .github/workflows/pr-tests.yml, .github/workflows/pr-validation.yml, .github/workflows/quality-gates.yml, .github/workflows/codeql.yml |
Deletes multiple existing GitHub Actions workflows and their jobs/steps. |
CI workflows — addition .github/workflows/sonarcloud.yml |
Adds a new "Build & SonarCloud" workflow including SonarCloud and CodeQL steps, multi-framework build/tests, net471 tests, artifact uploads, and an artifact-size check. |
Tensors csproj changes src/AiDotNet.Tensors/AiDotNet.Tensors.csproj |
Removes net462 from TargetFrameworks (now net8.0;net471), updates Description and PackageTags, moves ILGPU package refs to unconditional ItemGroup, removes net462-specific System.ValueTuple ref, and narrows a file exclusion condition to net471. |
Centralized error messages src/AiDotNet.Tensors/ErrorMessages.cs |
Adds internal static ErrorMessages class with constants for vector/span length and empty-collection validation messages. |
Primitives — message replacements src/AiDotNet.Tensors/Helpers/TensorPrimitivesCore.cs, src/AiDotNet.Tensors/Helpers/TensorPrimitivesHelper.cs |
Replaces hard-coded exception strings with ErrorMessages constants and adds using static for ErrorMessages; behavior preserved aside from standardized messages. |
Interface pragmas src/AiDotNet.Tensors/Interfaces/IBinaryOperator.cs |
Wraps the IBinaryOperator<T, TVector> interface with pragma directives to suppress/restore S2326 (no API changes). |
Coverage runsettings coverlet.runsettings |
Adds XPlat Code Coverage runsettings with OpenCover output and exclusion filters for tests/benchmarks and generated/obsolete attributes. |
Tests — metadata & nullability tests/** |
Adds [Trait("Category","Integration")] to selected tests and file-level #nullable disable directives in several test files to allow intentional null-value tests (no behavioral changes). |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
- Focus areas:
- Large benchmark GlobalSetup allocations and memory-profile implications (LossFunctionsBenchmarks, NeuralNetworkLayersBenchmarks, NormalizersBenchmarks).
- RAG benchmark generics and builder/evaluator compatibility with existing RAG APIs (RagBenchmarks.cs).
- Conditional package references and added ProjectReference in the benchmark csproj.
- Tensors csproj target removal (net462) and ILGPU package relocation impact on multi-target builds.
- CI workflow removals vs. newly added sonarcloud.yml to ensure required checks remain covered.
Possibly related PRs
- ooples/AiDotNet#457 — Touches retriever and RAG-related tests similar to the test metadata and retriever files changed here.
- ooples/AiDotNet#497 — Related edits to AiDotNet.Tensors helpers/csproj and standardizing error messages.
Poem
🐰
I nibbled bytes beneath the moonlit tree,
Benchmarks sprout where loops hop wild and free.
Optimizers sprint, layers stretch and play,
RAG fetches stories scattered far away.
Tiny paws count metrics — joy in each array.
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 22.38% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly summarizes the main change: adding comprehensive benchmarks for the AiDotNet library, which aligns with the bulk of the changeset. |
| Description check | ✅ Passed | The description is a template with placeholders (e.g., [US-XXX], [N], [M], [sha]) and incomplete sections, but it contains related content referencing the PR intent to add benchmarks and includes verification requirements relevant to the changeset. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
claude/add-benchmarks-011CUzfqaqetfMBMBXnDCTEf
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between bc5872a23a9a8e075451ba2497b9c641aea15297 and 6a49d63e8c4f8de1015d5afb033e830c0337a597.
📒 Files selected for processing (3)
tests/AiDotNet.Tests/UnitTests/RetrievalAugmentedGeneration/Retrievers/AdvancedRetrieverTests.cs(1 hunks)tests/AiDotNet.Tests/UnitTests/RetrievalAugmentedGeneration/Retrievers/BM25RetrieverTests.cs(1 hunks)tests/AiDotNet.Tests/UnitTests/RetrievalAugmentedGeneration/Retrievers/DenseRetrieverTests.cs(1 hunks)
✅ Files skipped from review due to trivial changes (3)
- tests/AiDotNet.Tests/UnitTests/RetrievalAugmentedGeneration/Retrievers/DenseRetrieverTests.cs
- tests/AiDotNet.Tests/UnitTests/RetrievalAugmentedGeneration/Retrievers/BM25RetrieverTests.cs
- tests/AiDotNet.Tests/UnitTests/RetrievalAugmentedGeneration/Retrievers/AdvancedRetrieverTests.cs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: CodeQL Analysis
- GitHub Check: SonarCloud Analysis
- GitHub Check: Codacy Security Scan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
