Repository navigation
Conversation
Signed-off-by: mkhona <mkhona@nvidia.com>
|
Signed-off-by: mkhona <mkhona@nvidia.com>
Signed-off-by: mkhona <mkhona@nvidia.com>
Signed-off-by: mkhona <mkhona@nvidia.com>
Signed-off-by: mkhona <mkhona@nvidia.com>
Signed-off-by: mkhona <mkhona@nvidia.com>
Signed-off-by: mkhona <mkhona@nvidia.com>
| # Apply the first row step separately, then express each remaining iteration as a column/row pair. | ||
| balanced_update.div_(row_norms.add_(eps)) | ||
| for _ in range(num_steps // 2): | ||
| # Normalize columns along the row/token dimension. |
There was a problem hiding this comment.
remove not very meaningful comment, and potentially wrong if used in say some image model. code is clean enough.
|
|
||
| # Apply the first row step separately, then express each remaining iteration as a column/row pair. | ||
| balanced_update.div_(row_norms.add_(eps)) | ||
| for _ in range(num_steps // 2): |
There was a problem hiding this comment.
Q: why num_steps is set up this way? positive integer // 2?
I can see each loop normalize twice, but positive integer // 2 has no value in the code. num_xxx_steps would be a better name if num_steps to loop count may cause confusion.
| torch.cuda.manual_seed_all(FLAGS.seed) | ||
|
|
||
|
|
||
| def _sinkhorn_balance_reference( |
There was a problem hiding this comment.
AI copying code as reference? that's a bad reference in case both are wrong.
Implement reference in a different way, could be a very naive serial CPU version.
|
|
||
|
|
||
| class SinkhornBalanceTest(parameterized.TestCase): | ||
| def test_defaults_match_deepseek_v41(self) -> None: |
There was a problem hiding this comment.
Use inspect to check default value would be a better implementation for the purpose of this test.
| ((17, 5), torch.bfloat16, 11, 1.0), | ||
| ((6, 6), torch.float32, 7, 0.0), | ||
| ) | ||
| def test_matches_step_by_step_reference(self, shape, dtype, num_steps, zero_row_threshold) -> None: |
There was a problem hiding this comment.
if not exact match, test name should say "close_to"
| rtol=0.05, | ||
| ) | ||
|
|
||
| def test_single_step_converts_unit_row_l2_norm_to_unit_rms(self) -> None: |
There was a problem hiding this comment.
Too many tests don't really add more protections. Use your best judgement to remove and keep the essential ones.
|
|
||
| self.assertFalse(result.requires_grad) | ||
|
|
||
| @parameterized.parameters(torch.float64, torch.int64, torch.complex64) |
There was a problem hiding this comment.
Nit: Combine input validation to the same test, otherwise it gets too noisy.
Signed-off-by: mkhona <mkhona@nvidia.com>
Signed-off-by: mkhona <mkhona@nvidia.com>
| Args: | ||
| update: Dense signed update with shape ``(num_rows, num_columns)``. | ||
| eps: Numerical stability term added to each row or column norm. | ||
| num_steps: Total positive odd number of individual axis-normalization steps. |
There was a problem hiding this comment.
Nit: if we keep this, would be better to explain how steps are counted and why positive odd number here.
Signed-off-by: mkhona <mkhona@nvidia.com>
|
/ok to test aa26a46 |
No description provided.