Skip to content

Modify ELU backward implementation to match Torch - #927

Merged
StrongSpoon merged 3 commits into
flagos-ai:masterfrom
Blury233:feat/elu-mod
Sep 12, 2025
Merged

Modify ELU backward implementation to match Torch#927
StrongSpoon merged 3 commits into
flagos-ai:masterfrom
Blury233:feat/elu-mod

Conversation

@Blury233

@Blury233 Blury233 commented Aug 30, 2025

Copy link
Copy Markdown
Contributor

PR Category

Operator

Type of Change

Bug Fix

Description

Align ELU backward input with Torch implementation

Issue

Progress

  • Change is properly reviewed (1 reviewer required, 2 recommended).
  • Change is responded to an issue.
  • Change is fully covered by a UT.

Performance

ELU backward Accuracy Test
截屏2025-08-30 17 31 39
ELU backward Performance Test
截屏2025-08-30 17 35 29
截屏2025-08-30 17 35 38

@Blury233 Blury233 changed the title Modify ELU backward implementation to match torch Modify ELU backward implementation to match Torch Aug 30, 2025
@StrongSpoon StrongSpoon self-assigned this Sep 1, 2025
@StrongSpoon
StrongSpoon self-requested a review September 1, 2025 03:28
Comment thread tests/test_unary_pointwise_ops.py Outdated
# res_grad_out, alpha, scale, input_scale, False, res_inp
# )

# gems_assert_close(res_in_grad, ref_in_grad, dtype)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please delete these code

Comment thread src/flag_gems/ops/elu.py Outdated
grad_input = tl.where(
y > 0,
grad_output * scale * input_scale,
grad_output * (y * input_scale + scale * alpha * input_scale),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what about grad_output * (y + scale * alpha) * input_scale?

@StrongSpoon StrongSpoon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lg

@StrongSpoon
StrongSpoon merged commit b75cdb5 into flagos-ai:master Sep 12, 2025
12 of 14 checks passed
meinie0826 pushed a commit that referenced this pull request Sep 15, 2025
* Align with torch

* ELU-backward-modification

* fix issue
nicelynice pushed a commit to nicelynice/FlagGems that referenced this pull request Feb 24, 2026
* Align with torch

* ELU-backward-modification

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants