Skip to content

[KernelGen][MThreads] Add special_gammainc Moore Threads specialized operator - #120

Merged
Dongxu-H merged 2 commits into
flagos-ai:masterfrom
Yukun-Cui:pr/mthreads-special_gammainc
Jul 27, 2026
Merged

[KernelGen][MThreads] Add special_gammainc Moore Threads specialized operator#120
Dongxu-H merged 2 commits into
flagos-ai:masterfrom
Yukun-Cui:pr/mthreads-special_gammainc

Conversation

@Yukun-Cui

@Yukun-Cui Yukun-Cui commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

[KernelGen][MThreads] Add special_gammainc Moore Threads specialized operator

Summary

Add a Moore Threads (MUSA) specialized Triton kernel for special_gammainc, overriding the generic
implementation via runtime.replace_customized_ops(). Implements the special gammainc operation.

Testing

  • Reused the existing upstream accuracy tests tests/test_special_gammainc.py (-m special_gammainc)
  • Validated against reference on the MUSA device; specialization confirmed active via the
    GEMS_MTHREADS SPECIAL_GAMMAINC debug log
  • Falls back to the generic implementation for unsupported dtype/device/shape
    (fp64/int64 are not supported on Moore Threads hardware)

Performance

Compared against the generic FlagGems implementation on Moore Threads (MUSA).

special_gammainc

dtype Size Torch Latency (ms) Gems Latency (ms) Speedup TFLOPS
float32 1073741824 5504.079590 796.210022 6.913x 0.003
float32 64, 64 0.364200 0.090720 4.015x 0.000
float32 4096, 4096 86.118317 12.576401 6.848x 0.003
float32 64, 512, 512 86.612679 12.582640 6.884x 0.003
float32 1024, 1024, 1024 5506.935059 796.191467 6.917x 0.003
float32 1024, 1 0.367960 0.094920 3.877x 0.000
float32 1024, 16 0.401440 0.087040 4.612x 0.000
float32 1024, 256 1.465340 0.227680 6.436x 0.002
float32 1024, 4096 21.792620 3.249160 6.707x 0.003
float32 1024, 65536 344.749237 49.897400 6.909x 0.003
float32 64, 64, 1 0.361640 0.094320 3.834x 0.000
float32 64, 64, 16 0.396440 0.097960 4.047x 0.001
float32 64, 64, 256 5.551840 0.903320 6.146x 0.002
float32 64, 64, 4096 86.310165 12.580560 6.861x 0.003
float32 64, 64, 65536 1377.455444 199.172760 6.916x 0.003
Operator Arithmetic Mean Speedup
special_gammainc 5.86x

Files Changed

  • src/flag_gems/runtime/backend/_mthreads/ops/special_gammainc.py: Moore Threads Triton kernel + fallback
  • src/flag_gems/runtime/backend/_mthreads/ops/__init__.py: Register import and __all__

@Dongxu-H

Copy link
Copy Markdown
Collaborator

/test | special_gammainc:mthreads

@github-actions

Copy link
Copy Markdown

❌ On-demand test failed

Operator: special_gammainc
Runner: mthreads
Backend: mthreads-musa520

The test failed to complete. Check the workflow run for details.

@Dongxu-H

Copy link
Copy Markdown
Collaborator

/test | special_gammainc_moore_threads_specialized:mthreads

@github-actions

Copy link
Copy Markdown

❌ On-demand test failed

Operator: special_gammainc_moore_threads_specialized
Runner: mthreads
Backend: mthreads-musa520

The test failed to complete. Check the workflow run for details.

@Dongxu-H

Copy link
Copy Markdown
Collaborator

/test | special_gammainc:mthreads

@github-actions

Copy link
Copy Markdown

⚠️ Cannot proceed with operation

  • reviewDecision: skip_reviews
  • commitStatus: FAILURE

Reviews are not required for this operation but CI checks must be passing in order to continue

@Dongxu-H

Copy link
Copy Markdown
Collaborator

/test | special_gammainc:mthreads

@github-actions

Copy link
Copy Markdown

⚠️ Cannot proceed with operation

  • reviewDecision: skip_reviews
  • commitStatus: FAILURE

Reviews are not required for this operation but CI checks must be passing in order to continue

@Dongxu-H

Copy link
Copy Markdown
Collaborator

/test | special_gammainc:mthreads

@github-actions

Copy link
Copy Markdown

⚠️ Cannot proceed with operation

  • reviewDecision: skip_reviews
  • commitStatus: FAILURE

Reviews are not required for this operation but CI checks must be passing in order to continue

@Dongxu-H
Dongxu-H merged commit c6d0cd1 into flagos-ai:master Jul 27, 2026
17 of 18 checks passed
@Yukun-Cui

Copy link
Copy Markdown
Contributor Author

2026.07.27已被移出待特化列表

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants