Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/integration/test_lists/test-db/l0_b200_m3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ l0_b200_m3:
- unittest/_torch/attention/sparse/test_minimax_m3_msa_selector.py
- unittest/_torch/models/test_minimax_m3.py
- unittest/_torch/models/checkpoints/hf/test_minimaxm3_weight_mapper.py
- unittest/_torch/thop/parallel_hw_agnostic/test_minimax_m3_fp8_horizontal_producer.py
- unittest/_torch/thop/parallel_hw_agnostic/test_minimax_m3_fp8_indexer.py
- unittest/_torch/thop/parallel_hw_agnostic/test_minimax_m3_fp8_main_kv_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ def test_minimax_m3_fp8_indexer_matches_bf16_then_cast(num_tokens):
q_ref, k_ref = _reference(qk, num_heads_q, q_weight, k_weight, position_ids)
k_out = cache[pages.long(), 0, within.long()]

assert torch.equal(q_out.view(torch.uint8), q_ref.contiguous().view(torch.uint8))
assert torch.equal(k_out.view(torch.uint8), k_ref.contiguous().view(torch.uint8))
# The specialized kernel uses powf while fused_qk_norm_rope uses the
# exp2f/log2f equivalent, so values at an FP8 boundary can round to
# adjacent E4M3 values.
torch.testing.assert_close(q_out.float(), q_ref.float(), rtol=0.13, atol=0.05)
torch.testing.assert_close(k_out.float(), k_ref.float(), rtol=0.13, atol=0.05)


def test_minimax_m3_fp8_indexer_cuda_graph_replay_updates_outputs():
Expand Down Expand Up @@ -122,5 +125,5 @@ def test_minimax_m3_fp8_indexer_cuda_graph_replay_updates_outputs():
k_out = cache[pages.long(), 0, within.long()]

assert not torch.equal(q_out.view(torch.uint8), first_q.view(torch.uint8))
assert torch.equal(q_out.view(torch.uint8), q_ref.contiguous().view(torch.uint8))
assert torch.equal(k_out.view(torch.uint8), k_ref.contiguous().view(torch.uint8))
torch.testing.assert_close(q_out.float(), q_ref.float(), rtol=0.13, atol=0.05)
torch.testing.assert_close(k_out.float(), k_ref.float(), rtol=0.13, atol=0.05)
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,15 @@ def test_minimax_m3_fp8_main_kv_insert_matches_materialize_then_scatter(
pages = slots.long() // page_size
within = slots.long() % page_size

assert torch.equal(q_out.view(torch.uint8), q_ref.contiguous().view(torch.uint8))
assert torch.equal(
kv_cache[:, 0][pages, :, within, :].view(torch.uint8),
k_ref.contiguous().view(torch.uint8),
# The specialized kernel uses powf while fused_qk_norm_rope_to_fp8 uses
# the exp2f/log2f equivalent, so values at an FP8 boundary can round to
# adjacent E4M3 values.
torch.testing.assert_close(q_out.float(), q_ref.float(), rtol=0.13, atol=0.05)
torch.testing.assert_close(
kv_cache[:, 0][pages, :, within, :].float(),
k_ref.float(),
rtol=0.13,
atol=0.05,
)
assert torch.equal(
kv_cache[:, 1][pages, :, within, :].view(torch.uint8),
Expand Down Expand Up @@ -155,10 +160,12 @@ def test_minimax_m3_fp8_main_kv_insert_uses_64bit_cache_offsets():
q_ref, k_ref, v_ref = _reference(qkv, 8, 1, q_weight, k_weight, position_ids)
torch.cuda.synchronize()

assert torch.equal(q_out.view(torch.uint8), q_ref.contiguous().view(torch.uint8))
assert torch.equal(
kv_cache[page, 0, :, 0, :].view(torch.uint8),
k_ref[0].contiguous().view(torch.uint8),
torch.testing.assert_close(q_out.float(), q_ref.float(), rtol=0.13, atol=0.05)
torch.testing.assert_close(
kv_cache[page, 0, :, 0, :].float(),
k_ref[0].float(),
rtol=0.13,
atol=0.05,
)
assert torch.equal(
kv_cache[page, 1, :, 0, :].view(torch.uint8),
Expand Down
Loading