FlagGems: trying Triton operators through PyTorch's eager API

I’m helping organize FlagOS Community and wanted to introduce FlagGems to PyTorch users investigating operator behavior or accelerator integration.

FlagGems is a Triton-based operator library. It can register implementations with PyTorch’s ATen dispatch system, letting applications use supported operators through familiar PyTorch calls. It supports eager execution without requiring torch.compile.

After configuring a supported environment, selective enablement lets you try a single operator. Run this in a fresh process without globally enabling FlagGems:

import torch
import flag_gems

x = torch.randn(128, 128, device=flag_gems.device)
y = torch.randn_like(x)
reference = torch.add(x, y)

with flag_gems.use_gems(include=["add"]):
    result = torch.add(x, y)

torch.testing.assert_close(result, reference)

This illustrates the documented API; it is not a new compatibility or performance result. Compatibility depends on the device, driver/runtime, PyTorch build and Triton/FlagTree compiler. Follow the project’s installation guide for the selected backend and release: installing the operator package alone does not install the full accelerator environment. Operator and dtype coverage should be checked for your setup.

Two kinds of feedback are particularly useful:

  • Correctness: a minimal reproducer with shapes, strides, dtypes, scalar arguments and a native PyTorch reference.
  • Integration and performance: which implementation actually ran, your complete software/hardware versions, and whether you measured device execution or a warmed, synchronized API call.

Please keep reproducible reports on the project’s GitHub issues. Our public community notes and contribution starting points include examples for preserving input layouts and interpreting timing measurements. I’d also welcome discussion here about where selective operator replacement fits—or creates friction—in your PyTorch workflow.