test: add coverage for compute_kl_divergence per_sample mode and disable_adapters - #24
Merged
marksverdhei merged 1 commit intoMar 29, 2026
Conversation
…le_adapters Extends test_kl.py with coverage for two previously untested paths: **per_sample=True** (5 tests): - Returns [batch] tensor with correct shape - Identical distributions → all zeros - mean(per_sample) == scalar result when masks are uniform - All values are non-negative - Fully-masked sample contributes 0 loss **disable_adapters** (2 tests): - Calls disable_adapter_layers() on entry and enable_adapter_layers() on exit - Re-enables adapters even when the body raises an exception Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Mar 29, 2026
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.
Summary
Extends
tests/test_kl.pyfrom 6 → 13 tests, covering two previously untested code paths:compute_kl_divergence(per_sample=True)— used in the vectorized loss loop (PR #20):[batch]tensor (not a scalar)mean(per_sample)equals the scalar result when masks are uniformdisable_adapterscontext manager — used in teacher forward passes:disable_adapter_layers()on entry andenable_adapter_layers()on exitTest plan
🤖 Generated with Claude Code