Liger-Kernel
Liger-Kernel copied to clipboard
[RFC] More robust revert functions for convergence tests
trafficstars
🐛 Describe the bug
Many discussions show that the current revert functions have several limitations, including:
- incomplete revert: https://github.com/linkedin/Liger-Kernel/pull/627#issuecomment-2757281103 #542
- not automatically updating old reference: #385
- comparing wrong references: https://github.com/linkedin/Liger-Kernel/pull/627#issuecomment-2756914629
Simply reloading the modules would generate new class/function objects different from the original ones, i.e. revert(patch(object)) != object, which can easily lead to bugs when doing comparisons (isinstance()), repatching, reusing configs and so on.
One way to address the issue is having a patch manager for testing to keep track of replaced objects, so we can easily revert back to the original objects after monkey patch. Or is there a way to achieve it with pytest?
cc @tyler-romero @austin362667
Reproduce
No response
Versions
none