Skip to content

[KernelGen] Add reciprocal operator for Iluvatar platform#2193

Open
zacliu2023 wants to merge 1 commit intoflagos-ai:masterfrom
zacliu2023:kernelgen2.0-tianshu-reciprocal
Open

[KernelGen] Add reciprocal operator for Iluvatar platform#2193
zacliu2023 wants to merge 1 commit intoflagos-ai:masterfrom
zacliu2023:kernelgen2.0-tianshu-reciprocal

Conversation

@zacliu2023
Copy link
Copy Markdown
Collaborator

Summary

  • Implement reciprocal/reciprocal_ operators with Triton kernel for Iluvatar platform
  • Use @pointwise_dynamic decorator for element-wise computation
  • Add empty tensor protection (Rule GR-030)
  • Pure Triton implementation with 1.0 / x (Rule GR-033 compliant)

MCP Autotune Results

  • Total versions: v1-v9
  • Best speedup: 0.84x (v7)
  • All 8/8 accuracy tests passed
  • Target speedup 1.5x not achieved, but kernel is functional

Files Changed

  • src/flag_gems/runtime/backend/_iluvatar/ops/reciprocal.py (new)
  • src/flag_gems/runtime/backend/_iluvatar/ops/init.py (updated)

Generated with

kernelgen MCP v2.0

🤖 Generated with Claude Code

- Implement reciprocal/reciprocal_ operators with Triton kernel
- Use @pointwise_dynamic decorator for element-wise computation
- Add empty tensor protection (Rule GR-030)
- Pure Triton implementation with 1.0 / x (Rule GR-033 compliant)
- Register operators in _iluvatar backend

MCP Autotune Results:
- Total versions: v1-v9
- Best speedup: 0.84x (v7)
- All 8/8 accuracy tests passed
- Target speedup 1.5x not achieved, but kernel is functional

Generated with kernelgen MCP v2.0
@zacliu2023 zacliu2023 changed the title [kernelgen2.0] Add reciprocal operator for Iluvatar platform [KernelGen] Add reciprocal operator for Iluvatar platform Mar 31, 2026

def reciprocal(input: torch.Tensor) -> torch.Tensor:
"""Compute reciprocal of input tensor: output = 1.0 / input"""
logger.debug("GEMS RECIPROCAL - Iluvatar")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.debug("GEMS RECIPROCAL - Iluvatar")
logger.debug("GEMS_ILUVATAR RECIPROCAL")


def reciprocal_(input: torch.Tensor) -> torch.Tensor:
"""In-place reciprocal: input = 1.0 / input"""
logger.debug("GEMS RECIPROCAL_ - Iluvatar in-place")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

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.

3 participants