{"id":26858,"library":"cpm-kernels","title":"CPM Kernels","description":"CUDA kernels for the CPM (Chinese Pre-trained Model) family, providing optimized operations like rotary position embedding, layer normalization, and activation functions. Current version is 1.0.11, with irregular release cadence.","status":"active","version":"1.0.11","language":"python","source_language":"en","source_url":"https://github.com/OpenBMB/cpm-kernels","tags":["cuda","transformers","nlp","chinese","pretrained model"],"install":[{"cmd":"pip install cpm-kernels","lang":"bash","label":"pip install"}],"dependencies":[{"reason":"CUDA kernels require PyTorch with CUDA support","package":"torch","optional":false}],"imports":[{"note":"Common misconception: kernel is not directly importable; CPUKernel is the main class","wrong":"","symbol":"CPUKernel","correct":"from cpm_kernels import CPUKernel"},{"note":"rotary_embedding is in the library submodule, not top-level","wrong":"from cpm_kernels import rotary_embedding","symbol":"rotary_embedding","correct":"from cpm_kernels.library import rotary_embedding"}],"quickstart":{"code":"import torch\nfrom cpm_kernels import CPMKernel\n\ndevice = 'cuda' if torch.cuda.is_available() else 'cpu'\nx = torch.randn(2, 4, 64).to(device)\nkernel = CPMKernel()\nresult = kernel.rotary_embedding(x, start=0)\nprint(result.shape)","lang":"python","description":"Initialize CPMKernel and apply rotary position embedding on a random tensor."},"warnings":[{"fix":"Ensure torch.cuda.is_available() is True before using.","message":"Requires a CUDA-capable GPU and PyTorch compiled with CUDA. Runtime errors if no GPU available.","severity":"gotcha","affected_versions":"all"},{"fix":"Use recommended alternatives (e.g., torch's native layernorm) or avoid deprecated calls.","message":"Some kernel functions (e.g., 'fused_ln') are deprecated in newer versions and may be removed. Check documentation.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from cpm_kernels.library import rotary_embedding' instead.","cause":"Wrong import path; rotary_embedding is in cpm_kernels.library.","error":"ImportError: cannot import name 'rotary_embedding' from 'cpm_kernels'"},{"fix":"Reinstall cpm-kernels from source with `pip install --no-binary cpm-kernels cpm-kernels` to compile for your GPU.","cause":"The installed cpm-kernels wheel may not have been compiled for your specific GPU architecture.","error":"RuntimeError: CUDA error: no kernel image is available for execution on the device"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}