Add KVTC integration regression tests (93 tests)#3
Open
OnlyTerp wants to merge 2 commits into
Open
Conversation
Comprehensive regression test suite for the KVTC llama.cpp integration: - Type registration: GGML_TYPE_KVTC enum, type traits, quantize cases - Patch correctness: real compression (turbo2), FA dispatch, FA remap, SET_ROWS - Asymmetric K/V configs: K1V3, K2V4, K4V6 roundtrips and quality - Compression metadata: shape, sink/window lengths, compression ratio - Compressed section consistency: bit widths, scales, zero points - Cache wrapper: multi-layer evict/restore cycles, sink preservation - Calibration serialization: save/load roundtrip for all fields - Edge cases: zero middle, few tokens, single head, many layers, uniform data - Determinism: compression and decompression reproducibility - RoPE consistency: key roundtrip through pipeline - PCA calibration: eigenvalue ordering, shapes, bit budgets - CUDA header API: struct fields, kernel declarations, encode/decode - DP bit allocation: budget respect, saturation, importance ordering Works around missing PCACalibrator by building CalibrationData directly via SVD in helper functions. Co-Authored-By: Rob <onerobby@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: Rob <onerobby@gmail.com>
| @@ -0,0 +1,1056 @@ | |||
| """Regression tests for the KVTC llama.cpp integration. | |||
Contributor
There was a problem hiding this comment.
🔴 Tests placed in wrong file, violating CONTRIBUTING.md rule
The CONTRIBUTING.md Code Style section states: "Tests go in src/test_kvtc.py". This PR creates an entirely new test file at src/test_kvtc_integration.py with all 93 tests, directly violating this mandatory repository rule. All tests should be added to the existing src/test_kvtc.py file instead.
Prompt for agents
The CONTRIBUTING.md mandates that all tests go in src/test_kvtc.py. This entire file (src/test_kvtc_integration.py) should be merged into src/test_kvtc.py instead of existing as a separate file. Move all test classes and helper functions from src/test_kvtc_integration.py into src/test_kvtc.py, merging the helper functions (_synthetic_kv, _cosine_similarity, etc.) with the existing ones in that file. The _synthetic_kv in the new file adds a seed parameter that the original lacks, so the merged version should incorporate that enhancement. The _build_pca_entry and _calibration_from_cache helpers are new and can be added directly. After merging, delete src/test_kvtc_integration.py.
Was this helpful? React with 👍 or 👎 to provide feedback.
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
Adds
src/test_kvtc_integration.py— a comprehensive regression test suite (93 tests, 16 test classes) covering the KVTC llama.cpp integration. Tests span type registration, patch script correctness, end-to-end compression roundtrips, edge cases, and CUDA header API consistency.Key design decision: The repo's
PCACalibratorclass is referenced but never defined insrc/pca.py, which makessrc/calibrate.pyunimportable. To work around this, the test helpers (_build_pca_entry,_calibration_from_cache) constructCalibrationDatadirectly viatorch.linalg.svdinstead of relying on the missing class. This is the biggest thing to review.Test categories:
cuda/*.pypatch scripts (type registration, turbo2 wiring, FA dispatch/remap, SET_ROWS)KVTCCacheevict/restore lifecycletorch.save/torch.loadUpdates since last revision
CalibrationData,PCAEntry,KVTCCache,KVTCCompressor, anddp_bit_allocationare imported now.KVTCCalibratorwith directtorch.save/torch.loadcalls.Review & Testing Checklist for Human
_build_pca_entry,_calibration_from_cache) produce data that is representative of real calibration. These are a reimplementation of the missingPCACalibrator— if the real calibrator normalizes differently or uses a different SVD convention, tests could pass while masking real bugs.PCACalibratorexists, or whether larger synthetic dimensions (e.g., dim=64) would allow stricter thresholds.pytest src/test_kvtc_integration.py -vlocally to confirm all 93 tests pass in your environment.Notes
src/calibrate.py→src/pca.PCACalibrator) is not addressed by this PR — it's a separate issue.Link to Devin session: https://app.devin.ai/sessions/44c7cd53500846bbb34d52c7a4ec5336
Requested by: @OnlyTerp