[KMCompiler] Add optimized index_copy and index_copy_ kernels for Ascend - #5507
Closed
Onisen7 wants to merge 192 commits into
Closed
[KMCompiler] Add optimized index_copy and index_copy_ kernels for Ascend#5507Onisen7 wants to merge 192 commits into
Onisen7 wants to merge 192 commits into
Conversation
Signed-off-by: Onisen7 <2084548879@qq.com>
Signed-off-by: Onisen7 <2084548879@qq.com>
Signed-off-by: Onisen7 <2084548879@qq.com>
Signed-off-by: Qiming Teng <tengqm@outlook.com>
Signed-off-by: Qiming Teng <tengqm@outlook.com>
Signed-off-by: Qiming Teng <tengqm@outlook.com>
Signed-off-by: Qiming Teng <tengqm@outlook.com>
Updated comment regarding numpy version requirements. Signed-off-by: Qiming Teng <tengqm@outlook.com>
* add sunrise's customized ops * add sunrise's change
…gos-ai#4141) * [KernelGen][Nvidia] Add float_power_ operator with Triton kernel * chore: rerun CI * Update operators.yaml Signed-off-by: Dingxingdi <784318034@qq.com> --------- Signed-off-by: Dingxingdi <784318034@qq.com> Co-authored-by: bin913 <842884726@qq.com>
…gos-ai#4341) Signed-off-by: Dongxu-H <dxhan@baai.ac.cn> Co-authored-by: Qiming Teng <tengqm@outlook.com> Co-authored-by: Dongxu-H <dxhan@baai.ac.cn> Co-authored-by: bin913 <842884726@qq.com>
…ai#4002) * [KernelGen][Nvidia] Add arccosh_ operator with Triton kernel * Fix(arccosh_):Rewrite arccosh_ with pointwise_dynamic and fix host-layer signature * Update src/flag_gems/runtime/backend/_iluvatar/ops/arccosh_.py Co-authored-by: wanghairui <wanghairui0927@gmail.com> Signed-off-by: Dongxu-H <dxhan@baai.ac.cn> * sort --------- Signed-off-by: Dongxu-H <dxhan@baai.ac.cn> Co-authored-by: kkkwb <1115095230@qq.com> Co-authored-by: Dongxu-H <dxhan@baai.ac.cn> Co-authored-by: wanghairui <wanghairui0927@gmail.com>
…with Triton kernel (flagos-ai#4003) * fix: rebase _native_batch_norm_legit_functional onto current master (clean) Clean additive rebase — only _native_batch_norm_legit_functional entries added. No upstream registration files overwritten. * fix: remove unused batch_norm_backward_kernel dead code * Fix:add missing save_var assertion in _native_batch_norm_legit_functional test * Fix isort order of _native_batch_norm_legit_functional import in iluvatar ops __init__.py * fix(_native_batch_norm_legit_functional):Correct save_var return semantics --------- Signed-off-by: Dongxu-H <dxhan@baai.ac.cn> Co-authored-by: yangy0906 <yangyang0906c@163.com> Co-authored-by: Dongxu-H <dxhan@baai.ac.cn> Co-authored-by: kkkwb <1115095230@qq.com> Co-authored-by: 103yiran <1039105206@qq.com>
Expand mthreads conv2d_forward autotune candidates for conv1d_padding. Verified with pytest perf and accuracy runs: representative fp32 speedup improved from 0.12x to 0.24x on [64,48,1024]x[128,48,5], and from 0.28x to 0.58x on [16,24,2048]x[96,12,7]. Accuracy passed with pytest -svx -m conv1d_padding --ref cpu.
Added 19 autotune configs for conv3d_forward on MTHREADS (BLOCK_NI_DO_HO_WO: 32–512, BLOCK_CO: 16–32, BLOCK_CI: 16–32, warps: 2–8, stages: 1–4). Previously only one config existed, causing Gems to be 22x–333x slower than Torch. Expanded configs enable shape-specific optimization, improving Gems speed from 0.60x to 9.14x vs Torch across all shapes and dtypes.
…os-ai#5276) Co-authored-by: shawn <chanceying@foxmail.com>
…gos-ai#5275) Co-authored-by: zhangbin <842884726@qq.com>
…os-ai#5274) Co-authored-by: zhangbin <842884726@qq.com>
…5308) - Convert tensor fill_value to scalar via .item() before kernel launch - Remove deprecated FILL_VALUE_IS_PTR parameter - Add SUBBLOCK_SIZE parameter to match updated full_kernel signature Co-authored-by: yzw1128 <yzw1128@users.noreply.github.com>
* fix: prevent run_tests.py deadlock when worker crashes Fixes worker process crashes causing job to hang at 99% indefinitely. Root cause: When a worker process crashes, it fails to send exit signal, causing display_loop to wait forever (while exited < n_workers). Additionally, stderr was redirected to /dev/null, hiding all crash info. Changes: - Redirect worker stderr to per-worker log files for debugging - Add try/finally to ensure exit signal is always sent - Add per-op exception handling to prevent single op from killing worker - Use Process.is_alive() in display_loop to detect dead workers - Pass Process list instead of count to enable liveness checks Evidence: Production deadlock on 10.0.29.1 showed GPU 5 worker died at 10:51 (after 20/920 ops), other 7 workers completed at 13:13, main process stuck in infinite loop waiting for 8th exit signal, all 8 workers became zombies. Orphan op 'convert_weight_to_int4pack' found with completed results but never written to summary5.json. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * docs: add detailed comments explaining deadlock prevention mechanisms - Explain why worker stderr goes to log files instead of /dev/null - Clarify why try/finally is critical for exit signal reliability - Document why per-op exception handling prevents worker cascade failures - Explain display_loop's is_alive() checks for hard crash detection These comments help reviewers understand the fix rationale and prevent future modifications from reintroducing the deadlock. * revert: remove worker log files to avoid subprocess file handle deadlocks Reviewer feedback: open file handles in forked worker processes can cause deadlocks. Revert to /dev/null redirection (original behavior). The core fix (try/finally for exit signals + is_alive() checks) remains intact. Defects B/C/D/E are accepted; only defect A is reverted per review. * style: apply black formatting fixes - Format multi-line dict for better readability (line 848) - Format list comprehension across multiple lines (line 851) - Add blank lines after import statements (lines 867, 883) - Use double quotes for string attribute access (line 907) Fixes CI pre-commit check failures. * style: fix black formatting issues with quotes and trailing commas * refactor: simplify worker exception handling - remove redundant outer try/except The outer try/except (lines 880-884) was redundant because: 1. It only printed traceback without any recovery logic 2. stderr is redirected to /dev/null, so traceback is invisible anyway 3. finally block already guarantees exit signal is sent Single-layer try/finally is sufficient and more readable. --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* fix * fix * pre-commit --------- Co-authored-by: jia-heng <you@example.com>
Signed-off-by: Onisen7 <2084548879@qq.com>
Signed-off-by: Onisen7 <2084548879@qq.com>
Signed-off-by: Onisen7 <2084548879@qq.com>
Signed-off-by: Onisen7 <2084548879@qq.com>
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.
PR Category
Operator
Type of Change
Performance Optimization
Description
This PR adds Ascend-specific Triton implementations of
index_copyandindex_copy_.The implementation is added in
src/flag_gems/runtime/backend/_ascend/ops/index_copy_.pyand exported fromsrc/flag_gems/runtime/backend/_ascend/ops/__init__.py.The Ascend implementation:
inner_size <= 4;recompilation;
index_copyand in-placeindex_copy_.Issue
N/A
Progress
Testing
Test environment:
Functional test command:
Result:
24 passed.The test covers both
index_copyandindex_copy_with the default dtype,shape, and dimension parameterization in
tests/test_index_copy_.py.Performance
Benchmark command:
The default benchmark ran in
kernelmode at thecomprehensivelevel.Speedup = PyTorch latency / FlagGems latency.The generic implementation completed the functional test with
24 passed,but did not complete the default Ascend benchmark. The new Ascend-specific
implementation completed all 48 benchmark rows: 2 APIs, 3 dtypes, and 8 input
configurations.
float16meanfloat32meanbfloat16meanindex_copyindex_copy_The values above are arithmetic means of the configured benchmark rows.
Performance varies by shape, so the table does not imply that every individual
configuration is faster than the native implementation. Full per-shape logs
are available if additional review is needed.