{"record":{"id":"81942053d9722845","repo":"ruvnet/ruflo","slug":"moe-attention-not-initialized","errorCode":null,"errorMessage":"MoE attention not initialized","messagePattern":"MoE attention not initialized","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/ruvector-training.ts","lineNumber":606,"sourceCode":"  values: Float32Array[]\n): Float32Array {\n  if (!flashAttention) {\n    throw new Error('Flash attention not initialized');\n  }\n\n  return flashAttention.computeRaw(query, keys, values);\n}\n\n/**\n * Compute MoE routing\n */\nexport function computeMoEAttention(\n  query: Float32Array,\n  keys: Float32Array[],\n  values: Float32Array[]\n): Float32Array {\n  if (!moeAttention) {\n    throw new Error('MoE attention not initialized');\n  }\n\n  return moeAttention.computeRaw(query, keys, values);\n}\n\n/**\n * Compute hyperbolic attention (for hierarchical patterns)\n */\nexport function computeHyperbolicAttention(\n  query: Float32Array,\n  keys: Float32Array[],\n  values: Float32Array[]\n): Float32Array {\n  if (!hyperbolicAttention) {\n    throw new Error('Hyperbolic attention not initialized');\n  }\n\n  return hyperbolicAttention.computeRaw(query, keys, values);","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/services/ruvector-training.ts#L588-L624","documentation":"Thrown by computeMoEAttention() when moeAttention is null. Unlike flash attention, MoE is opt-in: initializeTraining() constructs MoEAttention.simple(dim, 8, 2) only when config.useMoE is truthy AND the optional @ruvector/attention package is importable. The error therefore most commonly means you forgot { useMoE: true } rather than a broken install.","triggerScenarios":"Calling computeMoEAttention after init without the useMoE flag; passing { useMoE: true } in an environment where @ruvector/attention failed to import (init then silently skips all attention features, logging a warning); calling after cleanup().","commonSituations":"Copy-pasting MoE benchmark code into a pipeline whose init config was written before MoE existed; feature-flag configs where useMoE is conditioned on an env var that isn't set in the failing environment; slim production installs missing the optional attention package.","solutions":["Initialize with { useMoE: true } and assert the returned features include 'MoE (8 experts, top-2)'.","If you did pass useMoE: true and still see the error, check init logs/warnings for '@ruvector/attention unavailable' and reinstall the dependency.","Gate MoE code paths on the init result's features list so callers degrade to computeFlashAttention instead of throwing.","Re-run initializeTraining after cleanup() before any MoE call."],"exampleFix":"// before\nawait initializeTraining({});\nconst routed = computeMoEAttention(query, keys, values); // throws — MoE is opt-in\n\n// after\nconst init = await initializeTraining({ useMoE: true });\nif (!init.features.some(f => f.startsWith('MoE'))) {\n  throw new Error('MoE unavailable: ' + init.features.join(', '));\n}\nconst routed = computeMoEAttention(query, keys, values);","handlingStrategy":"validation","validationCode":"const init = await initializeTraining({ useMoE: true }); // MoE is opt-in\nif (!init.features.some(f => f.startsWith('MoE'))) {\n  throw new Error(`MoE unavailable — check @ruvector/attention install. Features: ${init.features.join(', ')}`);\n}\nconst routed = computeMoEAttention(query, keys, values);","typeGuard":"async function moeReady(cfg: TrainingConfig = {}): Promise<boolean> {\n  const init = await initializeTraining(cfg);\n  return init.features.some(f => f.startsWith('MoE'));\n}","tryCatchPattern":"try {\n  return computeMoEAttention(q, keys, values);\n} catch (e) {\n  if (e instanceof Error && e.message === 'MoE attention not initialized') {\n    return computeFlashAttention(q, keys, values); // feature-degrade, don't crash\n  }\n  throw e;\n}","preventionTips":["Pass { useMoE: true } in the same bootstrap that owns all training config — one config object, one source of truth.","Feature-detect via the init result instead of assuming flags took effect (the package may be missing).","Gate MoE-specific code paths behind the features check and provide a flash/dot-product fallback.","Verify optionalDependencies survive your deploy pipeline."],"tags":["initialization","ruvector","moe","attention","optional-dependency"],"backgroundTag":"component-not-initialized","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}