@cannbot-plugin/cannbot-harness 0.0.0-stage → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1291) hide show
  1. package/README.md +105 -3
  2. package/THIRD_PARTY_NOTICES.md +11 -0
  3. package/assets/ops-direct-invoke/.cannbot-bundle +1 -0
  4. package/assets/ops-direct-invoke/.claude-plugin/plugin.json +21 -0
  5. package/assets/ops-direct-invoke/.codex-plugin/plugin.json +30 -0
  6. package/assets/ops-direct-invoke/AGENTS.md +93 -0
  7. package/assets/ops-direct-invoke/LICENSE +38 -0
  8. package/assets/ops-direct-invoke/QUICKSTART.md +44 -0
  9. package/assets/ops-direct-invoke/README.md +219 -0
  10. package/assets/ops-direct-invoke/SKILLS_LICENSE +38 -0
  11. package/assets/ops-direct-invoke/agents/ops-direct-invoke-architect.md +39 -0
  12. package/assets/ops-direct-invoke/agents/ops-direct-invoke-developer.md +39 -0
  13. package/assets/ops-direct-invoke/agents/ops-direct-invoke-verifier.md +38 -0
  14. package/assets/ops-direct-invoke/init.sh +8 -0
  15. package/assets/ops-direct-invoke/plugin-install.json +24 -0
  16. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/SKILL.md +88 -0
  17. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/evals/evals.json +207 -0
  18. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-arithmetic.md +399 -0
  19. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-atomic.md +192 -0
  20. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-buffer.md +364 -0
  21. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-cross-gen-fixpipe.md +28 -0
  22. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-cross-gen-migration.md +91 -0
  23. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-crosscore-sync.md +259 -0
  24. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-datacopy.md +405 -0
  25. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-gathermask.md +243 -0
  26. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-gmm.md +260 -0
  27. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-hccl-host.md +187 -0
  28. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-hcomm.md +229 -0
  29. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-host-runtime.md +129 -0
  30. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-loaddata.md +196 -0
  31. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-matmul.md +364 -0
  32. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-mrgsort.md +636 -0
  33. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-pipeline.md +206 -0
  34. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-precision.md +146 -0
  35. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-quickref.md +192 -0
  36. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-reduce-pattern.md +132 -0
  37. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-reduce.md +282 -0
  38. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-repeat-limits.md +144 -0
  39. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-restrictions.md +200 -0
  40. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-transpose.md +234 -0
  41. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/SKILL.md +245 -0
  42. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/block/block_mmad_glu.h +238 -0
  43. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/block/block_scheduler_group_matmul.h +106 -0
  44. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/block/weight_quant_matmul_block_mmad.h +362 -0
  45. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/block_epilogue_dequant_swiglu.h +265 -0
  46. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/block_epilogue_pertoken_quant_single_pass.h +252 -0
  47. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/block_epilogue_pertoken_quant_two_pass_chunked.h +313 -0
  48. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/block_epilogue_swiglu.h +171 -0
  49. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/cv_sync_constants.h +32 -0
  50. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/epilogue_fusion_membase.h +212 -0
  51. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/epilogue_fusion_regbase.h +324 -0
  52. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/online_softmax_cross_core_epilogue.h +396 -0
  53. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/online_softmax_per_tile_epilogue.h +421 -0
  54. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/kernel/group_matmul_kernel_cv1_v2.h +150 -0
  55. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/kernel/group_matmul_kernel_glu_fused.h +345 -0
  56. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/kernel/weight_quant_matmul_kernel.h +611 -0
  57. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/policy/dispatch_policy.h +63 -0
  58. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/utils/common_utils.h +101 -0
  59. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/utils/integral_constant.h +38 -0
  60. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/matmul/blaze_group_matmul_pertoken_quant_selector.h +119 -0
  61. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/matmul/blaze_group_matmul_tiling_data.h +38 -0
  62. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/matmul/blaze_matmul_tiling.h +457 -0
  63. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/matmul/blaze_matmul_tiling_data.h +50 -0
  64. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/mx/quant_matmul_mx_tiling.h +549 -0
  65. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/mx/quant_matmul_mx_tiling_data.h +47 -0
  66. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/weight_quant/weight_quant_tiling.h +428 -0
  67. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/weight_quant/weight_quant_tiling_data.h +59 -0
  68. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/evals/evals.json +234 -0
  69. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/blaze-investigation/assembly-recovery-method.md +106 -0
  70. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/blaze-investigation/dependency-trace-method.md +140 -0
  71. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/blaze-investigation/design-contract-method.md +78 -0
  72. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/blaze-investigation/investigation-report-template.md +249 -0
  73. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/blaze-investigation/source-investigation-method.md +131 -0
  74. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/fundamentals/blaze-cmake-build-guide.md +184 -0
  75. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/fundamentals/blaze-framework-overview.md +403 -0
  76. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/fundamentals/blaze-matmul-layout.md +322 -0
  77. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/fundamentals/blaze-sync-patterns.md +814 -0
  78. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/fundamentals/tensor-api-reference.md +589 -0
  79. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/blaze-design-template.md +593 -0
  80. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/blaze-plan-template.md +391 -0
  81. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/glu-development.md +755 -0
  82. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/glu-precision-diagnosis.md +113 -0
  83. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/group-matmul-delta.md +299 -0
  84. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/per-token-quant-development.md +450 -0
  85. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/tiling-selection.md +114 -0
  86. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/launcher/launcher-development.md +346 -0
  87. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-elementwise-then-vector-pertoken-quant/cube-matmul-then-vector-elementwise-then-vector-pertoken-quant-design.md +196 -0
  88. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-elementwise-then-vector-pertoken-quant/cube-matmul-then-vector-elementwise-then-vector-pertoken-quant-development.md +104 -0
  89. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-glu/cube-matmul-then-vector-glu-design.md +150 -0
  90. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-glu/cube-matmul-then-vector-glu-development.md +54 -0
  91. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-glu-then-vector-pertoken-quant/cube-matmul-then-vector-glu-then-vector-pertoken-quant-design.md +189 -0
  92. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-glu-then-vector-pertoken-quant/cube-matmul-then-vector-glu-then-vector-pertoken-quant-development.md +52 -0
  93. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-pertoken-quant/cube-matmul-then-vector-pertoken-quant-design.md +138 -0
  94. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-pertoken-quant/cube-matmul-then-vector-pertoken-quant-development.md +45 -0
  95. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-softmax-reduce/cube-matmul-then-vector-softmax-reduce-design.md +205 -0
  96. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-softmax-reduce/cube-matmul-then-vector-softmax-reduce-development.md +99 -0
  97. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-softmax-reduce/cv-sync-and-two-phase-entry.md +156 -0
  98. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-softmax-reduce/cv1-v2-adaptation-for-softmax-reduce.md +331 -0
  99. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-softmax-reduce/online-softmax-reduce-epilogue-design.md +174 -0
  100. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-softmax-reduce/reduce-adaptation-guide.md +204 -0
  101. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/block-l0c2ub-extension.md +75 -0
  102. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/elementwise-broadcast-epilogue-fusion-design.md +280 -0
  103. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/elementwise-broadcast-epilogue-fusion-development.md +202 -0
  104. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/epilogue-membase-design.md +82 -0
  105. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/epilogue-regbase-design.md +95 -0
  106. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/fused-kernel-development.md +71 -0
  107. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/precision-diagnosis.md +86 -0
  108. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/splitm-contract-and-debugging.md +86 -0
  109. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/index.md +14 -0
  110. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/scenario-extension-guide.md +84 -0
  111. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/layout-variant-boundary.md +76 -0
  112. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/pitfalls-and-diagnosis.md +124 -0
  113. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/prologue-ub-layout-design.md +135 -0
  114. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/prologue-vf-dequant-design.md +213 -0
  115. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/vc-sync-and-l1-layout-design.md +103 -0
  116. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/weight-dequant-prologue-fusion-design.md +289 -0
  117. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/weight-dequant-prologue-fusion-development.md +232 -0
  118. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/weight-quant-tiling-contract.md +83 -0
  119. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/troubleshooting/compile-troubleshooting.md +231 -0
  120. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/troubleshooting/optimized-runtime-hang.md +102 -0
  121. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/workflow/step1-project-setup.md +170 -0
  122. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/workflow/step2-blaze-investigation.md +192 -0
  123. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/workflow/step3-kernel-design.md +246 -0
  124. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/workflow/step4-operator-development.md +166 -0
  125. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/SKILL.md +67 -0
  126. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/evals/evals.json +123 -0
  127. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/references/crash_workflow.md +193 -0
  128. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/references/memcheck/README.md +137 -0
  129. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/references/memcheck/automated_workflow.md +418 -0
  130. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/references/memcheck/mssanitizer_guide.md +181 -0
  131. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/scripts/memcheck_input.json.template +44 -0
  132. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/scripts/parse_plog.py +191 -0
  133. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/scripts/run_memcheck_pre.sh +696 -0
  134. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/SKILL.md +105 -0
  135. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/evals/evals.json +128 -0
  136. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/CMakeLists.txt +131 -0
  137. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/README.md +55 -0
  138. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_extension/add_custom_torch.cpp +82 -0
  139. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_extension/ops.h +23 -0
  140. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_extension/register.cpp +42 -0
  141. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_host/add_custom.asc +149 -0
  142. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_host/data_utils.h +98 -0
  143. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_kernel/add_custom_kernel.asc +136 -0
  144. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_kernel/add_custom_tiling.h +31 -0
  145. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/run.sh +86 -0
  146. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/scripts/gen_data.py +49 -0
  147. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/scripts/golden.py +36 -0
  148. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/scripts/test_torch.py +90 -0
  149. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/scripts/verify_result.py +54 -0
  150. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kernel_launch_details.md +116 -0
  151. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/CMakeLists.txt +19 -0
  152. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/README.md +214 -0
  153. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/UPSTREAM.md +35 -0
  154. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/add_custom.cpp +99 -0
  155. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/add_custom_tiling.h +25 -0
  156. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/cmake/Modules/CMakeCCECompiler.cmake.in +15 -0
  157. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/cmake/Modules/CMakeCCEInformation.cmake +51 -0
  158. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/cmake/Modules/CMakeDetermineCCECompiler.cmake +119 -0
  159. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/cmake/Modules/CMakeTestCCECompiler.cmake +11 -0
  160. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/cmake/npu/CMakeLists.txt +36 -0
  161. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/data_utils.h +132 -0
  162. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/ext_lib/.gitattributes +1 -0
  163. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/input/.keep +0 -0
  164. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/main.cpp +108 -0
  165. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/output/.keep +0 -0
  166. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/run.sh +141 -0
  167. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/scripts/acl.json +1 -0
  168. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/scripts/gen_data.py +26 -0
  169. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/scripts/verify_result.py +54 -0
  170. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_vector_guide.md +172 -0
  171. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_guide.md +348 -0
  172. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/CMakeLists.txt +157 -0
  173. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/common/acl_utils.h +70 -0
  174. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/common/common_utils.h +84 -0
  175. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/common/io_utils.h +163 -0
  176. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_extension/matmul_blaze_torch.cpp +55 -0
  177. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_extension/ops.h +22 -0
  178. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_extension/register.cpp +22 -0
  179. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_kernel/include/blaze_custom/.gitkeep +0 -0
  180. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_kernel/matmul_blaze_kernel.cpp +33 -0
  181. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_kernel/matmul_blaze_kernel.h +99 -0
  182. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_tiling/matmul_constant.h +31 -0
  183. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_tiling/matmul_tiling_data.h +45 -0
  184. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_tiling/matmul_tiling_stub.h +77 -0
  185. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/run.sh +94 -0
  186. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/scripts/gen_data_mxfp4.py +152 -0
  187. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/scripts/gen_data_mxfp8.py +114 -0
  188. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/scripts/verify_result.py +132 -0
  189. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/test_matmul_blaze.cpp +145 -0
  190. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/test_matmul_blaze_torch.py +141 -0
  191. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/SKILL.md +56 -0
  192. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/evals/evals.json +191 -0
  193. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/references/aclnn-api-doc-template.md +368 -0
  194. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/references/detailed-design-template.md +388 -0
  195. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/references/iteration-plan-template.md +45 -0
  196. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/references/operator-readme-template.md +234 -0
  197. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/references/operator-readme-template_bak.md +165 -0
  198. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/references/requirement-analysis-template.md +131 -0
  199. package/assets/ops-direct-invoke/skills/ascendc-docs-search/SKILL.md +163 -0
  200. package/assets/ops-direct-invoke/skills/ascendc-docs-search/evals/evals.json +197 -0
  201. package/assets/ops-direct-invoke/skills/ascendc-docs-search/references/api-index.md +207 -0
  202. package/assets/ops-direct-invoke/skills/ascendc-docs-search/references/compatibility.md +141 -0
  203. package/assets/ops-direct-invoke/skills/ascendc-docs-search/references/example-catalog.md +197 -0
  204. package/assets/ops-direct-invoke/skills/ascendc-docs-search/requirements.txt +2 -0
  205. package/assets/ops-direct-invoke/skills/ascendc-docs-search/scripts/__init__.py +6 -0
  206. package/assets/ops-direct-invoke/skills/ascendc-docs-search/scripts/ascend_content_fetcher.py +479 -0
  207. package/assets/ops-direct-invoke/skills/ascendc-docs-search/scripts/ascend_search_client.py +201 -0
  208. package/assets/ops-direct-invoke/skills/ascendc-docs-search/scripts/ascend_search_skill.py +163 -0
  209. package/assets/ops-direct-invoke/skills/ascendc-docs-search/scripts/clean_markdown.py +489 -0
  210. package/assets/ops-direct-invoke/skills/ascendc-docs-search/scripts/find_api_doc.sh +54 -0
  211. package/assets/ops-direct-invoke/skills/ascendc-env-check/SKILL.md +123 -0
  212. package/assets/ops-direct-invoke/skills/ascendc-env-check/evals/evals.json +211 -0
  213. package/assets/ops-direct-invoke/skills/ascendc-env-check/references/asys_commands.md +64 -0
  214. package/assets/ops-direct-invoke/skills/ascendc-env-check/references/env_config_guide.md +96 -0
  215. package/assets/ops-direct-invoke/skills/ascendc-env-check/references/kirin_platform_guide.md +11 -0
  216. package/assets/ops-direct-invoke/skills/ascendc-env-check/references/npu_commands.md +114 -0
  217. package/assets/ops-direct-invoke/skills/ascendc-env-check/references/troubleshooting.md +177 -0
  218. package/assets/ops-direct-invoke/skills/ascendc-env-check/scripts/_npu_info.py +763 -0
  219. package/assets/ops-direct-invoke/skills/ascendc-env-check/scripts/check_env.sh +320 -0
  220. package/assets/ops-direct-invoke/skills/ascendc-env-check/scripts/get_npu_arch.py +488 -0
  221. package/assets/ops-direct-invoke/skills/ascendc-env-check/scripts/npu_info.sh +228 -0
  222. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/SKILL.md +370 -0
  223. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/docs/CONTEXT.md +85 -0
  224. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/docs/MC2-CAPABILITY-PLAN.md +111 -0
  225. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/docs/adr/0001-mc2-skill-not-plugin.md +31 -0
  226. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/docs/adr/0002-decision-stack-path-registry.md +33 -0
  227. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/evals/evals.json +315 -0
  228. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/capability-declaration.md +97 -0
  229. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/codebase-analysis.md +34 -0
  230. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/fundamentals/architecture.md +444 -0
  231. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/fundamentals/communication.md +669 -0
  232. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/fundamentals/compute.md +587 -0
  233. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/fundamentals/fusion.md +550 -0
  234. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/design-template.md +313 -0
  235. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/dev-methodology.md +111 -0
  236. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/development-guide.md +445 -0
  237. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/host-and-testing.md +285 -0
  238. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/operator-anatomy.md +739 -0
  239. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/paradigm-mapping.md +93 -0
  240. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/plan-template.md +235 -0
  241. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/review-checklist.md +96 -0
  242. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/compute-first-reduce-scatter/design.md +107 -0
  243. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/compute-first-reduce-scatter/development.md +272 -0
  244. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/get-all-gather-quant-matmul/design.md +93 -0
  245. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/get-all-gather-quant-matmul/development.md +70 -0
  246. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/index.md +47 -0
  247. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/put-all-gather-quant-matmul/design.md +83 -0
  248. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/put-all-gather-quant-matmul/development.md +62 -0
  249. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/put-all-to-all-quant-matmul/design.md +106 -0
  250. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/put-all-to-all-quant-matmul/development.md +74 -0
  251. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/troubleshooting/failure-navigation.md +47 -0
  252. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/troubleshooting/optimization-playbook.md +143 -0
  253. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/workflow/step1-project-setup.md +52 -0
  254. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/workflow/step2-investigation.md +89 -0
  255. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/workflow/step3-design.md +69 -0
  256. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/workflow/step4-implementation.md +29 -0
  257. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/workflow_integration.md +122 -0
  258. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/api-rules/dispatch-combine-contracts.md +60 -0
  259. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/api-rules/index.md +71 -0
  260. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/api-rules/mte-address-access.md +374 -0
  261. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/api-rules/sync-and-visibility.md +105 -0
  262. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/reading/combine-reading-guide.md +102 -0
  263. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/reading/common-reading-method.md +226 -0
  264. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/reading/design-overview.md +558 -0
  265. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/reading/dispatch-reading-guide.md +81 -0
  266. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/reading/kernel-execution-units.md +189 -0
  267. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/reading/mega-moe-reading-guide.md +123 -0
  268. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/build-framework.md +177 -0
  269. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/change-routing.md +18 -0
  270. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/combine-dataflow.md +144 -0
  271. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/dispatch-dataflow.md +128 -0
  272. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/index.md +98 -0
  273. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/CMakeLists.txt +51 -0
  274. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/README.md +131 -0
  275. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/build.sh +56 -0
  276. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/include/moe_dispatch_base_compat.h +113 -0
  277. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/include/tiling_data.h +100 -0
  278. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/include/utils.h +57 -0
  279. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/kernel/moe_dispatch.h +524 -0
  280. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/kernel/mte_dispatch_comm.h +324 -0
  281. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/moe_dispatch.cpp +67 -0
  282. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/run.sh +61 -0
  283. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/run_multi_data_test.sh +80 -0
  284. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/scripts/verify_dispatch.py +248 -0
  285. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/test/test_moe_dispatch.cpp +679 -0
  286. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/sample-helper-map.md +47 -0
  287. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/spec-template.md +78 -0
  288. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/tiling-scheme/double-buffer-protocol.md +69 -0
  289. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/tiling-scheme/index.md +111 -0
  290. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/tiling-scheme/multi-core-formulas.md +126 -0
  291. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/tiling-scheme/split-core-design.md +100 -0
  292. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/tiling-scheme/window-memory-layout.md +199 -0
  293. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/CMakeLists.txt +95 -0
  294. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/cmake/ascend.cmake +59 -0
  295. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/cmake/shmem.cmake +75 -0
  296. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/cmake/tensor_api.cmake +48 -0
  297. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/common/host_utils/acl_utils.h +73 -0
  298. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/common/host_utils/common_utils.h +181 -0
  299. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/common/host_utils/io_utils.h +175 -0
  300. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/common/kernel_utils/common_utils.h +99 -0
  301. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/common/kernel_utils/integral_constant.h +36 -0
  302. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/common/kernel_utils/tuple_utils.h +34 -0
  303. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/block/block_mmad.h +27 -0
  304. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/block/block_scheduler_policy.h +35 -0
  305. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/block/block_scheduler_utils.h +27 -0
  306. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/block/quant_matmul_mx_block_mmad_swat.h +392 -0
  307. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/block/quant_matmul_mx_block_scheduler_swat.h +290 -0
  308. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/kernel/all_to_all_comm_udma.h +255 -0
  309. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/kernel/all_to_all_matmul_impl.h +370 -0
  310. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/kernel/heavy_kernels.h +128 -0
  311. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/kernel/qbmm_mx_kernel.h +395 -0
  312. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/policy/dispatch_policy.h +47 -0
  313. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tile/copy_scale_l1_to_l0a.h +61 -0
  314. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tile/copy_scale_l1_to_l0b.h +54 -0
  315. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tile/pad_mx_kl1.h +138 -0
  316. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tile/tile_mmad_mx.h +34 -0
  317. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tiling/all_to_all_matmul_tiling_data.h +29 -0
  318. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tiling/quant_matmul_mx_tiling_swat.h +410 -0
  319. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tiling/quant_matmul_tiling_base.h +116 -0
  320. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tiling/quant_matmul_tiling_common.h +101 -0
  321. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tiling/quant_matmul_tiling_data.h +61 -0
  322. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/utils/constant.h +106 -0
  323. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/run.sh +65 -0
  324. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/scripts/extract_perf.py +57 -0
  325. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/scripts/gen_data.py +139 -0
  326. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/scripts/verify_result.py +152 -0
  327. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/src/all_to_all_matmul.cpp +396 -0
  328. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/src/utils.h +168 -0
  329. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/codebase_map.md +342 -0
  330. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/comm_shmem.md +280 -0
  331. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/matmul_blaze.md +259 -0
  332. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/mc2_architecture.md +199 -0
  333. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/review-checklist.md +29 -0
  334. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/workflow_integration.md +215 -0
  335. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/CMakeLists.txt +559 -0
  336. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/build.sh +319 -0
  337. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/config.cmake +232 -0
  338. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/func.cmake +478 -0
  339. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/intf.cmake +4 -0
  340. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/intf_pub.cmake +67 -0
  341. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/modules/Findalog.cmake +105 -0
  342. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/scripts/check_version_compatible.py +94 -0
  343. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/scripts/prepare.sh +129 -0
  344. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/golden.py +27 -0
  345. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/run_test.sh +33 -0
  346. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/single_server_check_result.py +71 -0
  347. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/single_server_config.ini +17 -0
  348. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/single_server_gen_data.py +91 -0
  349. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/single_server_run.py +116 -0
  350. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/test_golden_cpu.py +63 -0
  351. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/CMakeLists.txt +202 -0
  352. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/mc2_common_infershape.cpp +163 -0
  353. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/mc2_common_infershape.h +49 -0
  354. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/formulaic_tiling_datatype.h +161 -0
  355. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/hccl_formulaic_tiling.cpp +373 -0
  356. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/hccl_formulaic_tiling.h +150 -0
  357. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/hccl_performance.cpp +206 -0
  358. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/hccl_performance.h +118 -0
  359. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/hcom_topo_info.h +81 -0
  360. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/matmul_formulaic_tiling.cpp +338 -0
  361. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/matmul_formulaic_tiling.h +340 -0
  362. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/matmul_performance.cpp +272 -0
  363. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/matmul_performance.h +152 -0
  364. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/mc2_tiling_struct.h +46 -0
  365. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/mc2_tiling_utils.cpp +296 -0
  366. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/mc2_tiling_utils.h +269 -0
  367. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_kernel/mc2_matmul_block.h +235 -0
  368. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_kernel/mc2_matmul_block_l2cache.h +165 -0
  369. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_kernel/mc2_matmul_compute.h +218 -0
  370. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_kernel/mc2_nd_to_nz.h +579 -0
  371. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_kernel/mc2_tiling_struct.h +164 -0
  372. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/utils/mc2_hcom_topo_info.cpp +390 -0
  373. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/utils/mc2_hcom_topo_info.h +81 -0
  374. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/utils/ops_utils.h +77 -0
  375. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_api/aclnn_x_all_gather_matmul.cpp +65 -0
  376. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_api/aclnn_x_all_gather_matmul.h +57 -0
  377. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/arch22/x_all_gather_formulaic_tiling_a2a3.cpp +50 -0
  378. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/arch22/x_all_gather_formulaic_tiling_a2a3.h +47 -0
  379. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/arch22/x_all_gather_matmul_tiling_a2a3.cpp +72 -0
  380. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/arch22/x_all_gather_matmul_tiling_a2a3.h +31 -0
  381. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/x_all_gather_formulaic_tiling.cpp +82 -0
  382. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/x_all_gather_formulaic_tiling.h +55 -0
  383. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/x_all_gather_matmul_tiling_base.cpp +508 -0
  384. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/x_all_gather_matmul_tiling_base.h +54 -0
  385. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/x_all_gather_matmul_def.cpp +79 -0
  386. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/x_all_gather_matmul_proto.cpp +39 -0
  387. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_kernel/x_all_gather_matmul.cpp +96 -0
  388. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_kernel/x_all_gather_matmul_base.h +152 -0
  389. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_kernel/x_all_gather_matmul_full_mesh.h +230 -0
  390. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_kernel/x_all_gather_matmul_tiling.h +45 -0
  391. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_kernel/x_all_gather_matmul_tiling_key.h +47 -0
  392. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/codebase_map.md +281 -0
  393. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/comm_hccl.md +201 -0
  394. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/matmul_fusion.md +50 -0
  395. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/mc2_architecture.md +142 -0
  396. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/op_architecture.md +167 -0
  397. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/pipeline_tuning.md +47 -0
  398. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/review-checklist.md +39 -0
  399. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/workflow_integration.md +152 -0
  400. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/operators/collective-comm.md +145 -0
  401. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/requirement-analysis/classification.md +27 -0
  402. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/requirement-analysis/comm-path-decision.md +51 -0
  403. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/requirement-analysis/grill-protocol.md +202 -0
  404. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/requirement-analysis/quality-checklist.md +57 -0
  405. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/requirement-analysis/template.md +208 -0
  406. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/shared/pipeline_tuning.md +232 -0
  407. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/shared/profiling_mc2.md +278 -0
  408. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/scripts/fetch_apace.sh +96 -0
  409. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/SKILL.md +121 -0
  410. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/evals/evals.json +138 -0
  411. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/advanced_tiling.md +92 -0
  412. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/broadcast_design.md +160 -0
  413. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/code/broadcast_add_kernel.cpp +118 -0
  414. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/code/broadcast_add_tiling.cpp +126 -0
  415. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/code/broadcast_common.h +344 -0
  416. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/code/onedim_add_kernel.cpp +97 -0
  417. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/code/onedim_add_tiling.cpp +57 -0
  418. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/datacopypad_design.md +46 -0
  419. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/nddma_design.md +53 -0
  420. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/onedim_design.md +114 -0
  421. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/ub_broadcast_design.md +67 -0
  422. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/common/core_shrink_design.md +126 -0
  423. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/common/datacopy_optimization_design.md +351 -0
  424. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/common/tail_block_design.md +268 -0
  425. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/common/ub_resident_design.md +342 -0
  426. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/guide.md +69 -0
  427. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_base.template +81 -0
  428. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_big_dim.template +217 -0
  429. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_cut_one_axis.template +336 -0
  430. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_cut_two_axis.template +781 -0
  431. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_n_last.template +340 -0
  432. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_small_shape.template +321 -0
  433. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_tensor_move.template +102 -0
  434. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_transdata_5hd.template +480 -0
  435. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_transdata_5hd_021axis.template +533 -0
  436. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_with_gather.template +688 -0
  437. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/transpose_tiling_data.template +192 -0
  438. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_big_dim.md +220 -0
  439. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_cut_one_axis.md +175 -0
  440. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_cut_two_axis.md +177 -0
  441. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_fusion_design.md +398 -0
  442. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_gather.md +191 -0
  443. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_n_last.md +276 -0
  444. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_small_shape.md +315 -0
  445. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_tensor_move.md +203 -0
  446. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_tiling_data.md +176 -0
  447. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_vconv_021.md +206 -0
  448. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_vconv_5hd.md +179 -0
  449. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/elementwise/double_buffer_design.md +288 -0
  450. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/elementwise/vector_efficiency_design.md +203 -0
  451. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/constant_folding_design.md +466 -0
  452. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/fullload_design.md +344 -0
  453. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/guide.md +16 -0
  454. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/mte2_preload_design.md +320 -0
  455. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/pingpong_design.md +254 -0
  456. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/scale_coalescing_design.md +282 -0
  457. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/small_m_wide_n_pipeline_design.md +137 -0
  458. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/streamk_design.md +374 -0
  459. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/swat_design.md +423 -0
  460. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/mc2/guide.md +45 -0
  461. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/mc2/local_matmul_design.md +130 -0
  462. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/mc2/pipeline_balancing_design.md +502 -0
  463. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/guide.md +178 -0
  464. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/kernel_utils.template +75 -0
  465. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_ar_full_load.template +429 -0
  466. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_ar_recompute.template +485 -0
  467. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_ar_small_r.template +348 -0
  468. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_ara_full_load.template +574 -0
  469. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_ara_online.template +324 -0
  470. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_ara_recompute.template +436 -0
  471. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_base.template +950 -0
  472. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/fused_attention_online_softmax_design.md +428 -0
  473. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_ar_full_load.md +137 -0
  474. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_ar_recompute.md +135 -0
  475. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_ar_small_r.md +122 -0
  476. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_ara_full_load.md +144 -0
  477. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_ara_online.md +185 -0
  478. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_ara_recompute.md +163 -0
  479. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_tiling.template +460 -0
  480. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_tiling_data.template +278 -0
  481. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/state_resident_design.md +337 -0
  482. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/usage_guide.md +253 -0
  483. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/scalar/coding_principles.md +476 -0
  484. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/scalar/conv_scalar.md +165 -0
  485. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/scalar/guide.md +31 -0
  486. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/simt/optimization-guide.md +110 -0
  487. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/sort/radix_sort.md +354 -0
  488. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/SKILL.md +361 -0
  489. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/evals/evals.json +161 -0
  490. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/ascendc-dumptensor-refs/api-reference.md +92 -0
  491. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/ascendc-dumptensor-refs/error-patterns.md +40 -0
  492. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/ascendc-dumptensor.md +205 -0
  493. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/best-practices.md +317 -0
  494. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/binary-search-debug.md +275 -0
  495. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/case-studies.md +459 -0
  496. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/common-traps.md +492 -0
  497. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/data-comparison.md +308 -0
  498. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/debug-summary-template.md +198 -0
  499. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/diagnosis-workflow.md +180 -0
  500. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/printf-debug.md +296 -0
  501. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/simt-precision-debug.md +76 -0
  502. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/tools-reference.md +364 -0
  503. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/scripts/error_analysis.py +148 -0
  504. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/scripts/gen_boundary_test.py +169 -0
  505. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/SKILL.md +47 -0
  506. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/evals/evals.json +115 -0
  507. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/arithmetic_and_reduce.md +228 -0
  508. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/compute_api_membase_vs_regbase.md +107 -0
  509. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/datacopy_best_practices.md +139 -0
  510. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/index.md +38 -0
  511. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/pipeline_and_buffer.md +105 -0
  512. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/regbase_api_reference.md +303 -0
  513. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/regbase_api_sync.md +173 -0
  514. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/regbase_api_whitelist.md +142 -0
  515. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/dev-experience/index.md +24 -0
  516. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/dev-experience/regbase_build_notes.md +49 -0
  517. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/dev-experience/regbase_performance_practices.md +52 -0
  518. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/dev-experience/regbase_programming_notes.md +120 -0
  519. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/dev-experience/tiling_review_notes.md +86 -0
  520. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/dev-experience/working_vs_failed_dav_3510_cases.md +49 -0
  521. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/README.md +190 -0
  522. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_host/adam_apply_one_assign_def.cpp +102 -0
  523. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_host/arch35/adam_apply_one_assign_tiling_arch35.cpp +597 -0
  524. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_host/arch35/adam_apply_one_assign_tiling_arch35.h +82 -0
  525. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_kernel/adam_apply_one_assign.cpp +44 -0
  526. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_kernel/arch35/adam_apply_one_assign_kernel.h +361 -0
  527. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_kernel/arch35/adam_apply_one_assign_struct.h +27 -0
  528. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_kernel/arch35/adam_apply_one_assign_tiling_struct.h +53 -0
  529. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-design/adam_apply_one_assign_analysis.md +143 -0
  530. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-design/adam_apply_one_assign_design.md +2865 -0
  531. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/CMakeLists.txt +328 -0
  532. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/README.md +163 -0
  533. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_graph/xdivy_graph_infer.cpp +38 -0
  534. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_graph/xdivy_proto.h +42 -0
  535. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_host/arch35/xdivy_tiling_arch35.cpp +601 -0
  536. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_host/arch35/xdivy_tiling_arch35.h +89 -0
  537. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_host/xdivy_def.cpp +60 -0
  538. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_host/xdivy_infershape.cpp +58 -0
  539. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_kernel/arch35/xdivy_kernel.h +331 -0
  540. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_kernel/arch35/xdivy_struct.h +28 -0
  541. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_kernel/arch35/xdivy_tiling_struct.h +57 -0
  542. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_kernel/xdivy.cpp +42 -0
  543. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/aclnn/CMakeLists.txt +67 -0
  544. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/aclnn/run.sh +56 -0
  545. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/aclnn/test_aclnn.cpp +354 -0
  546. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/geir/CMakeLists.txt +69 -0
  547. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/geir/run.sh +58 -0
  548. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/geir/test_geir.cpp +407 -0
  549. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/tiling/CMakeLists.txt +185 -0
  550. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/tiling/run.sh +61 -0
  551. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/tiling/test_tiling.cpp +386 -0
  552. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/patterns.md +324 -0
  553. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-kernel-entrance.md +95 -0
  554. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-overview.md +252 -0
  555. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-standard/broadcast-standard-compute-flow.md +214 -0
  556. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-standard/broadcast-standard-dag-buffers.md +285 -0
  557. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-standard/broadcast-standard-kernel-helpers.md +209 -0
  558. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-standard/broadcast-standard-kernel-template.md +611 -0
  559. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-standard/broadcast-standard-tiling-preprocess.md +545 -0
  560. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-standard/broadcast-standard-tiling.md +471 -0
  561. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/broadcast-rules.md +126 -0
  562. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/cast-rules.md +414 -0
  563. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/datacopypad-rules.md +185 -0
  564. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/nddma-rules.md +255 -0
  565. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/sync-and-consistency.md +314 -0
  566. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/value-depend-process.md +40 -0
  567. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/vf-programming-rules.md +150 -0
  568. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/dynamic_shape/knowledge.md +382 -0
  569. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/dynamic_shape/patterns.md +260 -0
  570. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/elewise/patterns.md +46 -0
  571. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/elewise/tiling.md +215 -0
  572. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/example-routes.yaml +17 -0
  573. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/general-methodology.md +94 -0
  574. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/mask_predicate/patterns.md +99 -0
  575. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/numerical_stable/knowledge.md +233 -0
  576. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/numerical_stable/patterns.md +390 -0
  577. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/CMakeLists.txt +289 -0
  578. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/README.md +148 -0
  579. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_graph/euclidean_norm_graph_infer.cpp +39 -0
  580. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_graph/euclidean_norm_proto.h +54 -0
  581. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_host/arch35/euclidean_norm_tiling_arch35.cpp +1040 -0
  582. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_host/arch35/euclidean_norm_tiling_arch35.h +28 -0
  583. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_host/euclidean_norm_def.cpp +86 -0
  584. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_host/euclidean_norm_infershape.cpp +205 -0
  585. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm.cpp +46 -0
  586. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_base.h +965 -0
  587. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_empty.h +153 -0
  588. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_group.h +396 -0
  589. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_tiling_data.h +74 -0
  590. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_tiling_key.h +32 -0
  591. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/aclnn/CMakeLists.txt +59 -0
  592. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/aclnn/run.sh +36 -0
  593. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/aclnn/test_aclnn.cpp +227 -0
  594. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/geir/CMakeLists.txt +84 -0
  595. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/geir/run.sh +48 -0
  596. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/geir/test_geir.cpp +297 -0
  597. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/tiling/CMakeLists.txt +143 -0
  598. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/tiling/run.sh +40 -0
  599. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/tiling/test_tiling.cpp +318 -0
  600. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/patterns.md +527 -0
  601. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-binary-sum.md +260 -0
  602. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-highlevel-api.md +146 -0
  603. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-kernel-entrance.md +96 -0
  604. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-survival-node.md +74 -0
  605. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-binary-base/reduction-binary-base-dag-buffers.md +612 -0
  606. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-binary-base/reduction-binary-base-kernel-template.md +1261 -0
  607. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-binary-base/reduction-binary-base-tiling.md +531 -0
  608. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-binary-group/reduction-binary-group-dag-buffers.md +209 -0
  609. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-binary-group/reduction-binary-group-kernel-template.md +588 -0
  610. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-binary-group/reduction-binary-group-tiling.md +203 -0
  611. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-empty/reduction-empty-dag-buffers.md +292 -0
  612. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-empty/reduction-empty-kernel-template.md +360 -0
  613. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-empty/reduction-empty-tiling.md +234 -0
  614. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-overview.md +238 -0
  615. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-tiling-preprocess.md +218 -0
  616. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-tuple-reduce.md +72 -0
  617. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-vf-fusion-rules.md +95 -0
  618. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/validate_gates.py +194 -0
  619. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/resolve_example.py +106 -0
  620. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/routes.yaml +39 -0
  621. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/stateful/patterns.md +146 -0
  622. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/variable_output/knowledge.md +366 -0
  623. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/variable_output/patterns.md +203 -0
  624. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/api_misuse.md +50 -0
  625. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/common_traps.md +67 -0
  626. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/index.md +25 -0
  627. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/precision_failures.md +51 -0
  628. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/precision_guide.md +85 -0
  629. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/regbase_vs_membase_confusions.md +52 -0
  630. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/symptom_to_cause.md +38 -0
  631. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/reference-ops/open_source_operator_table.md +740 -0
  632. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/regbase_development_guide.md +334 -0
  633. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/SKILL.md +107 -0
  634. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/evals/evals.json +44 -0
  635. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/compute-operators.md +34 -0
  636. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/data-transfer.md +51 -0
  637. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/debug-api.md +530 -0
  638. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/index-calculation.md +49 -0
  639. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/intra-core-shared.md +70 -0
  640. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/macro-api.md +65 -0
  641. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/multi-core-sync.md +39 -0
  642. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/overview.md +128 -0
  643. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/tensorlist-handling.md +92 -0
  644. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/thread-stride-pattern.md +49 -0
  645. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/vf-call.md +51 -0
  646. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/vf-declaration.md +39 -0
  647. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references//347/274/226/350/257/221/344/270/216/350/277/220/350/241/214.md +158 -0
  648. package/assets/ops-direct-invoke/skills/ascendc-simt-tiling-design/SKILL.md +42 -0
  649. package/assets/ops-direct-invoke/skills/ascendc-simt-tiling-design/evals/evals.json +44 -0
  650. package/assets/ops-direct-invoke/skills/ascendc-simt-tiling-design/references/guide.md +73 -0
  651. package/assets/ops-direct-invoke/skills/ascendc-st-design/SKILL.md +316 -0
  652. package/assets/ops-direct-invoke/skills/ascendc-st-design/evals/evals.json +44 -0
  653. package/assets/ops-direct-invoke/skills/ascendc-st-design/references/constraint-examples.md +392 -0
  654. package/assets/ops-direct-invoke/skills/ascendc-st-design/references/dependency-yaml-spec.md +625 -0
  655. package/assets/ops-direct-invoke/skills/ascendc-st-design/references/empty-tensor-guide.md +236 -0
  656. package/assets/ops-direct-invoke/skills/ascendc-st-design/references/parameter-definition.md +491 -0
  657. package/assets/ops-direct-invoke/skills/ascendc-st-design/references/standards.md +11 -0
  658. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/generate_empty_tensor_cases_derive.py +815 -0
  659. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/generate_factor_values.py +1287 -0
  660. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/generate_implicit_constraints.py +511 -0
  661. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/generate_solver_config.py +618 -0
  662. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/generate_test_cases.py +2800 -0
  663. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/generate_test_factors.py +762 -0
  664. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/utils.py +1931 -0
  665. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/SKILL.md +91 -0
  666. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/evals/evals.json +72 -0
  667. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/broadcast/dynamic-ub-broadcast.md +87 -0
  668. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/broadcast/nddma-broadcast.md +199 -0
  669. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/broadcast/onedim.md +152 -0
  670. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/broadcast/patterns.md +165 -0
  671. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/broadcast/ub-broadcast.md +331 -0
  672. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/conversion/patterns.md +261 -0
  673. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/elewise/patterns.md +46 -0
  674. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/elewise/tiling.md +215 -0
  675. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/design/_governance.md +132 -0
  676. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/design/execution.md +469 -0
  677. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/design/resources.md +339 -0
  678. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/design/shape.md +271 -0
  679. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/foundation/composition.md +138 -0
  680. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/foundation/extension_points.md +173 -0
  681. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/foundation/fundamentals.md +245 -0
  682. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/foundation/roofline.md +227 -0
  683. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/implementation_ref.md +201 -0
  684. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/patterns.md +239 -0
  685. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/specialization/feature_flags.md +216 -0
  686. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/specialization/sparse_design.md +198 -0
  687. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/subfamilies/base_design.md +395 -0
  688. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/subfamilies/quantization_design.md +233 -0
  689. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/index/gather.md +273 -0
  690. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/index/index_add.md +434 -0
  691. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/index/index_select.md +185 -0
  692. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/index/patterns.md +199 -0
  693. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/index/repeat_interleave.md +251 -0
  694. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/index/scatter.md +341 -0
  695. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/matmul/ascendc-api-gmm-tiling.md +313 -0
  696. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/matmul/ascendc-api-matmul-tiling.md +408 -0
  697. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/matmul/patterns.md +32 -0
  698. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/alg-dichotomy.md +56 -0
  699. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/alg-group-reduce.md +101 -0
  700. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/alg-welford.md +74 -0
  701. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/algorithms.md +35 -0
  702. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/ar-colsplit.md +149 -0
  703. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/ar-fullload.md +151 -0
  704. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/ara-fullload.md +228 -0
  705. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/ara-rowsplit.md +219 -0
  706. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/multi-axis-transform.md +83 -0
  707. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/multi-output-buffer.md +115 -0
  708. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/patterns.md +212 -0
  709. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/tiling-fields.md +94 -0
  710. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/with-index.md +247 -0
  711. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/scatter/patterns.md +827 -0
  712. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/sort/alg-two-level-mrgsort.md +681 -0
  713. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/sort/patterns.md +249 -0
  714. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/SKILL.md +109 -0
  715. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/coverage_files_question.json +24 -0
  716. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_cmake.txt +46 -0
  717. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_inferdtype.cpp +139 -0
  718. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_inferdtype.csv +5 -0
  719. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_infershape.cpp +122 -0
  720. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_infershape.csv +5 -0
  721. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_param.h +319 -0
  722. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_tiling.cpp +154 -0
  723. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_tiling.csv +5 -0
  724. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/question.json +100 -0
  725. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/template_report.md +112 -0
  726. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/todo.json +24 -0
  727. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/evals/evals.json +198 -0
  728. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/coverage-guide/coverage-extraction.md +78 -0
  729. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/coverage-guide/test-implementation.md +136 -0
  730. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/custom/custom.md +5 -0
  731. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ops-transformer/csv-format-spec.md +263 -0
  732. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ops-transformer/csv-refactor-workflow.md +494 -0
  733. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ops-transformer/legacy-code-extraction.md +325 -0
  734. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ops-transformer/ops-transformer.md +75 -0
  735. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ut-guide/build_ut.md +65 -0
  736. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ut-guide/op-api-ut-guide.md +237 -0
  737. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ut-guide/op-host-ut-guide.md +240 -0
  738. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ut-guide/op-kernel-ut-guide.md +198 -0
  739. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/workflow/step1.md +43 -0
  740. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/workflow/step2.md +26 -0
  741. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/workflow/step3.md +51 -0
  742. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/workflow/step4.md +130 -0
  743. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/workflow/step5.md +5 -0
  744. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/scripts/extract_dtype_combinations.py +200 -0
  745. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/scripts/generate_csv_template.py +270 -0
  746. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/SKILL.md +125 -0
  747. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/evals/evals.json +198 -0
  748. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/S1-input-collection.md +125 -0
  749. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/case-mapper/00-execution-order.md +58 -0
  750. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/case-mapper/01-variable-semantics.md +250 -0
  751. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/case-mapper/02-generate-mapper.md +218 -0
  752. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/case-mapper/S5_case_json_schema.md +373 -0
  753. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/case-mapper/S5_mapped_case_schema.md +131 -0
  754. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/case-mapper/s5_case_mapper_template.py +411 -0
  755. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/design-verifier/00-execution-order.md +114 -0
  756. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/source-analysis/00-execution-order.md +291 -0
  757. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/source-analysis/01-code-analyzer.md +121 -0
  758. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/source-analysis/02-interface-analyzer.md +417 -0
  759. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/source-analysis/03-param-derivation.md +45 -0
  760. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/source-analysis/04-test-design-template.md +231 -0
  761. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/source-analysis/05-network-search.md +154 -0
  762. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-a/00-overview.md +66 -0
  763. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-a/01-step1-tiling.md +114 -0
  764. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-a/02-step2-trace.md +81 -0
  765. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-a/03-step3-kernel.md +51 -0
  766. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-a/04-path-config-schema.md +342 -0
  767. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-d/00-execution-order.md +26 -0
  768. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-d/01-step1-merge.md +54 -0
  769. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-d/02-step2-group.md +44 -0
  770. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-d/03-step3-derive.md +416 -0
  771. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-d/04-step4-output.md +122 -0
  772. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-d/05-step5-gen-cases.md +156 -0
  773. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/ttk-converter/00-execution-order.md +108 -0
  774. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/ttk-converter/01-csv-common.md +33 -0
  775. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/ttk-converter/02-kernel-fields.md +64 -0
  776. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/ttk-converter/03-kernel-mode.md +142 -0
  777. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/workflow.md +193 -0
  778. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/_scout_common.py +53 -0
  779. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/assemble_dim_spec.py +232 -0
  780. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/build_param_def.py +134 -0
  781. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/build_path_list.py +520 -0
  782. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/format_json.py +135 -0
  783. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/gen_cases_template.py +196 -0
  784. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/generate_test_design.py +555 -0
  785. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/normalize_op_name.py +157 -0
  786. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/pick_dims.py +173 -0
  787. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/run_ttk_kernel_module.py +750 -0
  788. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/s2p0_verify.py +302 -0
  789. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/s3_task_d_gate.py +365 -0
  790. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/s5_append_empty.py +180 -0
  791. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/s5_check_mapper_outputs.py +292 -0
  792. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/s5_expand_high.py +208 -0
  793. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/scout_k.py +723 -0
  794. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/scout_t.py +983 -0
  795. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/ttk_generate_kernel_csv.py +346 -0
  796. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/ttk_precheck_env.py +248 -0
  797. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/ttk_validate_csv.py +315 -0
  798. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/update_path_list.py +143 -0
  799. package/assets/ops-direct-invoke/skills/cann-env-setup/SKILL.md +177 -0
  800. package/assets/ops-direct-invoke/skills/cann-env-setup/evals/evals.json +144 -0
  801. package/assets/ops-direct-invoke/skills/cann-env-setup/references/env_dependence.md +77 -0
  802. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/SKILL.md +51 -0
  803. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/overall-implementation.md +226 -0
  804. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/aclnn-adaptation.md +34 -0
  805. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/aicpu-load-balance-metadata.md +116 -0
  806. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/channel-buffer.md +36 -0
  807. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/compilation-launch.md +144 -0
  808. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/host-validation.md +34 -0
  809. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/layout-tail.md +53 -0
  810. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/synchronization.md +80 -0
  811. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/torch-registration.md +66 -0
  812. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/vf.md +144 -0
  813. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/workspace.md +67 -0
  814. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/production-code.md +120 -0
  815. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/SKILL.md +25 -0
  816. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/core/methodology.md +104 -0
  817. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/references/readability-rules.md +280 -0
  818. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/steps/clause-review.md +59 -0
  819. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/steps/report-write.md +60 -0
  820. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/workflows/file-review.md +49 -0
  821. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/workflows/pr-review.md +58 -0
  822. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/SKILL.md +97 -0
  823. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/references/checks-and-troubleshooting.md +96 -0
  824. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/references/env-selected-soc-schema.md +43 -0
  825. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/references/environment-schema.md +112 -0
  826. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/scripts/check_env.sh +34 -0
  827. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/scripts/env_check.py +946 -0
  828. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/scripts/probe_compile_stage.py +99 -0
  829. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/scripts/probe_kernel.py +33 -0
  830. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/tests/test_env_report.py +90 -0
  831. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/SKILL.md +60 -0
  832. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/references/pipeline-design.md +84 -0
  833. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/references/stage-cost-model.md +77 -0
  834. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/DESIGN-BRANCH.md.templ +119 -0
  835. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/INDEX.md.templ +34 -0
  836. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/API.md.templ +67 -0
  837. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/DevView.md.templ +67 -0
  838. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/HostLaunch.md.templ +119 -0
  839. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/InferShapeDtype.md.templ +56 -0
  840. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/Interface.md.templ +61 -0
  841. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/Kernel.md.templ +183 -0
  842. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/LaunchData.md.templ +126 -0
  843. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/Overview.md.templ +57 -0
  844. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/TemplatePartition.md.templ +69 -0
  845. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/Validation.md.templ +80 -0
  846. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/SKILL.md +64 -0
  847. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/assets/case_contract.py +269 -0
  848. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/assets/test.py +571 -0
  849. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/references/cases.md +29 -0
  850. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/references/evidence.md +67 -0
  851. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/references/golden.md +12 -0
  852. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/build_blackbox_cases.py +536 -0
  853. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/build_tdd_cases.py +498 -0
  854. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/build_whitebox_cases.py +183 -0
  855. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/casebook.py +71 -0
  856. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/generator_support.py +95 -0
  857. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/prepare_golden.py +390 -0
  858. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/recipe_validation.py +144 -0
  859. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/tests/test_evidence_chain.py +339 -0
  860. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/tests/test_skills.py +547 -0
  861. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/tests/test_synthesize_dtype.py +85 -0
  862. package/assets/ops-direct-invoke/skills/cannbot-dsl-unit-planner/SKILL.md +35 -0
  863. package/assets/ops-direct-invoke/skills/cannbot-dsl-unit-planner/references/decomposition-checks.md +46 -0
  864. package/assets/ops-direct-invoke/skills/cannbot-dsl-unit-planner/references/unit-format.md +77 -0
  865. package/assets/ops-direct-invoke/skills/npu-arch/SKILL.md +87 -0
  866. package/assets/ops-direct-invoke/skills/npu-arch/evals/evals.json +356 -0
  867. package/assets/ops-direct-invoke/skills/npu-arch/references/npu-arch-guide-triton.md +312 -0
  868. package/assets/ops-direct-invoke/skills/npu-arch/references/npu-arch-guide.md +454 -0
  869. package/assets/ops-direct-invoke/skills/npu-arch/references/npu-hardware-params.md +248 -0
  870. package/assets/ops-direct-invoke/skills/npu-arch/references/simt-arch-guide.md +303 -0
  871. package/assets/ops-direct-invoke/skills/ops-design-paradigms/SKILL.md +41 -0
  872. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/index.md +32 -0
  873. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/arithmetic_and_reduce.md +96 -0
  874. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/datacopy_best_practices.md +87 -0
  875. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/index.md +37 -0
  876. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/pipeline_and_buffer.md +87 -0
  877. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/precision_and_runtime.md +98 -0
  878. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/regbase_api_reference.md +88 -0
  879. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/regbase_api_sync.md +112 -0
  880. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/regbase_api_whitelist.md +121 -0
  881. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/complexity_and_route_selection.md +113 -0
  882. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/index.md +55 -0
  883. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/process_memory_cards.md +54 -0
  884. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/regbase_build_notes.md +87 -0
  885. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/regbase_kernel_case_notes.md +103 -0
  886. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/regbase_performance_practices.md +92 -0
  887. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/regbase_programming_notes.md +108 -0
  888. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/requirements_analysis_patterns.md +97 -0
  889. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/small_channel_transpose_notes.md +78 -0
  890. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/tiling_review_notes.md +87 -0
  891. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/working_vs_failed_950_cases.md +85 -0
  892. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/index.md +30 -0
  893. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/broadcast_patterns.md +132 -0
  894. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/index.md +48 -0
  895. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/inplace_operator_patterns.md +182 -0
  896. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/kernel_design_patterns.md +117 -0
  897. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/reduction_patterns.md +152 -0
  898. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/regbase_buffer_partitioning.md +122 -0
  899. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/regbase_kernel_dataflow_patterns.md +164 -0
  900. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/regbase_operator_patterns.md +138 -0
  901. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/regbase_sync_patterns.md +113 -0
  902. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/tiling_input_validation.md +267 -0
  903. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/tiling_patterns.md +124 -0
  904. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/api_misuse.md +161 -0
  905. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/common_traps.md +199 -0
  906. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/index.md +41 -0
  907. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/precision_failures.md +176 -0
  908. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/precision_guide.md +190 -0
  909. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/regbase_vs_membase_confusions.md +89 -0
  910. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/symptom_to_cause.md +58 -0
  911. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/regbase_development_guide.md +290 -0
  912. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/design_sample/flash_attn-arch35-best-practices.md +80 -0
  913. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/design_sample/quant_flash_attn-arch35-best-practices.md +67 -0
  914. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/design_sample/sparse_flash_attention-arch35-best-practices.md +66 -0
  915. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/design_sample/sparse_flash_mla-arch35-best-practices.md +69 -0
  916. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/patterns.md +65 -0
  917. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/advanced.md +37 -0
  918. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/buffer.md +241 -0
  919. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/compute-flow.md +111 -0
  920. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/load-balancing.md +42 -0
  921. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/pipeline-example.md +173 -0
  922. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/pipeline.md +60 -0
  923. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/pre-knowledge.md +197 -0
  924. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/roofline.md +220 -0
  925. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/selection.md +32 -0
  926. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/stage-cost.md +63 -0
  927. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/trait-mla.md +36 -0
  928. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/trait-quantization.md +51 -0
  929. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/trait-sparse.md +35 -0
  930. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/README.md +20 -0
  931. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/capability-mapping.md +41 -0
  932. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/dag-buffers.md +285 -0
  933. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/design-spec.md +24 -0
  934. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_host/adam_apply_one_assign_def.cpp +104 -0
  935. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_host/arch35/adam_apply_one_assign_tiling_arch35.cpp +572 -0
  936. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_host/arch35/adam_apply_one_assign_tiling_arch35.h +86 -0
  937. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_kernel/adam_apply_one_assign.cpp +46 -0
  938. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_kernel/arch35/adam_apply_one_assign_kernel.h +343 -0
  939. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_kernel/arch35/adam_apply_one_assign_struct.h +29 -0
  940. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_kernel/arch35/adam_apply_one_assign_tiling_struct.h +53 -0
  941. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-design/adam_apply_one_assign_analysis.md +143 -0
  942. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-design/adam_apply_one_assign_design.md +2840 -0
  943. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/CMakeLists.txt +328 -0
  944. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/README.md +162 -0
  945. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_graph/xdivy_graph_infer.cpp +40 -0
  946. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_graph/xdivy_proto.h +44 -0
  947. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_host/arch35/xdivy_tiling_arch35.cpp +582 -0
  948. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_host/arch35/xdivy_tiling_arch35.h +94 -0
  949. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_host/xdivy_def.cpp +62 -0
  950. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_host/xdivy_infershape.cpp +60 -0
  951. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_kernel/arch35/xdivy_kernel.h +337 -0
  952. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_kernel/arch35/xdivy_struct.h +30 -0
  953. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_kernel/arch35/xdivy_tiling_struct.h +57 -0
  954. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_kernel/xdivy.cpp +44 -0
  955. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/aclnn/CMakeLists.txt +67 -0
  956. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/aclnn/run.sh +57 -0
  957. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/aclnn/test_aclnn.cpp +353 -0
  958. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/geir/CMakeLists.txt +69 -0
  959. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/geir/run.sh +59 -0
  960. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/geir/test_geir.cpp +409 -0
  961. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/tiling/CMakeLists.txt +185 -0
  962. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/tiling/run.sh +62 -0
  963. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/tiling/test_tiling.cpp +355 -0
  964. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/index.md +48 -0
  965. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/kernel-entrance.md +95 -0
  966. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/kernel-helpers.md +208 -0
  967. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/kernel-template.md +617 -0
  968. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/overview.md +250 -0
  969. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/pitfalls.md +50 -0
  970. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/tiling-preprocess.md +487 -0
  971. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/tiling.md +374 -0
  972. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/dsl/capability-mapping.md +50 -0
  973. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/dsl/implementation-guide.md +52 -0
  974. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/dsl/index.md +33 -0
  975. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/capability-contract.md +41 -0
  976. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/compute-flow.md +216 -0
  977. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/index.md +23 -0
  978. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/liveness-fusion.md +200 -0
  979. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/scene.md +68 -0
  980. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/shape-preprocessing.md +209 -0
  981. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/splitting.md +158 -0
  982. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/sync-model.md +79 -0
  983. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/verification.md +131 -0
  984. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/patterns.md +62 -0
  985. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/broadcast-rules.md +126 -0
  986. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/cast-rules.md +414 -0
  987. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/datacopypad-rules.md +186 -0
  988. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/nddma-rules.md +257 -0
  989. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/sync-and-consistency.md +315 -0
  990. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/value-depend-process.md +40 -0
  991. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/vf-programming-rules.md +150 -0
  992. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/example-routes.yaml +31 -0
  993. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/general-methodology-dsl.md +11 -0
  994. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/general-methodology.md +94 -0
  995. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/binary-tree.md +260 -0
  996. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/capability-mapping.md +49 -0
  997. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/design-spec.md +26 -0
  998. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/CMakeLists.txt +289 -0
  999. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/README.md +147 -0
  1000. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_graph/euclidean_norm_graph_infer.cpp +39 -0
  1001. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_graph/euclidean_norm_proto.h +54 -0
  1002. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_host/arch35/euclidean_norm_tiling_arch35.cpp +1027 -0
  1003. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_host/arch35/euclidean_norm_tiling_arch35.h +28 -0
  1004. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_host/euclidean_norm_def.cpp +85 -0
  1005. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_host/euclidean_norm_infershape.cpp +211 -0
  1006. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_apt.cpp +41 -0
  1007. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_base.h +911 -0
  1008. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_empty.h +141 -0
  1009. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_group.h +381 -0
  1010. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_tiling_data.h +65 -0
  1011. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_tiling_key.h +30 -0
  1012. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/aclnn/CMakeLists.txt +59 -0
  1013. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/aclnn/run.sh +37 -0
  1014. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/aclnn/test_aclnn.cpp +223 -0
  1015. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/geir/CMakeLists.txt +84 -0
  1016. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/geir/run.sh +49 -0
  1017. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/geir/test_geir.cpp +296 -0
  1018. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/tiling/CMakeLists.txt +143 -0
  1019. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/tiling/run.sh +41 -0
  1020. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/tiling/test_tiling.cpp +320 -0
  1021. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/highlevel-api.md +146 -0
  1022. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/index.md +48 -0
  1023. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/kernel-entrance.md +97 -0
  1024. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/overview.md +237 -0
  1025. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/survival-node.md +74 -0
  1026. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/binary-base/dag-buffers.md +612 -0
  1027. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/binary-base/kernel-template.md +1213 -0
  1028. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/binary-base/tiling.md +511 -0
  1029. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/binary-group/dag-buffers.md +209 -0
  1030. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/binary-group/kernel-template.md +577 -0
  1031. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/binary-group/tiling.md +199 -0
  1032. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/empty/dag-buffers.md +292 -0
  1033. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/empty/kernel-template.md +349 -0
  1034. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/empty/tiling.md +230 -0
  1035. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/tiling-preprocess.md +218 -0
  1036. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/tuple-reduce.md +72 -0
  1037. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/vf-fusion-rules.md +95 -0
  1038. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/axis-preprocessing.md +109 -0
  1039. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/capability-contract.md +48 -0
  1040. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/index.md +23 -0
  1041. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/liveness-fusion.md +111 -0
  1042. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/scene.md +92 -0
  1043. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/splitting.md +230 -0
  1044. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/sync-model.md +86 -0
  1045. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/tree-reduction.md +160 -0
  1046. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/tuple-reduce.md +53 -0
  1047. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/patterns.md +62 -0
  1048. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/validate_gates.py +196 -0
  1049. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/resolve_example.py +170 -0
  1050. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/routes.yaml +39 -0
  1051. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/reference-ops/open_source_operator_table.md +715 -0
  1052. package/assets/ops-direct-invoke/skills/ops-design-paradigms/tests/test_language_route.py +142 -0
  1053. package/assets/ops-direct-invoke/skills/ops-direct-invoke/SKILL.md +249 -0
  1054. package/assets/ops-direct-invoke/skills/ops-direct-invoke/scripts/assemble_cannbotdsl_design.py +156 -0
  1055. package/assets/ops-direct-invoke/skills/ops-direct-invoke/scripts/assemble_workflow.py +571 -0
  1056. package/assets/ops-direct-invoke/skills/ops-direct-invoke/scripts/build_implementation_subgraph.py +320 -0
  1057. package/assets/ops-direct-invoke/skills/ops-direct-invoke/scripts/generate_workflow_guide.py +94 -0
  1058. package/assets/ops-direct-invoke/skills/ops-direct-invoke/scripts/run_workflow.py +121 -0
  1059. package/assets/ops-direct-invoke/skills/ops-direct-invoke/scripts/validate_unit_contracts.py +228 -0
  1060. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//344/273/243/347/240/201/344/277/256/345/244/215.yaml +39 -0
  1061. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//346/212/200/346/234/257/347/251/277/345/210/272.yaml +40 -0
  1062. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//346/226/207/346/241/243/345/207/206/345/244/207.yaml +27 -0
  1063. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//346/265/213/350/257/225/345/267/245/347/250/213/345/274/200/345/217/221.yaml +33 -0
  1064. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//347/231/275/347/233/222/346/265/213/350/257/225/350/256/276/350/256/241.yaml +34 -0
  1065. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//347/237/245/350/257/206/346/220/234/351/233/206.yaml +36 -0
  1066. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//347/256/227/345/255/220/345/274/200/345/217/221.yaml +47 -0
  1067. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//351/273/221/347/233/222/346/265/213/350/257/225/350/256/276/350/256/241.yaml +27 -0
  1068. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//344/272/244/344/273/230.yaml +15 -0
  1069. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//344/273/243/347/240/201/346/243/200/350/247/206.yaml +18 -0
  1070. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/210/233/345/273/272/345/267/245/344/275/234/345/214/272.yaml +17 -0
  1071. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/215/225/345/205/203/344/273/273/345/212/241/346/213/206/345/210/206.yaml +22 -0
  1072. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/215/225/345/205/203/345/256/236/347/216/260.yaml +27 -0
  1073. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/215/225/345/205/203/351/233/206/346/210/220/345/244/215/351/252/214.yaml +19 -0
  1074. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/256/236/347/216/260/344/277/256/345/244/215.yaml +21 -0
  1075. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/256/236/347/216/260/346/243/200/350/247/206.yaml +20 -0
  1076. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/256/236/347/216/260/351/227/250/347/246/201.yaml +17 -0
  1077. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//346/200/247/350/203/275/344/274/230/345/214/226.yaml +22 -0
  1078. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//346/226/207/346/241/243/347/224/237/346/210/220.yaml +15 -0
  1079. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//346/226/271/346/241/210/350/256/276/350/256/241.yaml +32 -0
  1080. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//346/265/213/350/257/225/347/224/237/346/210/220.yaml +29 -0
  1081. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//347/216/257/345/242/203/345/260/261/347/273/252.yaml +25 -0
  1082. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//347/262/276/345/272/246/351/252/214/350/257/201.yaml +25 -0
  1083. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//350/247/204/346/240/274/347/224/237/346/210/220.yaml +18 -0
  1084. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//351/234/200/346/261/202/345/210/206/346/236/220.yaml +16 -0
  1085. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//351/273/221/347/233/222/347/224/250/344/276/213/350/256/276/350/256/241.yaml +19 -0
  1086. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/common/.gitkeep +0 -0
  1087. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//344/273/243/347/240/201/346/243/200/350/247/206/346/212/245/345/221/212.md +70 -0
  1088. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//345/212/237/350/203/275/351/252/214/346/224/266/346/212/245/345/221/212.md +80 -0
  1089. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//346/265/213/350/257/225/346/211/247/350/241/214/350/256/260/345/275/225.md +73 -0
  1090. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//347/231/275/347/233/222/346/265/213/350/257/225/350/256/276/350/256/241.md +37 -0
  1091. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//347/237/245/350/257/206/346/220/234/351/233/206.md +25 -0
  1092. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//351/252/214/346/224/266/346/212/245/345/221/212.md +39 -0
  1093. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//351/273/221/347/233/222/346/265/213/350/257/225/350/256/276/350/256/241.md +130 -0
  1094. package/assets/ops-direct-invoke/skills/ops-direct-invoke/workflows/ascendc/basic.yaml +57 -0
  1095. package/assets/ops-direct-invoke/skills/ops-direct-invoke/workflows/ascendc/feasibility.yaml +13 -0
  1096. package/assets/ops-direct-invoke/skills/ops-direct-invoke/workflows/cannbot-dsl/op-dev.graph-preview.yaml +18 -0
  1097. package/assets/ops-direct-invoke/skills/ops-direct-invoke/workflows/cannbot-dsl/op-dev.yaml +142 -0
  1098. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/SKILL.md +115 -0
  1099. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/agents-entry.md +23 -0
  1100. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/documentation.md +52 -0
  1101. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/ops-direct-invoke.md +67 -0
  1102. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/repo-skills.md +85 -0
  1103. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/subagents.md +43 -0
  1104. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/task-authoring.md +83 -0
  1105. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/tests.md +33 -0
  1106. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/dsl_generation/test.py +499 -0
  1107. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/support.py +122 -0
  1108. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/test_all.py +59 -0
  1109. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/variables/test.py +100 -0
  1110. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/workflow_execution/test.py +134 -0
  1111. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/workflow_generation/test.py +457 -0
  1112. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/workflow_guide/test.py +91 -0
  1113. package/assets/ops-direct-invoke/skills/ops-precision-standard/SKILL.md +22 -0
  1114. package/assets/ops-direct-invoke/skills/ops-precision-standard/evals/evals.json +120 -0
  1115. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/benchmark_construction.md +77 -0
  1116. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/float_compute.md +126 -0
  1117. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/integer_compute.md +105 -0
  1118. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/non_compute.md +81 -0
  1119. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/quantization.md +49 -0
  1120. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/random_generation.md +198 -0
  1121. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/test_case_generation.md +61 -0
  1122. package/assets/ops-direct-invoke/skills/ops-precision-standard/scripts/bitwise_match.py +103 -0
  1123. package/assets/ops-direct-invoke/skills/ops-precision-standard/scripts/integer_compute_check.py +157 -0
  1124. package/assets/ops-direct-invoke/skills/ops-precision-standard/scripts/mixed_tolerance_check.py +178 -0
  1125. package/assets/ops-direct-invoke/skills/ops-precision-standard/scripts/random_distribution_check.py +247 -0
  1126. package/assets/ops-direct-invoke/skills/ops-profiling/SKILL.md +185 -0
  1127. package/assets/ops-direct-invoke/skills/ops-profiling/evals/evals.json +196 -0
  1128. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/SKILL.md +259 -0
  1129. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/VERSION +10 -0
  1130. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/evals/evals.json +33 -0
  1131. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/references/collection-workflow.md +91 -0
  1132. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/references/data-contract.md +63 -0
  1133. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/references/environment-and-failure.md +82 -0
  1134. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/references/validation-and-performance.md +63 -0
  1135. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/references/visualization-contract.md +86 -0
  1136. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/collect.py +2209 -0
  1137. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/collect_discovery.py +987 -0
  1138. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/collect_validate.py +607 -0
  1139. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/environment_context.py +723 -0
  1140. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/estimate_runtime.py +131 -0
  1141. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/run_pipeline.py +339 -0
  1142. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/runtime_guard.py +589 -0
  1143. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/self_check.py +465 -0
  1144. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/visualize.py +1004 -0
  1145. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/visualize_common.py +258 -0
  1146. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/visualize_parsers.py +1555 -0
  1147. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/visualize_render.py +286 -0
  1148. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/visualize_resolvers.py +1224 -0
  1149. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/visualize_source.py +1288 -0
  1150. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/templates/report_template.html +253 -0
  1151. package/assets/ops-direct-invoke/skills/ops-profiling/references/csv_fields_reference.md +260 -0
  1152. package/assets/ops-direct-invoke/skills/ops-profiling/references/msprof-guide.md +252 -0
  1153. package/assets/ops-direct-invoke/skills/ops-profiling/references/msprof-op-guide.md +241 -0
  1154. package/assets/ops-direct-invoke/skills/ops-profiling/references/optimization_quickref.md +265 -0
  1155. package/assets/ops-direct-invoke/skills/ops-profiling/scripts/msprof_perf_summary.py +2469 -0
  1156. package/assets/ops-direct-invoke/skills/ops-profiling/scripts/msprof_profile_run.sh +400 -0
  1157. package/assets/ops-direct-invoke/skills/ops-profiling/scripts/perf_summary.py +448 -0
  1158. package/assets/ops-direct-invoke/skills/ops-simulator/SKILL.md +233 -0
  1159. package/assets/ops-direct-invoke/skills/ops-simulator/evals/evals.json +128 -0
  1160. package/assets/ops-direct-invoke/skills/ops-simulator/references/pc-source-mapping.md +76 -0
  1161. package/assets/ops-direct-invoke/skills/ops-simulator/references/performance-issues-aic.md +557 -0
  1162. package/assets/ops-direct-invoke/skills/ops-simulator/references/performance-issues-aiv.md +674 -0
  1163. package/assets/ops-direct-invoke/skills/ops-simulator/references/performance-issues-general.md +199 -0
  1164. package/assets/ops-direct-invoke/skills/ops-simulator/references/performance-issues-template.md +143 -0
  1165. package/assets/ops-direct-invoke/skills/ops-simulator/references/performance-metrics-reference.md +350 -0
  1166. package/assets/ops-direct-invoke/skills/ops-simulator/references/pipeline-bubble-analysis.md +269 -0
  1167. package/assets/ops-direct-invoke/skills/ops-simulator/references/simulator-advanced.md +174 -0
  1168. package/assets/ops-direct-invoke/skills/ops-simulator/references/troubleshooting.md +105 -0
  1169. package/assets/ops-direct-invoke/skills/ops-simulator/scripts/map_pc_to_source.py +741 -0
  1170. package/assets/ops-direct-invoke/skills/ops-simulator/scripts/trace_bubble_analyzer.py +971 -0
  1171. package/assets/ops-direct-invoke/skills/ops-spec-gen/SKILL.md +350 -0
  1172. package/assets/ops-direct-invoke/skills/ops-spec-gen/evals/evals.json +114 -0
  1173. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/README.md +71 -0
  1174. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/add/spec.yaml +161 -0
  1175. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/complex/spec.yaml +154 -0
  1176. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/cumsum/spec.yaml +176 -0
  1177. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/dropout/spec.yaml +170 -0
  1178. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/fused_quant_matmul/spec.yaml +331 -0
  1179. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/matmul/spec.yaml +201 -0
  1180. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/nonzero/spec.yaml +174 -0
  1181. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/reduce_sum/spec.yaml +151 -0
  1182. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/reduce_sum_all/spec.yaml +135 -0
  1183. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/reduce_sum_fixed/spec.yaml +143 -0
  1184. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/softmax/spec.yaml +231 -0
  1185. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/split/spec.yaml +160 -0
  1186. package/assets/ops-direct-invoke/skills/ops-spec-gen/references/accumulation_order.md +63 -0
  1187. package/assets/ops-direct-invoke/skills/ops-spec-gen/references/error-codes.md +199 -0
  1188. package/assets/ops-direct-invoke/skills/ops-spec-gen/references/spec-cheatsheet.md +358 -0
  1189. package/assets/ops-direct-invoke/skills/ops-spec-gen/references/stage-rules.md +476 -0
  1190. package/assets/ops-direct-invoke/skills/ops-spec-gen/references/usage-scenarios.md +265 -0
  1191. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/anti_pattern_registry.yaml +51 -0
  1192. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/boundary_min_cases.yaml +215 -0
  1193. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/category_enum.yaml +37 -0
  1194. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/category_paradigm_map.yaml +145 -0
  1195. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/chip_registry.yaml +82 -0
  1196. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/error_code_enum.yaml +25 -0
  1197. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/framework_oracle_registry.yaml +22 -0
  1198. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/invariant_kind_registry.yaml +130 -0
  1199. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/machine_check_kind_registry.yaml +84 -0
  1200. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/paradigm_enum.yaml +48 -0
  1201. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/primitive_whitelist.yaml +67 -0
  1202. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/synthesize_pattern_registry.yaml +58 -0
  1203. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/tolerance_defaults.yaml +53 -0
  1204. package/assets/ops-direct-invoke/skills/ops-spec-gen/schemas/op-spec.json +762 -0
  1205. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/check_registry_schema_sync.py +167 -0
  1206. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/dump_rule_ids.py +168 -0
  1207. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/__init__.py +8 -0
  1208. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/_ast_sandbox.py +142 -0
  1209. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/broadcast.py +270 -0
  1210. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/dtype_eval.py +186 -0
  1211. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/extreme_inputs_check.py +355 -0
  1212. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/formula_eval.py +431 -0
  1213. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/formula_oracle_equiv.py +603 -0
  1214. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/invariant_exec.py +569 -0
  1215. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/oracle_check.py +465 -0
  1216. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/parser.py +71 -0
  1217. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/promote.py +254 -0
  1218. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/shape_eval.py +368 -0
  1219. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/stages.py +995 -0
  1220. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/types.py +130 -0
  1221. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/generate_spec.py +1571 -0
  1222. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/validate_spec.py +1848 -0
  1223. package/assets/ops-direct-invoke/skills/ops-spec-gen/templates/spec.yaml.tmpl +100 -0
  1224. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/conftest.py +21 -0
  1225. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_attr_resolve.py +72 -0
  1226. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_broadcast.py +85 -0
  1227. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_doc_drift.py +45 -0
  1228. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_dtype_eval.py +163 -0
  1229. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_examples.py +54 -0
  1230. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_extreme_inputs_check.py +181 -0
  1231. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_formula_eval.py +154 -0
  1232. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_formula_oracle_equiv.py +281 -0
  1233. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_generate_spec.py +98 -0
  1234. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_invariant_exec.py +235 -0
  1235. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_main_pipeline.py +419 -0
  1236. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_oracle.py +255 -0
  1237. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_promote.py +127 -0
  1238. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_registry_schema_sync.py +32 -0
  1239. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_sandbox_escape.py +90 -0
  1240. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_shape_eval.py +220 -0
  1241. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_shape_literal.py +82 -0
  1242. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_stage2_constraints.py +213 -0
  1243. package/assets/ops-direct-invoke/skills/repo-build-guide/SKILL.md +10 -0
  1244. package/assets/ops-direct-invoke/skills/repo-build-guide/references/build-guide.md +42 -0
  1245. package/assets/ops-direct-invoke/skills/repo-coding-rules/SKILL.md +10 -0
  1246. package/assets/ops-direct-invoke/skills/repo-coding-rules/references/red-lines.md +42 -0
  1247. package/assets/ops-direct-invoke/skills/repo-env-check/SKILL.md +44 -0
  1248. package/assets/ops-direct-invoke/skills/repo-env-check/references//347/216/257/345/242/203/344/277/241/346/201/257.md +42 -0
  1249. package/assets/ops-direct-invoke/skills/repo-knowledge/SKILL.md +12 -0
  1250. package/assets/ops-direct-invoke/skills/repo-knowledge/references/evaluation-contract.md +48 -0
  1251. package/assets/ops-direct-invoke/skills/repo-op-templates/SKILL.md +15 -0
  1252. package/assets/ops-direct-invoke/skills/repo-op-templates/references/operator-template.md +27 -0
  1253. package/assets/ops-direct-invoke/skills/repo-op-templates/references/project-skeleton.md +41 -0
  1254. package/assets/ops-direct-invoke/skills/repo-requirement/SKILL.md +39 -0
  1255. package/assets/ops-direct-invoke/skills/repo-requirement/references/requirement-checklist.md +70 -0
  1256. package/assets/ops-direct-invoke/skills/repo-test-develop/SKILL.md +17 -0
  1257. package/assets/ops-direct-invoke/skills/repo-test-develop/references/blackbox-design.md +30 -0
  1258. package/assets/ops-direct-invoke/skills/repo-test-develop/references/cannbench-integration.md +75 -0
  1259. package/assets/ops-direct-invoke/skills/repo-test-develop/references/precision-and-perf.md +36 -0
  1260. package/assets/ops-direct-invoke/skills/repo-test-develop/references/test-framework.md +75 -0
  1261. package/assets/ops-direct-invoke/skills/repo-test-develop/references/whitebox-design.md +19 -0
  1262. package/assets/ops-direct-invoke/skills/workflow-orchestrator/README.md +145 -0
  1263. package/assets/ops-direct-invoke/skills/workflow-orchestrator/SKILL.md +84 -0
  1264. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/approve_task.py +98 -0
  1265. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/get_task.py +1133 -0
  1266. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/init_status.py +131 -0
  1267. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/link_agent_config.py +89 -0
  1268. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/orchestrator.py +738 -0
  1269. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/poll_workflow.py +392 -0
  1270. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/task_graph.py +144 -0
  1271. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/update_status.py +149 -0
  1272. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/verdict_common.py +103 -0
  1273. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/verdict_fail.py +22 -0
  1274. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/verdict_pass.py +21 -0
  1275. package/assets/ops-direct-invoke/skills/workflow-orchestrator/templates/basic_workflow.yaml +113 -0
  1276. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_agent_exit.py +91 -0
  1277. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_approval.py +490 -0
  1278. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_link_agent_config.py +202 -0
  1279. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_nested_subgraphs.py +337 -0
  1280. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_orchestrator.py +1383 -0
  1281. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_poll_workflow.py +371 -0
  1282. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_verdict.py +148 -0
  1283. package/cordis.patch.yml +3 -0
  1284. package/icon.svg +1 -0
  1285. package/lib/client.js +255 -0
  1286. package/lib/client.js.map +1 -0
  1287. package/lib/index.js +15 -0
  1288. package/locale/en.json +1 -0
  1289. package/locale/zh.json +1 -0
  1290. package/package.json +62 -3
  1291. package/upstream.json +10 -0
@@ -0,0 +1,2209 @@
1
+ #!/usr/bin/env python3
2
+ # ----------------------------------------------------------------------------------------------------------
3
+ # Copyright (c) 2026 Huawei Technologies Co., Ltd.
4
+ # This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5
+ # CANN Open Software License Agreement Version 2.0 (the "License").
6
+ # Please refer to the License for details. You may not use this file except in compliance with the License.
7
+ # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8
+ # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9
+ # See LICENSE in the root of the software repository for the full text of the License.
10
+ # ----------------------------------------------------------------------------------------------------------
11
+ from __future__ import annotations
12
+
13
+ import argparse
14
+ import json
15
+ import logging
16
+ import shutil
17
+ import sys
18
+ import time
19
+ from pathlib import Path
20
+ from types import SimpleNamespace
21
+ from typing import Any, Dict, Iterable, List, Mapping, NamedTuple, Optional, Sequence, Set, Tuple
22
+
23
+ logger = logging.getLogger(__name__)
24
+
25
+ SCRIPT_DIR = Path(__file__).resolve().parent
26
+ if str(SCRIPT_DIR) not in sys.path:
27
+ sys.path.insert(0, str(SCRIPT_DIR))
28
+ import environment_context as envctx
29
+ import runtime_guard as rtguard
30
+
31
+ from collect_validate import (
32
+ DEFAULT_CSV_SUITE_NAMES, STANDARD_CSV_NAMES, bin_contains_all, bin_contains_any, csv_artifact_map,
33
+ detect_simt_evidence_from_bin, extract_log_diagnostics, fallback_allowed, has_standard_csv_suite,
34
+ infer_semantic_failure_reason, inspect_source_payload, metric_expression_contains,
35
+ metric_expression_key, normalize_metric_token, rel, split_metric_expression, trace_event_count,
36
+ validate_block_entry, validate_profiler_options, _TRACE_EVENT_PH, _block_log_text,
37
+ )
38
+ from collect_discovery import (
39
+ KNOWN_METRICS, TEST_LIKE_EXECUTABLE,
40
+ detect_kernel_scale_instrumentation, detect_relative_resource_hints, discover_executable_candidates,
41
+ discover_operators, find_latest_file, find_latest_result_dir, find_result_dirs,
42
+ is_candidate_executable, parse_cmake_cache, parse_supported_metrics, parse_supported_options,
43
+ resolve_app_cwd, resolve_executable, resolve_executable_details, run_capture, run_shell_capture,
44
+ test_like_executable_warning, _candidate_score, _debug_scope_root, _row_value_case_insensitive,
45
+ BLOCK_DIRS, DEFAULT_BLOCK_TIMEOUTS, derive_timeout_profile, parse_block_timeouts, parse_key_value,
46
+ ensure_msprof_output_permissions, fingerprint, fingerprint_key, is_single_exact_kernel_filter,
47
+ now_iso, previous_run_allows_reuse, read_json, sanitize_output_tree, shell_join, write_json,
48
+ BLOCKS, CONTRACT_SCHEMA, FEATURE_TO_BLOCK, FEATURE_TO_BLOCKS, PRESETS, RAW_COUNTER_METRICS,
49
+ command_description, feature_catalog, normalize_feature_name, print_feature_explanation,
50
+ print_feature_list, visualization_contract,
51
+ )
52
+ import collect_discovery as _collect_discovery
53
+
54
+ cli_logger = logging.getLogger(__name__ + ".cli")
55
+ cli_logger.propagate = False
56
+ if not cli_logger.handlers:
57
+ _cli_handler = logging.StreamHandler(sys.stdout)
58
+ _cli_handler.setFormatter(logging.Formatter("%(message)s"))
59
+ cli_logger.addHandler(_cli_handler)
60
+
61
+
62
+ def detect_debug_symbols_details(operator_root, app):
63
+ """Wrapper so this module's ``run_capture`` stays the effective patch point."""
64
+ return _collect_discovery.detect_debug_symbols_details(operator_root, app, capture=run_capture)
65
+
66
+ SKILL_ROOT = Path(__file__).resolve().parents[1]
67
+ VERSION = next(
68
+ (line.strip() for line in (SKILL_ROOT / "VERSION").read_text(encoding="utf-8").splitlines()
69
+ if line.strip() and not line.lstrip().startswith("#")),
70
+ "unknown",
71
+ )
72
+
73
+
74
+ def select_metric_candidates(block_id: str, supported: Iterable[str]) -> List[str]:
75
+ lookup: Dict[str, str] = {}
76
+ for actual in supported:
77
+ lookup.setdefault(normalize_metric_token(actual), actual)
78
+ out: List[str] = []
79
+ seen: Set[Tuple[str, ...]] = set()
80
+ for candidate_expression in BLOCKS[block_id]["metric_candidates"]:
81
+ candidate_tokens = split_metric_expression(candidate_expression)
82
+ actual_tokens: List[str] = []
83
+ for candidate in candidate_tokens:
84
+ actual = lookup.get(normalize_metric_token(candidate))
85
+ if actual is None:
86
+ actual_tokens = []
87
+ break
88
+ actual_tokens.append(actual)
89
+ if not actual_tokens:
90
+ continue
91
+ expression = ",".join(actual_tokens)
92
+ key = metric_expression_key(expression)
93
+ if key not in seen:
94
+ seen.add(key)
95
+ out.append(expression)
96
+ return out
97
+
98
+
99
+ def select_metric(block_id: str, supported: Iterable[str]) -> Optional[str]:
100
+ candidates = select_metric_candidates(block_id, supported)
101
+ return candidates[0] if candidates else None
102
+
103
+
104
+ def _check_required_options(options: Set[str]) -> None:
105
+ missing = [x for x in ["--aic-metrics", "--output"] if x not in options]
106
+ if missing:
107
+ raise rtguard.UsageError(
108
+ f"ERROR: installed msprof op help does not expose required option(s): {', '.join(missing)}"
109
+ )
110
+
111
+
112
+ def _normalize_metric_expression(metric: str) -> str:
113
+ metric_tokens = split_metric_expression(metric)
114
+ if not metric_tokens:
115
+ raise rtguard.UsageError("ERROR: --aic-metrics expression cannot be empty.")
116
+ return ",".join(metric_tokens)
117
+
118
+
119
+ def _require_option(options: Set[str], cli_name: str) -> None:
120
+ if cli_name not in options:
121
+ raise rtguard.UsageError(
122
+ f"ERROR: {cli_name} was requested but is not exposed by the installed msprof op CLI."
123
+ )
124
+
125
+
126
+ _PROFILER_OPTION_ORDER = [
127
+ ("launch_skip_before_match", "--launch-skip-before-match"),
128
+ ("replay_mode", "--replay-mode"),
129
+ ("warm_up", "--warm-up"),
130
+ ("kill", "--kill"),
131
+ ("mstx", "--mstx"),
132
+ ("mstx_include", "--mstx-include"),
133
+ ("dump", "--dump"),
134
+ ("core_id", "--core-id"),
135
+ ]
136
+
137
+
138
+ def _append_profiler_options(
139
+ cmd: List[str],
140
+ metric: str,
141
+ options: Set[str],
142
+ profiler_options: Optional[Mapping[str, Any]],
143
+ ) -> None:
144
+ extra = dict(profiler_options or {})
145
+ if not metric_expression_contains(metric, "TimelineDetail"):
146
+ extra["dump"] = None
147
+ extra["core_id"] = None
148
+ validate_profiler_options(metric, extra)
149
+ for key, cli_name in _PROFILER_OPTION_ORDER:
150
+ value = extra.get(key)
151
+ if value is None:
152
+ continue
153
+ _require_option(options, cli_name)
154
+ cmd.append(f"{cli_name}={value}")
155
+
156
+
157
+ class MsprofCommandSpec(NamedTuple):
158
+ """Bundled inputs for ``build_msprof_command`` (G.FNM.03)."""
159
+
160
+ msprof: str
161
+ metric: str
162
+ run_dir: Path
163
+ app: Path
164
+ app_args: Sequence[str]
165
+ kernel_name: Optional[str]
166
+ launch_count: int
167
+ instr_timeline_pipe: Optional[str] = None
168
+ supported_options: Optional[Iterable[str]] = None
169
+ profiler_options: Optional[Mapping[str, Any]] = None
170
+
171
+
172
+ def build_msprof_command(spec: MsprofCommandSpec) -> List[str]:
173
+ options = set(spec.supported_options or [
174
+ "--aic-metrics", "--output", "--launch-count", "--kernel-name", "--instr-timeline-pipe"
175
+ ])
176
+ _check_required_options(options)
177
+ metric = _normalize_metric_expression(spec.metric)
178
+ cmd = [spec.msprof, "op", f"--aic-metrics={metric}", f"--output={spec.run_dir}"]
179
+ if "--launch-count" in options:
180
+ cmd.append(f"--launch-count={spec.launch_count}")
181
+ if spec.kernel_name:
182
+ _require_option(options, "--kernel-name")
183
+ cmd.append(f"--kernel-name={spec.kernel_name}")
184
+ if metric_expression_contains(metric, "instrTimeLine") and spec.instr_timeline_pipe:
185
+ if "--instr-timeline-pipe" in options:
186
+ cmd.append(f"--instr-timeline-pipe={spec.instr_timeline_pipe}")
187
+ _append_profiler_options(cmd, metric, options, spec.profiler_options)
188
+ cmd.append(str(spec.app))
189
+ cmd.extend(spec.app_args)
190
+ return cmd
191
+
192
+
193
+ def build_artifacts(result_dir: Optional[Path], output_root: Path) -> Dict[str, Any]:
194
+ visualize = find_latest_file(result_dir, "visualize_data.bin")
195
+ trace = find_latest_file(result_dir, "trace.json")
196
+ return {
197
+ "visualize_data": rel(visualize, output_root),
198
+ "trace": rel(trace, output_root),
199
+ "csv": csv_artifact_map(result_dir, output_root),
200
+ }
201
+
202
+
203
+ def classify_status(return_code: int, result_dir: Optional[Path]) -> str:
204
+ # A timeout or non-zero command is never considered successful merely because
205
+ # it left a partial OPPROF directory behind.
206
+ if return_code != 0:
207
+ return "failed"
208
+ return "ok" if result_dir is not None else "empty"
209
+
210
+
211
+ def write_command_record(
212
+ internal_dir: Path,
213
+ block_id: str,
214
+ metric: str,
215
+ cmd: Sequence[str],
216
+ description: Dict[str, Any],
217
+ ) -> None:
218
+ write_json(internal_dir / "commands" / f"{block_id}.json", {
219
+ "block_id": block_id,
220
+ "metric": metric,
221
+ "argv": [str(x) for x in cmd],
222
+ "shell": shell_join(cmd),
223
+ "description": description,
224
+ })
225
+
226
+
227
+ class _BlockSpec(NamedTuple):
228
+ """Bundled identity of one collector block execution (G.FNM.03)."""
229
+
230
+ block_id: str
231
+ metric: str
232
+ relative_dir: str
233
+ requested_by: Sequence[str]
234
+
235
+
236
+ class BlockEntrySpec(NamedTuple):
237
+ """Bundled inputs for ``build_block_entry`` (G.FNM.03)."""
238
+
239
+ block_id: str
240
+ metric: Optional[str]
241
+ status: str
242
+ relative_dir: str
243
+ result_dir: Optional[Path]
244
+ output_root: Path
245
+ elapsed: float
246
+ return_code: Optional[int]
247
+ requested_by: Sequence[str]
248
+ reason: Optional[str] = None
249
+
250
+
251
+ def _block_fingerprint_key(
252
+ metric: str,
253
+ cmd: Sequence[str],
254
+ app_fp: Dict[str, Any],
255
+ msprof_fp: Optional[Dict[str, Any]],
256
+ cwd: Optional[Path],
257
+ ) -> str:
258
+ return fingerprint_key({
259
+ "metric": metric,
260
+ "command": list(cmd),
261
+ "app": app_fp,
262
+ "msprof": msprof_fp,
263
+ "collector": VERSION,
264
+ "cwd": str(cwd) if cwd else None,
265
+ })
266
+
267
+
268
+ def _reuse_match(old: Mapping[str, Any], key: str, reuse_existing: bool, existing: Optional[Path]) -> bool:
269
+ state_matches = (
270
+ reuse_existing
271
+ and old.get("fingerprint") == key
272
+ and old.get("reusable") is True
273
+ )
274
+ previous_status_ok = (old.get("entry") or {}).get("status") in {"ok", "partial"}
275
+ return bool(state_matches and previous_status_ok and existing)
276
+
277
+
278
+ def _reused_block_entry(spec: _BlockSpec, existing: Path, output_root: Path, cwd: Optional[Path]) -> Dict[str, Any]:
279
+ entry = build_block_entry(BlockEntrySpec(
280
+ spec.block_id, spec.metric, "reused", spec.relative_dir, existing, output_root,
281
+ 0.0, None, spec.requested_by,
282
+ ))
283
+ entry["cwd"] = str(cwd) if cwd else None
284
+ entry["reused_from_state"] = True
285
+ return entry
286
+
287
+
288
+ def _planned_block_entry(spec: _BlockSpec, output_root: Path, timeout: int, cwd: Optional[Path]) -> Dict[str, Any]:
289
+ entry = build_block_entry(BlockEntrySpec(
290
+ spec.block_id, spec.metric, "planned", spec.relative_dir, None, output_root,
291
+ 0.0, None, spec.requested_by,
292
+ ))
293
+ entry["cwd"] = str(cwd) if cwd else None
294
+ entry["timeout_seconds"] = timeout
295
+ return entry
296
+
297
+
298
+ def _execution_fields(
299
+ result: Mapping[str, Any],
300
+ logs: Path,
301
+ stem: str,
302
+ output_root: Path,
303
+ timeout: int,
304
+ ) -> Dict[str, Any]:
305
+ stdout_log = logs / f"{stem}.stdout.log"
306
+ stderr_log = logs / f"{stem}.stderr.log"
307
+ return {
308
+ "timed_out": bool(result.get("timed_out")),
309
+ "termination": result.get("termination") or {},
310
+ "heartbeat_count": int(result.get("heartbeat_count") or 0),
311
+ "pid": result.get("pid"),
312
+ "cwd": result.get("cwd"),
313
+ "timeout_seconds": timeout,
314
+ "logs": {
315
+ "stdout": rel(stdout_log, output_root),
316
+ "stderr": rel(stderr_log, output_root),
317
+ },
318
+ "diagnostic_warnings": extract_log_diagnostics(stderr_log),
319
+ }
320
+
321
+
322
+ def _write_block_state(
323
+ state_path: Path,
324
+ key: str,
325
+ started_at: str,
326
+ reusable: bool,
327
+ entry: Dict[str, Any],
328
+ ) -> None:
329
+ write_json(state_path, {
330
+ "fingerprint": key,
331
+ "started_at": started_at,
332
+ "finished_at": now_iso(),
333
+ "reusable": reusable,
334
+ "entry": entry,
335
+ })
336
+
337
+
338
+ def _prepare_fresh_run_dir(run_dir: Path) -> None:
339
+ if run_dir.exists():
340
+ shutil.rmtree(run_dir)
341
+ run_dir.mkdir(parents=True, exist_ok=True)
342
+ ensure_msprof_output_permissions(run_dir)
343
+
344
+
345
+ class _CompletedBlockSpec(NamedTuple):
346
+ """Bundled inputs for ``_completed_block_entry`` (G.FNM.03)."""
347
+
348
+ spec: _BlockSpec
349
+ output_root: Path
350
+ result: Mapping[str, Any]
351
+ logs: Path
352
+ stem: str
353
+ timeout: int
354
+
355
+
356
+ def _completed_block_entry(run: _CompletedBlockSpec) -> Tuple[Dict[str, Any], Optional[Path]]:
357
+ spec = run.spec
358
+ output_root = run.output_root
359
+ result = run.result
360
+ logs = run.logs
361
+ stem = run.stem
362
+ timeout = run.timeout
363
+ result_dir = find_latest_result_dir(output_root / spec.relative_dir)
364
+ status = classify_status(int(result["return_code"]), result_dir)
365
+ entry_spec = BlockEntrySpec(
366
+ spec.block_id, spec.metric, status, spec.relative_dir, result_dir, output_root,
367
+ float(result["elapsed_seconds"]), int(result["return_code"]), spec.requested_by,
368
+ )
369
+ entry = build_block_entry(entry_spec)
370
+ entry.update(_execution_fields(result, logs, stem, output_root, timeout))
371
+ return entry, result_dir
372
+
373
+
374
+ class BlockRunSpec(NamedTuple):
375
+ """Bundled inputs for ``execute_block`` (G.FNM.03)."""
376
+
377
+ block_id: str
378
+ metric: str
379
+ cmd: Sequence[str]
380
+ output_root: Path
381
+ internal_dir: Path
382
+ timeout: int
383
+ reuse_existing: bool
384
+ app_fp: Dict[str, Any]
385
+ dry_run: bool
386
+ requested_by: Sequence[str]
387
+ log_stem: Optional[str] = None
388
+ cwd: Optional[Path] = None
389
+ heartbeat_seconds: int = 30
390
+ msprof_fp: Optional[Dict[str, Any]] = None
391
+
392
+
393
+ def execute_block(run: BlockRunSpec) -> Dict[str, Any]:
394
+ spec = _BlockSpec(run.block_id, run.metric, BLOCK_DIRS[run.block_id], run.requested_by)
395
+ run_dir = run.output_root / spec.relative_dir
396
+ state_path = run.internal_dir / "state" / f"{run.block_id}.json"
397
+ key = _block_fingerprint_key(spec.metric, run.cmd, run.app_fp, run.msprof_fp, run.cwd)
398
+
399
+ old = read_json(state_path, {})
400
+ existing = find_latest_result_dir(run_dir)
401
+ if _reuse_match(old, key, run.reuse_existing, existing):
402
+ return _reused_block_entry(spec, existing, run.output_root, run.cwd)
403
+ if run.dry_run:
404
+ return _planned_block_entry(spec, run.output_root, run.timeout, run.cwd)
405
+
406
+ _prepare_fresh_run_dir(run_dir)
407
+
408
+ started_at = now_iso()
409
+ logs = run.internal_dir / "logs"
410
+ logs.mkdir(parents=True, exist_ok=True)
411
+ stem = run.log_stem or run.block_id
412
+ result = rtguard.run_managed_process(rtguard.ManagedProcessSpec(
413
+ run.cmd,
414
+ timeout=run.timeout,
415
+ cwd=run.cwd,
416
+ heartbeat_seconds=run.heartbeat_seconds,
417
+ stdout_log=logs / f"{stem}.stdout.log",
418
+ stderr_log=logs / f"{stem}.stderr.log",
419
+ progress_log=logs / f"{stem}.progress.log",
420
+ heartbeat_label=f"{run.block_id}/{run.metric}",
421
+ ))
422
+
423
+ entry, result_dir = _completed_block_entry(_CompletedBlockSpec(
424
+ spec, run.output_root, result, logs, stem, run.timeout,
425
+ ))
426
+ reusable = (
427
+ entry["status"] in {"ok", "partial"}
428
+ and entry.get("return_code") == 0
429
+ and not entry.get("timed_out")
430
+ and result_dir is not None
431
+ )
432
+ _write_block_state(state_path, key, started_at, reusable, entry)
433
+ return entry
434
+
435
+
436
+ def _raw_suite_planned(spec: _BlockSpec, timeout: int, cwd: Optional[Path], cmd: Sequence[str]) -> Dict[str, Any]:
437
+ return {
438
+ "block_id": "raw_data",
439
+ "display_name": BLOCKS["raw_data"]["display_name"],
440
+ "metric": spec.metric,
441
+ "status": "planned",
442
+ "reason": "Default was unavailable; all exposed standard counters are planned in one command.",
443
+ "requested_by": list(spec.requested_by),
444
+ "relative_dir": spec.relative_dir,
445
+ "result_dir": None,
446
+ "artifacts": {"visualize_data": None, "trace": None, "csv": {}},
447
+ "visual_features": list(BLOCKS["raw_data"]["visual_features"]),
448
+ "elapsed_seconds": 0.0,
449
+ "return_code": None,
450
+ "attempts": [{"metric": spec.metric, "status": "planned", "command": shell_join(cmd)}],
451
+ "timed_out": False,
452
+ "cwd": str(cwd) if cwd else None,
453
+ "timeout_seconds": timeout,
454
+ "collection_passes": 1,
455
+ }
456
+
457
+
458
+ def _raw_suite_status(result: Mapping[str, Any], csv_map: Mapping[str, str]) -> str:
459
+ if result.get("timed_out") or result["return_code"] != 0:
460
+ return "failed"
461
+ required = {f"{name}.csv" for name in RAW_COUNTER_METRICS}
462
+ present = set(csv_map)
463
+ if required.issubset(present):
464
+ return "ok"
465
+ return "partial" if present else "empty"
466
+
467
+
468
+ class _RawSuiteCtx(NamedTuple):
469
+ """Bundled context for the raw counter suite result builder (G.FNM.03)."""
470
+
471
+ spec: _BlockSpec
472
+ metrics: Sequence[str]
473
+ output_root: Path
474
+ timeout: int
475
+ cwd: Optional[Path]
476
+ result: Mapping[str, Any]
477
+
478
+
479
+ def _raw_suite_result(ctx: _RawSuiteCtx) -> Dict[str, Any]:
480
+ spec = ctx.spec
481
+ result = ctx.result
482
+ result_dir = find_latest_result_dir(ctx.output_root / spec.relative_dir)
483
+ csv_map = csv_artifact_map(result_dir, ctx.output_root) if result["return_code"] == 0 else {}
484
+ status = _raw_suite_status(result, csv_map)
485
+ return {
486
+ "block_id": "raw_data",
487
+ "display_name": BLOCKS["raw_data"]["display_name"],
488
+ "metric": spec.metric,
489
+ "status": status,
490
+ "reason": "Default was unavailable; collected all exposed standard counters in one comma-separated command.",
491
+ "requested_by": list(spec.requested_by),
492
+ "relative_dir": spec.relative_dir,
493
+ "result_dir": rel(result_dir, ctx.output_root),
494
+ "artifacts": build_artifacts(result_dir, ctx.output_root),
495
+ "visual_features": list(BLOCKS["raw_data"]["visual_features"]),
496
+ "elapsed_seconds": round(float(result["elapsed_seconds"]), 3),
497
+ "return_code": int(result["return_code"]),
498
+ "attempts": [{
499
+ "metric": spec.metric,
500
+ "metrics": list(ctx.metrics),
501
+ "status": status,
502
+ "return_code": int(result["return_code"]),
503
+ "elapsed_seconds": float(result["elapsed_seconds"]),
504
+ "result_dir": rel(result_dir, ctx.output_root),
505
+ "csv": csv_map,
506
+ "timed_out": bool(result.get("timed_out")),
507
+ "termination": result.get("termination") or {},
508
+ }],
509
+ "timed_out": bool(result.get("timed_out")),
510
+ "cwd": str(ctx.cwd) if ctx.cwd else None,
511
+ "timeout_seconds": ctx.timeout,
512
+ "collection_passes": 1,
513
+ }
514
+
515
+
516
+ def _write_raw_suite_record(
517
+ internal_dir: Path,
518
+ stem: str,
519
+ spec: _BlockSpec,
520
+ cmd: Sequence[str],
521
+ metrics: Sequence[str],
522
+ ) -> None:
523
+ write_command_record(
524
+ internal_dir, stem, spec.metric, cmd,
525
+ {
526
+ "purpose": "One-pass fallback raw counter bundle because Default is not exposed.",
527
+ "metrics": list(metrics),
528
+ "bundle_policy": "documented comma-separated standard counters",
529
+ },
530
+ )
531
+
532
+
533
+ class RawCounterSuiteSpec(NamedTuple):
534
+ """Bundled inputs for ``execute_raw_counter_suite`` (G.FNM.03)."""
535
+
536
+ metrics: Sequence[str]
537
+ msprof: str
538
+ output_root: Path
539
+ internal_dir: Path
540
+ app: Path
541
+ app_args: Sequence[str]
542
+ kernel_name: Optional[str]
543
+ launch_count: int
544
+ supported_options: Sequence[str]
545
+ timeout: int
546
+ dry_run: bool
547
+ requested_by: Sequence[str]
548
+ cwd: Optional[Path] = None
549
+ heartbeat_seconds: int = 30
550
+ profiler_options: Optional[Mapping[str, Any]] = None
551
+
552
+
553
+ def execute_raw_counter_suite(run: RawCounterSuiteSpec) -> Dict[str, Any]:
554
+ """Collect all exposed standard counters in one documented comma bundle.
555
+
556
+ msprof explicitly supports multiple standard counter metrics separated by commas.
557
+ Splitting these counters into seven application replays is both redundant and less
558
+ representative when the application has run-to-run variance.
559
+ """
560
+ spec = _BlockSpec("raw_data", ",".join(run.metrics), BLOCK_DIRS["raw_data"], run.requested_by)
561
+ run_dir = run.output_root / spec.relative_dir
562
+ _prepare_fresh_run_dir(run_dir)
563
+
564
+ cmd = build_msprof_command(MsprofCommandSpec(
565
+ run.msprof, spec.metric, run_dir, run.app, run.app_args, run.kernel_name,
566
+ run.launch_count, supported_options=run.supported_options,
567
+ profiler_options=run.profiler_options,
568
+ ))
569
+ stem = "raw_data_standard_counter_bundle"
570
+ _write_raw_suite_record(run.internal_dir, stem, spec, cmd, run.metrics)
571
+
572
+ if run.dry_run:
573
+ return _raw_suite_planned(spec, run.timeout, run.cwd, cmd)
574
+
575
+ logs = run.internal_dir / "logs"
576
+ result = rtguard.run_managed_process(rtguard.ManagedProcessSpec(
577
+ cmd,
578
+ timeout=run.timeout,
579
+ cwd=run.cwd,
580
+ heartbeat_seconds=run.heartbeat_seconds,
581
+ stdout_log=logs / f"{stem}.stdout.log",
582
+ stderr_log=logs / f"{stem}.stderr.log",
583
+ progress_log=logs / f"{stem}.progress.log",
584
+ heartbeat_label="raw_data/standard-counter-bundle",
585
+ ))
586
+ ctx = _RawSuiteCtx(spec=spec, metrics=run.metrics, output_root=run.output_root, timeout=run.timeout,
587
+ cwd=run.cwd, result=result)
588
+ return _raw_suite_result(ctx)
589
+
590
+
591
+ def build_block_entry(entry: BlockEntrySpec) -> Dict[str, Any]:
592
+ spec = BLOCKS[entry.block_id]
593
+ return {
594
+ "block_id": entry.block_id,
595
+ "display_name": spec["display_name"],
596
+ "metric": entry.metric,
597
+ "status": entry.status,
598
+ "reason": entry.reason,
599
+ "requested_by": list(entry.requested_by),
600
+ "relative_dir": entry.relative_dir,
601
+ "result_dir": rel(entry.result_dir, entry.output_root),
602
+ "artifacts": build_artifacts(entry.result_dir, entry.output_root),
603
+ "visual_features": list(spec["visual_features"]),
604
+ "elapsed_seconds": entry.elapsed,
605
+ "return_code": entry.return_code,
606
+ }
607
+
608
+
609
+ def unavailable_block_entry(block_id: str, requested_by: Sequence[str], reason: str) -> Dict[str, Any]:
610
+ return build_block_entry(BlockEntrySpec(
611
+ block_id=block_id,
612
+ metric=None,
613
+ status="unavailable",
614
+ relative_dir=BLOCK_DIRS[block_id],
615
+ result_dir=None,
616
+ output_root=Path.cwd(), # no artifact paths are produced
617
+ elapsed=0.0,
618
+ return_code=None,
619
+ requested_by=requested_by,
620
+ reason=reason,
621
+ ))
622
+
623
+
624
+ def resolve_requested_features(preset: str, explicit_features: Sequence[str]) -> List[str]:
625
+ if explicit_features:
626
+ raw = [normalize_feature_name(x) for x in explicit_features]
627
+ else:
628
+ raw = list(PRESETS[preset])
629
+ unknown = sorted(set(raw) - set(FEATURE_TO_BLOCK))
630
+ if unknown:
631
+ raise rtguard.UsageError(f"ERROR: unknown feature(s): {', '.join(unknown)}. Use --list-features.")
632
+ out: List[str] = []
633
+ seen: Set[str] = set()
634
+ for feature in raw:
635
+ if feature not in seen:
636
+ seen.add(feature)
637
+ out.append(feature)
638
+ return out
639
+
640
+
641
+ def resolve_blocks(features: Sequence[str], source_stall: str = "auto") -> Tuple[List[str], Dict[str, List[str]]]:
642
+ requested_by: Dict[str, List[str]] = {}
643
+ order: List[str] = []
644
+ for feature in features:
645
+ for block_id in FEATURE_TO_BLOCKS[feature]:
646
+ requested_by.setdefault(block_id, []).append(feature)
647
+ if block_id not in order:
648
+ order.append(block_id)
649
+ # A targeted Source report may consume PCSampling as an optional enhancer.
650
+ # This is a feature dependency, not an assumption about one operator.
651
+ if "source" in features and source_stall != "off":
652
+ requested_by.setdefault("warp_stall", []).append("source:optional-stall-augmentation")
653
+ if "warp_stall" not in order:
654
+ order.append("warp_stall")
655
+ # Stable execution order is the fixed directory order, not user argument order.
656
+ ordered = [b for b in BLOCK_DIRS if b != "discovery" and b in order]
657
+ return ordered, requested_by
658
+
659
+
660
+ def _resolve_explicit_memory_info(operator_root: Path, explicit_path: Path) -> Tuple[Optional[Path], Optional[str]]:
661
+ """Return (candidate, error_reason) for an explicitly supplied sidecar."""
662
+ explicit = explicit_path.expanduser()
663
+ if not explicit.is_absolute():
664
+ explicit = operator_root / explicit
665
+ explicit = explicit.resolve()
666
+ if not explicit.is_file() or explicit.is_symlink():
667
+ return None, f"Explicit memory_info.json is not a usable regular file: {explicit}"
668
+ return explicit, None
669
+
670
+
671
+ def _discover_memory_info_candidates(operator_root: Path, output_root: Path) -> List[Path]:
672
+ output_resolved = output_root.resolve()
673
+ candidates: List[Path] = []
674
+ for candidate in operator_root.rglob("memory_info.json"):
675
+ try:
676
+ resolved = candidate.resolve()
677
+ resolved.relative_to(output_resolved)
678
+ continue
679
+ except ValueError:
680
+ logger.debug("memory_info candidate outside output tree: %s", candidate)
681
+ if candidate.is_file() and not candidate.is_symlink():
682
+ candidates.append(candidate)
683
+ candidates.sort(key=lambda x: (x.stat().st_mtime_ns, str(x)), reverse=True)
684
+ return candidates
685
+
686
+
687
+ def _memory_info_selection_reason(candidate_count: int) -> Optional[str]:
688
+ if candidate_count == 1:
689
+ return None
690
+ return (f"Selected newest of {candidate_count} "
691
+ "memory_info.json files; pass --memory-info to bind an exact sidecar.")
692
+
693
+
694
+ def collect_onchip_memory_artifact(
695
+ operator_root: Path,
696
+ output_root: Path,
697
+ requested_by: Sequence[str],
698
+ explicit_path: Optional[Path] = None,
699
+ ) -> Dict[str, Any]:
700
+ """Copy the exact compiler-generated memory_info.json into the manifest contract."""
701
+ block_id = "onchip_memory"
702
+ block_dir = output_root / BLOCK_DIRS[block_id]
703
+ block_dir.mkdir(parents=True, exist_ok=True)
704
+ if explicit_path is not None:
705
+ explicit, error = _resolve_explicit_memory_info(operator_root, explicit_path)
706
+ if error is not None:
707
+ return unavailable_block_entry(block_id, requested_by, error)
708
+ candidates = [explicit]
709
+ selection_reason: Optional[str] = "Used the explicitly supplied memory_info.json."
710
+ else:
711
+ candidates = _discover_memory_info_candidates(operator_root, output_root)
712
+ if not candidates:
713
+ return unavailable_block_entry(block_id, requested_by, ("No memory_info.json was found in the "
714
+ "selected operator project/build tree. Generate the compiler sidecar before requesting On-Chip "
715
+ "Memory."))
716
+ selection_reason = _memory_info_selection_reason(len(candidates))
717
+ source = candidates[0]
718
+ target = block_dir / "memory_info.json"
719
+ shutil.copy2(source, target)
720
+ return {
721
+ "block_id": block_id,
722
+ "display_name": BLOCKS[block_id]["display_name"],
723
+ "metric": None,
724
+ "status": "ok",
725
+ "reason": selection_reason,
726
+ "requested_by": list(requested_by),
727
+ "relative_dir": BLOCK_DIRS[block_id],
728
+ "result_dir": BLOCK_DIRS[block_id],
729
+ "artifacts": {"visualize_data": None, "trace": None, "csv": {}, "memory_info": rel(target, output_root)},
730
+ "visual_features": list(BLOCKS[block_id]["visual_features"]),
731
+ "elapsed_seconds": 0.0,
732
+ "return_code": 0,
733
+ "coverage": {"memory_info": True, "candidate_count": len(candidates)},
734
+ }
735
+
736
+
737
+ def write_block_reference(output_root: Path, block_id: str, provider_block: str) -> None:
738
+ block_dir = output_root / BLOCK_DIRS[block_id]
739
+ block_dir.mkdir(parents=True, exist_ok=True)
740
+ write_json(block_dir / "block_reference.json", {
741
+ "schema": CONTRACT_SCHEMA,
742
+ "block_id": block_id,
743
+ "provider_block": provider_block,
744
+ "reason": ("The provider block already produced the required artifact set; no duplicate msprof replay "
745
+ "was executed."),
746
+ })
747
+
748
+
749
+ def alias_block_entry(
750
+ block_id: str,
751
+ provider: Dict[str, Any],
752
+ requested_by: Sequence[str],
753
+ output_root: Path,
754
+ ) -> Dict[str, Any]:
755
+ write_block_reference(output_root, block_id, provider["block_id"])
756
+ spec = BLOCKS[block_id]
757
+ return {
758
+ "block_id": block_id,
759
+ "display_name": spec["display_name"],
760
+ "metric": provider.get("metric"),
761
+ "status": "aliased",
762
+ "reason": f"Reused artifacts from block '{provider['block_id']}'.",
763
+ "requested_by": list(requested_by),
764
+ "relative_dir": BLOCK_DIRS[block_id],
765
+ "result_dir": provider.get("result_dir"),
766
+ "provider_block": provider["block_id"],
767
+ "artifacts": provider.get("artifacts", {"visualize_data": None, "trace": None, "csv": {}}),
768
+ "visual_features": list(spec["visual_features"]),
769
+ "elapsed_seconds": 0.0,
770
+ "return_code": None,
771
+ }
772
+
773
+
774
+ def semantic_alias_candidate(
775
+ block_id: str,
776
+ provider: Dict[str, Any],
777
+ requested_by: Sequence[str],
778
+ output_root: Path,
779
+ ) -> Optional[Dict[str, Any]]:
780
+ """Return a validated cross-metric alias when provider artifacts satisfy block semantics.
781
+
782
+ This is intentionally stricter than matching metric names. For example, a
783
+ Roofline replay already carries the Default CSV suite and may also contain
784
+ the compute/memory structures needed by the Memory Detail renderer. When
785
+ that semantic validation succeeds, a separate Default replay is redundant.
786
+ """
787
+ if provider.get("status") not in {"ok", "reused", "partial", "aliased"}:
788
+ return None
789
+ alias = alias_block_entry(block_id, provider, requested_by, output_root)
790
+ alias = validate_block_entry(block_id, alias, output_root)
791
+ if alias.get("status") not in {"ok", "reused", "partial", "aliased"}:
792
+ return None
793
+ alias["semantic_alias"] = True
794
+ alias["collection_passes_saved"] = 1
795
+ alias["reason"] = (
796
+ f"Reused semantically complete artifacts from block '{provider['block_id']}' "
797
+ f"({provider.get('metric')}); no redundant {block_id} replay was executed."
798
+ )
799
+ return alias
800
+
801
+
802
+ def _preflight_age(previous: Mapping[str, Any], preflight_path: Path) -> float:
803
+ created_at = previous.get("created_at")
804
+ try:
805
+ return max(0.0, time.time() - float(created_at))
806
+ except (TypeError, ValueError):
807
+ return max(0.0, time.time() - preflight_path.stat().st_mtime)
808
+
809
+
810
+ def _cache_identity_match(
811
+ previous: Mapping[str, Any],
812
+ expected_command: str,
813
+ app_fp: Dict[str, Any],
814
+ cwd: Path,
815
+ ) -> bool:
816
+ return (
817
+ previous.get("status") in {"ok", "reused"}
818
+ and previous.get("command") == expected_command
819
+ and previous.get("cwd") == str(cwd)
820
+ and previous.get("app_fingerprint") == app_fp
821
+ )
822
+
823
+
824
+ def _cache_payload_fresh(
825
+ previous_result: Path,
826
+ previous_csv: Path,
827
+ age_seconds: float,
828
+ cache_seconds: int,
829
+ ) -> bool:
830
+ return (
831
+ age_seconds <= cache_seconds
832
+ and previous_result.is_dir()
833
+ and previous_csv.is_file()
834
+ and previous_csv.stat().st_size > 0
835
+ )
836
+
837
+
838
+ class _ReusePreflightSpec(NamedTuple):
839
+ """Bundled inputs for ``_try_reuse_preflight`` (G.FNM.03)."""
840
+
841
+ internal_dir: Path
842
+ output_root: Path
843
+ expected_command: str
844
+ app_fp: Dict[str, Any]
845
+ cwd: Path
846
+ cache_seconds: int
847
+
848
+
849
+ def _try_reuse_preflight(spec: _ReusePreflightSpec) -> Optional[Dict[str, Any]]:
850
+ internal_dir = spec.internal_dir
851
+ output_root = spec.output_root
852
+ expected_command = spec.expected_command
853
+ app_fp = spec.app_fp
854
+ cwd = spec.cwd
855
+ cache_seconds = spec.cache_seconds
856
+ preflight_path = internal_dir / "preflight.json"
857
+ if cache_seconds <= 0 or not preflight_path.is_file():
858
+ return None
859
+ previous = read_json(preflight_path, {})
860
+ # Age comes from the payload creation time, not the file mtime: rewrites
861
+ # or unrelated touches of preflight.json must not extend the TTL forever.
862
+ age_seconds = _preflight_age(previous, preflight_path)
863
+ previous_result = output_root / str(previous.get("result_dir") or "")
864
+ previous_csv = output_root / str(previous.get("op_basic_info") or "")
865
+ identity_ok = _cache_identity_match(previous, expected_command, app_fp, cwd)
866
+ payload_ok = _cache_payload_fresh(previous_result, previous_csv, age_seconds, cache_seconds)
867
+ if not (identity_ok and payload_ok):
868
+ return None
869
+ original_elapsed = float(previous.get("original_elapsed_seconds") or previous.get("elapsed_seconds") or 0.0)
870
+ reused = dict(previous)
871
+ reused.update({
872
+ "status": "reused",
873
+ "reason": f"Reused successful preflight from {age_seconds:.1f}s ago (TTL {cache_seconds}s).",
874
+ "elapsed_seconds": 0.0,
875
+ "original_elapsed_seconds": original_elapsed,
876
+ "cache_age_seconds": round(age_seconds, 3),
877
+ "cache_seconds": cache_seconds,
878
+ })
879
+ # Do not rewrite preflight.json on reuse; the on-disk payload keeps
880
+ # its original created_at so the cache actually expires.
881
+ return reused
882
+
883
+
884
+ def _planned_preflight_result(internal_dir: Path, cmd: Sequence[str], cwd: Path) -> Dict[str, Any]:
885
+ result = {
886
+ "status": "planned",
887
+ "return_code": None,
888
+ "timed_out": False,
889
+ "elapsed_seconds": 0.0,
890
+ "command": shell_join(cmd),
891
+ "cwd": str(cwd),
892
+ }
893
+ write_json(internal_dir / "preflight.json", result)
894
+ return result
895
+
896
+
897
+ def _canary_failure_reason(
898
+ proc: Mapping[str, Any],
899
+ basic_csv: Optional[Path],
900
+ combined_output: str,
901
+ timeout: int,
902
+ ) -> Optional[str]:
903
+ if proc.get("timed_out"):
904
+ return f"BasicInfo canary exceeded {timeout}s; collection was circuit-broken before formal feature runs."
905
+ if proc["return_code"] != 0:
906
+ return f"BasicInfo canary exited with return code {proc['return_code']}."
907
+ if basic_csv is not None:
908
+ return None
909
+ reason = "BasicInfo canary returned zero but produced no non-empty OpBasicInfo.csv."
910
+ if "writable by any other users or group users" in combined_output:
911
+ reason += (
912
+ " msprof rejected the output directory as group/other-writable; "
913
+ "strip group/other write bits (chmod -R go-w) on the output tree and rerun."
914
+ )
915
+ return reason
916
+
917
+
918
+ class _CanaryCtx(NamedTuple):
919
+ """Bundled context for the preflight canary execution (G.FNM.03)."""
920
+
921
+ internal_dir: Path
922
+ output_root: Path
923
+ cmd: Sequence[str]
924
+ timeout: int
925
+ cwd: Path
926
+ heartbeat_seconds: int
927
+ app_fp: Dict[str, Any]
928
+ cache_seconds: int
929
+
930
+
931
+ def _execute_canary(ctx: _CanaryCtx) -> Dict[str, Any]:
932
+ logs = ctx.internal_dir / "logs"
933
+ proc = rtguard.run_managed_process(rtguard.ManagedProcessSpec(
934
+ ctx.cmd,
935
+ timeout=ctx.timeout,
936
+ cwd=ctx.cwd,
937
+ heartbeat_seconds=ctx.heartbeat_seconds,
938
+ stdout_log=logs / "preflight_canary.stdout.log",
939
+ stderr_log=logs / "preflight_canary.stderr.log",
940
+ progress_log=logs / "preflight_canary.progress.log",
941
+ heartbeat_label="preflight/BasicInfo",
942
+ ))
943
+ preflight_root = ctx.internal_dir / "preflight_output"
944
+ result_dir = find_latest_result_dir(preflight_root)
945
+ basic_csv = find_latest_file(result_dir, "OpBasicInfo.csv")
946
+ status = "ok" if proc["return_code"] == 0 and basic_csv is not None else "failed"
947
+ combined_output = f"{proc.get('stdout', '')}\n{proc.get('stderr', '')}"
948
+ reason = _canary_failure_reason(proc, basic_csv, combined_output, ctx.timeout)
949
+ result = {
950
+ "status": status,
951
+ "reason": reason,
952
+ "return_code": proc["return_code"],
953
+ "timed_out": bool(proc.get("timed_out")),
954
+ "elapsed_seconds": proc["elapsed_seconds"],
955
+ "pid": proc.get("pid"),
956
+ "termination": proc.get("termination") or {},
957
+ "heartbeat_count": proc.get("heartbeat_count") or 0,
958
+ "command": shell_join(ctx.cmd),
959
+ "cwd": str(ctx.cwd),
960
+ "created_at": time.time(),
961
+ "app_fingerprint": ctx.app_fp,
962
+ "finished_at": now_iso(),
963
+ "cache_seconds": ctx.cache_seconds,
964
+ "result_dir": rel(result_dir, ctx.output_root),
965
+ "op_basic_info": rel(basic_csv, ctx.output_root),
966
+ }
967
+ if status == "failed":
968
+ excerpt_lines = [line for line in combined_output.strip().splitlines() if line.strip()]
969
+ result["log_excerpt"] = "\n".join(excerpt_lines[-20:])
970
+ write_json(ctx.internal_dir / "preflight.json", result)
971
+ return result
972
+
973
+
974
+ class PreflightCanarySpec(NamedTuple):
975
+ """Bundled inputs for ``run_preflight_canary`` (G.FNM.03)."""
976
+
977
+ msprof: str
978
+ metric: str
979
+ output_root: Path
980
+ internal_dir: Path
981
+ app: Path
982
+ app_args: Sequence[str]
983
+ kernel_name: Optional[str]
984
+ supported_options: Sequence[str]
985
+ timeout: int
986
+ cwd: Path
987
+ heartbeat_seconds: int
988
+ dry_run: bool
989
+ profiler_options: Optional[Mapping[str, Any]] = None
990
+ reuse_existing: bool = False
991
+ cache_seconds: int = 0
992
+
993
+
994
+ def run_preflight_canary(canary: PreflightCanarySpec) -> Dict[str, Any]:
995
+ preflight_root = canary.internal_dir / "preflight_output"
996
+ cmd = build_msprof_command(MsprofCommandSpec(
997
+ canary.msprof, canary.metric, preflight_root, canary.app, canary.app_args, canary.kernel_name, 1,
998
+ supported_options=canary.supported_options,
999
+ profiler_options=canary.profiler_options,
1000
+ ))
1001
+ write_command_record(canary.internal_dir, "preflight_canary", canary.metric, cmd, {
1002
+ "purpose": "Short BasicInfo device canary before any expensive feature replay.",
1003
+ "output_directory": "_internal/preflight_output",
1004
+ "timeout_seconds": canary.timeout,
1005
+ "application_cwd": str(canary.cwd),
1006
+ "cache_seconds": canary.cache_seconds,
1007
+ })
1008
+ app_fp = fingerprint(canary.app)
1009
+ if canary.reuse_existing:
1010
+ reused = _try_reuse_preflight(_ReusePreflightSpec(canary.internal_dir, canary.output_root,
1011
+ shell_join(cmd), app_fp, canary.cwd, canary.cache_seconds))
1012
+ if reused is not None:
1013
+ return reused
1014
+ if preflight_root.exists():
1015
+ shutil.rmtree(preflight_root)
1016
+ preflight_root.mkdir(parents=True, exist_ok=True)
1017
+ ensure_msprof_output_permissions(preflight_root)
1018
+ if canary.dry_run:
1019
+ return _planned_preflight_result(canary.internal_dir, cmd, canary.cwd)
1020
+ ctx = _CanaryCtx(canary.internal_dir, canary.output_root, cmd, canary.timeout, canary.cwd,
1021
+ canary.heartbeat_seconds, app_fp, canary.cache_seconds)
1022
+ return _execute_canary(ctx)
1023
+
1024
+
1025
+ def can_promote_preflight_to_discovery(
1026
+ preflight: Mapping[str, Any],
1027
+ *,
1028
+ kernel_name: Optional[str],
1029
+ launch_count: int,
1030
+ dry_run: bool,
1031
+ ) -> bool:
1032
+ """Decide whether the one-launch BasicInfo canary is sufficient discovery.
1033
+
1034
+ Reuse is safe when formal collection targets only one launch, or when the
1035
+ kernel selector names one exact target. Multi-launch/wildcard discovery
1036
+ still performs its own wider BasicInfo pass.
1037
+ """
1038
+ return bool(
1039
+ not dry_run
1040
+ and preflight.get("status") in {"ok", "reused"}
1041
+ and (launch_count == 1 or is_single_exact_kernel_filter(kernel_name))
1042
+ )
1043
+
1044
+
1045
+ def promote_preflight_to_discovery(
1046
+ preflight: Mapping[str, Any], output_root: Path, metric: str,
1047
+ ) -> Optional[Dict[str, Any]]:
1048
+ """Reuse the successful BasicInfo canary as discovery for one exact target kernel."""
1049
+ result_rel = preflight.get("result_dir")
1050
+ if preflight.get("status") not in {"ok", "reused"} or not result_rel:
1051
+ return None
1052
+ source = output_root / str(result_rel)
1053
+ if not source.is_dir():
1054
+ return None
1055
+ discovery_root = output_root / BLOCK_DIRS["discovery"]
1056
+ if discovery_root.exists():
1057
+ shutil.rmtree(discovery_root)
1058
+ discovery_root.mkdir(parents=True, exist_ok=True)
1059
+ destination = discovery_root / source.name
1060
+ shutil.copytree(source, destination)
1061
+ entry = build_block_entry(BlockEntrySpec(
1062
+ "discovery", metric, "reused", BLOCK_DIRS["discovery"], destination,
1063
+ output_root, 0.0, 0, ["discovery"],
1064
+ reason="Promoted the successful BasicInfo preflight result; no second BasicInfo replay was needed.",
1065
+ ))
1066
+ entry["provider"] = "preflight_canary"
1067
+ entry["collection_passes_saved"] = 1
1068
+ return entry
1069
+
1070
+
1071
+ def append_skipped_after_circuit_breaker(
1072
+ block_entries: List[Dict[str, Any]],
1073
+ requested_blocks: Sequence[str],
1074
+ requested_by: Mapping[str, Sequence[str]],
1075
+ executed: Mapping[str, Dict[str, Any]],
1076
+ reason: str,
1077
+ ) -> None:
1078
+ for block_id in requested_blocks:
1079
+ if block_id in executed:
1080
+ continue
1081
+ block_entries.append(unavailable_block_entry(
1082
+ block_id,
1083
+ requested_by.get(block_id, []),
1084
+ f"Skipped by circuit breaker: {reason}",
1085
+ ))
1086
+
1087
+
1088
+ class ManifestSpec(NamedTuple):
1089
+ """Bundled inputs for ``build_manifest`` (G.FNM.03)."""
1090
+
1091
+ preset: str
1092
+ selection_mode: str
1093
+ requested_features: Sequence[str]
1094
+ supported: Sequence[str]
1095
+ supported_options: Sequence[str]
1096
+ op_type: str
1097
+ debug_symbols: bool
1098
+ simt_evidence: bool
1099
+ kernel_scale_instrumentation: bool
1100
+ build_provenance: Dict[str, Any]
1101
+ environment_context: Dict[str, Any]
1102
+ blocks: Sequence[Dict[str, Any]]
1103
+ run_status: str = "completed"
1104
+ run_reason: Optional[str] = None
1105
+ preflight: Optional[Dict[str, Any]] = None
1106
+ timeout_profile: Optional[Dict[str, int]] = None
1107
+ executable_context: Optional[Dict[str, Any]] = None
1108
+
1109
+
1110
+ def build_manifest(manifest: ManifestSpec) -> Dict[str, Any]:
1111
+ block_map = {b["block_id"]: b for b in manifest.blocks}
1112
+ return {
1113
+ "schema": CONTRACT_SCHEMA,
1114
+ "collector_version": VERSION,
1115
+ "created_at": now_iso(),
1116
+ "path_rule": "All artifact paths are POSIX-style paths relative to this manifest.",
1117
+ "default_behavior": "No --feature means preset=complete; duplicate Default replays are automatically aliased.",
1118
+ "preset": manifest.preset,
1119
+ "selection_mode": manifest.selection_mode,
1120
+ "requested_features": list(manifest.requested_features),
1121
+ "supported_metrics": list(manifest.supported),
1122
+ "supported_options": list(manifest.supported_options),
1123
+ "detected_capabilities": {
1124
+ "operator_type": manifest.op_type or "unknown",
1125
+ "debug_symbols": manifest.debug_symbols,
1126
+ "simt_evidence": manifest.simt_evidence,
1127
+ "kernel_scale_instrumentation": manifest.kernel_scale_instrumentation,
1128
+ },
1129
+ "build_provenance": manifest.build_provenance,
1130
+ "environment_context": manifest.environment_context,
1131
+ "run_status": manifest.run_status,
1132
+ "run_reason": manifest.run_reason,
1133
+ "preflight": manifest.preflight or {},
1134
+ "timeout_profile": manifest.timeout_profile or {},
1135
+ "executable_context": manifest.executable_context or {},
1136
+ "block_directories": BLOCK_DIRS,
1137
+ "feature_to_block": FEATURE_TO_BLOCK,
1138
+ "visualization_contract": visualization_contract(),
1139
+ "blocks": block_map,
1140
+ }
1141
+
1142
+
1143
+ def _add_target_arguments(parser: argparse.ArgumentParser) -> None:
1144
+ parser.add_argument("--operator-path", help="Operator sample/project root.")
1145
+ parser.add_argument("--output", help="Collection root; fixed relative feature directories are created here.")
1146
+ parser.add_argument("--app", help="Executable path; relative paths are resolved from --operator-path.")
1147
+ parser.add_argument("--app-cwd", help=("Application working directory; relative paths resolve from "
1148
+ "--operator-path. Defaults to the operator root so ./input resources are stable."))
1149
+ parser.add_argument("--kernel-name", help="Kernel filter. Omit for single-operator samples.")
1150
+ parser.add_argument("--op-type", help="Override discovered operator type.")
1151
+ parser.add_argument("--simt", choices=["auto", "on", "off"], default="auto", help=("SIMT evidence "
1152
+ "override for Warp Stall gating."))
1153
+ parser.add_argument("--source-stall", choices=["auto", "on", "off"], default="auto", help=("Collect "
1154
+ "PCSampling as an optional Source Explorer stall overlay; auto/on attempt it when Source is requested, "
1155
+ "off disables it."))
1156
+ parser.add_argument("--kernel-scale", choices=["auto", "on", "off"], default="auto", help=("KernelScale "
1157
+ "instrumentation override."))
1158
+ parser.add_argument("--app-arg", action="append", default=[], help="Repeatable application argument.")
1159
+ parser.add_argument("--msprof", default="msprof")
1160
+
1161
+
1162
+ def _add_environment_arguments(parser: argparse.ArgumentParser) -> None:
1163
+ parser.add_argument("--env-profile", help=("Reusable CANN/msOpProf environment profile. Relative paths "
1164
+ "resolve from --operator-path."))
1165
+ parser.add_argument("--env-profile-mode", choices=["auto",
1166
+ "readonly", "refresh", "off"], default="auto", help=("auto=reuse "
1167
+ "valid profile or refresh; readonly=require valid; refresh=re-probe and overwrite; off=ignore profile."))
1168
+ parser.add_argument("--env-source", action="append", default=[], help=("Repeatable shell source/init "
1169
+ "command used only when creating or refreshing the environment profile."))
1170
+ parser.add_argument("--env-var", action="append", default=[], metavar="KEY=VALUE", help=("Repeatable "
1171
+ "non-secret environment value to apply and save in the reusable profile."))
1172
+ parser.add_argument("--env-source-timeout", type=int, default=120, help=("Timeout for environment "
1173
+ "source/init commands."))
1174
+
1175
+
1176
+ def _add_feature_arguments(parser: argparse.ArgumentParser) -> None:
1177
+ parser.add_argument("--preset", choices=sorted(PRESETS), default="complete", help=("Default complete; "
1178
+ "ignored when --feature is supplied."))
1179
+ parser.add_argument("--feature", action="append", default=[], help=("Repeatable targeted visual feature, "
1180
+ "e.g. cache, timeline, raw-data."))
1181
+ parser.add_argument("--memory-info", help=("Exact memory_info.json for On-Chip Memory collection; "
1182
+ "relative paths resolve from --operator-path."))
1183
+ parser.add_argument("--list-features", action="store_true", help="List available user-facing features and exit.")
1184
+ parser.add_argument("--explain", metavar="FEATURE", help=("Explain command, data, visualization, and use "
1185
+ "cases for one feature and exit."))
1186
+
1187
+
1188
+ def _add_profiler_option_arguments(parser: argparse.ArgumentParser) -> None:
1189
+ parser.add_argument("--launch-count", type=int, default=1)
1190
+ parser.add_argument("--launch-skip-before-match", type=int, help=("Skip this many launched operators "
1191
+ "before matching/collecting."))
1192
+ parser.add_argument("--replay-mode", choices=["kernel", "application", "range"], help=("Explicit msprof "
1193
+ "replay mode. Omit to use the installed CLI default (normally kernel)."))
1194
+ parser.add_argument("--warm-up", type=int, help="Profiler warm-up count; installed CLI default is normally 5.")
1195
+ parser.add_argument("--kill", choices=["on", "off"], help=("Stop the user application after "
1196
+ "--launch-count is reached. Omit for profiler default off."))
1197
+ parser.add_argument("--mstx", choices=["on", "off"], help="Enable or disable mstx range selection.")
1198
+ parser.add_argument("--mstx-include", help="Pipe-separated mstx message filter; requires --mstx=on.")
1199
+ parser.add_argument("--dump", choices=["on", "off"], help="TimelineDetail simulator dump control.")
1200
+ parser.add_argument("--core-id", help="TimelineDetail logical-core filter, e.g. 0|31.")
1201
+ parser.add_argument("--instr-timeline-pipe", help="Optional pipe filter for instrTimeLine, e.g. mte1|vector.")
1202
+ parser.add_argument("--debug-rebuild-command", help=("Optional shell command executed only when Source is "
1203
+ "requested and debug symbols are missing."))
1204
+ parser.add_argument("--debug-rebuild-timeout", type=int, default=1800)
1205
+ parser.add_argument("--build-config", action="append", default=[], metavar="KEY=VALUE", help=("Repeatable "
1206
+ "build provenance metadata, e.g. SCENARIO_NUM=0."))
1207
+ parser.add_argument("--validation-note", action="append", default=[], help=("Repeatable "
1208
+ "validation/provenance note stored in the manifest."))
1209
+
1210
+
1211
+ def _add_runtime_arguments(parser: argparse.ArgumentParser) -> None:
1212
+ parser.add_argument("--timeout", type=int, default=1200, help=("Global hard timeout ceiling for one "
1213
+ "profiler command."))
1214
+ parser.add_argument("--preflight-mode", choices=["auto", "on", "off"], default="auto", help=("Run a short "
1215
+ "BasicInfo device canary before formal collection."))
1216
+ parser.add_argument("--preflight-timeout", type=int, default=60, help=("Canary timeout; a failure "
1217
+ "circuit-breaks the run."))
1218
+ parser.add_argument("--preflight-cache-seconds", type=int, default=300, help=("Reuse an identical "
1219
+ "successful canary from the same completed output for this many seconds; 0 disables."))
1220
+ parser.add_argument("--heartbeat-seconds", type=int, default=30, help=("Emit progress heartbeats while "
1221
+ "profiler commands are still running; 0 disables."))
1222
+ parser.add_argument("--circuit-breaker", action=argparse.BooleanOptionalAction, default=True, help=("Abort "
1223
+ "remaining blocks after any command timeout."))
1224
+ parser.add_argument("--adaptive-timeout", action=argparse.BooleanOptionalAction, default=True, help=("Use "
1225
+ "feature-class timeout floors scaled by observed canary cost."))
1226
+ parser.add_argument("--block-timeout", action="append", default=[], metavar="BLOCK=SECONDS", help=("Repeatable "
1227
+ "per-block timeout override."))
1228
+ parser.add_argument("--reuse-existing", action=argparse.BooleanOptionalAction, default=True)
1229
+ parser.add_argument("--independent-default", action="store_true", help=("Force a separate "
1230
+ "MemoryDetail/Default replay even when Roofline is semantically reusable; use for cross-replay "
1231
+ "diagnostics, not the minimum-pass default."))
1232
+ parser.add_argument("--clean", action="store_true")
1233
+ parser.add_argument("--strict", action="store_true", help=("Exit non-zero when any explicitly requested "
1234
+ "block is unavailable, failed, or semantically empty."))
1235
+ parser.add_argument("--dry-run", action="store_true", help=("Write plan/manifest without executing "
1236
+ "profiling commands."))
1237
+
1238
+
1239
+ def build_parser() -> argparse.ArgumentParser:
1240
+ parser = argparse.ArgumentParser(
1241
+ description="Collect msOpProf feature blocks into a fixed visualization-ready directory contract."
1242
+ )
1243
+ _add_target_arguments(parser)
1244
+ _add_environment_arguments(parser)
1245
+ _add_feature_arguments(parser)
1246
+ _add_profiler_option_arguments(parser)
1247
+ _add_runtime_arguments(parser)
1248
+ return parser
1249
+
1250
+
1251
+ def _validate_args(parser: argparse.ArgumentParser, args: argparse.Namespace) -> None:
1252
+ if args.timeout <= 0 or args.preflight_timeout <= 0:
1253
+ parser.error("--timeout and --preflight-timeout must be positive.")
1254
+ if args.heartbeat_seconds < 0:
1255
+ parser.error("--heartbeat-seconds cannot be negative.")
1256
+ if args.preflight_cache_seconds < 0:
1257
+ parser.error("--preflight-cache-seconds cannot be negative.")
1258
+ if not 1 <= args.launch_count <= 5000:
1259
+ parser.error("--launch-count must be in [1, 5000].")
1260
+ if args.launch_skip_before_match is not None and not 0 <= args.launch_skip_before_match <= 1000:
1261
+ parser.error("--launch-skip-before-match must be in [0, 1000].")
1262
+ if args.warm_up is not None and not 0 <= args.warm_up <= 500:
1263
+ parser.error("--warm-up must be in [0, 500].")
1264
+
1265
+
1266
+ def _plan_requested(run: Any) -> None:
1267
+ args = run.args
1268
+ run.requested_features = resolve_requested_features(args.preset, args.feature)
1269
+ run.requested_blocks, run.requested_by = resolve_blocks(run.requested_features, source_stall=args.source_stall)
1270
+ run.user_build_config = parse_key_value(args.build_config, "--build-config")
1271
+ run.explicit_environment = envctx.parse_key_value(args.env_var, "--env-var")
1272
+ run.block_timeout_overrides = parse_block_timeouts(args.block_timeout)
1273
+ run.profiler_options = {
1274
+ "launch_skip_before_match": args.launch_skip_before_match,
1275
+ "replay_mode": args.replay_mode,
1276
+ "warm_up": args.warm_up,
1277
+ "kill": args.kill,
1278
+ "mstx": args.mstx,
1279
+ "mstx_include": args.mstx_include,
1280
+ "dump": args.dump,
1281
+ "core_id": args.core_id,
1282
+ }
1283
+ # Discovery must use the same operator-selection filters as formal
1284
+ # collection, while replay-specific or expensive feature options remain
1285
+ # isolated to their intended blocks.
1286
+ run.selection_profiler_options = {
1287
+ "launch_skip_before_match": args.launch_skip_before_match,
1288
+ "mstx": args.mstx,
1289
+ "mstx_include": args.mstx_include,
1290
+ }
1291
+
1292
+
1293
+ def _prepare_output(run: Any) -> None:
1294
+ args = run.args
1295
+ run.operator_root = Path(args.operator_path).expanduser().resolve()
1296
+ run.output_root = Path(args.output).expanduser().resolve()
1297
+ if not run.operator_root.exists():
1298
+ raise rtguard.UsageError(f"ERROR: operator path does not exist: {run.operator_root}")
1299
+ if args.clean and run.output_root.exists():
1300
+ shutil.rmtree(run.output_root)
1301
+ run.output_root.mkdir(parents=True, exist_ok=True)
1302
+ run.internal_dir = run.output_root / "_internal"
1303
+ run.internal_dir.mkdir(parents=True, exist_ok=True)
1304
+ reuse_allowed, run.reuse_reason = previous_run_allows_reuse(run.output_root)
1305
+ run.effective_reuse = bool(args.reuse_existing and reuse_allowed)
1306
+ run.run_guard = rtguard.RunStateGuard(run.internal_dir / "run_state.json", {
1307
+ "collector_version": VERSION,
1308
+ "operator_path": str(run.operator_root),
1309
+ "output": str(run.output_root),
1310
+ "requested_features": run.requested_features,
1311
+ "reuse_requested": bool(args.reuse_existing),
1312
+ "reuse_enabled": run.effective_reuse,
1313
+ "reuse_reason": run.reuse_reason,
1314
+ })
1315
+
1316
+ # Ensure every fixed block directory exists, even when the block is unavailable.
1317
+ for block_id, dirname in BLOCK_DIRS.items():
1318
+ if block_id != "discovery":
1319
+ (run.output_root / dirname).mkdir(parents=True, exist_ok=True)
1320
+
1321
+ # msprof refuses to write into group/other-writable directories and exits 0
1322
+ # with zero artifacts; sanitize before any profiler command runs.
1323
+ permission_fixes = sanitize_output_tree(run.output_root)
1324
+ write_json(run.internal_dir / "output_permission_fixes.json", {
1325
+ "schema": "msopprof-output-permissions/v1",
1326
+ "checked_at": now_iso(),
1327
+ "fix_count": len(permission_fixes),
1328
+ "fixes": permission_fixes,
1329
+ })
1330
+
1331
+
1332
+ def _resolve_environment(run: Any) -> None:
1333
+ args = run.args
1334
+ env_profile_path = envctx.resolve_profile_path(args.env_profile, run.operator_root)
1335
+ phase_started = time.perf_counter()
1336
+ environment_result = envctx.prepare_environment(envctx.EnvironmentRequest(
1337
+ profile_path=env_profile_path,
1338
+ mode=args.env_profile_mode,
1339
+ source_commands=args.env_source,
1340
+ source_cwd=run.operator_root,
1341
+ requested_msprof=args.msprof,
1342
+ source_timeout=args.env_source_timeout,
1343
+ parse_supported_metrics=parse_supported_metrics,
1344
+ parse_supported_options=parse_supported_options,
1345
+ explicit_environment=run.explicit_environment,
1346
+ ))
1347
+ run.environment_context = envctx.public_context(environment_result)
1348
+ run.local_phase_seconds["environment_resolution"] = time.perf_counter() - phase_started
1349
+ write_json(run.internal_dir / "environment_profile_status.json", run.environment_context)
1350
+
1351
+ run.msprof = str(environment_result["msprof"])
1352
+ help_text = str(environment_result.get("help_text") or "")
1353
+ # Toolchain identity participates in block reuse: a different msprof binary
1354
+ # or CLI surface must invalidate cached command state and force a re-run.
1355
+ run.msprof_fp = {"path": run.msprof, "help_sha256": envctx.text_sha256(help_text)}
1356
+ (run.internal_dir / "msprof_op_help.txt").write_text(help_text, encoding="utf-8")
1357
+ run.supported = list(environment_result.get("supported_metrics") or [])
1358
+ run.supported_options = list(environment_result.get("supported_options") or [])
1359
+ run.basic_info_supported = any(
1360
+ normalize_metric_token(x) == normalize_metric_token("BasicInfo") for x in run.supported
1361
+ )
1362
+
1363
+
1364
+ def _executable_context_payload(selection: Mapping[str, Any], app: Path, app_cwd: Path) -> Dict[str, Any]:
1365
+ context = {k: v for k, v in selection.items() if k != "selected"}
1366
+ context["selected"] = str(app)
1367
+ context["application_cwd"] = str(app_cwd)
1368
+ context["relative_resource_hints"] = detect_relative_resource_hints(app, app_cwd)
1369
+ context["test_like_executable_warning"] = test_like_executable_warning(app)
1370
+ return context
1371
+
1372
+
1373
+ def _resolve_executable(run: Any) -> None:
1374
+ args = run.args
1375
+ phase_started = time.perf_counter()
1376
+ run.executable_selection = resolve_executable_details(run.operator_root, args.app)
1377
+ run.app = Path(run.executable_selection["selected"])
1378
+ run.app_cwd = resolve_app_cwd(run.operator_root, args.app_cwd)
1379
+ run.executable_context = _executable_context_payload(run.executable_selection, run.app, run.app_cwd)
1380
+ write_json(run.internal_dir / "executable_selection.json", run.executable_context)
1381
+ run.local_phase_seconds["executable_resolution"] = time.perf_counter() - phase_started
1382
+
1383
+
1384
+ def _check_capabilities(run: Any) -> None:
1385
+ args = run.args
1386
+ if not run.basic_info_supported and not args.kernel_name and not args.op_type:
1387
+ raise rtguard.UsageError(
1388
+ "ERROR: BasicInfo is not exposed and neither --kernel-name nor --op-type was supplied."
1389
+ )
1390
+ if "--aic-metrics" not in run.supported_options or "--output" not in run.supported_options:
1391
+ raise rtguard.UsageError(("ERROR: installed msprof op CLI does not expose the required --aic-metrics/--output "
1392
+ "interface."))
1393
+
1394
+
1395
+ def _run_preflight(run: Any) -> Optional[int]:
1396
+ args = run.args
1397
+ run.preflight = {"status": "skipped", "reason": "Preflight disabled or BasicInfo unavailable."}
1398
+ if args.preflight_mode == "on" and not run.basic_info_supported:
1399
+ run.run_guard.finalize("aborted", "Preflight was required but BasicInfo is not exposed.")
1400
+ raise rtguard.UsageError("ERROR: --preflight-mode=on requires BasicInfo support.")
1401
+ if not run.basic_info_supported or args.preflight_mode == "off":
1402
+ return None
1403
+ basic_metric = next(x for x in run.supported if normalize_metric_token(x) == normalize_metric_token("BasicInfo"))
1404
+ run.preflight = run_preflight_canary(PreflightCanarySpec(
1405
+ msprof=run.msprof, metric=basic_metric, output_root=run.output_root, internal_dir=run.internal_dir,
1406
+ app=run.app, app_args=args.app_arg, kernel_name=args.kernel_name,
1407
+ supported_options=run.supported_options, timeout=args.preflight_timeout,
1408
+ cwd=run.app_cwd, heartbeat_seconds=args.heartbeat_seconds, dry_run=args.dry_run,
1409
+ profiler_options=run.selection_profiler_options, reuse_existing=run.effective_reuse,
1410
+ cache_seconds=args.preflight_cache_seconds,
1411
+ ))
1412
+ if run.preflight.get("status") != "failed":
1413
+ return None
1414
+ return _abort_after_preflight(run)
1415
+
1416
+
1417
+ def _abort_after_preflight(run: Any) -> int:
1418
+ args = run.args
1419
+ reason = str(run.preflight.get("reason") or "Preflight failed.")
1420
+ rtguard.collect_device_diagnostics(
1421
+ run.internal_dir / "diagnostics" / "preflight", reason=reason, command_result=run.preflight,
1422
+ )
1423
+ skipped: List[Dict[str, Any]] = []
1424
+ for block_id in run.requested_blocks:
1425
+ skipped.append(unavailable_block_entry(
1426
+ block_id, run.requested_by[block_id], f"Skipped by preflight circuit breaker: {reason}"
1427
+ ))
1428
+ manifest = build_manifest(ManifestSpec(
1429
+ preset=args.preset, selection_mode="features" if args.feature else "preset",
1430
+ requested_features=run.requested_features, supported=run.supported, supported_options=run.supported_options,
1431
+ op_type=args.op_type or "unknown", debug_symbols=False, simt_evidence=False,
1432
+ kernel_scale_instrumentation=False, build_provenance=parse_cmake_cache(run.operator_root),
1433
+ environment_context=run.environment_context, blocks=skipped, run_status="aborted",
1434
+ run_reason=reason, preflight=run.preflight, timeout_profile={}, executable_context=run.executable_context,
1435
+ ))
1436
+ write_json(run.output_root / "collection_manifest.json", manifest)
1437
+ run.run_guard.finalize("aborted", reason, {"diagnostics": "diagnostics/preflight/device_diagnostics.json"})
1438
+ cli_logger.info(json.dumps({
1439
+ "schema": CONTRACT_SCHEMA, "output": str(run.output_root), "run_status": "aborted",
1440
+ "reason": reason, "preflight": run.preflight,
1441
+ "diagnostics": str(run.internal_dir / "diagnostics" / "preflight" / "device_diagnostics.json"),
1442
+ }, ensure_ascii=False, indent=2))
1443
+ return 3
1444
+
1445
+
1446
+ def _derive_timeouts(run: Any) -> None:
1447
+ args = run.args
1448
+ run.timeout_profile = derive_timeout_profile(
1449
+ args.timeout, run.block_timeout_overrides,
1450
+ # A reused canary reports elapsed_seconds=0.0; derive adaptive timeouts
1451
+ # from the original observed cost so blocks do not fall back to floors.
1452
+ preflight_elapsed=run.preflight.get("original_elapsed_seconds") or run.preflight.get("elapsed_seconds"),
1453
+ adaptive=args.adaptive_timeout,
1454
+ )
1455
+ write_json(run.internal_dir / "timeout_profile.json", run.timeout_profile)
1456
+
1457
+
1458
+ def _rederive_timeouts(run: Any, discovery_entry: Mapping[str, Any]) -> None:
1459
+ args = run.args
1460
+ run.timeout_profile = derive_timeout_profile(
1461
+ args.timeout, run.block_timeout_overrides,
1462
+ preflight_elapsed=max(
1463
+ float(run.preflight.get("original_elapsed_seconds") or run.preflight.get("elapsed_seconds") or 0),
1464
+ float(discovery_entry.get("elapsed_seconds") or 0),
1465
+ ),
1466
+ adaptive=args.adaptive_timeout,
1467
+ )
1468
+ write_json(run.internal_dir / "timeout_profile.json", run.timeout_profile)
1469
+
1470
+
1471
+ def _run_debug_rebuild(run: Any) -> None:
1472
+ args = run.args
1473
+ run.debug_rebuild = run_shell_capture(args.debug_rebuild_command, run.operator_root, args.debug_rebuild_timeout)
1474
+ logs = run.internal_dir / "logs"
1475
+ logs.mkdir(parents=True, exist_ok=True)
1476
+ (logs / "debug_rebuild.stdout.log").write_text(run.debug_rebuild.get("stdout", ""), encoding="utf-8")
1477
+ (logs / "debug_rebuild.stderr.log").write_text(run.debug_rebuild.get("stderr", ""), encoding="utf-8")
1478
+ run.executable_selection = resolve_executable_details(run.operator_root, args.app)
1479
+ run.app = Path(run.executable_selection["selected"])
1480
+ run.executable_context.update(_executable_context_payload(run.executable_selection, run.app, run.app_cwd))
1481
+ write_json(run.internal_dir / "executable_selection.json", run.executable_context)
1482
+ run.debug_details = detect_debug_symbols_details(run.operator_root, run.app)
1483
+
1484
+
1485
+ def _detect_debug_symbols(run: Any) -> None:
1486
+ args = run.args
1487
+ # readelf-based detection can cost 160 sequential subprocesses; only pay it
1488
+ # when Source is actually requested, and never during a dry run.
1489
+ if args.dry_run:
1490
+ run.debug_details = {
1491
+ "detected": True,
1492
+ "reason": "Debug-symbol detection skipped during dry run; Source eligibility is assumed for planning.",
1493
+ }
1494
+ elif "source" not in run.requested_blocks:
1495
+ run.debug_details = {
1496
+ "detected": False,
1497
+ "reason": "Source block was not requested; debug-symbol detection skipped.",
1498
+ }
1499
+ else:
1500
+ run.debug_details = detect_debug_symbols_details(run.operator_root, run.app)
1501
+ run.debug_rebuild = None
1502
+ rebuild_requested = (
1503
+ "source" in run.requested_blocks
1504
+ and not run.debug_details.get("detected")
1505
+ and args.debug_rebuild_command
1506
+ )
1507
+ if rebuild_requested:
1508
+ _run_debug_rebuild(run)
1509
+ run.debug_symbols = bool(run.debug_details.get("detected"))
1510
+
1511
+
1512
+ def _detect_kernel_scale(run: Any) -> None:
1513
+ args = run.args
1514
+ if args.dry_run:
1515
+ run.kernel_scale_details = {
1516
+ "detected": True,
1517
+ "source_files": [],
1518
+ "binary_evidence": False,
1519
+ "reason": ("Instrumentation detection skipped during dry run; KernelScale eligibility is assumed "
1520
+ "for planning."),
1521
+ }
1522
+ elif "kernel_scale" not in run.requested_blocks:
1523
+ run.kernel_scale_details = {
1524
+ "detected": False,
1525
+ "source_files": [],
1526
+ "binary_evidence": False,
1527
+ "reason": "KernelScale block was not requested; instrumentation detection skipped.",
1528
+ }
1529
+ else:
1530
+ run.kernel_scale_details = detect_kernel_scale_instrumentation(run.operator_root, run.app)
1531
+
1532
+
1533
+ def _detect_capabilities(run: Any) -> None:
1534
+ args = run.args
1535
+ _detect_debug_symbols(run)
1536
+ run.app_fp = fingerprint(run.app)
1537
+ _detect_kernel_scale(run)
1538
+ provenance = parse_cmake_cache(run.operator_root)
1539
+ provenance["user_build_config"] = run.user_build_config
1540
+ provenance["validation_notes"] = list(args.validation_note)
1541
+ provenance["executable_selection"] = run.executable_context
1542
+ run.build_provenance = provenance
1543
+ run.block_entries = []
1544
+
1545
+
1546
+ def _execute_discovery_block(run: Any, discovery_metric: str) -> Dict[str, Any]:
1547
+ args = run.args
1548
+ discovery_dir = run.output_root / BLOCK_DIRS["discovery"]
1549
+ discovery_cmd = build_msprof_command(MsprofCommandSpec(
1550
+ run.msprof, discovery_metric, discovery_dir, run.app, args.app_arg,
1551
+ args.kernel_name, 10, supported_options=run.supported_options,
1552
+ profiler_options=run.selection_profiler_options,
1553
+ ))
1554
+ write_command_record(run.internal_dir, "discovery", discovery_metric, discovery_cmd, {
1555
+ "purpose": "Discover operator names and reported operator type before feature collection.",
1556
+ "output_directory": BLOCK_DIRS["discovery"],
1557
+ "application_cwd": str(run.app_cwd),
1558
+ "timeout_seconds": run.timeout_profile["discovery"],
1559
+ })
1560
+ return execute_block(BlockRunSpec(
1561
+ "discovery", discovery_metric, discovery_cmd, run.output_root, run.internal_dir,
1562
+ run.timeout_profile["discovery"], run.effective_reuse, run.app_fp, args.dry_run, ["discovery"],
1563
+ cwd=run.app_cwd, heartbeat_seconds=args.heartbeat_seconds, msprof_fp=run.msprof_fp,
1564
+ ))
1565
+
1566
+
1567
+ def _abort_after_discovery_timeout(run: Any, discovery_entry: Mapping[str, Any]) -> int:
1568
+ args = run.args
1569
+ reason = f"Discovery timed out after {discovery_entry.get('timeout_seconds')}s."
1570
+ rtguard.collect_device_diagnostics(
1571
+ run.internal_dir / "diagnostics" / "discovery", reason=reason, command_result=discovery_entry,
1572
+ )
1573
+ append_skipped_after_circuit_breaker(run.block_entries, run.requested_blocks,
1574
+ run.requested_by, {"discovery": discovery_entry}, reason)
1575
+ manifest = build_manifest(ManifestSpec(
1576
+ preset=args.preset, selection_mode="features" if args.feature else "preset",
1577
+ requested_features=run.requested_features, supported=run.supported, supported_options=run.supported_options,
1578
+ op_type=args.op_type or "unknown", debug_symbols=run.debug_symbols, simt_evidence=False,
1579
+ kernel_scale_instrumentation=bool(run.kernel_scale_details.get("detected")),
1580
+ build_provenance=run.build_provenance, environment_context=run.environment_context, blocks=run.block_entries,
1581
+ run_status="aborted", run_reason=reason, preflight=run.preflight, timeout_profile=run.timeout_profile,
1582
+ executable_context=run.executable_context,
1583
+ ))
1584
+ write_json(run.output_root / "collection_manifest.json", manifest)
1585
+ run.run_guard.finalize("aborted", reason, {"diagnostics": "diagnostics/discovery/device_diagnostics.json"})
1586
+ cli_logger.info(json.dumps({"run_status": "aborted", "reason": reason, "manifest": str(run.output_root /
1587
+ "collection_manifest.json")}, ensure_ascii=False, indent=2))
1588
+ return 3
1589
+
1590
+
1591
+ def _run_discovery(run: Any) -> Optional[int]:
1592
+ args = run.args
1593
+ # Discovery is infrastructure, not a visual feature block.
1594
+ run.discovered_ops = []
1595
+ if not run.basic_info_supported or (args.kernel_name and args.op_type):
1596
+ return None
1597
+ discovery_metric = ""
1598
+ for candidate in run.supported:
1599
+ if normalize_metric_token(candidate) == normalize_metric_token("BasicInfo"):
1600
+ discovery_metric = candidate
1601
+ break
1602
+ discovery_entry: Optional[Dict[str, Any]] = None
1603
+ if can_promote_preflight_to_discovery(
1604
+ run.preflight, kernel_name=args.kernel_name, launch_count=args.launch_count, dry_run=args.dry_run
1605
+ ):
1606
+ discovery_entry = promote_preflight_to_discovery(run.preflight, run.output_root, discovery_metric)
1607
+ if discovery_entry is None:
1608
+ discovery_entry = _execute_discovery_block(run, discovery_metric)
1609
+ run.block_entries.append(discovery_entry)
1610
+ if discovery_entry.get("timed_out") and args.circuit_breaker:
1611
+ return _abort_after_discovery_timeout(run, discovery_entry)
1612
+ result_dir = run.output_root / discovery_entry["result_dir"] if discovery_entry.get("result_dir") else None
1613
+ run.discovered_ops = discover_operators(result_dir)
1614
+ _rederive_timeouts(run, discovery_entry)
1615
+ return None
1616
+
1617
+
1618
+ def _resolve_operator_identity(run: Any) -> None:
1619
+ args = run.args
1620
+ run.op_type = args.op_type or "unknown"
1621
+ run.kernel_name = args.kernel_name
1622
+ if not run.discovered_ops:
1623
+ return
1624
+ if len(run.discovered_ops) == 1:
1625
+ run.op_type = args.op_type or run.discovered_ops[0].get("type") or "unknown"
1626
+ elif not run.kernel_name:
1627
+ names = ", ".join(x.get("name", "?") for x in run.discovered_ops)
1628
+ raise rtguard.UsageError(f"ERROR: multiple operators discovered ({names}). Re-run with --kernel-name.")
1629
+
1630
+
1631
+ def _environment_record(run: Any) -> Dict[str, Any]:
1632
+ args = run.args
1633
+ return {
1634
+ "collector_version": VERSION,
1635
+ "environment_context": run.environment_context,
1636
+ "app": str(run.app),
1637
+ "app_cwd": str(run.app_cwd),
1638
+ "executable_context": run.executable_context,
1639
+ "app_fingerprint": run.app_fp,
1640
+ "msprof": run.msprof,
1641
+ "supported_metrics": run.supported,
1642
+ "supported_options": run.supported_options,
1643
+ "debug_symbols": run.debug_symbols,
1644
+ "debug_symbol_details": run.debug_details,
1645
+ "debug_rebuild": run.debug_rebuild,
1646
+ "kernel_scale_instrumentation": run.kernel_scale_details,
1647
+ "build_provenance": run.build_provenance,
1648
+ "kernel_name": run.kernel_name,
1649
+ "operator_type": run.op_type,
1650
+ "requested_features": run.requested_features,
1651
+ "requested_blocks": run.requested_blocks,
1652
+ "profiler_options": {k: v for k, v in run.profiler_options.items() if v is not None},
1653
+ "selection_profiler_options": {k: v for k, v in run.selection_profiler_options.items() if v is not None},
1654
+ "preflight": run.preflight,
1655
+ "timeout_profile": run.timeout_profile,
1656
+ "reuse_enabled": run.effective_reuse,
1657
+ "reuse_reason": run.reuse_reason,
1658
+ "created_at": now_iso(),
1659
+ }
1660
+
1661
+
1662
+ def _build_plan_rows(run: Any) -> List[Dict[str, Any]]:
1663
+ # Write the user-visible plan before execution.
1664
+ plan_rows: List[Dict[str, Any]] = []
1665
+ for block_id in run.requested_blocks:
1666
+ metric = select_metric(block_id, run.supported)
1667
+ plan_rows.append({
1668
+ "block_id": block_id,
1669
+ "requested_by": run.requested_by[block_id],
1670
+ "metric": metric,
1671
+ "relative_dir": BLOCK_DIRS[block_id],
1672
+ "timeout_seconds": run.timeout_profile.get(block_id),
1673
+ "application_cwd": str(run.app_cwd),
1674
+ "profiler_options": {k: v for k, v in run.profiler_options.items() if v is not None},
1675
+ "description": command_description(block_id, metric or "UNAVAILABLE"),
1676
+ })
1677
+ return plan_rows
1678
+
1679
+
1680
+ def _write_context_files(run: Any) -> None:
1681
+ write_json(run.output_root / "feature_catalog.json", feature_catalog())
1682
+ write_json(run.internal_dir / "environment.json", _environment_record(run))
1683
+ write_json(run.internal_dir / "collection_plan.json", _build_plan_rows(run))
1684
+
1685
+
1686
+ def _semantic_memory_detail_alias(
1687
+ run: Any,
1688
+ block_id: str,
1689
+ candidate_metrics: Sequence[str],
1690
+ req: Sequence[str],
1691
+ executed: Mapping[str, Dict[str, Any]],
1692
+ ) -> Optional[Dict[str, Any]]:
1693
+ # When the installed CLI has no native MemoryDetail token, do not launch
1694
+ # a redundant Default replay if a richer completed replay already
1695
+ # satisfies the same compute/memory/cache/advice contract. Roofline is
1696
+ # checked first because it is documented to include Default counters.
1697
+ native_memory_detail = any(
1698
+ normalize_metric_token(metric) == normalize_metric_token("MemoryDetail")
1699
+ for metric in candidate_metrics
1700
+ )
1701
+ if native_memory_detail:
1702
+ return None
1703
+ for provider_id in ["roofline", "raw_data", "details"]:
1704
+ provider = executed.get(provider_id)
1705
+ if not provider:
1706
+ continue
1707
+ candidate_alias = semantic_alias_candidate(block_id, provider, req, run.output_root)
1708
+ if candidate_alias is not None:
1709
+ return candidate_alias
1710
+ return None
1711
+
1712
+
1713
+ def _standard_csv_provider(executed: Mapping[str, Dict[str, Any]]) -> Optional[Dict[str, Any]]:
1714
+ for provider_id in ["memory_detail", "roofline", "details"]:
1715
+ candidate = executed.get(provider_id)
1716
+ reusable_status = candidate and candidate.get("status") in {"ok", "reused", "partial", "aliased"}
1717
+ if reusable_status and has_standard_csv_suite(candidate):
1718
+ return candidate
1719
+ return None
1720
+
1721
+
1722
+ def _available_raw_metrics(supported: Sequence[str]) -> List[str]:
1723
+ # Some CANN versions expose the seven raw counters but not Default.
1724
+ raw_metrics: List[str] = []
1725
+ for canonical in RAW_COUNTER_METRICS:
1726
+ actual = next(
1727
+ (x for x in supported if normalize_metric_token(x) == normalize_metric_token(canonical)),
1728
+ None,
1729
+ )
1730
+ if actual:
1731
+ raw_metrics.append(actual)
1732
+ return raw_metrics
1733
+
1734
+
1735
+ def _raw_data_shortcut(
1736
+ run: Any,
1737
+ block_id: str,
1738
+ candidate_metrics: Sequence[str],
1739
+ req: Sequence[str],
1740
+ executed: Mapping[str, Dict[str, Any]],
1741
+ ) -> Optional[Dict[str, Any]]:
1742
+ args = run.args
1743
+ # Raw Data first reuses any richer replay that already emitted the standard CSV suite.
1744
+ provider = _standard_csv_provider(executed)
1745
+ if provider is not None:
1746
+ entry = alias_block_entry(block_id, provider, req, run.output_root)
1747
+ return validate_block_entry(block_id, entry, run.output_root)
1748
+ if candidate_metrics:
1749
+ return None
1750
+ raw_metrics = _available_raw_metrics(run.supported)
1751
+ if not raw_metrics:
1752
+ return None
1753
+ entry = execute_raw_counter_suite(RawCounterSuiteSpec(
1754
+ raw_metrics, run.msprof, run.output_root, run.internal_dir, run.app, args.app_arg,
1755
+ run.kernel_name, args.launch_count, run.supported_options, run.timeout_profile["raw_data"],
1756
+ args.dry_run, req, cwd=run.app_cwd, heartbeat_seconds=args.heartbeat_seconds,
1757
+ profiler_options=run.profiler_options,
1758
+ ))
1759
+ if entry.get("timed_out") and args.circuit_breaker:
1760
+ run.circuit_breaker_reason = (f"Raw Data metric suite timed out after "
1761
+ f"{entry.get('timeout_seconds')}s.")
1762
+ diag_dir = run.internal_dir / "diagnostics" / "raw_data"
1763
+ rtguard.collect_device_diagnostics(diag_dir,
1764
+ reason=run.circuit_breaker_reason, command_result=entry)
1765
+ run.circuit_breaker_diagnostics = rel(diag_dir / "device_diagnostics.json", run.output_root)
1766
+ return entry
1767
+
1768
+
1769
+ def _resolve_shortcut_entry(
1770
+ run: Any,
1771
+ block_id: str,
1772
+ candidate_metrics: Sequence[str],
1773
+ req: Sequence[str],
1774
+ executed: Mapping[str, Dict[str, Any]],
1775
+ ) -> Optional[Dict[str, Any]]:
1776
+ args = run.args
1777
+ if block_id == "onchip_memory":
1778
+ return collect_onchip_memory_artifact(run.operator_root, run.output_root,
1779
+ req, Path(args.memory_info) if args.memory_info else None)
1780
+ if block_id == "memory_detail" and not args.independent_default:
1781
+ entry = _semantic_memory_detail_alias(run, block_id, candidate_metrics, req, executed)
1782
+ if entry is not None:
1783
+ return entry
1784
+ if block_id == "raw_data":
1785
+ return _raw_data_shortcut(run, block_id, candidate_metrics, req, executed)
1786
+ return None
1787
+
1788
+
1789
+ def _simt_eligible(args: argparse.Namespace, block_id: str, requested_features: Sequence[str],
1790
+ simt_evidence: bool) -> bool:
1791
+ explicit_target = bool(args.feature) and (
1792
+ any(block_id in FEATURE_TO_BLOCKS[f] for f in requested_features)
1793
+ or (block_id == "warp_stall" and "source" in requested_features and args.source_stall != "off")
1794
+ )
1795
+ if args.simt == "on":
1796
+ return True
1797
+ if args.simt == "off":
1798
+ return False
1799
+ return bool(simt_evidence or explicit_target)
1800
+
1801
+
1802
+ def _kernel_scale_eligible(args: argparse.Namespace, kernel_scale_details: Mapping[str, Any]) -> bool:
1803
+ if args.kernel_scale == "on":
1804
+ return True
1805
+ if args.kernel_scale == "off":
1806
+ return False
1807
+ return bool(kernel_scale_details.get("detected"))
1808
+
1809
+
1810
+ def _check_eligibility(
1811
+ run: Any,
1812
+ block_id: str,
1813
+ spec: Mapping[str, Any],
1814
+ candidate_metrics: Sequence[str],
1815
+ req: Sequence[str],
1816
+ ) -> Optional[Dict[str, Any]]:
1817
+ args = run.args
1818
+ if not candidate_metrics:
1819
+ return unavailable_block_entry(
1820
+ block_id, req,
1821
+ f"Installed msprof op CLI exposes none of: {', '.join(spec['metric_candidates'])}.",
1822
+ )
1823
+ if spec.get("requires_debug_symbols") and not run.debug_symbols:
1824
+ return unavailable_block_entry(
1825
+ block_id, req,
1826
+ ("Usable .debug_line information was not detected in the selected executable build tree. "
1827
+ "Rebuild the exact selected executable/kernel with -g, or pass --debug-rebuild-command so "
1828
+ "the collector can rebuild conditionally before Source collection."),
1829
+ )
1830
+ if spec.get("requires_simt") and not _simt_eligible(args, block_id, run.requested_features, run.simt_evidence):
1831
+ return unavailable_block_entry(
1832
+ block_id, req,
1833
+ ("No SIMT evidence detected. Run Details first, use --simt on, or request warp-stall "
1834
+ "explicitly for best-effort collection."),
1835
+ )
1836
+ if spec.get("requires_kernel_scale_instrumentation") and not _kernel_scale_eligible(
1837
+ args, run.kernel_scale_details
1838
+ ):
1839
+ return unavailable_block_entry(
1840
+ block_id, req,
1841
+ ("KernelScale requires MetricsProfStart/MetricsProfStop instrumentation. Add the markers "
1842
+ "or use --kernel-scale on for a best-effort run."),
1843
+ )
1844
+ return None
1845
+
1846
+
1847
+ def _find_reusable_provider(
1848
+ executed: Mapping[str, Dict[str, Any]],
1849
+ candidate_metrics: Sequence[str],
1850
+ ) -> Optional[Dict[str, Any]]:
1851
+ # Reuse a previous identical metric replay when no block-specific command option differs.
1852
+ for provider in executed.values():
1853
+ if provider.get("status") not in {"ok", "reused", "partial", "aliased"}:
1854
+ continue
1855
+ provider_metric = provider.get("metric")
1856
+ if (provider_metric and normalize_metric_token(provider_metric)
1857
+ == normalize_metric_token(candidate_metrics[0])):
1858
+ return provider
1859
+ return None
1860
+
1861
+
1862
+ def _find_metric_provider(executed: Mapping[str, Dict[str, Any]], metric: str) -> Optional[Dict[str, Any]]:
1863
+ for provider in executed.values():
1864
+ provider_metric = provider.get("metric")
1865
+ if (provider.get("status") in {"ok", "reused", "partial", "aliased"}
1866
+ and provider_metric
1867
+ and normalize_metric_token(provider_metric) == normalize_metric_token(metric)):
1868
+ return provider
1869
+ return None
1870
+
1871
+
1872
+ class _SingleAttemptSpec(NamedTuple):
1873
+ """Bundled inputs for ``_run_single_attempt`` (G.FNM.03)."""
1874
+
1875
+ run: Any
1876
+ block_id: str
1877
+ metric: str
1878
+ attempt_index: int
1879
+ candidate_metrics: Sequence[str]
1880
+ req: Sequence[str]
1881
+
1882
+
1883
+ def _run_single_attempt(spec: _SingleAttemptSpec) -> Dict[str, Any]:
1884
+ run = spec.run
1885
+ block_id = spec.block_id
1886
+ metric = spec.metric
1887
+ attempt_index = spec.attempt_index
1888
+ candidate_metrics = spec.candidate_metrics
1889
+ req = spec.req
1890
+ args = run.args
1891
+ run_dir = run.output_root / BLOCK_DIRS[block_id]
1892
+ cmd = build_msprof_command(MsprofCommandSpec(
1893
+ run.msprof, metric, run_dir, run.app, args.app_arg, run.kernel_name, args.launch_count,
1894
+ instr_timeline_pipe=args.instr_timeline_pipe,
1895
+ supported_options=run.supported_options,
1896
+ profiler_options=run.profiler_options,
1897
+ ))
1898
+ command_id = block_id
1899
+ if len(candidate_metrics) > 1:
1900
+ metric_token = normalize_metric_token(metric)
1901
+ command_id = f"{block_id}_attempt_{attempt_index:02d}_{metric_token}"
1902
+ write_command_record(run.internal_dir, command_id, metric, cmd, command_description(block_id, metric))
1903
+ entry = execute_block(BlockRunSpec(
1904
+ block_id, metric, cmd, run.output_root, run.internal_dir,
1905
+ run.timeout_profile[block_id], run.effective_reuse, run.app_fp, args.dry_run, req,
1906
+ log_stem=command_id, cwd=run.app_cwd, heartbeat_seconds=args.heartbeat_seconds,
1907
+ msprof_fp=run.msprof_fp,
1908
+ ))
1909
+ if not args.dry_run:
1910
+ entry = validate_block_entry(block_id, entry, run.output_root)
1911
+ return entry
1912
+
1913
+
1914
+ def _run_metric_attempts(
1915
+ run: Any,
1916
+ block_id: str,
1917
+ candidate_metrics: Sequence[str],
1918
+ req: Sequence[str],
1919
+ executed: Mapping[str, Dict[str, Any]],
1920
+ ) -> Tuple[List[Dict[str, Any]], Optional[Dict[str, Any]]]:
1921
+ args = run.args
1922
+ attempts: List[Dict[str, Any]] = []
1923
+ best_entry: Optional[Dict[str, Any]] = None
1924
+ for attempt_index, metric in enumerate(candidate_metrics, start=1):
1925
+ metric_provider = _find_metric_provider(executed, metric)
1926
+ if metric_provider is not None:
1927
+ entry = alias_block_entry(block_id, metric_provider, req, run.output_root)
1928
+ entry = validate_block_entry(block_id, entry, run.output_root)
1929
+ attempts.append({"metric": metric, "status": entry.get("status"),
1930
+ "provider_block": metric_provider.get("block_id"), "aliased": True})
1931
+ if entry.get("status") in {"aliased", "ok", "reused", "partial"}:
1932
+ best_entry = entry
1933
+ break
1934
+ entry = _run_single_attempt(_SingleAttemptSpec(run, block_id, metric, attempt_index,
1935
+ candidate_metrics, req))
1936
+ attempts.append({
1937
+ "metric": metric, "status": entry.get("status"),
1938
+ "return_code": entry.get("return_code"), "coverage": entry.get("coverage"),
1939
+ "timed_out": entry.get("timed_out", False),
1940
+ })
1941
+ if entry.get("status") in {"ok", "reused"}:
1942
+ best_entry = entry
1943
+ break
1944
+ best_entry = entry
1945
+ if entry.get("timed_out") and args.circuit_breaker:
1946
+ run.circuit_breaker_reason = f"{block_id}/{metric} timed out after {entry.get('timeout_seconds')}s."
1947
+ diag_dir = run.internal_dir / "diagnostics" / block_id
1948
+ rtguard.collect_device_diagnostics(diag_dir, reason=run.circuit_breaker_reason, command_result=entry)
1949
+ run.circuit_breaker_diagnostics = rel(diag_dir / "device_diagnostics.json", run.output_root)
1950
+ break
1951
+ has_fallback = attempt_index < len(candidate_metrics)
1952
+ if has_fallback and fallback_allowed(entry):
1953
+ continue
1954
+ if has_fallback:
1955
+ entry["fallback_suppressed"] = {
1956
+ "next_metric": candidate_metrics[attempt_index],
1957
+ "reason": ("Fallback is allowed only when the preferred command exits 0 and semantic "
1958
+ "validation returns empty; timeout/non-zero/partial results are not retried."),
1959
+ }
1960
+ break
1961
+ return attempts, best_entry
1962
+
1963
+
1964
+ def _execute_block_with_fallbacks(
1965
+ run: Any,
1966
+ block_id: str,
1967
+ candidate_metrics: Sequence[str],
1968
+ req: Sequence[str],
1969
+ executed: Mapping[str, Dict[str, Any]],
1970
+ ) -> Dict[str, Any]:
1971
+ reusable_provider = _find_reusable_provider(executed, candidate_metrics)
1972
+ if reusable_provider is not None and block_id not in {"raw_data"}:
1973
+ entry = alias_block_entry(block_id, reusable_provider, req, run.output_root)
1974
+ return validate_block_entry(block_id, entry, run.output_root)
1975
+ attempts, best_entry = _run_metric_attempts(run, block_id, candidate_metrics, req, executed)
1976
+ entry = best_entry or unavailable_block_entry(block_id, req, "No metric attempt produced an entry.")
1977
+ entry["attempts"] = attempts
1978
+ entry["preferred_metric"] = candidate_metrics[0]
1979
+ entry["fallback_used"] = bool(
1980
+ entry.get("metric")
1981
+ and normalize_metric_token(entry["metric"]) != normalize_metric_token(candidate_metrics[0])
1982
+ )
1983
+ if entry["fallback_used"]:
1984
+ entry["reason"] = (f"Preferred metric {candidate_metrics[0]} did not provide a usable payload; "
1985
+ f"used {entry.get('metric')} fallback.")
1986
+ return entry
1987
+
1988
+
1989
+ def _update_simt_evidence(run: Any, block_id: str, entry: Mapping[str, Any]) -> None:
1990
+ # BasicInfo may report Vector while the profiling payload contains SIMT instructions.
1991
+ if block_id != "details" or entry.get("status") not in {"ok", "reused", "partial", "aliased"}:
1992
+ return
1993
+ path = (entry.get("artifacts") or {}).get("visualize_data")
1994
+ bin_path = run.output_root / path if path else None
1995
+ if detect_simt_evidence_from_bin(bin_path):
1996
+ run.simt_evidence = True
1997
+
1998
+
1999
+ def _execute_blocks(run: Any) -> None:
2000
+ executed: Dict[str, Dict[str, Any]] = {x["block_id"]: x for x in run.block_entries}
2001
+ run.simt_evidence = "simt" in run.op_type.lower() if run.op_type else False
2002
+
2003
+ for block_id in run.requested_blocks:
2004
+ spec = BLOCKS[block_id]
2005
+ candidate_metrics = select_metric_candidates(block_id, run.supported)
2006
+ req = run.requested_by[block_id]
2007
+ entry = _resolve_shortcut_entry(run, block_id, candidate_metrics, req, executed)
2008
+ if entry is None:
2009
+ entry = _check_eligibility(run, block_id, spec, candidate_metrics, req)
2010
+ if entry is None:
2011
+ entry = _execute_block_with_fallbacks(run, block_id, candidate_metrics, req, executed)
2012
+ run.block_entries.append(entry)
2013
+ executed[block_id] = entry
2014
+ if run.circuit_breaker_reason:
2015
+ break
2016
+ _update_simt_evidence(run, block_id, entry)
2017
+
2018
+ if run.circuit_breaker_reason:
2019
+ append_skipped_after_circuit_breaker(
2020
+ run.block_entries, run.requested_blocks, run.requested_by, executed, run.circuit_breaker_reason,
2021
+ )
2022
+
2023
+
2024
+ def _block_timing_row(block: Mapping[str, Any]) -> Dict[str, Any]:
2025
+ return {
2026
+ "phase": str(block.get("block_id")),
2027
+ "elapsed_seconds": round(float(block.get("elapsed_seconds") or 0.0), 6),
2028
+ "kind": "profiler" if block.get("metric") else "metadata",
2029
+ "status": block.get("status"),
2030
+ "metric": block.get("metric"),
2031
+ "provider_block": block.get("provider_block"),
2032
+ "collection_passes_saved": int(block.get("collection_passes_saved") or 0),
2033
+ }
2034
+
2035
+
2036
+ def _timing_rows(run: Any) -> List[Dict[str, Any]]:
2037
+ timing_rows: List[Dict[str, Any]] = []
2038
+ for name, seconds in run.local_phase_seconds.items():
2039
+ timing_rows.append({"phase": name, "elapsed_seconds": round(seconds, 6), "kind": "local"})
2040
+ if run.debug_rebuild is not None:
2041
+ timing_rows.append({
2042
+ "phase": "debug_rebuild",
2043
+ "elapsed_seconds": round(float(run.debug_rebuild.get("elapsed_seconds") or 0.0), 6),
2044
+ "kind": "build",
2045
+ "status": "ok" if int(run.debug_rebuild.get("return_code") or 0) == 0 else "failed",
2046
+ })
2047
+ timing_rows.append({
2048
+ "phase": "preflight",
2049
+ "elapsed_seconds": round(float(run.preflight.get("elapsed_seconds") or 0.0), 6),
2050
+ "kind": "profiler",
2051
+ "status": run.preflight.get("status"),
2052
+ })
2053
+ for block in run.block_entries:
2054
+ timing_rows.append(_block_timing_row(block))
2055
+ return timing_rows
2056
+
2057
+
2058
+ def _build_timing_summary(run: Any) -> Dict[str, Any]:
2059
+ timing_rows = _timing_rows(run)
2060
+ collector_wall_seconds = time.perf_counter() - run.collector_wall_started
2061
+ profiler_seconds = sum(
2062
+ float(row.get("elapsed_seconds") or 0.0)
2063
+ for row in timing_rows if row.get("kind") == "profiler"
2064
+ )
2065
+ saved_replays = sum(int(row.get("collection_passes_saved") or 0) for row in timing_rows)
2066
+ timing_summary = {
2067
+ "schema": "msopprof-timing/v1",
2068
+ "collector_version": VERSION,
2069
+ "wall_seconds": round(collector_wall_seconds, 6),
2070
+ "profiler_seconds": round(profiler_seconds, 6),
2071
+ "saved_replay_count": saved_replays,
2072
+ "preflight_discovery_fused": any(
2073
+ block.get("block_id") == "discovery" and block.get("provider") == "preflight_canary"
2074
+ for block in run.block_entries
2075
+ ),
2076
+ "phases": timing_rows,
2077
+ "scope_note": ("Measures pipeline execution only; agent reading, manual repository search, and "
2078
+ "external shell preparation are outside this timer."),
2079
+ }
2080
+ write_json(run.internal_dir / "timing_summary.json", timing_summary)
2081
+ return timing_summary
2082
+
2083
+
2084
+ def _write_final_manifest(run: Any) -> str:
2085
+ args = run.args
2086
+ run_status = "aborted" if run.circuit_breaker_reason else "completed"
2087
+ manifest = build_manifest(ManifestSpec(
2088
+ preset=args.preset,
2089
+ selection_mode="features" if args.feature else "preset",
2090
+ requested_features=run.requested_features,
2091
+ supported=run.supported,
2092
+ supported_options=run.supported_options,
2093
+ op_type=run.op_type,
2094
+ debug_symbols=run.debug_symbols,
2095
+ simt_evidence=run.simt_evidence,
2096
+ kernel_scale_instrumentation=bool(run.kernel_scale_details.get("detected")),
2097
+ build_provenance=run.build_provenance,
2098
+ environment_context=run.environment_context,
2099
+ blocks=run.block_entries,
2100
+ run_status=run_status,
2101
+ run_reason=run.circuit_breaker_reason,
2102
+ preflight=run.preflight,
2103
+ timeout_profile=run.timeout_profile,
2104
+ executable_context=run.executable_context,
2105
+ ))
2106
+ write_json(run.output_root / "collection_manifest.json", manifest)
2107
+ return run_status
2108
+
2109
+
2110
+ def _run_summary(run: Any, timing_summary: Mapping[str, Any], run_status: str) -> Dict[str, Any]:
2111
+ args = run.args
2112
+ blocks: List[Dict[str, Any]] = []
2113
+ for entry in run.block_entries:
2114
+ blocks.append({
2115
+ "block_id": entry["block_id"], "metric": entry.get("metric"),
2116
+ "status": entry["status"], "reason": entry.get("reason"), "coverage": entry.get("coverage"),
2117
+ })
2118
+ return {
2119
+ "schema": CONTRACT_SCHEMA,
2120
+ "output": str(run.output_root),
2121
+ "manifest": str(run.output_root / "collection_manifest.json"),
2122
+ "preset": args.preset,
2123
+ "selection_mode": "features" if args.feature else "preset",
2124
+ "requested_features": run.requested_features,
2125
+ "simt_evidence": run.simt_evidence,
2126
+ "environment_context": run.environment_context,
2127
+ "run_status": run_status,
2128
+ "run_reason": run.circuit_breaker_reason,
2129
+ "preflight": run.preflight,
2130
+ "timeout_profile": run.timeout_profile,
2131
+ "diagnostics": run.circuit_breaker_diagnostics,
2132
+ "timing": timing_summary,
2133
+ "blocks": blocks,
2134
+ }
2135
+
2136
+
2137
+ def _finalize(run: Any) -> int:
2138
+ run_status = _write_final_manifest(run)
2139
+ timing_summary = _build_timing_summary(run)
2140
+ failures = [
2141
+ b for b in run.block_entries
2142
+ if b["block_id"] != "discovery" and b["status"] in {"failed", "unavailable", "empty"}
2143
+ ]
2144
+ cli_logger.info(json.dumps(_run_summary(run, timing_summary, run_status), ensure_ascii=False, indent=2))
2145
+
2146
+ if run.circuit_breaker_reason:
2147
+ run.run_guard.finalize("aborted", run.circuit_breaker_reason, {
2148
+ "diagnostics": run.circuit_breaker_diagnostics,
2149
+ })
2150
+ return 3
2151
+ run.run_guard.finalize("completed", extra={
2152
+ "manifest": "collection_manifest.json",
2153
+ "block_count": len(run.block_entries),
2154
+ })
2155
+ if run.args.strict and failures:
2156
+ return 2
2157
+ return 0
2158
+
2159
+
2160
+ def _run(args: argparse.Namespace) -> int:
2161
+ run = SimpleNamespace(
2162
+ args=args,
2163
+ collector_wall_started=time.perf_counter(),
2164
+ local_phase_seconds={},
2165
+ circuit_breaker_reason=None,
2166
+ circuit_breaker_diagnostics=None,
2167
+ )
2168
+ _plan_requested(run)
2169
+ _prepare_output(run)
2170
+ _resolve_environment(run)
2171
+ _resolve_executable(run)
2172
+ _check_capabilities(run)
2173
+ preflight_rc = _run_preflight(run)
2174
+ if preflight_rc is not None:
2175
+ return preflight_rc
2176
+ _derive_timeouts(run)
2177
+ _detect_capabilities(run)
2178
+ discovery_rc = _run_discovery(run)
2179
+ if discovery_rc is not None:
2180
+ return discovery_rc
2181
+ _resolve_operator_identity(run)
2182
+ _write_context_files(run)
2183
+ _execute_blocks(run)
2184
+ return _finalize(run)
2185
+
2186
+
2187
+ def main(argv: Optional[Sequence[str]] = None) -> int:
2188
+ logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
2189
+ parser = build_parser()
2190
+ args = parser.parse_args(argv)
2191
+ _validate_args(parser, args)
2192
+
2193
+ if args.list_features:
2194
+ print_feature_list()
2195
+ return 0
2196
+ try:
2197
+ if args.explain:
2198
+ print_feature_explanation(args.explain)
2199
+ return 0
2200
+ if not args.operator_path or not args.output:
2201
+ parser.error("--operator-path and --output are required unless using --list-features or --explain.")
2202
+ return _run(args)
2203
+ except rtguard.UsageError as exc:
2204
+ rtguard.log_usage_error(exc)
2205
+ return 1
2206
+
2207
+
2208
+ if __name__ == "__main__":
2209
+ raise SystemExit(main())