ruvnet/ruflo · error
dropoutRate must be between 0 and 1
Error message
dropoutRate must be between 0 and 1
What it means
Thrown by AttentionCoordinator#validateConfig (v3/@claude-flow/integration/src/attention-coordinator.ts:488) when config.dropoutRate is outside [0, 1]. Dropout is a probability, so negative values or values above 1 are rejected (both boundaries inclusive — 0 and 1 are valid).
Source
Thrown at v3/@claude-flow/integration/src/attention-coordinator.ts:488
return {
avgLatencyMs: 0,
throughputTps: 0,
memoryEfficiency: 1.0,
cacheHitRate: 0,
totalOperations: 0,
speedupFactor: 1.0,
};
}
private validateConfig(): void {
if (this.config.numHeads <= 0) {
throw new Error('numHeads must be positive');
}
if (this.config.headDim <= 0) {
throw new Error('headDim must be positive');
}
if (this.config.dropoutRate < 0 || this.config.dropoutRate > 1) {
throw new Error('dropoutRate must be between 0 and 1');
}
if (this.config.flashOptLevel < 0 || this.config.flashOptLevel > 3) {
throw new Error('flashOptLevel must be between 0 and 3');
}
}
private async prewarmCache(): Promise<void> {
// Pre-compute common attention patterns
// This is a no-op in the simplified implementation
}
/**
* Perform attention computation
*
* ADR-001: For sequences longer than 512 tokens, delegates to
* agentic-flow's native Flash Attention (approximate sparse attention;
* speedup unverified — see docs/reviews/intelligence-system-audit-2026-05-29.md).
*/View on GitHub (pinned to fa13ee4ad6)
Solutions
- Express dropout as a fraction in [0, 1] — e.g. 0.1 for 10%, not 10.
- If your config stores percent, convert before constructing: dropoutRate: percent / 100.
- Add a config lint that clamps or rejects out-of-range probabilities at load time.
Example fix
// before
new AttentionCoordinator({ dropoutRate: 10 }); // meant 10%
// after
new AttentionCoordinator({ dropoutRate: 0.1 }); // fraction Defensive patterns
Strategy: validation
Validate before calling
function toProbability(v: unknown, fallback = 0.1): number {
const n = typeof v === 'number' ? v : Number(v);
return Number.isFinite(n) && n >= 0 && n <= 1 ? n : fallback;
}
new AttentionCoordinator({ ...cfg, dropoutRate: toProbability(cfg.dropoutRate) }); Type guard
function isProbability(v: unknown): v is number {
return typeof v === 'number' && Number.isFinite(v) && v >= 0 && v <= 1;
} Try / catch
try {
coord = new AttentionCoordinator(cfg);
} catch (e) {
if ((e as Error).message === 'dropoutRate must be between 0 and 1') {
coord = new AttentionCoordinator({ ...cfg, dropoutRate: 0.1 });
} else throw e;
} Prevention
- Store dropout as a fraction everywhere — document 0.1 = 10%.
- Convert percent configs at the boundary: value / 100.
- NaN bypasses the range check (NaN comparisons are false) — always check Number.isFinite too.
When it happens
Trigger: Passing dropoutRate: 5 (a percentage instead of a fraction), -1, or NaN-sourced values; configs shared with a library that expresses dropout in percent (0–100); values parsed from strings ('0.1' works via coercion, but '1e-' style typos yield NaN which passes the range check silently only if NaN — note NaN < 0 is false and NaN > 1 is false, so NaN slips through; the thrown case is concrete out-of-range numbers).
Common situations: Porting a config from a framework using percent dropout; hand-edited YAML with a typo like 0..1; LLM-generated config with plausible-looking but wrong values.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- flashOptLevel must be between 0 and 3
- numHeads must be positive
- headDim must be positive
- SemanticRouter requires a dimension in config
- Flash attention not initialized
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/360c8436a3b825e8.
Report an issue: GitHub.