Skip to content

Add bit-exact tests for SonicMoE weight layout kernels#62

Open
A-nnonymous wants to merge 1 commit into
paddlefrom
panzhaowu/optimize-layout-fusion-kernels
Open

Add bit-exact tests for SonicMoE weight layout kernels#62
A-nnonymous wants to merge 1 commit into
paddlefrom
panzhaowu/optimize-layout-fusion-kernels

Conversation

@A-nnonymous

Copy link
Copy Markdown
Collaborator

Summary

  • Add strict bit-exact tests for the three ernie_compat.weight_layout_fusion entry points:
    • fused_grouped_w1_to_sonic
    • fused_sonic_w1_to_grouped
    • fused_transpose_w2_layout
  • Cover BF16, FP16, and FP32 across exact block, partial block, odd, tiny, and medium shapes.
  • Add opt-in >4GB tensor tests gated by SONIC_MOE_RUN_LARGE_LAYOUT_TESTS=1 so CI can keep the normal path lightweight while still supporting int32-index-boundary validation on large-GPU runners.
  • Load the layout module directly from file in the test to avoid unrelated package-level optional dependencies masking layout-kernel regressions.

Large tensor coverage

The opt-in cases allocate BF16 tensors with more than 2^31 elements and more than 4GiB per weight tensor, then check high-address sentinel mappings for each layout kernel without building another full-size reference tensor.

Validation

  • python -m py_compile sonicmoe/ernie_compat/weight_layout_fusion.py tests/ops/test_weight_layout_fusion.py
  • CUDA_VISIBLE_DEVICES=0 python -m pytest -q tests/ops/test_weight_layout_fusion.py
    • 54 passed, 3 skipped
  • CUDA_VISIBLE_DEVICES=5 SONIC_MOE_RUN_LARGE_LAYOUT_TESTS=1 python -m pytest -q tests/ops/test_weight_layout_fusion.py -k large_tensor_crosses_int32_boundary
    • 3 passed
  • CUDA_VISIBLE_DEVICES=6 SONIC_MOE_RUN_LARGE_LAYOUT_TESTS=1 compute-sanitizer --tool memcheck --leak-check no --target-processes all --error-exitcode 99 --print-limit 20 python -m pytest -q tests/ops/test_weight_layout_fusion.py::test_transpose_w2_large_tensor_crosses_int32_boundary
    • 1 passed
    • ERROR SUMMARY: 0 errors
  • CUDA_VISIBLE_DEVICES=6 SONIC_MOE_RUN_LARGE_LAYOUT_TESTS=1 compute-sanitizer --tool memcheck --leak-check no --target-processes all --error-exitcode 99 --print-limit 20 python -m pytest -q tests/ops/test_weight_layout_fusion.py::test_grouped_w1_to_sonic_large_tensor_crosses_int32_boundary tests/ops/test_weight_layout_fusion.py::test_sonic_w1_to_grouped_large_tensor_crosses_int32_boundary
    • 2 passed
    • ERROR SUMMARY: 0 errors

No kernel implementation changes are included in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant