feat: added support for getTotalSwapTime and getTimePerSwap#288
Open
amanbharti008 wants to merge 2 commits into
Open
feat: added support for getTotalSwapTime and getTimePerSwap#288amanbharti008 wants to merge 2 commits into
amanbharti008 wants to merge 2 commits into
Conversation
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
Instruments swap phases so
getTotalSwapTime()(total milliseconds) andgetTimePerSwap()(average ms per timed swap iteration) reflect measured wall time.getTimePerSwap()now divides by the number of timed swap iterations (swapTimingIterations), not the generic swap steps counter where those differ.Adds a Python regression test on the MNIST_100 subset used elsewhere in the smaller test suite.
Motivation
totalSwapTimewas not updated inside the swap loops.getTimePerSwap()usedtotalSwapTime / steps, which does not match “average time per timed swap iteration” whenstepscounts something other than timed iterations.stepsis outer-loop iterations while timing sums innerswapFastPAM1iterations.Implementation
KMedoids
Introduces
swapTimingIterationscounter.totalSwapTimereset along withswapTimingIterationsatfit()start.getTimePerSwap():0when there are no timed iterations.totalSwapTime / swapTimingIterations.Changes mirrored in
R_package/banditpam/src/headers and sources.Timing
Each timed swap loop uses:
std::chrono::steady_clockstd::chrono::duration_cast<std::chrono::milliseconds>Applied in:
BanditPAMBanditPAM_origFastPAM1::swapFastPAM1PAM::fitPAM(whennMedoids > 1in the main tree)Tests
File:
tests/test_smaller.pytest_swap_timing_statsFits
k = 5onsmall_mnist(data/MNIST_100.csv) for:BanditPAMBanditPAM_origFastPAM1PAMAssertions
time_per_swap == 0whentotal_swap_time == 0Additional Checks
For BanditPAM, BanditPAM_orig, and PAM:
time_per_swap * steps ≈ total_swap_timestepsmatches timed iterations)For FastPAM1:
stepsdoes not match inner timed swap count)How to Verify