skills/skillxiv-v0.0.2-claude-opus-4.6/cuda-l2-kernel-optimization/SKILL.md
Uses LLMs with RL to automatically optimize HGEMM CUDA kernels across 1,000 configurations, systematically outperforming NVIDIA's cuBLAS and cuBLASLt through continued pretraining, general RL, and specialized HGEMM RL stages.
npx skillsauth add ADu2021/skillXiv cuda-l2-kernel-optimizationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
CUDA-L2 combines large language models with reinforcement learning to automatically optimize Half-precision General Matrix Multiply (HGEMM) CUDA kernels. The system employs a three-stage training approach: continued pretraining on diverse CUDA code, general kernel RL training, and specialized HGEMM RL training using execution speed as the reward signal.
Multi-Stage LLM Training:
Kernel Generation: The LLM generates complete CUDA kernel source code as text. Each generation is compiled, executed, and evaluated on speed.
Reward Signal: Execution time on representative workloads:
reward = baseline_speed / optimized_speed
Higher reward indicates better optimization.
Continued pretraining data: Collect CUDA kernel implementations:
# Dataset: [kernel_code, optimization_notes, performance_hints]
pretrain_data = [(kernel1, notes1), (kernel2, notes2), ...]
General RL training:
for iteration in range(num_iterations):
# Generate kernel code
kernel_code = llm.generate(prompt=problem_spec)
# Compile and execute
compiled = compile_cuda(kernel_code)
speed = measure_execution_time(compiled, workload)
# Compute reward
reward = baseline_speed / speed if compiled_successfully else -1.0
# Update LLM
llm.update_with_rl(trajectory, reward)
HGEMM specialization: Create specialized prompts:
task_prompt = """
Optimize HGEMM for:
- Matrix size: 4096x4096
- Batch size: 16
- Hardware: A100 GPU
Requirements: maximize throughput
"""
testing
Uses flow maps as look-ahead operators to enable principled reward-guided diffusion by predicting trajectory endpoints at any denoising step. Deploy when applying rewards or preferences to diffusion trajectories with meaningful gradients throughout generation.
testing
Train language models where each expert learns independently on closed datasets, enabling flexible inference with selective data inclusion or exclusion. 41% performance improvement while allowing users to opt out of specific data sources without retraining.
data-ai
Understand how token generation flexibility in diffusion LMs paradoxically constrains reasoning, as models exploit ordering flexibility to avoid uncertain tokens, and apply simplified approaches that preserve parallel decoding benefits. Use when optimizing diffusion-based language models for reasoning tasks.
devops
Enable LLM agents to improve continuously during deployment by constructing structured experience libraries through self-reflection on successes and failures—achieving 23% improvement on reasoning without gradient-based parameter updates or external training.