Fix formatting in README.md for clarity #32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Signal - Correctness Gates | ||
| # Run on every push and PR to enforce correctness invariants | ||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
| jobs: | ||
| numerics-test: | ||
| name: Numerics Test (Triton backward vs FP64 reference) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: "3.10" | ||
| - name: Install dependencies | ||
| run: | | ||
| pip install -q torch pytest numpy pyyaml | ||
| - name: Run numerics tests | ||
| run: | | ||
| cd moe-engine && python -m pytest tests/test_kernels_numerics.py -v --tb=short | ||
| - name: Alternative: Run standalone numerics test (if pytest unavailable) | ||
| if: failure() | ||
| run: | | ||
| cd moe-engine && python tests/run_numerics_tests.py | ||
| token-conservation-check: | ||
| name: Token Conservation Invariant | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: "3.10" | ||
| - name: Install dependencies | ||
| run: | | ||
| pip install -q torch pytest numpy pyyaml | ||
| - name: Test token conservation in smoke run | ||
| run: | | ||
| cd moe-engine && python -m pytest tests/test_smoke_e2e.py -v -k "smoke" --tb=short | ||
| continue-on-error: true | ||
| - name: Manual token conservation check (standalone) | ||
| run: | | ||
| cd moe-engine && python -c " | ||
| import torch | ||
| from pkg.kernels.moe_router import MoERouter | ||
| # Quick sanity check | ||
| router = MoERouter(hidden_dim=256, num_experts=64, top_k=2) | ||
| tokens = torch.randn(1024, 256) | ||
| idx, w, dispatch_cnt = router(tokens) | ||
| N, K = idx.shape | ||
| total_dispatched = dispatch_cnt.sum().item() | ||
| expected = N * K | ||
| assert total_dispatched == expected, f'Token loss: {total_dispatched} != {expected}' | ||
| assert not torch.isnan(idx.float()).any(), 'NaN in indices' | ||
| assert (idx >= 0).all() and (idx < 64).all(), 'Out-of-range indices' | ||
| print(f'✓ Token conservation: {total_dispatched} == {expected}') | ||
| " | ||
| syntax-check: | ||
| name: Python Syntax Validation | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: "3.10" | ||
| - name: Validate Python syntax | ||
| run: | | ||
| python -m py_compile \ | ||
| moe-engine/pkg/kernels/moe_router.py \ | ||
| moe-engine/pkg/distributed/parallel_mesh.py \ | ||
| moe-engine/pkg/elastic/fault_monitor.py \ | ||
| moe-engine/tests/test_kernels_numerics.py \ | ||
| moe-engine/tests/run_numerics_tests.py | ||
| assertions-present: | ||
| name: Verify Assertion Guards | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: Check for token conservation assertions | ||
| run: | | ||
| # Verify moe_router.py has assert for dispatch_cnt | ||
| if grep -q "dispatch_cnt.sum().item() == N \* K" moe-engine/pkg/kernels/moe_router.py; then | ||
| echo "✓ Token conservation assertion found in moe_router.py" | ||
| else | ||
| echo "✗ MISSING: token conservation assertion in moe_router.py" | ||
| exit 1 | ||
| fi | ||
| # Verify parallel_mesh.py has assertions for combine | ||
| if grep -q "assert out.shape == (N, H)" moe-engine/pkg/distributed/parallel_mesh.py; then | ||
| echo "✓ Combine shape assertion found in parallel_mesh.py" | ||
| else | ||
| echo "✗ MISSING: combine shape assertion in parallel_mesh.py" | ||
| exit 1 | ||
| fi | ||
| if grep -q "assert ids_recv.shape\[0\] == received.shape\[0\]" moe-engine/pkg/distributed/parallel_mesh.py; then | ||
| echo "✓ Expert ID shape assertion found in parallel_mesh.py" | ||
| else | ||
| echo "✗ MISSING: expert ID shape assertion in parallel_mesh.py" | ||
| exit 1 | ||
| fi | ||
| # Status gate: require all checks to pass | ||
| all-checks: | ||
| name: All Checks Passed | ||
| needs: [syntax-check, assertions-present] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo "✓ All correctness gates passed" | ||