Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #48 +/- ##
==========================================
+ Coverage 97.19% 97.30% +0.11%
==========================================
Files 39 41 +2
Lines 2426 2489 +63
==========================================
+ Hits 2358 2422 +64
+ Misses 68 67 -1 ☔ View full report in Codecov by Sentry. |
Owner
Author
|
@Xmaster6y I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 7 files
Confidence score: 4/5
- This PR is likely safe to merge, but there is a moderate edge-case risk:
torch.stack(cka_values)insrc/tdhook/latent/representation_similarity/cka.pycan raise at runtime whencka_valuesis empty. - The issue is reasonably well-supported (severity 5/10, confidence 9/10) and appears user-facing only when flattened batch size is 0, so impact is conditional rather than broad.
- Pay close attention to
src/tdhook/latent/representation_similarity/cka.py- handle empty-batch flows socka_valuesis validated before stacking.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/tdhook/latent/representation_similarity/cka.py">
<violation number="1" location="src/tdhook/latent/representation_similarity/cka.py:46">
P2: `torch.stack(cka_values)` crashes for empty batches because `cka_values` can be empty when the flattened batch size is 0.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 7 files
Confidence score: 4/5
- This PR looks safe to merge with minimal risk, but there is a user-facing reproducibility concern in
docs/source/notebooks/methods/representation-similarity.ipynb. - The most significant issue is defaulting
DEV=True, which can make Colab examples pull unreleasedmaincode instead of the published package, leading to inconsistent results for readers. - Because the issue is moderate (4/10) and isolated to documentation notebook behavior rather than core runtime logic, the overall merge risk stays low.
- Pay close attention to
docs/source/notebooks/methods/representation-similarity.ipynb- ensureDEVdefaults toFalseso users only opt into dev behavior explicitly.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docs/source/notebooks/methods/representation-similarity.ipynb">
<violation number="1" location="docs/source/notebooks/methods/representation-similarity.ipynb:29">
P2: Defaulting `DEV` to `True` makes Colab run against unreleased `main` code by default. Set it to `False` so documentation examples are reproducible against the published package unless a user explicitly opts into dev mode.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
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.
What does this PR do?
Key insights about the PR.
Linked Issues
Checklist
Summary by cubic
Add centered kernel alignment (CKA) to compare latent representations, with a new estimator, tests, and a docs notebook. Introduces
tdhook.latent.representation_similarity.CkaEstimator(re-exported fromtdhook.latent); related to #34.New Features
tdhook.latent.representation_similarityexportingCkaEstimator.(N, D)or(..., N, D); readsin_key_a/in_key_b, writescka; validates shapes/device; promotes dtypes; returnsnanon degenerate inputs; deterministic..gitignoreignoresdocs/source/api/.repr.Refactors
Written for commit c300361. Summary will update on new commits.