feat: Add generic InfiniOps operator performance adapter - #47
Merged
Conversation
This was referenced Aug 4, 2026
baominghelly
marked this pull request as ready for review
August 4, 2026 07:56
Chamberlain0w0
requested changes
Aug 4, 2026
| def operation(*args): | ||
| inps = list(args[:-1]) | ||
| output = args[-1] | ||
| infini.ops.cat(inps[0], inps[1:], dim, output, stream=stream) |
Collaborator
There was a problem hiding this comment.
其他算子都通过 _pick_slot() 获取已注册实现,cat 却直接调用默认槽。这与 PR 声称“只调用 active_implementation_indices 返回的实现”不一致,在缺少原生实现时仍可能调用未注册槽。建议对 cat 同样检查并显式传递 implementation_index。
Collaborator
Author
There was a problem hiding this comment.
已加入implementation_index.
| out = _empty_strided(shape, strides, dtype=dtype, device=device) | ||
| out.as_strided( | ||
| (out.untyped_storage().size() // out.element_size(),), (1,) | ||
| ).normal_() |
Collaborator
There was a problem hiding this comment.
DTYPE_MAP 包含 int8/int16/int32/int64,但所有输入均调用 normal();而 PyTorch 不支持对整数张量执行正态初始化。整数 cast、二元算子会在 benchmark 前失败。建议按 dtype 使用 random_/randint,并增加整数 cast 测试。
baominghelly
force-pushed
the
feat/cambricon-op-performance-adapter
branch
from
August 7, 2026 03:31
27b89e4 to
ffb79d8
Compare
Chamberlain0w0
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Supported Operators
add,sub,mul,divcast,catgemm,matmul,mm,linearModel-specific and stateful operators such as flash attention, rotary embedding, and KV cache updates are intentionally deferred. Their optional inputs, mixed dtypes, multiple outputs, and aliasing rules need separate contracts and correctness references.
Why
The source branch implemented each operator with a separate setup method and duplicated platform mappings and JSON field strings throughout the adapter. It also assumed implementation slot
8existed whenever no native implementation was found, which can terminate the InfiniOps C++ dispatcher.The refactored adapter uses four reusable builder families and only invokes implementation indices returned by
active_implementation_indices. Missing runtime implementations become actionable per-test failures instead of process-level aborts.Input generation and result aggregation utilities are split into PR #48 so this PR remains focused on adapter integration.
Validation
Current software validation on
ffb79d8f:python -m pytest -q tests/test_infiniops_adapter.py tests/test_executor_adapter_response.py tests/test_operator_flops.py: 23 passedpython -m pytest -q --ignore=tests/test_hardware_adapter.py --ignore=tests/test_hardware_detection.py: 23 passedpython -m compileall -q infinibench tests main.py: passedgit diff --check: passedThe unfiltered test suite currently stops during collection because two tests already on
masterstill import the renamedinfinimetricspackage.Earlier Cambricon hardware smoke test (performed before the current
masterrebase):main.py -> Dispatcher -> Executor -> InfiniOpsAdapterpathadd/sub/div/mm: 12/12 passedPASSand populated latency, TFLOPS, and bandwidth metricsThe hardware result is historical smoke-test evidence, not current-head validation or a performance baseline.
Supersedes #43, which GitHub automatically closed when its head branch was renamed.