[Raiden Weight Sync 1/7] Add cross-repo drift guard and FFI resolution tests - #5166
[Raiden Weight Sync 1/7] Add cross-repo drift guard and FFI resolution tests#5166YixuanWang-99 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new test file, cross_repo_drift_test.py, to verify that vendored MoE weight interleaving functions and constants match across the maxtext and tunix repositories, and to test the Raiden FFI resolution matrix. Feedback on the tests suggests comparing both parameter names and default values in the signature drift guard to prevent silent behavior drift, and avoiding clear=True when patching os.environ to prevent potential test flakiness from missing ambient environment variables.
| self.assertEqual( | ||
| list(maxtext_sig.parameters.keys()), | ||
| list(tunix_sig.parameters.keys()), | ||
| ) |
There was a problem hiding this comment.
Comparing only the parameter names (keys()) in the signature drift guard is insufficient. If a default value of a parameter changes in one of the repositories, the parameter names will still match, but the behavior will silently drift. To prevent this, compare both the parameter names and their default values.
| self.assertEqual( | |
| list(maxtext_sig.parameters.keys()), | |
| list(tunix_sig.parameters.keys()), | |
| ) | |
| self.assertEqual( | |
| [(p.name, p.default) for p in maxtext_sig.parameters.values()], | |
| [(p.name, p.default) for p in tunix_sig.parameters.values()], | |
| ) |
| with mock.patch.dict("os.environ", env_dict, clear=True), mock.patch.object( | ||
| raiden_synchronizer, "_get_raiden_ffi", return_value=fake_wheel | ||
| ): |
There was a problem hiding this comment.
Using clear=True in mock.patch.dict completely empties os.environ during the test execution. This can cause unexpected failures or flakiness if JAX, pytest, or other system/test runner components rely on ambient environment variables (such as PATH, PYTHONPATH, or JAX configuration variables). Instead, patch the environment without clearing it, and explicitly remove RAIDEN_USE_FFI if env_val is None.
with mock.patch.dict("os.environ", env_dict), mock.patch.object(
raiden_synchronizer, "_get_raiden_ffi", return_value=fake_wheel
):
if env_val is None:
os.environ.pop("RAIDEN_USE_FFI", None)There was a problem hiding this comment.
Why do we need this test?
| @pytest.mark.cpu_only | ||
| def test_raiden_ffi_resolution_matrix(self): | ||
| from unittest import mock | ||
| from tunix.experimental.weight_sync import raiden_synchronizer |
There was a problem hiding this comment.
can you move the import on top
e16fd8a to
4f55851
Compare
4f55851 to
92e8726
Compare
|
Closing as per maintainer feedback: cross-repo drift guard test is unnecessary. |
Overview
Part of the stacked Raiden weight-sync enablement PR chain replacing #5089.
Stack:
Details
Verification
pytest tests/post_training/unit/cross_repo_drift_test.py(5/5 passed).Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.