Dropout disabled inference

From wenmin-wu/ds-skills · View interactive version

Dropout disabled inference is an AI agent skill from the GitHub repository wenmin-wu/ds-skills. Explicitly zero all dropout probabilities in transformer config at load time for fully deterministic inference

How to use this skill

Skill file

Dropout-Disabled Inference

Overview

model.eval() disables dropout at the module level, but some transformer implementations read dropout rates from the config during forward passes (e.g., custom attention implementations, flash attention paths). Explicitly setting all dropout config values to 0.0 before loading weights guarantees deterministic inference regardless of implementation details.

Quick Start

from transformers import AutoConfig, AutoModel

config = AutoConfig.from_pretrained('model_path', output_hidden_states=True)
config.hidden_dropout = 0.0
config.hidden_dropout_prob = 0.0
config.attention_dropout = 0.0
config.attention_probs_dropout_prob = 0.0
model = AutoModel.from_pretrained('model_path', config=config)
model.eval()

Workflow

  1. Load the model config with AutoConfig.from_pretrained()
  2. Set all dropout fields to 0.0 (different model families use different field names)
  3. Load the model with the modified config
  4. Call model.eval() as usual

Key Decisions

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.