Potential numerical accuracy issue in the fused_moe implementation

Open
#23 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 8 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python, pytorch

Research direction

Start with tests/ops/test_moe.py, reproduce the reported parameter set with torch.manual_seed(0), and compare bfloat16 against float16. Trace the fused_moe entry point used by that test and investigate the mismatched outputs for the larger dimensions. Done means the bfloat16 case matches the reference within the test tolerance without regressing the passing cases.

Written by the indexing model from the issue text.

Description

Test environment: CTK 13.1, torch = 2.9.1+cu130, cuda-tile = 1.0.0, single B200 GPU

When using a parameter set (num_tokens, hidden_size, moe_intermediate_size, n_experts, top_k) = (128, 4096, 2048, 16, 4) in tests/ops/test_moe.py and add torch.manual_seed(0) in line 101, will have mismatched results:

(Earlier output omitted)
>       assert passed, f"\n{failed_msgs}"
               ^^^^^^
E       AssertionError:
E               *** OUTPUT 0 DID NOT MATCH THE REFERENCE (rtol=0.1, atol=0.1) ***
E                       allclose: False
E                       matched: 523466 / 524288 [99.84%]
E                       ref range:    -1.1700e+02 :  1.2300e+02
E                       test range:   -1.1650e+02 :  1.2300e+02
E                       |ref| range:   0.0000e+00 :  1.2300e+02
E                       |test| range:  0.0000e+00 :  1.2300e+02
E                       max absolute difference:  1.0000e+00
E                       max relative change:      4.3000e+01
E                       max max mean change:      2.0000e+00
E                       max arith mean change:    5.1400e+02
E                       shape: torch.Size([128, 4096]) stride: (4096, 1) dtype: torch.bfloat16
E                       mismatched indices:tensor([[   0, 1842],
E               [   0, 2071],
E               [   1,  675],
E               ...,
E               [ 127, 1728],
E               [ 127, 2207],
E               [ 127, 2628]])

For the same parameter set, if dtype is changed to float16, the test can pass.
Using a smaller hidden_size or a smaller moe_intermediate_size can also pass the test.

Dominant language
Python
Stars
830
Forks
92
Avg merge
8d 11h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/TileGym

All issues in NVIDIA/TileGym

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.