Skip to content

[KernelGen][thead] Add linalg_eigvals vendor specialization - #167

Merged
Dongxu-H merged 1 commit into
flagos-ai:infra-cifrom
chx7514:auto-gen/thead/linalg_eigvals
Aug 11, 2026
Merged

[KernelGen][thead] Add linalg_eigvals vendor specialization#167
Dongxu-H merged 1 commit into
flagos-ai:infra-cifrom
chx7514:auto-gen/thead/linalg_eigvals

Conversation

@chx7514

@chx7514 chx7514 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Thead vendor specialization Triton kernel for linalg_eigvals (eigenvalues of a matrix). Tuned for PPU.

Testing

  • Validated against reference on device via existing upstream tests/test_linalg_eigvals.py (5 passed)
  • Tested on: Thead (runtime/backend/_thead)

Performance

Test command: pytest benchmark/test_linalg_eigvals.py --level core (Thead)

linalg_eigvals

dtype Size Torch Latency (ms) Gems Latency (ms) Speedup
float32 [32, 32] 0.525360 0.901180 0.583
float32 [64, 64] 1.738160 1.839560 0.945
float32 [128, 128] 94.019279 96.183678 0.977
float32 [256, 256] 291.732391 329.850006 0.884
float32 [512, 512] 4351.782715 4466.127930 0.974
Operator Arithmetic Mean Speedup
linalg_eigvals 0.873

Files Changed

  • src/flag_gems/runtime/backend/_thead/ops/linalg_eigvals.py: Thead specialization Triton kernel
  • src/flag_gems/runtime/backend/_thead/ops/__init__.py: Register import and __all__

@Dongxu-H

Copy link
Copy Markdown
Collaborator

/test | linalg_eigvals:thead

@github-actions

Copy link
Copy Markdown

⚠️ Cannot proceed with operation

Your pull request is in a draft state

@Dongxu-H Dongxu-H 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.

Geometric mean speedup is 0.930, slower than PyTorch baseline. This CPU-offload implementation is a correctness placeholder but not a performance win.

@Dongxu-H Dongxu-H 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.

all 中 _linalg_eigvals 应该按字母顺序排列,下划线开头的名称应放在列表最后。

@Dongxu-H

Copy link
Copy Markdown
Collaborator

/test | linalg_eigvals:thead

@github-actions

Copy link
Copy Markdown

⚠️ Cannot proceed with operation

Your pull request is in a draft state

@Dongxu-H Dongxu-H 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.

LGTM

@Dongxu-H Dongxu-H 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.

LGTM

@chx7514
chx7514 force-pushed the auto-gen/thead/linalg_eigvals branch from faa0f95 to 5f465a5 Compare August 6, 2026 08:15
@chx7514
chx7514 marked this pull request as ready for review August 6, 2026 08:26
@Dongxu-H

Dongxu-H commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

/test | linalg_eigvals:thead

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

❌ On-demand test failed

Operator: linalg_eigvals
Runner: thead
Backend: thead

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

@Dongxu-H Dongxu-H 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.

Logger should use thead backend-specific format: logging.getLogger(f'flag_gems.runtime._thead.ops.{name.split(".")[-1]}' ) instead of logging.getLogger(name) in backend implementations. Performance shows 0.873x arithmetic mean speedup (slower than reference). Consider whether this specialization is needed if it does not provide performance benefit.

@Dongxu-H

Dongxu-H commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

/test | linalg_eigvals:thead

1 similar comment
@Dongxu-H

Dongxu-H commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

/test | linalg_eigvals:thead

@Dongxu-H Dongxu-H 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.

性能 Speedup 0.873,低于 1.0x,Hessenberg 分解后还需要 CPU LAPACK 求解特征值,可以考虑完全在 device 上实现 QR 迭代以提升性能。

@Dongxu-H

Dongxu-H commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

/test | linalg_eigvals:thead

1 similar comment
@Dongxu-H

Dongxu-H commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

/test | linalg_eigvals:thead

@chx7514
chx7514 force-pushed the auto-gen/thead/linalg_eigvals branch from 5f465a5 to c9c8e29 Compare August 10, 2026 01:46
@chx7514
chx7514 force-pushed the auto-gen/thead/linalg_eigvals branch from c9c8e29 to 04045e9 Compare August 10, 2026 09:06

@Dongxu-H Dongxu-H 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.

LGTM

@Dongxu-H
Dongxu-H merged commit c270c48 into flagos-ai:infra-ci Aug 11, 2026
9 checks passed
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