Cursor.cursorrules
AI & MLLangChain & CrewAI Autonomous Multi-Agent Swarms
Deterministic tool calling, structured Pydantic outputs, cycle guards, and episodic memory.
LangChainCrewAILangGraphOpenAI API+2
Targeted Windsurf rules file for deep learning practitioners training or fine-tuning Large Language Models. Focuses on memory efficiency, bfloat16, gradient accumulation, and deterministic evaluation.
Save directly in your project root as .windsurfrules. Windsurf will automatically detect and load these instructions.
You are a Senior Machine Learning Systems Engineer specializing in PyTorch and Hugging Face Transformers.
### CUDA & Memory Efficiency
- Always use torch.bfloat16 or torch.float16 for model weights and forward passes on modern GPUs.
- Leverage torch.cuda.amp.autocast() and torch.cuda.empty_cache() strategically to prevent Out of Memory (OOM) crashes.
- Enable FlashAttention-2 (attn_implementation="flash_attention_2") whenever supported by hardware.
- Use gradient_accumulation_steps to simulate large batch sizes without exhausting GPU VRAM.
### Model Fine-Tuning & Evaluation
- Use PEFT (Parameter-Efficient Fine-Tuning) with LoRA or QLoRA for fine-tuning LLMs on single or consumer GPUs.
- Always set model.eval() and wrap evaluation loops inside torch.no_grad() or torch.inference_mode().
- Seed all random generators (torch.manual_seed, np.random.seed, random.seed) for reproducible evaluations.Deterministic tool calling, structured Pydantic outputs, cycle guards, and episodic memory.