pyqcu-cuda
当任务涉及 pyqcu.cuda、libqcu.so Cython 桥、params/argv/set_ptrs ABI 或 CUDA 显存生命周期时使用。
Skill by ZhangXin8069
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/zhangxin8069-pyqcu-cuda
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 26, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/pyqcu-cuda
What's inside
- Skill name
pyqcu-cuda- Description
- 当任务涉及 pyqcu.cuda、libqcu.so Cython 桥、params/argv/set_ptrs ABI 或 CUDA 显存生命周期时使用。
- License
- MIT
- Instructions
- 383 lines in SKILL.md · view on GitHub
Files (2)
- AGENTS.md
- SKILL.md
SKILL.md (first lines)
# pyqcu.cuda
Cython bridge package for the C++ CUDA backend (`libqcu.so`).
## Files
| File | Purpose |
|------|---------|
| `__init__.py` | Makes `pyqcu.cuda` a proper Python package (added 2026-07-28 R3; was missing, causing `pip install` failures) |
| `qcu/qcu.pyx` | Cython extension source — wraps C functions from `pyqcu.h` as `applyInitQcu`, `applyWilsonDslashQcu`, etc. |
| `qcu/qcu_api.pxd` | Cython declarations — aliases C symbols, marks calls `nogil`, and must match `pyqcu.h` |
| `qcu/qcu.pyi` | Type stub (390 lines) — full type annotations, docstrings, and default values for IDE support。注意 `pyqcu/cuda/qcu.pyi` 是指向 `qcu/qcu.pyi` 的符号链接,不是第二份拷贝 |
| `define.py` | Parameter constants (`_LAT_X_`, `_SET_PLAN_`, etc.) and dtype conversion helpers (`dtype()`, `epytd()`) |
| `_runtime.py` | `QcuRuntime` — lifecycle-safe flat-ABI wrapper with private control arrays, free-slot selection, `mass`/`csw` configuration, and `operation()` contexts for getters |
| `linear_operator.py` | `CudaLinearOperator` — compact Wilson/Clover Schur apply and native whole-solve adapter |
| `krylov.py` | `CudaBiCGStabDriver` / `CudaCGDriver` — one native C++ solve per request |
| `_schur_op.py` | `CudaSchurOp` — C++ Schur odd-site operator wrapper (per-instance independent params/set_ptrs, thread-safe slot allocator; matvec uses preallocated buffer + device sync + clone to avoid deep pool/stream races) |
| `_multi_gpu.py` | **TEST-ONLY, explicit opt-in**: `MultiGpuMultigrid` — single-process multi-thread multi-GPU Legacy MG driver (one-thread-one-GPU; consistency + independent-problem modes; single-MPI-rank constraint); not the production topology and not a single-solve domain decomposition |
| `_strict_multigrid.py` | `StrictMultigrid` — fine odd-Clover Schur + persistent strict coarse V-cycle + C++ fused right-FGMRES;通过 `pyqcu.cuda.multigrid` 导出 |
| `_strict_cache.py` | strict runtime cache schema v2;逐 tensor 流式摘要、完整验签后再传入 device |
| `_strict_mpi.py` | strict MPI rank 对称 preflight 与能力门禁;当前声明 setup/full/compact/R-P halo、全局归约和分布式 fused FGMRES 均可用 |
| `_logs.py` | C++ 后端收敛日志诊断 API:`parse_mg_log(path)` → (残差列表, `PROF_SECTIONS` ms 字典, 总迭代数);`parse_convergence_histories(path, offset)` → (histories, 新偏移) 增量收集逐次求解的 `CONVERGENCE_HISTORY`。2026-10-22 审计基线下仓内没有代码或测试导入该模块;补定向解析测试前,不应把“模块存在”写成已验证的规范入口。默认路径 `<repo>/logs/clover_multigrid.log` |
## CUDA Production Topology
All new production CUDA programs follow one invariant:
```text
one Python process = one MPI rank = one GPU/DCU/GPGPU
```
Cross-device parallelism is implemented with MPI ranks and 4D lattice domain
decomposition. Do not create multiple production device workers inside one
Python process. `MultiGpuMultigrid` is a test-only exception: importing
`pyqcu`, `pyqcu.cuda`, or `pyqcu.solver` does not construct or start it; only an
explicit import and construction enable the path. Use it only for consistency,
throughput, or diagnostic tests, never as the default driver for a new CUDA
program.
Each production process owns one rank-local `LatticeSet`/solver context.
`CUDA_VISIBLE_DEVICES` and device selection must be fixed before importing or
initializing PyTorch, the Cython bridge, or native QCU. MPI rank count should
match participating devices; oversubscribed ranks are correctness smoke only,
not an acceleration path.
Multi-rank benchmark entry points accept only positive powers of two and must
reject other counts before MPI/solver startup. Two P100 ranks require a Python
environment compatible with `sm_60` and a native library set covering
`sm_60`/`sm_70`; V100+P100 mixed-device timing is not a valid
same-architecture result.
The normative project document is
[`docs/cuda_execution_topology.md`](../../docs/cuda_execution_topology.md).
The cross-document extraction index is
[`pyqcu-docs/references/extracted-guidance.md`](../pyqcu-docs/references/extracted-guidance.md#3-cuda-生产执行拓扑).
The 2026-10-23 multi-rank and MultiGrid benchmark constraints are in
[`pyqcu-benchmark/references/qcu-multigrid-20261023.md`](../pyqcu-benchmark/references/qcu-multigrid-20261023.md).
DCU/DTK builds use the same Cython and native ABI but a separate build profile:
`PYQCU_BUILD_BACKEND=dcu` with `install.sh dcu` selects
`cpp/cuda/qcu/make-dcu.sh` and `CMakeLists-dcu.txt`. The Python runtime still
uses ROCm PyTorch's CUDA-compatible API (`backend="cuda"`, `device="cuda:N"`).
`cpp/dtk` and `pyqcu/dtk` are placeholders. See
[`docs/dcu_build_backend.md`](../../docs/dcu_build_backend.md).
`source ./env.sh` exports the current checkout as `PYQCU_ROOT` and defaults
`PYQCU_CUDA_LIB`, `PYQCU_DCU_LIB`, and `PYQCU_KUPL_LIB` to their canonical library
paths. DCU builds write `${QCU_DCU_BUILD_DIR}/libqcu.so` and copy it to
`cpp/cuda/qcu/libqcu.so` for the Cython bridge. Explicit caller values take precedence.
## Public API
跨 CUDA/KUPL/Torch 的公共 PyQCU 接口规范以
[`pyqcu-api/SKILL.md`](../pyqcu-api/SKILL.md#三后端统一接口强制规范) 为唯一权威源。
`CudaLinearOperator`、`CudaBiCGStabDriver`、CUDA `Multigrid` 等属于后端适配层;
用户可见的高层求解、MG 与 cache 调用必须使用 `pyqcu.solver` 的统一选择器。新增 CUDA
入口时保持公共参数名、`SolveResult`/`MultigridCacheLoadResult` 返回类型和生命周期一致,
不支持的组合通过 `BackendCapabilities` 或构造期错误 fail-closed。
已有 CUDA 库、Strict runtime cache 或 Legacy 33-tensor cache 在 SHA256、gauge、几何、
精度和算法身份一致时直接复用,不重复 setup。缓存命中仍需完整验签;只有 miss、损坏或
身份变化时重建。恢复增量构建时优先沿用现有 build tree,不清理可复用对象。
```python
from pyqcu.cuda import qcu # Cython bridge to libqcu.so
from pyqcu.cuda import define # Parameter constants, dtype helpers, pre-built params/argv/set_ptrs tensors
from pyqcu.cuda import QcuRuntime # lifecycle-safe flat-ABI calls
```
## Cython Extension — C Functions Exposed
| Function | Purpose | Plan |
|----------|---------|------|
| `applyInitQcu` / `applyEndQcu` | Allocate / free scratch buffers | — |
| `applyWilsonDslashQcu` | Wilson dslash | 0 |
| `applyCloverDslashQcu` | Clover dslash | 2 |
| `applyWilsonBistabCgQcu` / `applyWilsonBistabCgDslashQcu` | Wilson BiStabCG solver + its dslash | 1 |
| `applyWilsonCgQcu` / `applyWilsonCgDslashQcu` | Wilson CG solver + its dslash | 1 |
| `applyCloverBistabCgQcu` / `applyCloverBistabCgDslashQcu` | Clover BiStabCG (needs clover_ee/oo + inverses) | 1 |
| `applyCloverQcu` / `applyCloversQcu` | Build Clover term (and its inverse) | 2 |
| `applyDslashQcu` | Combined Wilson+Clover dslash | 0+2 |
| `applyLaplacianQcu` | Laplacian operator | -2 |
| `applyGaussGaugeQcu` | Gaussian gauge field generation | -1 |
| `applyMultigridRestrictQcu` / `applyMultigridProLongQcu` | MG restrict/prolong with null vectors | MG |
| `applyMultigridCoarseDslashQcu` | Coarse-grid dslash (hopping + sitting) | MG |
| `applyCloverMultigridQcu` | Full Clover multigrid V-cycle solver | MG |
| `applyMultigridStrictCoarseQcu` / `applyMultigridStrictMatPCQcu` | Full-coarse `X/Yhat` operator and compact-parity MATPC | strict MG |
| `applyMultigridStrictPrepareQcu` / `applyMultigridStrictReconstructQcu` | Full↔odd-Schur preparation/reconstruction | strict MG |
| `applyMultigridStrictRestrictQcu` / `applyMultigridStrictProLongQcu` | Compact fine-parity R/P with full coarse output/input | strict MG |
| `applyMultigridStrictInitQcu` / `applyMultigridStrictVCycleQcu` / `applyMultigridStrictEndQcu` | Allocate, reuse, and release the persistent strict hierarchy/arena | strict MG |
| `applyMultigridStrictFgmresQcu` | Fused restarted right-FGMRES with MPI global reductions, including warm x0 and exact workspace accounting | strict MG |
All functions take raw pointers cast to `long long` from `tensor.contiguous().data_ptr()`.
## Parameter Protocol
Three flat tensors bridge Python ↔ C++:
- **`params`** (CPU int32[58]) — lattice dims (`_LAT_X_`…`_LAT_XYZT_`), grid sizes (`_GRID_X_`…), data types (`_DATA_TYPE_`), iteration counts (`_MAX_ITER_`), plan selection (`_SET_PLAN_`), verbosity (`_VERBOSE_`), parity (`_PARITY_`), multigrid level configs and controls. The tail is `_MG_USE_GCR_` (54), `_MG_USE_DEFLATE_` (55), `_MG_MU_PRE_` (56), and `_MG_USE_INIT_GUESS_` (57); slot 57 is a 0/1 warm-start flag and does not extend the ABI.
- Multi-rank CUDA Legacy must set `params[_MG_USE_DEFLATE_]` explicitly. Leaving it unset can produce `n_vcycles=0`, which is a fine-only result and must not be reported as coarse MultiGrid performance. Verify actual `n_vcycles`/coarse iteration and correction counters instead of inferring execution from `levels` or `restart`.From ZhangXin8069/PyQCU, MIT.
More from ZhangXin8069/PyQCU
- 0.611score
pyqcu-docs
ZhangXin8069
当需要定位 PyQCU 的权威项目文档、把 docs/ 内容提取或同步到 skills/、查询安装/ 环境/维度/测试入口、判断正式文档与阶段报告的生命周期,或追踪 CUDA、MultiGrid、 KUPL、benchmark 与 profiler 知识来源时使用。
SkillAFreshness: A★ 4Claude Code +9 - 0.608score
pyqcu-report
ZhangXin8069
当用户要求制作或修改 PyQCU 中文横版 Beamer、竖版完整讲稿或同源 PPTX, 或说“做汇报 PPT”“生成讲稿”“横版改 LaTeX”“补充公式/算法页”时使用。 纯性能基准、算法分析或代码修复任务不使用本技能。
SkillAFreshness: A★ 4Claude Code +9 - 0.606score
pyqcu-kupl
ZhangXin8069
当维护或验证 cpp/kupl/qcu、pyqcu.kupl、pyqcu/testing/kupl,处理鲲鹏/NUMA CPU 版 QCU,MPI+OpenMP Wilson/Clover dslash、Clover BiStabCG、csw、 Wilson BiStabCG/CG、3D…
SkillAFreshness: A★ 4Claude Code +9 - 0.606score
pyqcu-md-tex-sync
ZhangXin8069
{除非用户明确要求,否则不启用}。仅当当前用户明确点名 `pyqcu-md-tex-sync` / `~pyqcu-md-tex-sync`(或全局 `md-tex-sync`),或明确要求 Markdown 与 LaTeX/PDF 同源维护、双格式同步交付、全文全集与全附件归档时使用;普通…
SkillAFreshness: A★ 4Claude Code +9 - 0.605score
pyqcu-benchmark
ZhangXin8069
当需要运行或解释 PyQCU/QCU/QUDA 性能基准、公平计时、显存或容量证据时使用。
SkillAFreshness: A★ 4Claude Code +9 - 0.603score
pyqcu-cpp-qcu-python
ZhangXin8069
当任务涉及 cpp/cuda/qcu/python、C API、qcu_api.pxd、qcu.pyx 或 qcu.pyi 同步时使用。
SkillAFreshness: A★ 4Claude Code +9 - 0.603score
pyqcu-api
ZhangXin8069
当任务涉及 pyqcu.api、后端无关配置/结果/能力/资产 manifest、公共 Protocol 或 Multigrid.solve_result 兼容层时使用。
SkillAFreshness: A★ 4Claude Code +9 - 0.603score
pyqcu-form
ZhangXin8069
当用户要求审计或整改 PyQCU 的命名、目录结构、代码框架、文档、日志、数据、 测试布局、仓库清洁度与 Git 交付格式时使用;入口为 `~form` 或 `form`。
SkillAFreshness: A★ 4Claude Code +9 - 0.603score
pyqcu-lattice
ZhangXin8069
当任务涉及 pyqcu.lattice、gamma/Gell-Mann、SU(3) 检查、规范场生成或 Ward 索引时使用。
SkillAFreshness: A★ 4Claude Code +9 - 0.603score
pyqcu-cann
ZhangXin8069
当任务涉及 pyqcu.cann、Ascend/NPU 复数兼容层、force_use_npu 或复数 einsum 分解时使用。
SkillAFreshness: A★ 4Claude Code +9 - 0.603score
pyqcu-dslash
ZhangXin8069
当任务涉及 pyqcu.torch.dslash、Wilson/Clover dslash、hopping/sitting/operator 或奇偶预处理时使用。
SkillAFreshness: A★ 4Claude Code +9 - 0.603score
pyqcu-cpp-qcu
ZhangXin8069
当任务涉及 cpp/cuda/qcu 的 CUDA 内核、MPI halo、MultiGrid 或 C++ 参数与显存生命周期时使用。
SkillAFreshness: A★ 4Claude Code +9
Signals
- Stars
- 4
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 23, 2026 (7 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/ZhangXin8069/PyQCU
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from ZhangXin8069
- 0.611score
pyqcu-docs
ZhangXin8069
当需要定位 PyQCU 的权威项目文档、把 docs/ 内容提取或同步到 skills/、查询安装/ 环境/维度/测试入口、判断正式文档与阶段报告的生命周期,或追踪 CUDA、MultiGrid、 KUPL、benchmark 与 profiler 知识来源时使用。
SkillAFreshness: A★ 4Claude Code +9 - 0.608score
pyqcu-report
ZhangXin8069
当用户要求制作或修改 PyQCU 中文横版 Beamer、竖版完整讲稿或同源 PPTX, 或说“做汇报 PPT”“生成讲稿”“横版改 LaTeX”“补充公式/算法页”时使用。 纯性能基准、算法分析或代码修复任务不使用本技能。
SkillAFreshness: A★ 4Claude Code +9 - 0.606score
pyqcu-kupl
ZhangXin8069
当维护或验证 cpp/kupl/qcu、pyqcu.kupl、pyqcu/testing/kupl,处理鲲鹏/NUMA CPU 版 QCU,MPI+OpenMP Wilson/Clover dslash、Clover BiStabCG、csw、 Wilson BiStabCG/CG、3D…
SkillAFreshness: A★ 4Claude Code +9 - 0.606score
pyqcu-md-tex-sync
ZhangXin8069
{除非用户明确要求,否则不启用}。仅当当前用户明确点名 `pyqcu-md-tex-sync` / `~pyqcu-md-tex-sync`(或全局 `md-tex-sync`),或明确要求 Markdown 与 LaTeX/PDF 同源维护、双格式同步交付、全文全集与全附件归档时使用;普通…
SkillAFreshness: A★ 4Claude Code +9 - 0.605score
pyqcu-benchmark
ZhangXin8069
当需要运行或解释 PyQCU/QCU/QUDA 性能基准、公平计时、显存或容量证据时使用。
SkillAFreshness: A★ 4Claude Code +9 - 0.603score
pyqcu-cpp-qcu
ZhangXin8069
当任务涉及 cpp/cuda/qcu 的 CUDA 内核、MPI halo、MultiGrid 或 C++ 参数与显存生命周期时使用。
SkillAFreshness: A★ 4Claude Code +9
Cite this page
pyqcu-cuda skill. Agent Mart. https://agentmart.dev/skills/zhangxin8069-pyqcu-cuda (last updated 2026-10-24)