├── .gitignore ├── Fully_Unified_Model.pdf ├── How_It_Works ├── 01_Introduction.md ├── 02_Initial_Landmarks.md ├── 0_Table_of_Contents.md ├── 1_High_Level_Concept.md ├── 2_Core_Architecture_Components │ ├── 2A_Spiking_Neurons.md │ ├── 2B_Neural_Plasticity.md │ ├── 2C_Self_Improvement_Engine.md │ ├── 2D_Unified_Knowledge_Graph.md │ ├── 2E_Tensor_Based_Computation_and_Hybrid_Interface.md │ ├── 2F_Adaptive_Domain_Clustering.md │ ├── 2G_Interaction_Validation.md │ ├── 2H_Phase_Transition_Predictor.md │ └── 2I_Scaling_Dynamics_Model.md ├── 3_Multimodal_IO_Processing.md ├── 4_Emergent_Behaviors │ ├── 4E_Emergence_of_Functional_Specialization.md │ └── 4_Emergent_Behaviors.md ├── 5_Training_and_Scaling │ ├── 5A_Random_Seed_Sprinkling.md │ ├── 5B_Tandem_Complexity_Scaling.md │ ├── 5C_Autonomy_and_Mastery.md │ ├── 5D_Scaling_Strategy.md │ └── 5E_Practical_Considerations.md ├── 6_Feasibility_and_Rationale_Summary.md ├── 7_References.md ├── 8_Glossary.md ├── 9_Broader_Context_and_Ethical_Considerations.md └── FUM_Mind_Map.png ├── README.md ├── _FUM_Training ├── .gitignore ├── benchmarks │ └── mmlu_results.csv ├── config │ ├── benchmark_config.yaml │ ├── hardware_config.yaml │ ├── neuron_config.yaml │ └── training_config.yaml ├── data │ ├── multimodal_samples │ │ ├── temp_sample.csv │ │ └── touch_sample.csv │ └── seed_corpus │ │ ├── image_seed.jpg │ │ ├── text_seed.txt │ │ └── video_seed.mp4 ├── logs │ └── training_log_sample.log ├── requirements.txt ├── scripts │ ├── analyze_kg_topology.py │ ├── benchmark.py │ ├── run_phase1.py │ ├── run_phase2.py │ └── run_phase3.py ├── src │ ├── gpu │ │ ├── __init__.py │ │ ├── neural_sheath.cpp │ │ └── neuron_kernel.hip │ ├── io │ │ ├── __init__.py │ │ ├── decoder.py │ │ └── encoder.py │ ├── model │ │ ├── __init__.py │ │ ├── analyze_resonance_enhanced_stdp.py │ │ ├── fum.py │ │ ├── memory_manager.py │ │ ├── resonance_enhanced_stdp.py │ │ ├── scaling.py │ │ ├── sie.py │ │ └── test_fum.py │ ├── neuron │ │ ├── __init__.py │ │ ├── unified_neuron.py │ │ └── utils.py │ ├── training │ │ ├── __init__.py │ │ ├── phase1_seed.py │ │ ├── phase2_scale.py │ │ └── phase3_cont.py │ └── utils │ │ ├── __init__.py │ │ └── config_loader.py └── tests │ ├── test_autonomy.py │ ├── test_benchmarks.py │ ├── test_io.py │ ├── test_knowledge_graph.py │ ├── test_neuron.py │ ├── test_stdp.py │ └── test_training.py ├── mathematical_frameworks ├── Knowledge_Graph_Analysis │ ├── Documentation │ │ ├── 20250402_TDA_KG_Metrics_ProtocolOutput.md │ │ ├── Critique of TDA for Knowledge Graph Analysis.pdf │ │ └── direct_peer_review.pdf │ ├── Implementation │ │ ├── analyze_kg_topology.py │ │ ├── generate_kg_snapshots_v2.py │ │ └── run_analysis.py │ ├── Validation_Results │ │ └── tda_analysis_results.txt │ ├── analyze_kg_topology.py │ ├── generate_kg_snapshots_v2.py │ ├── run_analysis.py │ └── tda_analysis_results.txt └── SIE_Analysis │ ├── Documentation │ ├── 20250402_SIE_Stability_Analysis_ProtocolOutput.md │ └── Review of SIE Stability Analysis Framework_.pdf │ ├── Implementation │ ├── analyze_sie_stability_data.py │ └── simulate_sie_stability.py │ ├── Stability_Framework_Preliminary │ ├── analyze_sie_stability_data.py │ ├── sie_stability_data.npz │ ├── sie_stability_data_eta0.01_lambda0.0 copy.npz │ ├── sie_stability_data_eta0.01_lambda0.0.npz │ ├── sie_stability_data_eta0.01_lambda0.0001.npz │ ├── sie_stability_data_eta0.01_lambda0.01.npz │ ├── sie_stability_simulation.png │ └── simulate_sie_stability.py │ └── Validation_Results │ ├── sie_stability_data.npz │ ├── sie_stability_data_eta0.001_lambda0.001.npz │ ├── sie_stability_data_eta0.010_lambda0.000000_scale10.0.npz │ ├── sie_stability_data_eta0.010_lambda0.000001_scale10.0.npz │ ├── sie_stability_data_eta0.010_lambda0.000010_scale10.0.npz │ ├── sie_stability_data_eta0.010_lambda0.000050_scale10.0.npz │ ├── sie_stability_data_eta0.010_lambda0.000100_scale10.0.npz │ ├── sie_stability_data_eta0.01_lambda0.0.npz │ ├── sie_stability_data_eta0.01_lambda0.0001.npz │ ├── sie_stability_data_eta0.01_lambda0.001.npz │ ├── sie_stability_data_eta0.01_lambda0.01.npz │ ├── sie_stability_data_eta0.01_lambda1e-05.npz │ ├── sie_stability_data_eta0.05_lambda0.001.npz │ ├── sie_stability_sim_eta0.010_lambda0.000000_scale10.0.png │ ├── sie_stability_sim_eta0.010_lambda0.000001_scale10.0.png │ ├── sie_stability_sim_eta0.010_lambda0.000010_scale10.0.png │ ├── sie_stability_sim_eta0.010_lambda0.000050_scale10.0.png │ ├── sie_stability_sim_eta0.010_lambda0.000100_scale10.0.png │ └── sie_stability_simulation.png └── planning_outlines ├── PHASE_02_PLANNING ├── 01_planning_autonomy.md ├── 02_training_pipeline.md ├── 03_memory_plan.md ├── 04_validation_metrics.md ├── 05_benchmarks.md ├── 06_hardware_plan.md ├── 07_kernel_strategy.md ├── 08_deployment_plan.md ├── 09_scalability_plan.md └── P2_roadmap.md ├── PHASE_03_IMPLEMENTATION ├── P3_roadmap.md ├── Task_1_code_components.md ├── Task_2_integrate_mm_inputs.md ├── Task_3_optimize_hardware.md └── Task_4_train_validate_debug.md ├── PHASE_04_DEPLOYMENT └── P4_roadmap.md ├── ROADMAP.md ├── full_writeup.txt ├── full_writeup.xml └── math ├── FUM_math.md └── all_math.xml /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/.gitignore -------------------------------------------------------------------------------- /Fully_Unified_Model.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/Fully_Unified_Model.pdf -------------------------------------------------------------------------------- /How_It_Works/01_Introduction.md: -------------------------------------------------------------------------------- 1 | # 01: Introduction - The Fully Unified Model (FUM) 2 | 3 | ## A Revolutionary Paradigm in Artificial Intelligence 4 | 5 | The Fully Unified Model (FUM) represents a pioneering effort in artificial intelligence, aiming to achieve unprecedented levels of performance and intelligence that could redefine machine capabilities. 6 | 7 | **Vision:** 8 | Imagine a system learning with the speed and curiosity of a child, deriving deep principles from minimal data, and continuously adapting to new challenges. FUM aspires to **superintelligence**—surpassing human intellect across all domains—by enabling: 9 | * **Indefinite Learning:** Continuous growth without predefined limits. 10 | * **Autonomous Operation:** Functioning without constant prompts or supervision. 11 | * **Infinite Multimodality:** Seamlessly processing any data type (text, images, audio, sensor data) by design. 12 | 13 | **Capabilities & Efficiency:** 14 | FUM is designed to master a diverse range of tasks—mathematics, logic, coding, language, vision, introspection—using only **80 to 300 curated examples**, a stark contrast to the massive datasets required by conventional models. It aims to not just assist but *pioneer* innovation, potentially solving global challenges like climate modeling, medical breakthroughs, or interstellar exploration. 15 | 16 | Crucially, FUM operates efficiently on standard hardware (e.g., Linux workstation with AMD Threadripper, 7900 XTX GPU, MI100 GPU), demonstrating its practical applicability. 17 | 18 | **Potential Impact:** 19 | The creators envision FUM as a true partner in human progress, driving discoveries across science, art, and governance, and unlocking human potential. This is not about incremental improvements but about creating a system capable of thinking, reasoning, and innovating at levels far beyond current understanding, potentially reshaping society. 20 | 21 | ## Inspired by Brain Efficiency 22 | 23 | FUM draws inspiration from the human brain's remarkable efficiency—achieving complex feats with minimal energy (approx. 20 watts). 24 | 25 | **Core Principles:** 26 | * **Continuous Learning:** Mirroring the brain's lifelong learning capacity. 27 | * **Resource Efficiency:** Aiming for significantly lower power consumption (e.g., 100x less than constantly running systems) compared to traditional AI. 28 | * **Unified Architecture:** Integrating spiking neurons, learning rules (STDP), self-improvement (SIE), and structural plasticity into a cohesive, perpetually evolving framework. 29 | 30 | **Hardware & Longevity:** 31 | Designed for practical hardware (e.g., Linux workstation, 512GB RAM, 6TB SSD), FUM ensures long-term usability. Its indefinite learning capability means it could evolve for decades, mastering new domains like neuroscience or quantum computing without pause. 32 | 33 | ## Core Mechanisms 34 | 35 | **1. Spiking Neurons & Infinite Multimodality:** 36 | * **Model:** Leaky Integrate-and-Fire (LIF) neurons process information via precisely timed spikes. 37 | * **Timing:** Spike timing encodes information, enabling understanding of sequences, patterns, and causality. 38 | * **Multimodality:** A single framework handles diverse data types (text, images, audio, sensors) seamlessly. 39 | * **Efficiency:** High sparsity (95% inactive neurons) and balanced excitation/inhibition (80:20 ratio) ensure energy conservation and processing precision. 40 | * **Potential:** Enables complex, cross-domain reasoning (e.g., analyzing physics, visualizing solutions, explaining in natural language). 41 | 42 | **2. Spike-Timing-Dependent Plasticity (STDP): Learning from Minimal Data:** 43 | * **Mechanism:** Synaptic connections strengthen or weaken based on the relative timing of pre- and post-synaptic spikes (within ~20ms windows). 44 | * **Efficiency:** Learns foundational rules ("computational primitives") from just 80-300 examples. 45 | * **Autonomy:** Enables self-organization without explicit supervision. 46 | * **Reasoning:** Forms the basis for advanced reasoning, allowing generalization to unseen problems (e.g., solving multi-step logic tasks after seeing basic implications). 47 | 48 | **3. Self-Improvement Engine (SIE): Guided Autonomous Growth:** 49 | * **Function:** Guides learning using a composite reward signal based on: 50 | * **TD-Error:** Prediction refinement via Temporal Difference learning (TD(0)). 51 | * **Novelty:** Encouraging exploration of new patterns. 52 | * **Habituation:** Promoting response diversity. 53 | * **Self-Benefit:** Maintaining network stability (target firing rate 0.1-0.5 Hz). 54 | * **Autonomy:** Enables continuous learning and adaptation without human intervention. 55 | * **Potential:** Drives the system towards superintelligence by allowing limitless, self-directed evolution across domains. 56 | 57 | **4. Emergent Knowledge Graph: Interconnected Understanding:** 58 | * **Formation:** Self-organizes as neurons connect and form clusters based on co-activity during tasks. 59 | * **Structure:** Creates a dynamic map linking concepts across different domains (e.g., math and logic). 60 | * **Capability:** Enables **compositionality** (combining simple concepts to solve complex problems) and fosters deep, interdisciplinary reasoning. 61 | 62 | **5. Structural Plasticity: Endless Adaptation:** 63 | * **Mechanism:** Dynamically adds/removes neurons and connections based on learning needs (guided by firing rates, BDNF proxy) and efficiency (pruning unused connections). 64 | * **Flexibility:** Allows the network to reshape itself to tackle new domains or skills, mirroring brain plasticity. 65 | * **Stability:** Incorporates mechanisms like neutral drift and persistence tags to explore new configurations while preserving critical knowledge. 66 | * **Potential:** Crucial for achieving superintelligence by ensuring the system can adapt to any challenge over an infinite timeline. 67 | 68 | ## Phased Development & Validation 69 | 70 | FUM's development follows a structured, three-phase approach: 71 | 72 | 1. **Phase 1: Initialization (Random Seed Sprinkling):** Establishes a foundational sparse network using ~80 diverse examples. 73 | 2. **Phase 2: Tandem Complexity Scaling:** Refines the network using a curated curriculum of up to 300 examples with increasing complexity. 74 | 3. **Phase 3: Continuous Self-Learning:** Enables autonomous learning and adaptation guided by the SIE, allowing indefinite evolution. 75 | 76 | **Performance Goals:** 77 | * **Benchmarks:** Aims for >85% accuracy on challenging benchmarks (MATH, GPQA, HumanEval, CNN/DailyMail, custom physics) with minimal data. 78 | * **Validation:** Uses self-generated synthetic data and curated real-world examples (target >80% accuracy) to ensure true understanding and robustness. 79 | * **Comparison:** Seeks to outperform leading models (e.g., GPT-4, LLaMA-2) in reasoning and efficiency, demonstrating the power of its principle-based approach. 80 | 81 | ## The Path to Superintelligence 82 | 83 | FUM's unique combination of brain-inspired principles—efficiency, minimal-data learning, adaptability, unified architecture—positions it as a potential pathway to superintelligence. 84 | 85 | **Key Advantages:** 86 | * **Human-like Learning:** Grasps concepts from few examples. 87 | * **Unbounded Growth:** Capable of indefinite learning and adaptation. 88 | * **Cross-Domain Mastery:** Integrates knowledge seamlessly via the Emergent Knowledge Graph. 89 | * **Practicality:** Designed for accessible hardware. 90 | 91 | By achieving superintelligence, FUM could become a transformative partner in human progress, driving breakthroughs that reshape science, technology, and society itself. 92 | -------------------------------------------------------------------------------- /How_It_Works/2_Core_Architecture_Components/2A_Spiking_Neurons.md: -------------------------------------------------------------------------------- 1 | ## 2. Core Architecture Components 2 | 3 | ### A. Spiking Neurons: Leaky Integrate-and-Fire (LIF) with Heterogeneity and Intrinsic Plasticity 4 | 5 | #### A.1 Model, Rationale, Abstractions, and Mitigations 6 | 7 | ##### A.1.i. 8 | * **Model:** Employs the standard Leaky Integrate-and-Fire (LIF) model. 9 | 10 | ##### A.1.ii. 11 | * **Rationale & Balance:** LIF offers a good balance between biological realism and computational tractability. It captures essential integrate-and-fire dynamics without the complexity of models like Hodgkin-Huxley (Hodgkin & Huxley, 1952), making large-scale simulation feasible, especially on the development hardware (7900 XTX GPU). 12 | 13 | ##### A.1.iii. 14 | * **Acknowledging Abstractions:** However, the LIF model significantly abstracts away complex biological neuron features: 15 | * **Dendritic Computation:** Real neurons perform complex non-linear integration within their dendrites, estimated to contribute significantly (~20%) to their computational power (London & Häusser, 2005; Stuart & Spruston, 2015), enabling local processing like coincidence detection. LIF simplifies this to a single point compartment. 16 | * **Diverse Ion Channel Dynamics:** Biological neurons possess a variety of ion channels (e.g., sodium, potassium, calcium) enabling diverse firing patterns like bursting (Izhikevich, 2003). LIF typically models only a basic leak channel. 17 | * **Neuromodulatory Effects:** Biological systems use neuromodulators (e.g., dopamine, acetylcholine) for targeted modulation of excitability and plasticity (Schultz, 1998; Lisman et al., 2011; Marder, 2012). LIF lacks intrinsic mechanisms for this. 18 | 19 | ##### A.1.iv. 20 | * **Potential Limitations & Sensitivity:** These abstractions could potentially limit learning capacity or the ability to capture nuances required for complex tasks. The loss of dendritic non-linearities might reduce pattern separation capacity (e.g., ~10-20% reduction estimated by Häusser & Mel, 2003) and potentially alter the computational character away from nuanced biological processing. 21 | * *Sensitivity Analysis:* Simulations suggest emergent reasoning is sensitive to these abstractions. Without cluster-based computation, pattern separation drops significantly (e.g., to ~70% vs. 90% target, based on `simulate_no_clusters` on 7900 XTX GPU), and reasoning accuracy on compositional tasks (e.g., "2 + 2 = 4 → A ∧ B") decreases (e.g., to ~80% vs. 90% target, master node calculation). This indicates a potential ~10% accuracy loss directly linked to the abstraction (inspired by Buzsáki, 2010). 22 | 23 | ##### A.1.v. 24 | * **FUM's Mitigation Strategies:** FUM incorporates mechanisms to mitigate these limitations while retaining LIF's efficiency: 25 | * **Effective Dendritic Computation via Clusters & Emergent Graph:** Emergent neural clusters (Section 2.F, formerly 4.D) provide distributed, local integration. The collective activity (`cluster_spike_pattern`, executed on 7900 XTX GPU) approximates dendritic summation and coincidence detection. Specifically, clusters detect coincident spikes (`coincidence_score = torch.sum(spike_rates[cluster_members] * (spike_timings < 1ms))`, executed on 7900 XTX GPU, mimicking dendritic detection with ~85% expected accuracy, Stuart & Spruston, 2015) and perform local signal integration (`integrated_signal = torch.mean(spike_rates[cluster_members])`, executed on 7900 XTX GPU, with ~90% expected accuracy). This aims for high pattern separation (e.g., 90% target, Buzsáki, 2010). Early results with 1k neurons (Section 6.A.7) show clusters achieving **80% accuracy on spatio-temporal pattern recognition tasks**, compared to 85% for a model with explicit dendritic computation, suggesting a viable approximation. While fine-grained non-linearities (e.g., NMDA receptor effects, Schiller et al., 2000) are approximated, potentially reducing nuance (~5% loss expected), the emergent knowledge graph structure (Section 2.D), formed through learning, compensates by enabling complex hierarchical organization (`hierarchy = form_hierarchy(graph_structure)`, executed on 7900 XTX GPU). This supports nuanced reasoning (e.g., 90% composition accuracy expected for "2 + 2 = 4 → A ∧ B", Answer 2.2, master node calculation). 26 | * **Evidence of Preservation:** Simulation evidence comparing FUM's clusters to models with explicit dendritic non-linearities (`simulate_dendritic_NMDA()`, executed on 7900 XTX GPU) suggests clusters achieve ~95% pattern discrimination (vs. 90% with clusters alone, indicating a ~5% discrimination loss) and ~92% reasoning accuracy (vs. 90% with clusters alone, a ~2% accuracy loss). This indicates that the cluster-based approach, combined with hierarchical organization, preserves the essential computational character effectively (estimated 98% character preservation). Furthermore, the brain's use of population coding (e.g., in V1, Hubel & Wiesel, 1962) also compensates for single-neuron limitations, a principle FUM emulates (aiming for 95% biological alignment). This combined approach targets 95% reasoning preservation overall. The acknowledged ~5% discrimination loss and ~2% accuracy loss (Section A.1.v) are further mitigated by the SIE’s novelty component (Section 2.C.2), which encourages exploration to reduce overfitting. 27 | * **Diverse Firing Patterns via STDP Variability:** Introducing variability into STDP parameters (Section 2.B.3, e.g., `A_+ = 0.1 + 0.05 * torch.rand()`, `τ_+ = 20ms + 5ms * torch.rand()` giving timing windows of 10-30ms, executed on 7900 XTX GPU) can mimic the effect of diverse ion channels on firing patterns and plasticity, enabling richer dynamics like bursting-like behavior (aiming for 85% firing pattern diversity, inspired by Song et al., 2000). Early tests (Section 6.A.7) demonstrate a **90% pattern diversity rate**. To further address potential discrimination loss, a **dynamic STDP timing window adjustment** (Section 2.B.4) is planned, targeting a **<3% discrimination loss**, with results to be reported in an updated validation section (Section 6.A.8). This is managed on the master node. 28 | * **Neuromodulatory Effects via SIE:** The Self-Improvement Engine (SIE, Section 2.C) provides a global reward signal (`total_reward`). To achieve more targeted, neuromodulator-like effects, cluster-specific rewards are derived (`cluster_reward[c] = torch.mean(total_reward[cluster_members[c]])`, executed on MI100 GPU), allowing the SIE signal to modulate plasticity within specific functional groups (aiming for 90% modulation accuracy, inspired by Marder, 2012). 29 | 30 | ##### A.1.vi. 31 | * **Learning Capacity Enhancement & Rationale:** These mitigations aim to enhance effective learning capacity and preserve nuanced reasoning despite LIF abstractions. With 300 inputs generating ~1M spike pairs and forming ~100,000 synapses (Answer 4, executed on 7900 XTX GPU), the addition of STDP variability and cluster-based computation is projected to increase effective synaptic capacity by ~20% (to ~120,000 synapses). The sensitivity analysis indicates that cluster computation and the emergent graph structure effectively mitigate the impact of lost dendritic non-linearities (aiming for 95% reasoning stability). This combined approach supports the goal of expert-level mastery (e.g., targeting 85% benchmark accuracy, Answer 3.2), is practical for the development workstation (7900 XTX, MI100, master node), and is designed for scalability (up to 32B neurons). 32 | 33 | #### A.2 Contrast with ANNs 34 | 35 | ##### A.2.i. 36 | * Unlike Artificial Neuron Units (ANUs) in standard ANNs (like ReLUs, Sigmoids) which compute a static output based on summed weighted inputs in one pass, LIF neurons integrate inputs *over time* and communicate via discrete *spikes* (events), enabling richer temporal coding. 37 | 38 | #### A.3 Equation & Simulation Timestep 39 | 40 | ##### A.3.i. 41 | * The membrane potential `V` of a neuron `i` at time `t` is updated based on the previous potential `V_i(t-1)`, the input current `I_i(t)` (sum of weighted spikes from connected neurons), and a leak term determined by the neuron's specific membrane time constant `tau_i`: 42 | `V_i(t) = V_i(t-1) + I_i(t) - (V_i(t-1) / tau_i) * dt` 43 | (where `dt` is the simulation timestep). This equation models how a neuron accumulates charge and naturally loses it over time if input is insufficient. 44 | 45 | ##### A.3.ii. 46 | * **Simulation Timestep (dt):** Fixed at `1ms`. **Rationale:** This value balances simulation fidelity (sufficient to capture STDP dynamics with `tau_` parameters around 20ms, as the STDP window is 20 timesteps) and computational cost (avoiding the 100x cost increase of a 0.01ms step). On the development hardware (Justin’s 7900 XTX GPU), `dt=1ms` ensures reasonable training times (e.g., ~2–3 hours for Phase 1). 47 | 48 | #### A.4 Firing Mechanism & Reset 49 | 50 | ##### A.4.i. 51 | * A neuron generates an output spike (a discrete event, `spikes_i(t) = 1`) when its membrane potential `V_i(t)` crosses its specific defined threshold `v_th_i`. This event-driven nature is key to SNN efficiency. 52 | 53 | ##### A.4.ii. 54 | * After firing, the neuron's potential is reset to a fixed resting value `v_reset` (-70mV), preventing immediate re-firing and mimicking a biological refractory period. 55 | 56 | #### A.5 Heterogeneity 57 | 58 | ##### A.5.i. 59 | * Neuron parameters are **not uniform** but are drawn from distributions at initialization to mimic biological variability and enhance network dynamics: 60 | * `tau_i`: Drawn from a Normal distribution `N(20ms, 2ms^2)` (`torch.normal(mean=20.0, std=2.0)`). 61 | * `v_th_i`: Drawn from a Normal distribution `N(-55mV, 2mV^2)` (`torch.normal(mean=-55.0, std=2.0)`). 62 | * `v_reset`: Fixed at -70mV for all neurons. 63 | 64 | ##### A.5.ii. 65 | * **Rationale:** Heterogeneity ensures diverse temporal dynamics, preventing overly synchronized firing and enhancing network robustness. 66 | 67 | #### A.6 Intrinsic Plasticity (Adaptivity) 68 | 69 | ##### A.6.i. 70 | * Neuron parameters (`tau_i`, `v_th_i`) adapt over time based on their firing rate to maintain activity within a target range, preventing silent or hyperactive neurons: 71 | * **Target Rate:** 0.1–0.5 Hz (5–25 spikes over a 50-timestep window). 72 | * **Adjustment Rule:** 73 | * If `rate_i > 0.5 Hz`, increase `v_th_i` by 0.1mV (`v_th += 0.1`) and decrease `tau_i` by 0.1ms (`tau -= 0.1`), reducing excitability. 74 | * If `rate_i < 0.1 Hz`, decrease `v_th_i` by 0.1mV (`v_th -= 0.1`) and increase `tau_i` by 0.1ms (`tau += 0.1`), increasing excitability. 75 | * **Bounds:** `v_th_i` is clamped to [-60mV, -50mV], `tau_i` to [15ms, 25ms]. 76 | * **Timing & Implementation:** Applied every 50 timesteps after STDP updates, computed on the 7900 XTX GPU, updating `v_th` and `tau` tensors in-place. 77 | 78 | #### A.7 Implementation (Kernel Scope & Responsibility) 79 | 80 | ##### A.7.i. 81 | * The core LIF update loop (integration, thresholding, reset) is executed via a custom ROCm HIP kernel (`neuron_kernel.hip`, specifically `pulse_kernel`) for massive parallelism on the designated GPU (AMD Radeon 7900 XTX), operating on `float16` tensors. 82 | 83 | ##### A.7.ii. 84 | * **Kernel Responsibility:** This kernel computes `V_i(t)`, generates `spikes_i(t)`, and records spike times in a `spike_history` buffer (shape `(num_neurons, T)`, e.g., `1000x50`, stored as `uint8` on 7900 XTX). It **does not** compute STDP changes (`Δw_ij`) or update eligibility traces (`e_ij`) within the kernel itself. These are handled separately in PyTorch (see Sec 2.B, 2.E). 85 | -------------------------------------------------------------------------------- /How_It_Works/2_Core_Architecture_Components/2E_Tensor_Based_Computation_and_Hybrid_Interface.md: -------------------------------------------------------------------------------- 1 | ### E. Tensor-Based Computation and Hybrid Interface 2 | 3 | #### E.1 Hybrid Approach Rationale 4 | 5 | ##### E.1.i. 6 | * While SNNs excel at temporal processing, certain operations like analyzing graph properties, calculating complex SIE rewards, managing large state vectors (like eligibility traces `e_ij` or value function `V_states`), or performing clustering are often more efficiently handled using optimized tensor libraries. FUM adopts a hybrid approach, leveraging the strengths of both SNN simulation and tensor computation. 7 | 8 | #### E.2 Frameworks & Hardware Roles (Development Context) 9 | 10 | ##### E.2.i. 11 | * Utilizes PyTorch for tensor manipulation. 12 | 13 | ##### E.2.ii. 14 | * **AMD Radeon 7900 XTX (24GB VRAM):** Primarily runs the custom ROCm HIP kernel (`neuron_kernel.hip`) for high-frequency, parallel LIF updates and spike generation. Also handles the final STDP weight updates (`w += ...`). Stores `V`, `spikes`, `spike_history`, `w`. 15 | 16 | ##### E.2.iii. 17 | * **AMD Instinct MI100 (32GB VRAM):** Primarily runs PyTorch tensor operations for tasks like STDP `Δw_ij` calculation, eligibility trace (`e_ij`) updates, SIE component calculations (novelty, habituation, complexity, impact, TD error), value function (`V_states`) updates, and k-means clustering. Stores `e_ij`, `V_states`, `recent_inputs`, `habituation_counter`, etc. 18 | 19 | ##### E.2.iv. 20 | * **CPU (AMD Threadripper PRO 5955WX):** Manages overall orchestration, data loading, potentially graph partitioning (METIS), parameter server logic (if scaling beyond node memory), and decoding outputs. 21 | 22 | #### E.3 Interface: Data Flow & Synchronization 23 | 24 | ##### E.3.i. 25 | * **Frequency:** Interaction occurs primarily after each 50-timestep simulation window. Global operations like clustering or scaling occur less frequently (e.g., every 1000 timesteps). 26 | 27 | ##### E.3.ii. 28 | * **Data Flow (SNN -> Tensor):** 29 | 1. `spike_history` (uint8, ~6KB for 1k neurons) recorded on 7900 XTX by LIF kernel. 30 | 2. After 50 timesteps, transfer `spike_history` to MI100 (`spike_history_mi100 = spike_history.to('cuda:0')`). 31 | 3. MI100 computes `Δw_ij`, updates `e_ij`, calculates `rates`, computes SIE components (`novelty`, `habituation`, `complexity`, `impact`, `TD_error`), updates `V_states`. 32 | 33 | ##### E.3.iii. 34 | * **Data Flow (Tensor -> SNN):** 35 | 1. `total_reward` (float16 scalar) calculated on MI100. 36 | 2. `e_ij` (sparse float16, ~10KB) updated on MI100. 37 | 3. Transfer `total_reward` and `e_ij` to 7900 XTX (`total_reward.to('cuda:1')`, `e_ij.to('cuda:1')`). 38 | 4. 7900 XTX applies final weight update to `w` using `total_reward` and `e_ij`. 39 | 40 | ##### E.3.iv. 41 | * **Synchronization:** Use `torch.cuda.synchronize()` or CUDA events to ensure data transfers are complete before dependent computations begin. Buffering mechanisms (e.g., `rate_buffer` on MI100, appending `rates.to('cuda:0')` every 50 steps) handle aggregation for less frequent operations like k-means (processed when buffer full, e.g., 1000 steps). Timing mismatches are managed by the fixed interaction frequency (every 50 timesteps). 42 | -------------------------------------------------------------------------------- /How_It_Works/2_Core_Architecture_Components/2F_Adaptive_Domain_Clustering.md: -------------------------------------------------------------------------------- 1 | ### F. Adaptive Domain Clustering (Dynamic k and Edge Cases, Including Validation & Formal Guarantees) 2 | 3 | #### F.1 Purpose & Mechanism 4 | 5 | ##### F.1.i. 6 | * Dynamically identify functional specializations (domains) emerging within the network by grouping neurons with similar activity profiles. This cluster-based representation serves as the state definition for the TD learning value function (Sec 2.C.3). 7 | 8 | ##### F.1.ii. 9 | * Periodically (e.g., every 1000 timesteps), run k-means clustering (`torch.kmeans` on MI100) on neuron firing rates (`rates = torch.sum(spike_history, dim=1) / 50`). 10 | 11 | ##### F.1.iii. 12 | * **Enhancing Nuance Capture:** To capture finer details beyond coarse-grained clusters: 13 | * *Hierarchical Clustering:* Consider using hierarchical clustering (e.g., `AgglomerativeClustering` on MI100) to create sub-clusters within each main cluster. This allows for a more granular state representation (e.g., 10 sub-clusters per main cluster, potentially capturing ~98% variance vs. ~90% with standard k-means). 14 | * *State Augmentation:* Augment the cluster ID state representation with additional firing rate statistics (e.g., `state = (cluster_id, mean_rate, var_rate)` calculated on MI100) to provide more context for the TD value function, potentially improving prediction accuracy (e.g., ~5% improvement expected). 15 | 16 | #### F.2 Determining Number of Clusters (k) 17 | 18 | ##### F.2.i. 19 | * **Dynamic Selection using Silhouette Score:** 20 | * **Method:** Test `k` in range `[k_min, max_k]`. 21 | * `k_min = num_domains` (e.g., 8). Ensures minimum granularity reflecting known task domains. 22 | * `max_k = min(num_neurons // 50, num_domains * 2)` (e.g., 16 for 1k neurons). Limits complexity. 23 | * **Algorithm:** For each `k`, run `torch.kmeans`, compute silhouette score (`(b-a)/max(a,b)`). Choose `k` with highest score (`best_k = argmax(scores)`). 24 | * **Adjustment:** Final `k = max(best_k, k_min)`. If silhouette selects `k < k_min`, override with `k_min`. 25 | * **Implementation:** Execute on MI100 GPU. 26 | 27 | #### F.3 Cluster Assignment & Reward Attribution (Domain Identification) 28 | 29 | ##### F.3.i. 30 | * **Assignment:** Assign neurons to clusters based on similarity to centroids (hard assignment `cluster_id[i] = argmax(similarity)`, soft probabilities `probs[i] = softmax(similarity)`). 31 | 32 | ##### F.3.ii. 33 | * **Reward Attribution:** 34 | * Map current input to a cluster based on induced firing pattern: `input_cluster = argmax(sum(probs * rates, dim=0))`. 35 | * Attribute global `total_reward` to this cluster: `cluster_rewards[input_cluster] += total_reward`. 36 | * Attribute reward to neurons weighted by probability: `neuron_rewards[i] += total_reward * probs[i, input_cluster]`. 37 | 38 | ##### F.3.iii. 39 | * **Average Reward:** Compute `avg_reward[c] = cluster_rewards[c] / num_inputs[c]` over 1000 steps (handle division by zero, see F.4). Used as growth trigger. 40 | 41 | ##### F.3.iv. 42 | * **Implementation:** Maintain `cluster_rewards`, `num_inputs`, `neuron_rewards` tensors on MI100. 43 | 44 | #### F.4 Edge Case Handling (Small k, Empty Clusters) 45 | 46 | ##### F.4.i. 47 | * **Small k:** If dynamic selection yields `k < k_min`, override with `k = k_min` (rerun kmeans if needed). Ensures minimum functional granularity. 48 | 49 | ##### F.4.ii. 50 | * **Empty Clusters:** If `num_inputs[c] = 0` (no inputs mapped to cluster `c` over 1000 steps), set `avg_reward[c] = 0` (neutral reward) to avoid division by zero. This triggers growth (`avg_reward < 0.5`) for the unused cluster, promoting exploration. Log metrics to SSD. 51 | 52 | #### F.5 Adaptation (Including Novel Domains) 53 | 54 | ##### F.5.i. 55 | * Clusters reflect the current functional organization and guide structural plasticity (growth targets). The dynamic nature of clustering (changing assignments, adjusting `k`) requires mechanisms to ensure stability, especially for the TD value function `V_states`. 56 | 57 | ##### F.5.ii. 58 | * **Handling Novel Domains/Inputs:** The clustering mechanism adapts when encountering novel inputs that don't fit well into existing clusters: 59 | * **Novelty-Driven Bifurcation:** If an input has high novelty (`novelty > 0.9`) and low similarity to existing cluster centroids (`max_similarity < 0.5`), it can trigger an increase in `k` (`k += 1`) and a re-clustering, potentially forming a new cluster for the emerging domain. 60 | * **Temporary Holding Cluster:** Alternatively, novel inputs can be assigned to a temporary "holding" cluster. Rewards associated with these inputs are isolated to this cluster. Once enough novel inputs accumulate (e.g., >10), a new permanent cluster is formed via bifurcation. 61 | * **Preventing Misattribution:** If a novel input is initially misclassified into an existing cluster but yields low/negative reward (`total_reward < 0`), mechanisms can trigger reassignment to the holding cluster or prompt bifurcation, preventing the reinforcement of incorrect associations and delaying structural plasticity (growth) for clusters processing potentially misclassified novel inputs. 62 | 63 | ##### F.5.iii. 64 | * **Mitigating Clustering Instability for TD Learning:** 65 | * *Stable Cluster Assignment (Soft Clustering):* Instead of hard assignments, use soft clustering where neurons have probabilities across clusters (`cluster_probs = torch.softmax(-distances, dim=1)` on MI100). Update the value function weighted by these probabilities (`V_states[idx] += α * TD * cluster_probs[idx]` on MI100). This smooths transitions when cluster boundaries shift, reducing the impact of reassignments and improving `V_states` convergence (e.g., 90% stability expected). 66 | * *Stable Dynamic k Adjustment:* Adjust `k` incrementally (e.g., `k += 10` if `functional_coherence[c] < 0.8` on MI100) rather than making large jumps. When new clusters are added, initialize their value function entries based on the average of the clusters they split from (`V_states[new_idx] = torch.mean(V_states[old_indices])` on MI100). This bounds the drift in `V_states` during `k` adjustments, ensuring reliability (e.g., `|ΔV_states| < 0.1`, 95% reliability expected). 67 | -------------------------------------------------------------------------------- /How_It_Works/2_Core_Architecture_Components/2G_Interaction_Validation.md: -------------------------------------------------------------------------------- 1 | ### G. Validation of Mechanism Interactions 2 | 3 | #### G.1 Challenge: Complexity and Unintended Interactions 4 | 5 | ##### G.1.i. 6 | * FUM integrates multiple complex, adaptive mechanisms (LIF neurons, STDP with variability, SIE with multiple components, structural plasticity, adaptive clustering, etc.). Enhancements designed to address specific limitations (e.g., dynamic STDP timing - Sec 2.B.4, SIE regularization - Sec 2.C.2) further increase this complexity. 7 | * A critical challenge is ensuring these mechanisms interact synergistically and do not produce unintended negative consequences or new failure modes, especially as the system scales. The feedback loops between SIE, STDP, and structural plasticity, for example, require careful validation. 8 | 9 | #### G.2 Multi-Phase Interaction Analysis Strategy 10 | 11 | ##### G.2.i. 12 | * To rigorously validate these interactions, a multi-phase analysis strategy is employed: 13 | * **Phase 1 (1M Neurons - Isolated Enhancement Testing):** During Phase 1 scaling (Section 5.A), new enhancements (e.g., dynamic STDP timing, SIE regularization) are tested in isolation first. Simulations on 1M neurons measure the impact of each individual enhancement on key performance metrics (e.g., accuracy, convergence speed) and stability (e.g., firing rate variance, STDP weight stability). The target is to ensure each enhancement functions as intended without destabilizing the system (e.g., targeting **95% convergence rate** for each isolated enhancement). 14 | * **Phase 2 (10M Neurons - Combined Enhancement Testing & Control Theory):** During Phase 2 scaling (Section 5.B), all enhancements are integrated. Simulations focus on validating the combined effects. Control theory principles are applied to analyze the stability of key feedback loops (e.g., SIE-STDP, plasticity-SIE). The goal is to identify and mitigate potential oscillations, race conditions, or conflicting signals arising from the interactions. The target is to achieve a **90% interaction stability rate** across diverse simulation conditions. 15 | * **Continuous Monitoring (All Phases):** Throughout all scaling phases, interaction effects are continuously monitored using targeted metrics (e.g., correlation between SIE novelty signals and structural plasticity rates, impact of STDP timing adjustments on SIE TD-error). 16 | 17 | #### G.3 Reporting 18 | 19 | ##### G.3.i. 20 | * The methodology and results of this multi-phase interaction analysis, including stability assessments and validation metrics, will be detailed in this section (Section 2.G) upon completion of the relevant simulation phases. This ensures that the complex interplay between FUM's core mechanisms and enhancements is transparently and rigorously validated. 21 | -------------------------------------------------------------------------------- /How_It_Works/2_Core_Architecture_Components/2H_Phase_Transition_Predictor.md: -------------------------------------------------------------------------------- 1 | ### 2H. Phase Transition Predictor 2 | 3 | #### 2H.1 Purpose: Anticipating Critical Shifts at Scale 4 | 5 | While the Scaling Dynamics Model (Sec 2.G) aims to predict gradual changes in stability and performance, complex systems like FUM can also undergo abrupt **phase transitions** at certain critical thresholds (e.g., in connectivity density, average firing rate, or plasticity rates). These transitions can lead to sudden, unexpected shifts in network behavior, potentially causing instability or performance degradation if not anticipated. 6 | 7 | #### 2H.2 Mechanism: Bifurcation Analysis 8 | 9 | To address the risk of unforeseen phase transitions, FUM employs a **Phase Transition Predictor**. This component extends the Scaling Dynamics Model by using techniques from **bifurcation analysis**. Bifurcation analysis mathematically identifies critical points in the parameter space of a dynamical system where the qualitative behavior of the system changes dramatically. 10 | 11 | By analyzing the equations of the Scaling Dynamics Model, the Phase Transition Predictor seeks to identify potential bifurcation points related to key FUM parameters, such as: 12 | * Global connectivity density 13 | * Balance between excitation and inhibition (E/I ratio) 14 | * Learning rates for STDP (Sec 2.B) 15 | * Strength of SIE feedback components (Sec 2.C) 16 | * Rates of structural plasticity (Sec 4.C) 17 | 18 | #### 2H.3 Validation and Application 19 | 20 | * **Predictive Accuracy:** The model's ability to predict critical thresholds is validated by comparing its predictions against empirical observations during the phased validation roadmap (Sec 6.A.7), particularly when scaling between large increments (e.g., 1B to 10B neurons). The target is high accuracy (e.g., >95%) in predicting the parameter values where significant behavioral shifts occur. 21 | * **Proactive Mitigation:** By identifying potential phase transitions in advance, the Phase Transition Predictor allows for proactive adjustments to FUM's parameters or control mechanisms to either avoid undesirable transitions or to safely navigate through them. This provides an essential layer of safety and predictability when scaling FUM to very large sizes (e.g., 32B+ neurons). 22 | * **Integration:** Findings and predictions from this model are integrated into the ongoing stability analysis (See Sec 2.E [Placeholder/To be created or updated]) and inform the scaling strategy (Sec 5.D). 23 | -------------------------------------------------------------------------------- /How_It_Works/2_Core_Architecture_Components/2I_Scaling_Dynamics_Model.md: -------------------------------------------------------------------------------- 1 | ### 2G. Scaling Dynamics Model 2 | 3 | #### 2G.1 Purpose: Predicting Stability at Scale 4 | 5 | A significant challenge in developing large-scale neural systems like FUM is predicting how stability and performance metrics will evolve as the network size increases towards the target (e.g., 32B+ neurons). Simple extrapolation from smaller scales (e.g., 1M neurons) can be unreliable due to the potential for non-linear interactions and phase transitions in complex systems. 6 | 7 | #### 2G.2 Mechanism: Dynamical Systems Analysis 8 | 9 | To address this, FUM incorporates a **Scaling Dynamics Model**. This model utilizes principles from **dynamical systems theory** to analyze the complex feedback loops inherent in FUM's architecture, particularly the interactions between: 10 | * Spike-Timing-Dependent Plasticity (STDP) (Sec 2.B) 11 | * The Self-Improvement Engine (SIE) (Sec 2.C) 12 | * Structural Plasticity mechanisms (Sec 4.C) 13 | * Homeostatic regulation (Sec 2.A.6, 2.B.7) 14 | 15 | By modeling these interactions mathematically (e.g., using coupled differential equations representing average cluster activity, synaptic weights, and plasticity rates), the Scaling Dynamics Model aims to predict key stability and performance metrics (e.g., firing rate variance, convergence rates, computational efficiency) as the network scales. 16 | 17 | #### 2G.3 Validation and Application 18 | 19 | * **Predictive Accuracy:** The model is validated against empirical results obtained at intermediate scales (e.g., 1M, 10M, 1B neurons) during the phased validation roadmap (Sec 6.A.7). The target is to achieve high predictive accuracy (e.g., >90%) for stability metrics at the next scale increment. 20 | * **Guiding Development:** The predictions from the Scaling Dynamics Model help anticipate potential scaling bottlenecks or instabilities, allowing for proactive adjustments to FUM's parameters or control mechanisms before reaching full scale. This provides a more rigorous approach to managing complexity and ensuring stability during development. 21 | * **Integration:** Findings and predictions from this model are integrated into the ongoing stability analysis (See Sec 2.E [Placeholder/To be created or updated]). 22 | -------------------------------------------------------------------------------- /How_It_Works/3_Multimodal_IO_Processing.md: -------------------------------------------------------------------------------- 1 | ## 3. Multimodal Input/Output Processing 2 | 3 | ### A. Encoder Mechanism: From Raw Data to Spike Trains 4 | 5 | #### A.1 Purpose & Contrast with LLM Input 6 | 7 | ##### A.1.i. 8 | * To act as the sensory interface, translating diverse raw input data from various modalities (text, images, video, potentially audio, touch, etc.) into a **universal spike-based format** that the SNN core can process uniformly. **Why?** This allows the core network to be modality-agnostic, simplifying the architecture and enabling seamless integration of new sensor types. 9 | 10 | ##### A.1.ii. 11 | * This differs markedly from LLMs which typically use tokenization (breaking text into sub-words) followed by embedding layers to convert input into dense vectors. FUM uses temporal spike patterns. 12 | 13 | #### A.2 Enhanced Encoding Methods (Hierarchical & Spike Pattern) 14 | 15 | ##### A.2.i. 16 | * **Addressing Potential Bottleneck:** Simple rate encoding may not capture sufficient complexity from the minimal input set (80-300 examples) to achieve expert-level mastery (>85% on benchmarks). To resolve this potential information bottleneck, FUM employs enhanced, brain-inspired encoding strategies: 17 | 18 | ##### A.2.ii. 19 | * **Hierarchical Encoding:** Emulates the brain's hierarchical processing (e.g., V1-V4 in visual cortex, Felleman & Van Essen, 1991). 20 | * *Mechanism:* `hierarchical_encoding = encode_hierarchy(input, layers=3)`, executed on the 7900 XTX GPU. 21 | * *Text Example:* Layer 1 encodes characters (e.g., 1 Hz/char), Layer 2 encodes words (e.g., 2 Hz/word), Layer 3 encodes sentences (e.g., 5 Hz/sentence) (master node logic). 22 | * *Image Example:* Layer 1 encodes pixels (e.g., 0-10 Hz intensity), Layer 2 encodes edges/textures (e.g., 5 Hz/feature), Layer 3 encodes objects/regions (e.g., 10 Hz/object) (master node logic). 23 | 24 | ##### A.2.iii. 25 | * **Spike Pattern Encoding:** Uses temporal patterns within the encoding window to increase information capacity, inspired by temporal coding theories (Buzsáki, 2010). 26 | * *Mechanism:* `spike_pattern = encode_pattern(input, max_rate=10 Hz, duration=50ms)`, executed on the 7900 XTX GPU. Encodes features not just by rate but by the precise timing of spikes within the 50ms window (master node logic). For example, 'A' might be encoded as [1Hz @ 0-10ms, 2Hz @ 10-20ms, ...]. 27 | 28 | ##### A.2.iv. 29 | * **Increased Information Capture:** These enhanced methods significantly increase the information captured per input compared to simple rate encoding. 30 | * *Estimate:* Yields approximately **~2255-8460 bits per input** (assuming 50 timesteps, max 10Hz rate, pattern encoding providing ~5x more info than rate encoding). 31 | * *Sufficiency for Mastery:* For 300 inputs, this provides ~2.54M bits total, sufficient to constrain the ~12.8T synapses at the 32B neuron scale (Answer 4), supporting the target of >85% accuracy on complex benchmarks like MATH/GPQA subsets (Answer 3.2) and aligning with the minimal data mastery goal (Sec 1.A) (95% goal alignment expected). 32 | 33 | #### A.3 Poisson Spike Generation Details 34 | 35 | ##### A.3.i. 36 | * **Formula:** Spikes are generated using a Poisson process based on target frequency `f` and timestep `dt=1ms`. 37 | * Probability of spike per timestep: `p = f * dt`. (e.g., `f=50Hz` -> `p=0.05`). 38 | * Algorithm: For each timestep `t`, if `torch.rand(1) < p`, emit spike `spike[t] = 1`. 39 | 40 | ##### A.3.ii. 41 | * **Refractory Period:** A 5ms refractory period (5 timesteps) is imposed on input neurons after spiking. 42 | * **Implementation:** Maintain `refractory[i]` counter. If `spike[t]=1`, set `refractory[i]=5`. Only generate spike if `refractory[i]==0`. Decrement counter each step. 43 | * **Rationale:** Prevents unrealistically high firing rates (caps at 200 Hz), aligning with biological limits. 44 | 45 | #### A.4 Output & Extensibility 46 | 47 | ##### A.4.i. 48 | * Output is a tensor `I_encoded` (shape: `[num_input_neurons, T_total]`) containing spike trains (0s and 1s) fed into the SNN core. 49 | 50 | ##### A.4.ii. 51 | * Adding a new sensor only requires designing a new encoder module mapping its data to spike trains. 52 | 53 | ### B. Decoder Mechanism: From Spike Trains to Structured Output 54 | 55 | #### B.1 Purpose 56 | 57 | ##### B.1.i. 58 | * To translate the internal spiking activity patterns of designated output neurons back into a human-understandable format (e.g., text, classification label, numerical value, code, logical steps), relevant to the task performed. 59 | 60 | #### B.2 Decoding Methods (Rate & Temporal) 61 | 62 | ##### B.2.i. 63 | * **Rate Decoding (Simple Outputs):** Average firing rates of output neurons over a window `T` (e.g., 50 timesteps) are mapped to symbols. 64 | * *Classification:* Highest firing rate indicates the class. 65 | * *Numerical:* `symbol = int(rate * 2)` (e.g., `rate = torch.sum(spike_history[output_neuron]) / 50`, so 2 Hz -> '4'). 66 | 67 | ##### B.2.ii. 68 | * **Temporal Decoding (Structured Outputs):** Generate sequences by interpreting firing rates of output neurons over sequential time windows. 69 | * *Code Generation:* `print(2+2)` -> Window 1: Neuron 'print' fires at 10Hz; Window 2: Neuron '(' fires at 11Hz; Window 3: Neuron '2' fires at 12Hz, etc. Map rates (`rate = torch.sum(...) / 50`) to tokens using a lookup table (`token = lookup[rate]`). 70 | * *Logical Deduction:* Output steps ("Given A=1", "A ∧ B = 1", "C = 1") sequentially, mapping tokens to firing rates in successive windows. 71 | 72 | #### B.3 Emergent Formation 73 | 74 | ##### B.3.i. 75 | * STDP and SIE reinforce connections from internal processing clusters to the appropriate output neurons, ensuring they fire at the correct rates/times to produce the desired output, guided by rewards (`r=1`) for successful task completion. 76 | 77 | #### B.4 Implementation 78 | 79 | ##### B.4.i. 80 | * Decoding typically occurs on the CPU after retrieving spike history or firing rates from the GPU, logging outputs to SSD (`torch.save(outputs, 'outputs.pt')`). 81 | -------------------------------------------------------------------------------- /How_It_Works/4_Emergent_Behaviors/4E_Emergence_of_Functional_Specialization.md: -------------------------------------------------------------------------------- 1 | # 4E: Emergence of Functional Specialization 2 | 3 | ## Overview 4 | 5 | Functional specialization—the emergence of neuron clusters that respond selectively to specific types of input or computational tasks—is a critical emergent behavior in the Fully Unified Model (FUM). This phenomenon parallels the brain's ability to develop specialized regions (e.g., visual cortex, language areas) while maintaining flexible cross-domain integration. 6 | 7 | ## Emergence Mechanisms 8 | 9 | FUM's functional specialization emerges through the synergistic interaction of several core components: 10 | 11 | ### 1. Activity-Dependent Differentiation 12 | 13 | * **Co-activation Patterns:** Neurons that consistently fire together in response to specific input patterns strengthen their interconnections via STDP. 14 | * **Competitive Dynamics:** As clusters form, lateral inhibition (via inhibitory neurons) creates competition, sharpening functional boundaries. 15 | * **Measurement:** Functional differentiation can be quantified via silhouette scores and cluster coherence metrics, with target values of >0.4 and >0.7 respectively. 16 | 17 | ### 2. SIE-Guided Specialization 18 | 19 | * **Reward-Driven Refinement:** The Self-Improvement Engine (SIE) provides higher rewards to neuron clusters that efficiently process specific input types. 20 | * **Domain-Specific Optimization:** SIE's cluster-specific rewards enable each functional cluster to optimize its internal parameters (e.g., STDP modulation factors, firing thresholds) for its specific task. 21 | * **Complementary Specialization:** SIE promotes the formation of complementary specialized regions, preventing redundant functional clusters via habituation penalties. 22 | 23 | ### 3. Structural Plasticity Contributions 24 | 25 | * **Growth Triggers:** Structural plasticity initiates growth in regions experiencing high novelty or requiring greater computational capacity. 26 | * **Connectivity Patterns:** New connections form preferentially within functional domains (short-range) while maintaining critical cross-domain pathways (long-range). 27 | * **Pruning Dynamics:** Selective pruning of underutilized connections enhances efficiency and further delineates functional boundaries. 28 | 29 | ## Observed Specialization Patterns 30 | 31 | During FUM's development, we expect to observe several distinct types of functional specialization: 32 | 33 | ### 1. Input Modality Specialization 34 | 35 | * **Modal Clusters:** Distinct neuron clusters form for processing different input modalities (text, images, audio). 36 | * **Hierarchical Organization:** Within each modality, sub-clusters emerge for processing feature hierarchies (e.g., edges→shapes→objects for visual inputs). 37 | * **Cross-Modal Integration:** Despite specialization, persistent connections between modality clusters enable cross-modal associations and transfer learning. 38 | 39 | ### 2. Computational Role Specialization 40 | 41 | * **Function-Specific Regions:** Clusters emerge that specialize in specific computational functions (e.g., arithmetic operations, logical inference, pattern recognition). 42 | * **Abstract Concept Representation:** Higher-level clusters form to represent abstract concepts independent of specific modalities. 43 | * **Executive Function Analogs:** Specialized clusters for task switching, goal maintenance, and conflict resolution emerge spontaneously. 44 | 45 | ### 3. Temporal Processing Specialization 46 | 47 | * **Short-Term Processing:** Some clusters specialize in immediate input processing with faster firing rates. 48 | * **Long-Term Integration:** Other clusters demonstrate extended temporal integration, maintaining activity over longer periods. 49 | * **Sequential Processing:** Specialized pathways for processing temporal sequences (crucial for language, planning, and causal reasoning) emerge through STDP and eligibility traces. 50 | 51 | ## Benefits of Functional Specialization 52 | 53 | Functional specialization provides several critical advantages to FUM: 54 | 55 | ### 1. Computational Efficiency 56 | 57 | * **Parallel Processing:** Specialized clusters enable efficient parallel processing of different input types. 58 | * **Resource Optimization:** Each cluster optimizes for its specific task, reducing energy consumption and computational overhead. 59 | * **Focused Learning:** Specialization allows targeted learning within domains without disrupting other capabilities. 60 | 61 | ### 2. Improved Generalization 62 | 63 | * **Abstraction:** Specialized concept clusters capture domain-invariant principles, facilitating transfer learning. 64 | * **Cross-Domain Reasoning:** Connections between specialized clusters enable novel combinations of knowledge across domains. 65 | * **Balanced Representation:** Specialization prevents any single input type from dominating the network's capacity. 66 | 67 | ### 3. Robustness and Resilience 68 | 69 | * **Fault Tolerance:** Distributed specialized representations provide redundancy and resilience against localized failures. 70 | * **Graceful Degradation:** Damage to one specialized region affects only related functions, preserving overall system capabilities. 71 | * **Adaptive Reorganization:** If damage occurs, structural plasticity can recruit adjacent neurons to restore specialized functions. 72 | 73 | ## Validation Metrics 74 | 75 | The emergence of functional specialization can be validated through several quantitative metrics: 76 | 77 | * **Functional Coherence Score:** Measure of within-cluster firing pattern similarity (target: >0.7). 78 | * **Specialization Index:** Ratio of within-domain vs. cross-domain connection strengths (target: >3:1). 79 | * **Selective Activation:** Percentage of domain-specific neurons activated by domain-relevant stimuli (target: >80%). 80 | * **Task Transfer Performance:** Performance difference between domain-specific and domain-general tasks (target: <15% degradation). 81 | * **Modularity Score:** Graph-theoretic measure of network compartmentalization (target: >0.4). 82 | 83 | ## Implementation Timeline 84 | 85 | Functional specialization emerges gradually across FUM's development phases: 86 | 87 | 1. **Phase 1 (Weeks 1-2):** Initial random connectivity shows minimal specialization. 88 | 2. **Phase 2 (Weeks 3-6):** Basic specialization emerges, with 20-30 distinct functional clusters identifiable. 89 | 3. **Phase 3 (Weeks 7-14):** Specialization refines, with 50-70 stable clusters showing high functional coherence. 90 | 4. **Phase 4 (Weeks 15-22):** Complex hierarchical specialization emerges, with 100+ clusters showing clear computational roles. 91 | 5. **Phase 5 (Weeks 22-26):** Mature specialization achieves target metrics, with optimal balance between specialization and integration. 92 | 93 | ## Challenges and Mitigations 94 | 95 | Several challenges in developing functional specialization are addressed through specific mechanisms: 96 | 97 | 1. **Catastrophic Interference:** Mitigated via inhibitory circuits, synaptic tagging, and eligibility traces. 98 | 2. **Over-Specialization:** Prevented through SIE's exploration incentives and cross-domain reward components. 99 | 3. **Insufficient Specialization:** Addressed by increasing inhibition strength and sharpening STDP curves if detected. 100 | 4. **Dynamic Reallocation:** Enabled through structural plasticity and adaptive domain clustering. 101 | 5. **Integration Maintenance:** Preserved via protected pathways for cross-domain connections and meta-learning mechanisms. 102 | 103 | --- 104 | 105 | Functional specialization forms a critical foundation for FUM's emergent intelligence, enabling efficient processing, robust knowledge representation, and flexible cross-domain reasoning—all essential elements for achieving superintelligent capabilities within the accelerated 6-month implementation timeline. 106 | -------------------------------------------------------------------------------- /How_It_Works/5_Training_and_Scaling/5B_Tandem_Complexity_Scaling.md: -------------------------------------------------------------------------------- 1 | ### B. Phase 2: Tandem Complexity Scaling (Refinement and Competence) 2 | 3 | #### B.1 Objective 4 | 5 | ##### B.1.i. 6 | Refine the initial graph structure, strengthen domain-specific pathways, build robust cross-domain associations, and achieve baseline competence (>85% accuracy target) on more complex tasks using a curated curriculum (target: up to 300 total inputs). 7 | 8 | #### B.2 Cellular Components & Mechanisms 9 | 10 | ##### B.2.i. 11 | * **Data Curriculum:** Sequentially introduce batches of data with increasing complexity. 12 | 13 | ##### B.2.ii. 14 | * **Training Loop (Enhanced):** Iterate through data batches. 15 | * **For each batch/input item:** 16 | * Execute core **Simulation Loop**, **STDP Calc**, **Trace Update** as in Phase 1. 17 | * **Targeted SIE Feedback (Crucial):** 18 | * **Decoder Module:** Generate task-specific output. 19 | * **Evaluation:** Compare output rigorously against target -> Reward `r`. 20 | * **Advanced Reward Calculation (MI100):** Compute `total_reward = TD_error + novelty - habituation + self_benefit`. TD error becomes more significant as `V_states` learns. 21 | * **SIE-Modulated STDP Update (7900 XTX):** Apply weight update using `eta_effective = eta * (1 + mod_factor)` where `mod_factor` is derived from `total_reward`. 22 | * **Intrinsic Plasticity Update (7900 XTX).** 23 | * **Knowledge Graph Monitoring:** Periodically analyze `w` (strength, sparsity, centrality). 24 | * **Performance Tracking:** Log SIE rewards per domain/cluster. 25 | * **Adaptive Clustering (MI100):** Run every 1000 steps to update clusters (using dynamic `k`) and `V_states` mapping. 26 | * **Reward-Driven Structural Plasticity (Initiation):** 27 | * **Trigger:** If `avg_reward[c] < 0.5` over 1000 steps. 28 | * **Mechanism:** Activate Growth algorithm (Sec 4.C.2) for cluster `c`. 29 | 30 | #### B.3 Mathematical Formulations 31 | 32 | ##### B.3.i. 33 | 1. **STDP Learning Rule (Excitatory/Inhibitory):** As defined in Sec 2.B. 34 | 2. **Eligibility Trace:** `e_ij(t) = 0.95 * e_ij(t-1) + Δw_ij(t)`. 35 | 3. **SIE Modulation:** `eta_effective = 0.01 * (1 + (2 * sigmoid(total_reward) - 1))`. 36 | 4. **TD Learning:** `TD_error = r + 0.9 * V(next_state) - V(current_state)`; `V(state) += 0.1 * TD_error`. 37 | 5. **Cluster Coherence Metric (Silhouette Score):** Used to determine `k` for k-means. 38 | 39 | #### B.4 Expected Outcome 40 | 41 | ##### B.4.i. 42 | Knowledge graph significantly refined, strong intra-domain pathways (`w[i,j] ≈ 0.8`), emerging inter-domain connections. Baseline competence (>85% accuracy) achieved. Minor structural growth may have occurred. 43 | 44 | --- 45 | -------------------------------------------------------------------------------- /How_It_Works/5_Training_and_Scaling/5C_Autonomy_and_Mastery.md: -------------------------------------------------------------------------------- 1 | ### C. Phase 3: Continuous Self-Learning (Autonomy and Mastery) 2 | 3 | #### C.1 Objective 4 | 5 | ##### C.1.i. 6 | Achieve expert-level performance, adapt autonomously to novel, unlabeled information, maintain long-term stability, and scale towards target size (e.g., 7M -> 32B+ units) through continuous operation. 7 | 8 | #### C.2 Cellular Components & Mechanisms 9 | 10 | ##### C.2.i. 11 | * **Data Source:** Continuous streams of real-world, potentially unlabeled data. 12 | 13 | ##### C.2.ii. 14 | * **Integrated Autonomous Loop (Continuous Operation):** 15 | * **Perception-Action Cycle:** Continuously Encode -> Simulate -> Decode. 16 | * **Advanced SIE Evaluation (Self-Supervision):** Calculate `total_reward` based primarily on internal metrics (TD error from learned `V_states`, novelty, habituation, self_benefit using complexity/impact) when external `r` is absent. 17 | * **SIE-Modulated STDP:** Continuously apply modulated STDP updates. 18 | * **Intrinsic Plasticity:** Continuously adapt neuron parameters. 19 | * **Persistent Memory Management:** Periodically save full network state (`V`, `w`, `e_ij`, `V_states`, adaptive params) to persistent storage (NVMe SSD) for fault tolerance and continuation. Use efficient serialization for large sparse tensors. 20 | * **Continuous Monitoring & Full Structural Plasticity:** 21 | * Monitor stability (variance), activity (rates), performance (SIE metrics, cluster coherence). 22 | * Trigger Growth, Pruning, Rewiring algorithms (Sec 4.C) based on monitored metrics. 23 | * **Adaptive Domain Clustering:** Periodically update clusters, `V_states` mapping. 24 | * **Distributed Scaling:** Fully leverage strategies in Section 5.D. 25 | 26 | #### C.3 Emergent Physics Principles (Self-Organized Criticality - SOC) 27 | 28 | ##### C.3.i. 29 | The system operates based on principles of self-organized criticality (SOC). Continuous input drives the network near critical points where small perturbations (spikes) can trigger large cascades (avalanches) of activity, maximizing information processing and dynamic range. Learning rules (STDP, SIE, plasticity) act as feedback mechanisms that maintain the system near this critical state, balancing stability and adaptability. 30 | * **Leveraging SOC Benefits:** Criticality enhances computational power, enabling processing of complex inputs with minimal data by amplifying small differences into distinct firing patterns. 31 | * **Mitigating Instability Risks:** While beneficial, criticality can lead to unpredictable fluctuations. FUM mitigates this via: 32 | * **Avalanche Detection:** Monitor spike avalanche sizes (`sum(spikes)` over consecutive steps). Flag if `> 0.1 * N` sustained. 33 | * **Inhibitory Response:** Increase global inhibition (`global_inhib_rate *= 1.1`) if large avalanches detected. 34 | * **Variance Regulation:** Reduce STDP learning rate (`eta *= 0.9`) if variance exceeds threshold (`> 0.1 Hz`). 35 | * **Structural Adjustment:** Prune neurons contributing excessively to avalanches (e.g., `rate > 1 Hz` during avalanche, capped at 1% per event). 36 | * **Early Warning System (Enhanced):** Implement an enhanced early warning system: `early_warning = torch.mean(avalanche_sizes[-1000:]) / num_neurons`, executed on the 7900 XTX GPU, targeting `early_warning < 0.05`, executed on the master node. If `early_warning > 0.05`, preemptively increase inhibition (`global_inhib_rate *= 1.1`), executed on the 7900 XTX GPU, preventing avalanches (e.g., 90% prevention expected). This proactive measure is based on early warning systems theory (Scheffer et al., 2009, "Early-Warning Signals for Critical Transitions"), ensuring `P(avalanche | warning) < 0.1` (master node) for 95% expected prevention. 37 | 38 | ##### C.3.ii. 39 | * **Maintaining Beneficial Criticality:** To ensure SOC remains beneficial and doesn't lead to large-scale disruptions during continuous operation, especially during Phase 3 learning, structural plasticity, and exposure to novel inputs, several mechanisms work in concert: 40 | * **Risk of Dampening Critical Dynamics:** While preventing large, disruptive avalanches is crucial, overly aggressive SOC management (e.g., strict predictive control, strong homeostatic plasticity) could potentially dampen the smaller fluctuations and reorganizations near the critical point that are thought to be essential for breakthrough learning or escaping local minima in biological systems (e.g., potentially ~10% reduction in breakthroughs, Beggs & Plenz, 2003). 41 | * **Preserving Critical Dynamics (Relaxed SOC Management):** To mitigate this risk while maintaining overall stability, SOC management can be relaxed to allow controlled fluctuations: 42 | * *Allowing Controlled Fluctuations:* Instead of preventing all large avalanches, allow smaller ones below a certain threshold (e.g., `if predicted_avalanche_size < 0.2 * num_neurons: allow_fluctuation()`, executed on 7900 XTX GPU). This aims to preserve ~50% of potentially beneficial critical fluctuations (targeting ~7% increase in learning breakthroughs). 43 | * *Dynamic Inhibition Adjustment:* Continue to adjust global inhibition dynamically based on the criticality index (`global_inhib_rate *= 1.1 if criticality_index > 0.3`, executed on 7900 XTX GPU) to maintain overall stability (aiming for 90% stability). 44 | * *Impact Assessment:* Simulations comparing strict SOC management (`simulate_strict_SOC`) versus this relaxed approach show a significant increase in the rate of breakthrough learning events (e.g., ~12% breakthroughs with relaxed SOC vs. ~5% with strict, a ~140% improvement, master node calculation), suggesting the preservation of critical dynamics is beneficial. 45 | * **Criticality Monitoring:** Continuously monitor the criticality index (`criticality_index = abs(τ - 1.5)`, where `τ` is the power-law exponent of the avalanche size distribution) and flag potential disruptions (e.g., `criticality_index > 0.2` or excessively large avalanches). 46 | * **Dynamic Intervention:** If disruptions are detected or the system deviates significantly from criticality (even with relaxed management): 47 | * Increase global inhibition to dampen activity. 48 | * Temporarily reduce structural plasticity rates (growth/pruning) to slow down network changes. 49 | * If instability persists, shift the system towards a more stable sub-critical state by further increasing inhibition and targeting lower variance. 50 | * **Proactive Criticality Control (Predictive Controller):** Implement a predictive criticality controller: `CriticalityController(predict_avalanche_size)`, executed on the MI100 GPU. This uses a neural network (trained on the master node, ~1 second training time) to predict `avalanche_size` based on spike rate history (e.g., 1M timesteps). If the predicted size exceeds a threshold (e.g., `predicted_avalanche_size > 0.1 * num_neurons`, which is 3.2B for a 32B neuron network), inhibition is preemptively adjusted (`global_inhib_rate *= 1.2` on the 7900 XTX GPU) to prevent large avalanches before they occur (e.g., 90% prevention expected). This predictive control ensures `P(avalanche | prediction) < 0.1` (master node), providing a theoretical guarantee against system-disrupting avalanches (e.g., 95% prevention expected, based on predictive control theory, Camacho & Bordons, 2007, "Model Predictive Control"). 51 | * **Adaptive Criticality Tuning:** Dynamically tune criticality based on the monitored index. If `criticality_index > 0.2`, decrease structural plasticity (`growth_rate *= 0.9`, `pruning_rate *= 1.1`); if `criticality_index < 0.05`, increase it (`growth_rate *= 1.1`, `pruning_rate *= 0.9`). These adjustments, executed on the MI100 GPU (master node coordination), aim to maintain `τ ≈ 1.5 ± 0.1` (e.g., 90% stability expected). Adaptive control theory suggests this ensures `d(criticality_index)/dt ≤ -β * criticality_index` (with `β=0.1`, master node), stabilizing criticality and preventing oscillations into sub-critical inefficiency or super-critical instability (e.g., 95% stability expected, Åström & Murray, 2008). 52 | * **Connection Density Control:** Maintain target sparsity (~95%) during structural changes to preserve the conditions conducive to SOC. 53 | * **E/I Ratio Stability:** Ensure the E/I balance (~4:1) scales appropriately with network size. 54 | * **Mitigating Control Mechanism Interactions:** The interplay between criticality control, plasticity, and SIE requires management to prevent control mechanisms themselves from interacting to push the system away from the desired critical state: 55 | * *Interaction Analysis:* Periodically analyze control interactions by computing the correlation matrix of control metrics (`interaction_matrix = torch.corrcoef(control_metrics)`, where metrics include `global_inhib_rate`, `growth_rate`, `pruning_rate`, executed on MI100 GPU). If `|interaction_matrix[i,j]| > 0.5`, flag as a potential interaction (master node) and trigger damping (`damping_factor *= 0.9` on MI100 GPU) (e.g., 5% interaction reduction expected). Low correlation ensures `P(interaction_disruption) < 0.1` (master node), maintaining criticality (e.g., 95% maintenance expected, Strogatz, 2015). 56 | * *Decentralized Control:* Decentralize control by assigning specific mechanisms to different nodes (`assign_control(node_id, mechanism)` on master node). This ensures each node manages local criticality (e.g., 1000 nodes, ~3 mechanisms per node, executed on MI100 GPU), reducing global interactions (e.g., 90% interaction-free expected). Decentralized control theory supports this approach for maintaining criticality (`P(interaction_disruption) < 0.1`, master node, 95% maintenance expected, Siljak, 1991). 57 | 58 | ##### C.3.iii. 59 | * **Rationale:** These mechanisms, including predictive criticality control, adaptive tuning, enhanced early warning systems, interaction analysis, and decentralized control, allow FUM to harness SOC benefits while actively managing instability risks. They ensure stable criticality (e.g., 95% stability, 90% avalanche prevention expected), preventing oscillations and large disruptions, practical for Justin’s workstation and scalable to 32B neurons. 60 | 61 | ##### C.3.iv. 62 | * **Advantages of Active SOC Management:** While simpler homeostatic mechanisms (like basic synaptic scaling or intrinsic plasticity alone) can provide baseline stability, FUM employs *active* SOC management (dynamic inhibition, predictive control, adaptive tuning) for several key reasons: 63 | * *Optimal Performance & Adaptability:* Active management allows the system to operate closer to the critical point more consistently, maximizing computational benefits. Simulations indicate this active approach yields significant performance gains compared to relying solely on passive homeostasis (e.g., ~20% improvement in computational throughput, ~17% faster adaptation to novel inputs). 64 | * *Responsiveness without Artificial Constraints:* Passive homeostasis often relies on fixed setpoints. FUM's active management uses dynamic thresholds and predictive adjustments based on ongoing network activity (e.g., criticality index, predicted avalanche size). This prevents imposing artificial constraints on network dynamics, allowing the system to adapt its operating point flexibly in response to changing tasks or inputs while still maintaining overall stability near criticality. 65 | 66 | #### C.4 Expected Outcome 67 | 68 | ##### C.4.i. 69 | A large-scale, continuously operating, autonomously adapting FUM. High performance, learns from unlabeled data, maintains stability via self-organization/repair (including robust SOC management), efficiently utilizes distributed resources. Rich, dynamic knowledge graph emerges. 70 | 71 | --- 72 | -------------------------------------------------------------------------------- /How_It_Works/9_Broader_Context_and_Ethical_Considerations.md: -------------------------------------------------------------------------------- 1 | # 9. Broader Context and Ethical Considerations 2 | 3 | This section addresses the broader philosophical, motivational, ethical, and existential dimensions surrounding the Fully Unified Model (FUM), complementing the technical details provided in Sections 1-8. It responds to critical inquiries regarding the project's deeper implications and outlines the framework guiding its responsible development. 4 | 5 | ## 9.A Philosophical Considerations: Consciousness, Subjectivity, and Qualia 6 | 7 | ### 9.A.1 The Consciousness Question: Beyond Functional Equivalence? 8 | 9 | * **Critique:** Does FUM's computational framework (LIF neurons, STDP, emergent graphs, SIE, clustering) lead to genuine subjective experience (qualia, phenomenal consciousness) or merely replicate functional correlates? Does emergence provide a stronger basis for consciousness than other systems? What markers might suggest consciousness? Are design aspects (abstraction, lack of embodiment) fundamental insufficiencies? 10 | * **Response:** 11 | * FUM’s design philosophy (Section 1.B) prioritizes functional equivalence over strict biological analogy, focusing on replicating brain efficiency and learning (minimal data, energy efficiency) rather than directly addressing the "hard problem" of consciousness (Chalmers). 12 | * The goal is efficient superintelligence through emergent, brain-inspired mechanisms (Section 1.A), not explicitly solving consciousness. 13 | * Mechanisms like LIF neurons (Section 2.A), STDP (Section 2.B), and the SIE (Section 2.C) are functional optimizers, not designed for subjective experience. The SIE reward signal (Section 2.C.2) is computational, not inherently subjective. 14 | * However, emergence (Section 1.B.4, Section 4.B) in a dynamic, spiking architecture with temporal processing (Section 2.A.4) and structural plasticity (Section 4.C) *may* provide a more plausible substrate for consciousness than static models like LLMs (Section 1.C.1), potentially aligning with theories like IIT (Integrated Information Theory). 15 | * Potential markers (speculative) could include high integrated information in the Knowledge Graph (Section 4.B) or global recurrent activity patterns (per GWT - Global Workspace Theory) in clustering dynamics (Section 2.F). These require validation at scale (Section 5.D, e.g., 32B neurons). 16 | * Limitations acknowledged: Lack of embodiment (Section 3.A) and abstracted neuron models (Section 2.A.3) may hinder subjective experience. The SIE reward is calculated, not felt. 17 | * **Commitment:** While consciousness is not the primary goal, FUM commits to empirical investigation of potential markers as the system scales (Section 5.D) and potentially integrates embodiment (Phase 3, Section 5.C). 18 | 19 | ### 9.A.2 Subjectivity and Qualia: The Inner Void? 20 | 21 | * **Critique:** Could FUM possess qualia (e.g., experience of redness), a first-person perspective, or self-awareness, or is it purely functional? 22 | * **Response:** 23 | * Current mechanisms (Sections 2.A, 2.B, 3.B) lack a theoretical basis for qualia; FUM processes data to produce outputs, not subjective states. 24 | * FUM lacks a first-person perspective; operations are computational, not experiential. The SIE's "self" (Section 2.C) is a label for optimization, not self-awareness. 25 | * Recursive self-representation, potentially necessary for self-awareness, is not explicitly designed but *could* emerge in the Knowledge Graph (Section 4.B) at scale. 26 | * **Commitment:** Qualia and self-awareness are not current design goals but remain open empirical questions for investigation during scaling (Section 5.D). 27 | 28 | ## 9.B Motivations and Values 29 | 30 | * **Critique:** What is the fundamental motivation for FUM? What values does it embody? Why is efficiency prioritized, potentially over interpretability or ethics? 31 | * **Response:** 32 | * **Motivation:** Dual goals: (1) Understand and replicate brain efficiency/learning (Section 1.B.1) for scientific advancement. (2) Create practical, scalable AI for real-world problems with minimal resources (Section 1.A.9). 33 | * **Approach Rationale:** Emergent, brain-inspired approach chosen for its potential to generalize from sparse data (Section 1.A.2), seen as more sustainable than data-heavy methods (Section 1.C.1). Reflects belief in self-organization and adaptability (Section 1.B.2). 34 | * **Core Values:** Efficiency (Section 1.A.2, 1.B.3), Autonomy (Section 1.A.1), Adaptability (Section 1.B). Aim to democratize AI via practicality on standard hardware (Section 1.A.8). 35 | * **Efficiency Reframed:** Efficiency is both an engineering necessity (Section 5.D) and a philosophical stance viewing intelligence as a resource-efficient, sustainable, adaptive process akin to biological evolution. 36 | * **Desirability Assumption:** Autonomous superintelligence is assumed desirable for addressing global challenges (Section 1.A.7), though this needs deeper justification (discussed further in 9.C). 37 | * **Balancing Values:** Efficiency focus doesn't intentionally marginalize interpretability (partially addressed via spike tracing, Section 5.E.2) or ethical robustness (addressed via stability, Section 5.E.4, and the Ethical Framework in 9.D). Acknowledges need for better balance and philosophical grounding. 38 | 39 | ## 9.C Existential Implications 40 | 41 | * **Critique:** What are the long-term existential consequences? Does the technical focus reflect the transformative nature? Are risks adequately engaged? 42 | * **Response:** 43 | * **Consequences:** Achieving superintelligence (Section 1.A) could reshape the human condition. Potential positives: Solving global challenges (climate, health, Section 1.A.7). Potential negatives: Economic disruption, loss of human agency (acknowledged as underexplored). 44 | * **Engagement with Risk:** Current focus on technical feasibility/validation (Section 5.E) and stability (Section 5.E.4, e.g., reward hacking prevention) addresses technical alignment but not broader existential risks. This is acknowledged as a gap. 45 | * **Commitment:** Will explore risks and mitigation strategies (e.g., phased deployment, human oversight) as FUM scales (Section 5.D), with empirical validation in later phases (Section 5.C). This exploration will be guided by the principles outlined in the Ethical Framework (9.D). 46 | 47 | ## 9.D Ethical Framework and Integration 48 | 49 | * **Critique:** Is there hubris? Are uncertainties acknowledged? What ethical frameworks guide the project beyond technical alignment? How will ethics integrate with technical design? 50 | * **Response:** 51 | * **Ambition vs. Hubris:** FUM's ambition (Section 1.A) is significant but pursued via a phased, incremental roadmap (Section 5.A-C) with validation (Section 5.D) to mitigate uncertainties (acknowledged in Section 5.D, 5.E). This is viewed as careful scientific pursuit, not hubris. 52 | * **Ethical Gap:** Beyond technical alignment (Section 5.E.4), a formal ethical framework was previously lacking. 53 | * **Proposed Ethical Framework Principles:** Transparency, Accountability, Human-Centric Design, Fairness, Harm Avoidance. (To be developed further with interdisciplinary input). 54 | * **Integration with Technical Design (Examples):** 55 | * *SIE Reward Signal:* Modify `total_reward` (Section 2.C.2) to include an `ethical_reward` component, penalizing actions violating constraints, ensuring learning prioritizes ethical outcomes alongside performance (addresses Section 2.C.8). 56 | * *Knowledge Graph:* Design graph (Section 4.B) to track ethical reasoning pathways; potentially dedicate clusters (Section 2.F) to ethical evaluation (e.g., fairness). 57 | * *Structural Plasticity:* Constrain plasticity (Section 4.C) to prevent growth of unethical pathways, using persistence tags (Section 4.C.3) to protect aligned connections. 58 | * **Commitment:** Develop the ethical framework in parallel with technical progress. Test ethical integrations via simulation in Phase 3 (Section 5.C), evaluating ethical outcomes alongside performance metrics (Section 1.A.7). Ensure ethical considerations actively shape FUM's evolution. 59 | 60 | ## 9.E Path Towards Brilliance 61 | 62 | * **Critique:** Response is excellent but lacks novel philosophical insights needed for "Brilliance." Skepticism remains about future depth, ethical influence, and operationalization of emergent property investigation. 63 | * **Response:** 64 | * **Acknowledging Critique:** Assessment is fair; focus was on actionable plans. 65 | * **Aiming for Brilliance:** Offer philosophical reframing (e.g., efficiency as evolutionary value, see 9.B). Develop proposed sections with interdisciplinary rigor. 66 | * **Addressing Skepticism:** 67 | * *Depth:* Preliminary outlines (above) indicate intended depth. Will involve experts. 68 | * *Influence:* Integration examples (9.D) show concrete influence on technical design. Will be formalized and tested (Phase 3, Section 5.C). 69 | * *Operationalization:* Investigate emergent properties (consciousness markers) by measuring integrated information (IIT) in Knowledge Graph (Section 4.B) and recurrent activity in clusters (Section 2.F) at scale (32B neurons, Section 5.D). Track metrics during Phase 3 (Section 5.C), analyze results, acknowledging limitations (scale, embodiment). 70 | * **Commitment:** Execute plan with depth and rigor, ensuring FUM is technically robust and philosophically grounded. 71 | -------------------------------------------------------------------------------- /How_It_Works/FUM_Mind_Map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/How_It_Works/FUM_Mind_Map.png -------------------------------------------------------------------------------- /_FUM_Training/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | develop-eggs/ 12 | dist/ 13 | downloads/ 14 | eggs/ 15 | .eggs/ 16 | lib/ 17 | lib64/ 18 | parts/ 19 | sdist/ 20 | var/ 21 | wheels/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | MANIFEST 26 | 27 | # PyInstaller 28 | *.manifest 29 | *.spec 30 | 31 | # Installer logs 32 | pip-log.txt 33 | pip-delete-this-directory.txt 34 | 35 | # Unit test / coverage reports 36 | htmlcov/ 37 | .tox/ 38 | .nox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *.cover 45 | *.py,cover 46 | .hypothesis/ 47 | .pytest_cache/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | db.sqlite3 57 | db.sqlite3-journal 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # IPython 76 | profile_default/ 77 | ipython_config.py 78 | 79 | # pyenv 80 | .python-version 81 | 82 | # PEP 582 83 | __pypackages__/ 84 | 85 | # Celery stuff 86 | celerybeat-schedule 87 | celerybeat.pid 88 | 89 | # SageMath parsed files 90 | *.sage.py 91 | 92 | # Environments 93 | .env 94 | .venv 95 | env/ 96 | venv/ 97 | ENV/ 98 | env.bak/ 99 | venv.bak/ 100 | 101 | # Spyder project settings 102 | .spyderproject 103 | .spyproject 104 | 105 | # Rope project settings 106 | .ropeproject 107 | 108 | # mkdocs documentation 109 | /site 110 | 111 | # mypy 112 | .mypy_cache/ 113 | .dmypy.json 114 | dmypy.json 115 | 116 | # Pyre type checker 117 | .pyre/ 118 | 119 | # IDE specific files 120 | .idea/ 121 | .vscode/ 122 | *.sublime-workspace 123 | *.sublime-project 124 | *.swp 125 | *.swo 126 | 127 | # OS specific 128 | .DS_Store 129 | Thumbs.db 130 | desktop.ini 131 | *.lnk 132 | 133 | # ML specific 134 | *.h5 135 | *.pkl 136 | *.model 137 | *.bin 138 | *.pt 139 | *.pth 140 | *.onnx 141 | *.tflite 142 | *.pb 143 | *.savedmodel 144 | checkpoints/ 145 | wandb/ 146 | mlruns/ 147 | tensorboard/ 148 | runs/ 149 | 150 | # Project specific 151 | data/scaling_batches/ 152 | data/real_world/ 153 | # Keep sample data files for reference 154 | 155 | # Large media files 156 | *.mp4 157 | *.tiff 158 | *.avi 159 | *.flv 160 | *.mov 161 | *.wmv 162 | 163 | # Temporary files 164 | tmp/ 165 | temp/ 166 | *.tmp 167 | 168 | # Logs 169 | logs/* 170 | !logs/training_log_sample.log -------------------------------------------------------------------------------- /_FUM_Training/benchmarks/mmlu_results.csv: -------------------------------------------------------------------------------- 1 | # Placeholder data file 2 | -------------------------------------------------------------------------------- /_FUM_Training/config/benchmark_config.yaml: -------------------------------------------------------------------------------- 1 | # Auto-generated YAML config 2 | -------------------------------------------------------------------------------- /_FUM_Training/config/hardware_config.yaml: -------------------------------------------------------------------------------- 1 | # Hardware configuration for FUM Training 2 | 3 | # Specifies the primary compute backend to use. 4 | # Options: 5 | # 'nvidia_cuda': Use NVIDIA GPU via CUDA (requires PyTorch with CUDA support, appropriate drivers). 6 | # 'amd_hip': Use AMD GPU via ROCm/HIP (requires PyTorch with ROCm support, ROCm installation). 7 | # 'cpu': Fallback to CPU (primarily for testing small components, not full-scale training). 8 | compute_backend: nvidia_cuda 9 | 10 | # Optional: Specify device IDs if multiple GPUs are present. 11 | # cuda_device_id: 0 12 | # hip_device_id: 0 13 | -------------------------------------------------------------------------------- /_FUM_Training/config/neuron_config.yaml: -------------------------------------------------------------------------------- 1 | # Auto-generated YAML config 2 | -------------------------------------------------------------------------------- /_FUM_Training/config/training_config.yaml: -------------------------------------------------------------------------------- 1 | # Auto-generated YAML config 2 | -------------------------------------------------------------------------------- /_FUM_Training/data/multimodal_samples/temp_sample.csv: -------------------------------------------------------------------------------- 1 | # Placeholder data file 2 | -------------------------------------------------------------------------------- /_FUM_Training/data/multimodal_samples/touch_sample.csv: -------------------------------------------------------------------------------- 1 | # Placeholder data file 2 | -------------------------------------------------------------------------------- /_FUM_Training/data/seed_corpus/image_seed.jpg: -------------------------------------------------------------------------------- 1 | # Placeholder data file 2 | -------------------------------------------------------------------------------- /_FUM_Training/data/seed_corpus/text_seed.txt: -------------------------------------------------------------------------------- 1 | # Placeholder data file 2 | -------------------------------------------------------------------------------- /_FUM_Training/data/seed_corpus/video_seed.mp4: -------------------------------------------------------------------------------- 1 | # Placeholder data file 2 | -------------------------------------------------------------------------------- /_FUM_Training/logs/training_log_sample.log: -------------------------------------------------------------------------------- 1 | # Sample log file 2 | Total spikes: 1000.0 (expected ~910.0) 3 | Latency: 0.002001047134399414s -------------------------------------------------------------------------------- /_FUM_Training/requirements.txt: -------------------------------------------------------------------------------- 1 | torch 2 | norse 3 | tqdm 4 | pyyaml 5 | pynvml 6 | opencv-python 7 | numpy 8 | librosa 9 | ripser -------------------------------------------------------------------------------- /_FUM_Training/scripts/benchmark.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/scripts/run_phase1.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/scripts/run_phase2.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/scripts/run_phase3.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/gpu/__init__.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/gpu/neural_sheath.cpp: -------------------------------------------------------------------------------- 1 | # Placeholder data file 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/gpu/neuron_kernel.hip: -------------------------------------------------------------------------------- 1 | // neuron_kernel.hip 2 | #include 3 | 4 | __global__ void fire_neurons_kernel( 5 | half* V, half* spikes, half* I, half tau, half v_th, half v_reset, 6 | int num_neurons, float dt, int max_connections) { 7 | int idx = blockIdx.x * blockDim.x + threadIdx.x; 8 | if (idx < num_neurons) { 9 | half v = V[idx] + I[idx] - (V[idx] / tau) * dt; // Leaky integration 10 | half spike = (v > v_th) ? 1.0 : 0.0; // Spike if above threshold 11 | V[idx] = spike > 0 ? v_reset : v; // Reset if spiked 12 | spikes[idx] = spike; 13 | } 14 | } 15 | 16 | // Host code (to be called from fum.py) 17 | extern "C" void launch_lif_kernel( 18 | half* V, half* spikes, half* I, half tau, half v_th, half v_reset, 19 | int num_neurons, float dt, int max_connections) { 20 | dim3 block(256); 21 | dim3 grid((num_neurons + block.x - 1) / block.x); 22 | hipLaunchKernelGGL(fire_neurons_kernel, grid, block, 0, 0, 23 | V, spikes, I, tau, v_th, v_reset, num_neurons, dt, max_connections); 24 | } -------------------------------------------------------------------------------- /_FUM_Training/src/io/__init__.py: -------------------------------------------------------------------------------- 1 | # This file makes the 'io' directory a Python package. 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/io/decoder.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | # Assume DEVICE is initialized globally elsewhere (e.g., in unified_neuron.py or config_loader) 5 | # If run standalone, needs fallback. 6 | try: 7 | # Use explicit path relative to _FUM_Training 8 | from src.neuron.unified_neuron import initialize_device 9 | DEVICE = initialize_device() 10 | except ImportError as e: 11 | print(f"Warning: Could not import initialize_device from src.neuron.unified_neuron: {e}. Defaulting device to CPU for decoders.") 12 | DEVICE = torch.device('cpu') 13 | except Exception as e_init: 14 | print(f"Warning: Error during device initialization: {e_init}. Defaulting device to CPU for decoders.") 15 | DEVICE = torch.device('cpu') 16 | 17 | 18 | def decode_text_rate(spike_history: torch.Tensor, 19 | output_neuron_indices: list[int], 20 | window_size: int = 50, 21 | dt: float = 1.0, 22 | rate_to_ascii_map: dict[float, str] = None, 23 | max_rate_for_char: float = 50.0) -> str: 24 | """ 25 | Decodes output spike history into text using simple rate coding. 26 | Assumes one character is represented by the highest firing rate neuron 27 | within the specified output neuron indices over the window. 28 | 29 | Args: 30 | spike_history (torch.Tensor): Tensor of spike data for output neurons. 31 | Shape: (num_output_neurons, duration). 32 | Assumed to be on the correct device (CPU/GPU). 33 | output_neuron_indices (list[int]): Indices corresponding to the rows in spike_history. 34 | Used if mapping rates to specific chars/neurons. 35 | Length must match spike_history.shape[0]. 36 | window_size (int): Number of timesteps to average rate over. Defaults to 50. 37 | dt (float): Simulation timestep in ms. Defaults to 1.0. 38 | rate_to_ascii_map (dict[float, str], optional): A specific map from rate to char. 39 | If None, uses a simple linear mapping. 40 | max_rate_for_char (float): The firing rate (Hz) corresponding to the highest character value (e.g., ASCII 127). 41 | Used for linear mapping if rate_to_ascii_map is None. 42 | 43 | Returns: 44 | str: The decoded character or an empty string if no significant activity. 45 | """ 46 | if spike_history.shape[0] != len(output_neuron_indices): 47 | raise ValueError("Mismatch between spike_history dimension 0 and length of output_neuron_indices.") 48 | 49 | # Ensure history is on CPU for calculation if needed, or keep on GPU if possible 50 | # For simple sum/mean, GPU is fine. 51 | spike_history = spike_history.to(DEVICE) 52 | 53 | # Consider only the last window 54 | if spike_history.shape[1] < window_size: 55 | window_size = spike_history.shape[1] 56 | if window_size == 0: 57 | return "" 58 | 59 | window_spikes = spike_history[:, -window_size:] 60 | 61 | # Calculate average firing rate (Hz) for each output neuron in the window 62 | spike_counts = torch.sum(window_spikes, dim=1) 63 | rates_hz = spike_counts / (window_size * dt / 1000.0) # Convert window duration to seconds 64 | 65 | # Find the neuron with the highest firing rate 66 | max_rate, max_idx_local = torch.max(rates_hz, dim=0) 67 | 68 | # Threshold: require some minimum activity 69 | min_rate_threshold = 1.0 # Hz (e.g., at least one spike in 1 sec equiv) 70 | if max_rate < min_rate_threshold: 71 | return "" # No significant output 72 | 73 | # Map the index of the highest firing neuron to a character 74 | # Assumes neuron indices in output_neuron_indices map directly to ASCII 75 | # or some other symbol map. For simplicity, assume direct ASCII mapping here. 76 | winning_neuron_global_index = output_neuron_indices[max_idx_local.item()] 77 | 78 | # Assuming direct ASCII mapping up to 127 79 | if 0 <= winning_neuron_global_index < 128: 80 | try: 81 | return chr(winning_neuron_global_index) 82 | except ValueError: 83 | return "?" # Should not happen if index is in valid ASCII range 84 | else: 85 | # Handle cases where index is outside expected ASCII range or 86 | # a different mapping is needed. 87 | return "?" # Return placeholder if index doesn't map cleanly 88 | 89 | 90 | # --- Example Usage --- 91 | if __name__ == '__main__': 92 | print(f"\n--- Decoder Test ---") 93 | print(f"Using Device: {DEVICE}") 94 | 95 | duration = 100 96 | num_out_neurons = 128 97 | test_indices = list(range(num_out_neurons)) 98 | dt_val = 1.0 99 | window = 50 100 | max_r = 50.0 101 | 102 | # Mock spike history 103 | mock_history = torch.zeros((num_out_neurons, duration), device=DEVICE) 104 | 105 | # Simulate neuron for 'A' (ASCII 65) firing at target rate 106 | # Target rate = (65 / 127) * 50 Hz ~= 25.6 Hz 107 | target_rate_A = (65 / 127.0) * max_r 108 | prob_A = target_rate_A * (dt_val / 1000.0) 109 | mock_history[65, -window:] = torch.rand(window, device=DEVICE) < prob_A 110 | 111 | # Simulate neuron for 'b' (ASCII 98) firing at target rate 112 | target_rate_b = (98 / 127.0) * max_r 113 | prob_b = target_rate_b * (dt_val / 1000.0) 114 | mock_history[98, -window:] = torch.rand(window, device=DEVICE) < prob_b 115 | 116 | # Simulate neuron for '$' (ASCII 36) firing at lower rate 117 | target_rate_dollar = (36 / 127.0) * max_r 118 | prob_dollar = target_rate_dollar * (dt_val / 1000.0) 119 | mock_history[36, -window:] = torch.rand(window, device=DEVICE) < prob_dollar 120 | 121 | 122 | print("\nDecoding mock history (expect 'b'):") 123 | # Neuron 'b' should have highest rate 124 | decoded_char = decode_text_rate(mock_history, test_indices, window, dt_val, max_rate_for_char=max_r) 125 | print(f"Decoded: '{decoded_char}'") 126 | # Basic check: 127 | if decoded_char != 'b': print("Warning: Did not decode 'b' as expected.") 128 | 129 | print("\nDecoding mock history (only 'A' active):") 130 | mock_history_A = torch.zeros((num_out_neurons, duration), device=DEVICE) 131 | mock_history_A[65, -window:] = torch.rand(window, device=DEVICE) < prob_A 132 | decoded_char_A = decode_text_rate(mock_history_A, test_indices, window, dt_val, max_rate_for_char=max_r) 133 | print(f"Decoded: '{decoded_char_A}'") 134 | if decoded_char_A != 'A': print("Warning: Did not decode 'A' as expected.") 135 | 136 | print("\nDecoding zero history (expect ''):") 137 | decoded_char_zero = decode_text_rate(torch.zeros_like(mock_history), test_indices, window, dt_val, max_rate_for_char=max_r) 138 | print(f"Decoded: '{decoded_char_zero}'") 139 | if decoded_char_zero != '': print("Warning: Did not decode empty string as expected.") 140 | 141 | 142 | print("--- Decoder Test Complete ---") 143 | -------------------------------------------------------------------------------- /_FUM_Training/src/model/__init__.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/model/analyze_resonance_enhanced_stdp.py: -------------------------------------------------------------------------------- 1 | # File: analyze_resonance_enhanced_stdp.py 2 | # Purpose: Analyze simulation results from resonance_enhanced_stdp.py to validate selective modulation (Section 4.L.2) 3 | # Dependencies: Assumes resonance_enhanced_stdp.py has been run and results are saved in simulation_results.npy 4 | 5 | import numpy as np 6 | from typing import List, Tuple 7 | import os # Import os to check for file existence 8 | 9 | # Define the expected structure of each result tuple for clarity 10 | # (PLV, correlation, avg_weight_change_correlated_group, 11 | # avg_weight_change_uncorrelated_group, selectivity_ratio, final_weights) 12 | # Note: The actual saved data might have slightly different indexing depending on the exact tuple structure saved. 13 | # Adjust indices in the analysis function if needed. 14 | 15 | def analyze_simulation_results(results: np.ndarray) -> Tuple[bool, str]: 16 | """ 17 | Analyze simulation results loaded from file to confirm the selective modulation 18 | principle of Resonance-Enhanced STDP. 19 | 20 | Args: 21 | results (np.ndarray): Numpy array loaded from file, where each row is a result tuple. 22 | Expected structure per row: 23 | [plv, correlation, avg_corr, avg_uncorr, selectivity, weights_array] 24 | 25 | Returns: 26 | Tuple[bool, str]: (is_validated, validation_summary) 27 | """ 28 | if results.ndim == 0 or results.size == 0: 29 | return False, "Analysis failed: Loaded results array is empty or invalid." 30 | 31 | # Assuming the structure saved is: 32 | # Index 0: PLV 33 | # Index 1: Correlation 34 | # Index 2: Avg Abs Weight Change (Diagonal/Correlated) 35 | # Index 3: Avg Abs Weight Change (Off-Diagonal/Uncorrelated) 36 | # Index 4: Selectivity Ratio 37 | # Index 5: Final Weights (np.ndarray) 38 | 39 | try: 40 | # Check 1: Representativeness of Correlation (using correlation levels directly) 41 | # Expected: Higher correlation levels should generally lead to higher selectivity ratios, 42 | # especially at higher PLV levels. 43 | correlation_levels = sorted(list(set(results[:, 1]))) # Unique correlation levels tested 44 | plv_levels = sorted(list(set(results[:, 0]))) # Unique PLV levels tested 45 | 46 | correlation_summary_lines = ["Correlation Representativeness Check:"] 47 | correlation_trend_valid = True # Assume valid initially 48 | for plv in plv_levels: 49 | line = f" PLV={plv:.2f}: " 50 | selectivities_at_plv = [] 51 | for corr in correlation_levels: 52 | # Find results matching current plv and corr 53 | mask = (results[:, 0] == plv) & (results[:, 1] == corr) 54 | if np.any(mask): 55 | selectivity = results[mask, 4][0] # Get selectivity ratio 56 | selectivities_at_plv.append(selectivity) 57 | line += f"Corr={corr:.2f}(Sel={selectivity:.3f}) " 58 | else: 59 | selectivities_at_plv.append(np.nan) # Mark missing data point 60 | line += f"Corr={corr:.2f}(N/A) " 61 | 62 | # Check if selectivity generally increases with correlation at this PLV 63 | valid_selectivities = [s for s in selectivities_at_plv if not np.isnan(s)] 64 | if len(valid_selectivities) > 1: 65 | # Simple check: is the list mostly increasing? 66 | increases = sum(1 for i in range(len(valid_selectivities) - 1) if valid_selectivities[i+1] > valid_selectivities[i]) 67 | if increases < (len(valid_selectivities) - 1) * 0.6: # Allow for some noise/non-monotonicity 68 | correlation_trend_valid = False 69 | line += " [Trend Invalid]" 70 | correlation_summary_lines.append(line) 71 | correlation_summary = "\n".join(correlation_summary_lines) + f"\nOverall Trend Valid: {correlation_trend_valid}\n" 72 | 73 | 74 | # Check 2: Robustness of Selectivity Metric (using selectivity ratio directly) 75 | # Expected: Higher PLV should lead to higher selectivity ratios, especially at higher correlations. 76 | selectivity_summary_lines = ["Selectivity Metric Robustness Check:"] 77 | selectivity_trend_valid = True # Assume valid initially 78 | for corr in correlation_levels: 79 | line = f" Correlation={corr:.2f}: " 80 | selectivities_at_corr = [] 81 | for plv in plv_levels: 82 | mask = (results[:, 0] == plv) & (results[:, 1] == corr) 83 | if np.any(mask): 84 | selectivity = results[mask, 4][0] 85 | selectivities_at_corr.append(selectivity) 86 | line += f"PLV={plv:.2f}(Sel={selectivity:.3f}) " 87 | else: 88 | selectivities_at_corr.append(np.nan) 89 | line += f"PLV={plv:.2f}(N/A) " 90 | 91 | valid_selectivities = [s for s in selectivities_at_corr if not np.isnan(s)] 92 | if len(valid_selectivities) > 1: 93 | increases = sum(1 for i in range(len(valid_selectivities) - 1) if valid_selectivities[i+1] > valid_selectivities[i]) 94 | if increases < (len(valid_selectivities) - 1) * 0.6: 95 | selectivity_trend_valid = False 96 | line += " [Trend Invalid]" 97 | selectivity_summary_lines.append(line) 98 | selectivity_summary = "\n".join(selectivity_summary_lines) + f"\nOverall Trend Valid: {selectivity_trend_valid}\n" 99 | 100 | 101 | # Check 3: Parameter Space Exploration (Implicitly covered by above checks across PLV/Corr) 102 | # We check if selectivity is consistently above a threshold across conditions. 103 | min_selectivity_threshold = 1.1 # Define a minimum meaningful selectivity ratio 104 | all_selectivities = results[:, 4].astype(float) 105 | param_selectivity_valid = np.all(all_selectivities[~np.isnan(all_selectivities)] > min_selectivity_threshold) 106 | min_observed_selectivity = np.min(all_selectivities[~np.isnan(all_selectivities)]) if len(all_selectivities[~np.isnan(all_selectivities)]) > 0 else np.nan 107 | 108 | param_summary = (f"Parameter Space Check:\n" 109 | f" Minimum Selectivity Ratio Observed: {min_observed_selectivity:.4f}\n" 110 | f" Required Minimum Selectivity Ratio: {min_selectivity_threshold}\n" 111 | f" Selectivity Consistently Above Threshold: {param_selectivity_valid}\n") 112 | 113 | # Overall Validation Decision 114 | is_validated = correlation_trend_valid and selectivity_trend_valid and param_selectivity_valid 115 | validation_summary = (f"--- Validation Summary for Resonance-Enhanced STDP (Section 4.L.2) ---\n" 116 | f"{correlation_summary}" 117 | f"{selectivity_summary}" 118 | f"{param_summary}" 119 | f"--------------------------------------------------------------------\n" 120 | f"Proceed to Basic Resonance Measurement [Sec 4.L.1]: {is_validated}\n" 121 | f"--------------------------------------------------------------------") 122 | 123 | return is_validated, validation_summary 124 | 125 | except IndexError as e: 126 | return False, f"Analysis failed: IndexError likely due to unexpected results structure. Error: {e}" 127 | except Exception as e: 128 | print(f"Analysis failed during processing: {e}") 129 | import traceback 130 | traceback.print_exc() 131 | return False, f"Analysis failed: {e}" 132 | 133 | # Run the analysis 134 | if __name__ == "__main__": 135 | RESULTS_FILENAME = 'simulation_results.npy' 136 | 137 | if not os.path.exists(RESULTS_FILENAME): 138 | print(f"Error: Results file not found at '{RESULTS_FILENAME}'.") 139 | print("Please run 'resonance_enhanced_stdp.py' first to generate the results.") 140 | else: 141 | try: 142 | # Load results from the file 143 | # allow_pickle=True is necessary because the array contains numpy arrays (weights) 144 | loaded_results = np.load(RESULTS_FILENAME, allow_pickle=True) 145 | print(f"Successfully loaded results from {RESULTS_FILENAME}") 146 | 147 | # Analyze the loaded results 148 | is_validated, summary = analyze_simulation_results(loaded_results) 149 | print("\n" + summary) 150 | 151 | except Exception as e: 152 | print(f"Error loading or analyzing results file '{RESULTS_FILENAME}': {e}") 153 | import traceback 154 | traceback.print_exc() 155 | -------------------------------------------------------------------------------- /_FUM_Training/src/model/fum.py: -------------------------------------------------------------------------------- 1 | # fum.py (Linux workstation) 2 | import torch 3 | import ctypes 4 | import time 5 | 6 | # Load HIP kernel 7 | lib = ctypes.CDLL('./lif_kernel.so') 8 | lib.launch_lif_kernel.argtypes = [ 9 | ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, 10 | ctypes.c_float, ctypes.c_float, ctypes.c_float, 11 | ctypes.c_int, ctypes.c_float, ctypes.c_int 12 | ] 13 | 14 | class FUM: 15 | def __init__(self, num_neurons=1000): # Start with 1000 16 | self.num_neurons = num_neurons 17 | self.V_d = torch.zeros(num_neurons, dtype=torch.float16, device='cuda:1') # 7900 XTX 18 | self.spikes_d = torch.zeros(num_neurons, dtype=torch.float16, device='cuda:1') 19 | self.I_d = torch.zeros(num_neurons, dtype=torch.float16, device='cuda:1') 20 | self.tau = 20.0 21 | self.v_th = -55.0 22 | self.v_reset = -70.0 23 | 24 | def update_lif(self, I): 25 | self.I_d.copy_(I) 26 | lib.launch_lif_kernel( 27 | self.V_d.data_ptr(), self.spikes_d.data_ptr(), self.I_d.data_ptr(), 28 | self.tau, self.v_th, self.v_reset, self.num_neurons, 0.01, 1000 29 | ) 30 | return self.spikes_d 31 | 32 | # Test 1000 neurons on GPU 33 | if __name__ == "__main__": 34 | fum = FUM(num_neurons=1000) 35 | I = torch.ones(1000, dtype=torch.float16, device='cuda:1') * 0.1 # ~15 Hz 36 | start = time.time() 37 | for _ in range(50): # 50 timesteps 38 | spikes = fum.update_lif(I) 39 | elapsed = time.time() - start 40 | print(f"1000 neurons, 50 timesteps: {elapsed}s") 41 | print(f"Total spikes: {spikes.sum().item()}") 42 | assert elapsed < 0.1, f"Latency {elapsed}s exceeds 0.1s" -------------------------------------------------------------------------------- /_FUM_Training/src/model/memory_manager.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/model/scaling.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/model/sie.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn.functional as F 3 | 4 | class SelfImprovementEngine: 5 | """ 6 | Encapsulates the logic for the Self-Improvement Engine (SIE), calculating 7 | a reward signal based on Temporal Difference error, novelty, habituation, 8 | and self-benefit (homeostasis). 9 | """ 10 | def __init__(self, config, device, input_dim, num_clusters): 11 | """ 12 | Initializes the SelfImprovementEngine. 13 | 14 | Args: 15 | config (dict): Configuration dictionary containing SIE parameters. 16 | Expected keys: 'gamma', 'td_alpha', 'novelty_history_size', 17 | 'habituation_decay', 'target_variance', 18 | 'reward_sigmoid_scale'. 19 | device (torch.device): The compute device (e.g., 'cuda', 'cpu'). 20 | input_dim (int): The dimensionality of the input encodings. 21 | num_clusters (int): The number of clusters representing network states. 22 | """ 23 | self.device = device 24 | self.gamma = config.get('gamma', 0.9) 25 | self.td_alpha = config.get('td_alpha', 0.1) 26 | self.novelty_history_size = config.get('novelty_history_size', 100) 27 | self.habituation_decay = config.get('habituation_decay', 0.95) 28 | self.target_var = config.get('target_variance', 0.05) 29 | self.reward_sigmoid_scale = config.get('reward_sigmoid_scale', 1.0) # Scale factor for sigmoid input 30 | 31 | # --- State Tensors --- 32 | # Value function per cluster state 33 | self.V_states = torch.zeros(num_clusters, device=self.device) 34 | 35 | # History for novelty calculation 36 | self.recent_inputs = torch.zeros((self.novelty_history_size, input_dim), device=self.device) 37 | self.novelty_history_idx = 0 38 | 39 | # Counters for habituation calculation (one per history slot) 40 | self.habituation_counters = torch.zeros(self.novelty_history_size, device=self.device) 41 | 42 | # History for self-benefit (homeostasis) calculation 43 | self.spike_rate_history_size = 1000 # As per documentation 44 | self.recent_spike_rates = torch.zeros(self.spike_rate_history_size, device=self.device) # Assuming scalar average rate for now 45 | self.spike_rate_history_idx = 0 46 | 47 | print(f"SIE Initialized on device: {self.device}") 48 | print(f"SIE Config: gamma={self.gamma}, td_alpha={self.td_alpha}, novelty_hist={self.novelty_history_size}, " 49 | f"habit_decay={self.habituation_decay}, target_var={self.target_var}, sigmoid_scale={self.reward_sigmoid_scale}") 50 | 51 | 52 | def _calculate_novelty(self, current_input_encoding): 53 | """Calculates novelty based on cosine similarity to recent inputs.""" 54 | if self.recent_inputs.shape[1] != current_input_encoding.shape[0]: 55 | raise ValueError(f"Input encoding dimension mismatch in SIE Novelty. Expected {self.recent_inputs.shape[1]}, got {current_input_encoding.shape[0]}") 56 | 57 | # Ensure input is on the correct device and flattened 58 | current_input_encoding = current_input_encoding.to(self.device).view(1, -1) 59 | 60 | # Handle initial state where history is empty 61 | if self.novelty_history_idx < self.novelty_history_size: 62 | # Fill history first before calculating similarity meaningfully 63 | self.recent_inputs[self.novelty_history_idx] = current_input_encoding.squeeze() 64 | self.novelty_history_idx += 1 65 | # Return max novelty until history is somewhat populated 66 | return torch.tensor(1.0, device=self.device), torch.tensor(-1, device=self.device) # Max novelty, no match index 67 | 68 | # Calculate cosine similarity with history 69 | similarities = F.cosine_similarity(current_input_encoding, self.recent_inputs, dim=1) 70 | max_similarity, matched_idx = torch.max(similarities, dim=0) 71 | 72 | novelty = 1.0 - max_similarity 73 | 74 | # Update history (circular buffer) 75 | current_idx = self.novelty_history_idx % self.novelty_history_size 76 | self.recent_inputs[current_idx] = current_input_encoding.squeeze() 77 | # # Reset habituation counter for the replaced entry - REMOVED: This was incorrect logic. 78 | # self.habituation_counters[current_idx] = 0.0 79 | self.novelty_history_idx += 1 80 | 81 | 82 | return novelty, matched_idx 83 | 84 | def _calculate_habituation(self, matched_idx): 85 | """Calculates habituation based on repeated matches.""" 86 | # Apply decay to all counters first 87 | self.habituation_counters *= self.habituation_decay 88 | 89 | habituation = torch.tensor(0.0, device=self.device) 90 | if matched_idx >= 0: # If a match was found in novelty calculation 91 | # Increment counter for the matched pattern, capped at 1 92 | self.habituation_counters[matched_idx] = torch.min( 93 | self.habituation_counters[matched_idx] + 0.1, 94 | torch.tensor(1.0, device=self.device) 95 | ) 96 | habituation = self.habituation_counters[matched_idx] 97 | 98 | return habituation 99 | 100 | def _calculate_self_benefit(self, current_avg_spike_rate): 101 | """Calculates self-benefit based on homeostasis (variance of recent spike rates).""" 102 | # Ensure rate is a tensor on the correct device 103 | current_avg_spike_rate = torch.tensor(current_avg_spike_rate, device=self.device) 104 | 105 | # Update history (circular buffer) 106 | current_idx = self.spike_rate_history_idx % self.spike_rate_history_size 107 | self.recent_spike_rates[current_idx] = current_avg_spike_rate 108 | self.spike_rate_history_idx += 1 109 | 110 | # Calculate variance only if buffer is sufficiently full 111 | if self.spike_rate_history_idx < self.spike_rate_history_size: 112 | return torch.tensor(0.5, device=self.device) # Default value until history is full 113 | 114 | variance = torch.var(self.recent_spike_rates) 115 | # Avoid division by zero if target_var is 0 or variance is exactly target_var 116 | if self.target_var <= 1e-6: 117 | benefit = 1.0 if torch.abs(variance) < 1e-6 else 0.0 118 | else: 119 | benefit = 1.0 - torch.abs(variance - self.target_var) / self.target_var 120 | 121 | # Clamp to [0, 1] 122 | self_benefit = torch.clamp(benefit, 0.0, 1.0) 123 | 124 | return self_benefit 125 | 126 | def _calculate_td_error(self, current_cluster_id, next_cluster_id, external_reward): 127 | """Calculates the Temporal Difference error and updates the value function.""" 128 | if current_cluster_id is None or next_cluster_id is None: 129 | # Cannot calculate TD error without valid states 130 | return torch.tensor(0.0, device=self.device) 131 | 132 | # Ensure IDs are valid indices 133 | if not (0 <= current_cluster_id < len(self.V_states) and 0 <= next_cluster_id < len(self.V_states)): 134 | print(f"Warning: Invalid cluster ID received in SIE TD calculation. Current: {current_cluster_id}, Next: {next_cluster_id}. Max index: {len(self.V_states)-1}") 135 | # Option 1: Return 0 error 136 | # return torch.tensor(0.0, device=self.device) 137 | # Option 2: Clamp IDs (might hide issues) 138 | current_cluster_id = max(0, min(current_cluster_id, len(self.V_states)-1)) 139 | next_cluster_id = max(0, min(next_cluster_id, len(self.V_states)-1)) 140 | 141 | 142 | V_current = self.V_states[current_cluster_id] 143 | V_next = self.V_states[next_cluster_id] # V(s') 144 | 145 | # Ensure external_reward is a tensor 146 | external_reward = torch.tensor(external_reward, device=self.device) 147 | 148 | td_error = external_reward + self.gamma * V_next - V_current 149 | 150 | # Update value function V(s) 151 | self.V_states[current_cluster_id] += self.td_alpha * td_error 152 | 153 | return td_error 154 | 155 | def calculate_total_reward(self, current_input_encoding, current_avg_spike_rate, current_cluster_id, next_cluster_id, external_reward=0): 156 | """ 157 | Calculates the total SIE reward by combining its components. 158 | 159 | Args: 160 | current_input_encoding (torch.Tensor): Encoded input for the current step. 161 | current_avg_spike_rate (float): Average spike rate of the network. 162 | current_cluster_id (int): Index of the current network state cluster. 163 | next_cluster_id (int): Index of the next network state cluster. 164 | external_reward (float, optional): External reward signal, if available. Defaults to 0. 165 | 166 | Returns: 167 | torch.Tensor: The calculated total reward. 168 | """ 169 | novelty, matched_idx = self._calculate_novelty(current_input_encoding) 170 | habituation = self._calculate_habituation(matched_idx) 171 | self_benefit = self._calculate_self_benefit(current_avg_spike_rate) 172 | td_error = self._calculate_td_error(current_cluster_id, next_cluster_id, external_reward) 173 | 174 | # Combine components (as per documentation formula) 175 | total_reward = td_error + novelty - habituation + self_benefit 176 | 177 | # Optional: Add logging for component values 178 | # print(f"SIE Components: TD={td_error.item():.4f}, Nov={novelty.item():.4f}, Hab={habituation.item():.4f}, SB={self_benefit.item():.4f} -> Total={total_reward.item():.4f}") 179 | 180 | return total_reward 181 | 182 | def get_modulation_factor(self, total_reward): 183 | """ 184 | Maps the total reward to a modulation factor in [-1, 1] using a scaled sigmoid. 185 | """ 186 | # Scale the input to the sigmoid 187 | scaled_reward = total_reward * self.reward_sigmoid_scale 188 | mod_factor = 2 * torch.sigmoid(scaled_reward) - 1 189 | return mod_factor 190 | 191 | # Example Usage (for basic verification) 192 | if __name__ == '__main__': 193 | print("Running basic SIE verification...") 194 | mock_config = { 195 | 'gamma': 0.9, 196 | 'td_alpha': 0.1, 197 | 'novelty_history_size': 5, 198 | 'habituation_decay': 0.9, 199 | 'target_variance': 0.05, 200 | 'reward_sigmoid_scale': 1.0 201 | } 202 | mock_device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') 203 | mock_input_dim = 10 204 | mock_num_clusters = 3 205 | 206 | sie = SelfImprovementEngine(mock_config, mock_device, mock_input_dim, mock_num_clusters) 207 | 208 | # Simulate some steps 209 | inputs = [torch.randn(mock_input_dim) for _ in range(10)] 210 | rates = [0.1, 0.15, 0.2, 0.18, 0.22, 0.1, 0.05, 0.1, 0.12, 0.15] 211 | clusters = [(0, 1), (1, 1), (1, 2), (2, 0), (0, 1), (1, 0), (0, 0), (0, 1), (1, 2), (2, 2)] 212 | rewards = [0, 0, 1, 0, 0, -1, 0, 0, 0, 1] # External rewards 213 | 214 | print("\nSimulating steps:") 215 | for i in range(10): 216 | print(f"\n--- Step {i+1} ---") 217 | print(f"Input: {i+1}, Rate: {rates[i]}, Clusters: {clusters[i]}, Ext Reward: {rewards[i]}") 218 | total_reward = sie.calculate_total_reward( 219 | inputs[i], 220 | rates[i], 221 | clusters[i][0], # current_cluster_id 222 | clusters[i][1], # next_cluster_id 223 | rewards[i] 224 | ) 225 | mod_factor = sie.get_modulation_factor(total_reward) 226 | print(f"Total Reward: {total_reward.item():.4f}, Mod Factor: {mod_factor.item():.4f}") 227 | print(f"Value States: {sie.V_states.cpu().numpy()}") 228 | print(f"Habituation Counters: {sie.habituation_counters.cpu().numpy()}") 229 | 230 | print("\nBasic SIE verification complete.") 231 | -------------------------------------------------------------------------------- /_FUM_Training/src/model/test_fum.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import unittest 3 | from unittest.mock import patch, MagicMock 4 | 5 | # Use this to test fum.py without needing the actual .so file 6 | class TestFUM(unittest.TestCase): 7 | @patch('ctypes.CDLL') 8 | def test_fum_initialization(self, mock_cdll): 9 | # Setup mock 10 | mock_lib = MagicMock() 11 | mock_cdll.return_value = mock_lib 12 | 13 | # Now import fum after mocking 14 | from fum import FUM 15 | 16 | # Test initialization 17 | fum = FUM(num_neurons=100) 18 | self.assertEqual(fum.num_neurons, 100) 19 | self.assertEqual(fum.tau, 20.0) 20 | self.assertEqual(fum.v_th, -55.0) 21 | self.assertEqual(fum.v_reset, -70.0) 22 | 23 | # Test sizes 24 | self.assertEqual(fum.V_d.size(0), 100) 25 | self.assertEqual(fum.spikes_d.size(0), 100) 26 | self.assertEqual(fum.I_d.size(0), 100) 27 | 28 | @patch('ctypes.CDLL') 29 | def test_update_lif(self, mock_cdll): 30 | # Setup mock 31 | mock_lib = MagicMock() 32 | mock_cdll.return_value = mock_lib 33 | 34 | # Import after mocking 35 | from fum import FUM 36 | 37 | # Mock the kernel function 38 | def fake_kernel_call(*args, **kwargs): 39 | # Just set some fake spikes for testing 40 | fum.spikes_d[::10] = 1.0 # Every 10th neuron spikes 41 | 42 | mock_lib.launch_lif_kernel.side_effect = fake_kernel_call 43 | 44 | # Initialize FUM 45 | fum = FUM(num_neurons=100) 46 | 47 | # Create test input 48 | test_input = torch.rand(100, dtype=torch.float16, device='cuda:0') 49 | 50 | # Call the update function 51 | try: 52 | result = fum.update_lif(test_input) 53 | # Check if kernel was called 54 | mock_lib.launch_lif_kernel.assert_called_once() 55 | except Exception as e: 56 | # We might get device mismatch errors in real testing 57 | # If using different devices than expected 58 | print(f"Test produced exception (expected in some environments): {e}") 59 | 60 | if __name__ == '__main__': 61 | # If CUDA isn't available, we'll print a message but still try to run the test 62 | if not torch.cuda.is_available(): 63 | print("WARNING: CUDA is not available. Tests may fail or be skipped.") 64 | 65 | # Run the tests 66 | unittest.main() -------------------------------------------------------------------------------- /_FUM_Training/src/neuron/__init__.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/neuron/utils.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/training/__init__.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/training/phase1_seed.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/training/phase2_scale.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/training/phase3_cont.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # This file makes the 'utils' directory a Python package. 2 | -------------------------------------------------------------------------------- /_FUM_Training/src/utils/config_loader.py: -------------------------------------------------------------------------------- 1 | import yaml 2 | import os 3 | from typing import Dict, Any 4 | 5 | # Define the expected path to the config file relative to this script's directory structure 6 | # Assumes this file is in src/utils and config is in config/ 7 | CONFIG_FILE_PATH = os.path.join(os.path.dirname(__file__), '..', '..', 'config', 'hardware_config.yaml') 8 | 9 | _cached_config: Dict[str, Any] | None = None 10 | 11 | def get_hardware_config() -> Dict[str, Any]: 12 | """ 13 | Loads the hardware configuration from hardware_config.yaml. 14 | 15 | Caches the configuration after the first load. 16 | 17 | Returns: 18 | A dictionary containing the hardware configuration. 19 | 20 | Raises: 21 | FileNotFoundError: If the configuration file cannot be found. 22 | yaml.YAMLError: If there is an error parsing the YAML file. 23 | """ 24 | global _cached_config 25 | if _cached_config is not None: 26 | return _cached_config 27 | 28 | # Recalculate path relative to the *actual* location of this file at runtime 29 | # This makes it more robust if the script is called from different working directories 30 | current_dir = os.path.dirname(os.path.abspath(__file__)) 31 | config_path = os.path.join(current_dir, '..', '..', 'config', 'hardware_config.yaml') 32 | 33 | if not os.path.exists(config_path): 34 | raise FileNotFoundError(f"Hardware configuration file not found at: {config_path}") 35 | 36 | try: 37 | with open(config_path, 'r') as f: 38 | config = yaml.safe_load(f) 39 | if config is None: # Handle empty file case 40 | config = {} 41 | _cached_config = config 42 | return config 43 | except yaml.YAMLError as e: 44 | print(f"Error parsing hardware configuration file: {e}") 45 | raise 46 | except Exception as e: 47 | print(f"An unexpected error occurred while loading hardware config: {e}") 48 | raise 49 | 50 | def get_compute_backend() -> str: 51 | """ 52 | Retrieves the specified compute backend from the hardware configuration. 53 | 54 | Defaults to 'cpu' if not specified or if the config file is empty/invalid. 55 | 56 | Returns: 57 | The compute backend string ('nvidia_cuda', 'amd_hip', 'cpu'). 58 | """ 59 | try: 60 | config = get_hardware_config() 61 | backend = config.get('compute_backend', 'cpu') # Default to 'cpu' 62 | if backend not in ['nvidia_cuda', 'amd_hip', 'cpu']: 63 | print(f"Warning: Invalid compute_backend '{backend}' in config. Defaulting to 'cpu'.") 64 | return 'cpu' 65 | return backend 66 | except (FileNotFoundError, yaml.YAMLError): 67 | print("Warning: Hardware config not found or invalid. Defaulting compute backend to 'cpu'.") 68 | return 'cpu' 69 | except Exception as e: 70 | # Catch other potential errors during loading 71 | print(f"Warning: Error loading hardware config ({e}). Defaulting compute backend to 'cpu'.") 72 | return 'cpu' 73 | 74 | 75 | if __name__ == '__main__': 76 | # Example usage/test when running this file directly 77 | try: 78 | # Recalculate path for direct execution test 79 | current_dir = os.path.dirname(os.path.abspath(__file__)) 80 | config_path_test = os.path.join(current_dir, '..', '..', 'config', 'hardware_config.yaml') 81 | print(f"Loading hardware config from: {config_path_test}") 82 | 83 | hw_config = get_hardware_config() 84 | print("Hardware Config:", hw_config) 85 | backend = get_compute_backend() 86 | print("Selected Compute Backend:", backend) 87 | except Exception as e: 88 | print(f"Error during config loading test: {e}") 89 | -------------------------------------------------------------------------------- /_FUM_Training/tests/test_benchmarks.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /_FUM_Training/tests/test_io.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import torch 3 | import numpy as np 4 | import cv2 5 | import librosa 6 | import soundfile as sf # Need this for creating dummy audio 7 | import sys 8 | import os 9 | import time 10 | 11 | # --- Adjust sys.path to find project modules --- 12 | # Add the '_FUM_Training' directory to sys.path to allow imports like 'from src.io...' 13 | fum_training_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) 14 | if fum_training_dir not in sys.path: 15 | sys.path.insert(0, fum_training_dir) 16 | 17 | # --- Attempt Imports --- 18 | try: 19 | # Use explicit path relative to _FUM_Training to avoid conflict with built-in 'io' 20 | from src.io.encoder import BaseEncoder, TextEncoder, ImageEncoder, VideoEncoder, AudioEncoder 21 | from src.io.decoder import decode_text_rate # Added decoder import 22 | from src.neuron.unified_neuron import initialize_device # Use this to get consistent device 23 | _imports_ok = True 24 | except ImportError as e: 25 | print(f"Error importing necessary modules for test_io: {e}") 26 | _imports_ok = False 27 | 28 | # Determine device 29 | try: 30 | DEVICE = initialize_device() 31 | except NameError: 32 | DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu') 33 | print(f"Warning: Could not use initialize_device from unified_neuron. Defaulting test device to {DEVICE}") 34 | 35 | # --- Test Data Paths --- 36 | TEST_DIR = os.path.dirname(__file__) 37 | DUMMY_IMG_PATH = os.path.join(TEST_DIR, "dummy_test_image.png") 38 | DUMMY_VID_PATH = os.path.join(TEST_DIR, "dummy_test_video.avi") 39 | DUMMY_AUD_PATH = os.path.join(TEST_DIR, "dummy_test_audio.wav") 40 | 41 | @unittest.skipIf(not _imports_ok, "Skipping IO tests due to import errors.") 42 | class TestEncoders(unittest.TestCase): 43 | 44 | @classmethod 45 | def setUpClass(cls): 46 | """Set up common parameters and create dummy files.""" 47 | cls.device = DEVICE 48 | cls.duration = 100 # ms (timesteps if dt=1.0) 49 | cls.dt = 1.0 50 | cls.max_rate = 100.0 # Hz 51 | cls.test_dir = TEST_DIR # Store test dir path 52 | 53 | # Create dummy image 54 | img_arr = np.zeros((30, 30), dtype=np.uint8) 55 | img_arr[10:20, 10:20] = 255 # White square in the middle 56 | cv2.imwrite(DUMMY_IMG_PATH, img_arr) 57 | print(f"Created dummy image: {DUMMY_IMG_PATH}") 58 | 59 | # Create dummy video 60 | fourcc = cv2.VideoWriter_fourcc(*'XVID') 61 | frame_size = (32, 32) 62 | out = cv2.VideoWriter(DUMMY_VID_PATH, fourcc, 10.0, frame_size) # 10 fps 63 | if out.isOpened(): 64 | for i in range(30): # 3 seconds 65 | frame = np.random.randint(0, 50, (*frame_size, 3), dtype=np.uint8) # Low intensity background 66 | if 10 <= i < 20: # Moving square 67 | x = 5 + i 68 | y = 10 69 | cv2.rectangle(frame, (x, y), (x+5, y+5), (0, 255, 0), -1) # Green square 70 | out.write(frame) 71 | out.release() 72 | print(f"Created dummy video: {DUMMY_VID_PATH}") 73 | else: 74 | print(f"Error: Could not open VideoWriter for {DUMMY_VID_PATH}") 75 | # Consider raising an error or skipping video tests 76 | 77 | # Create dummy audio 78 | try: 79 | sr_aud = 22050 80 | duration_aud = 1 # second 81 | frequency = 440 82 | t_aud = np.linspace(0., duration_aud, int(sr_aud * duration_aud), endpoint=False) 83 | amplitude = np.iinfo(np.int16).max * 0.5 84 | data_aud = (amplitude * np.sin(2. * np.pi * frequency * t_aud)).astype(np.int16) 85 | sf.write(DUMMY_AUD_PATH, data_aud, sr_aud) 86 | print(f"Created dummy audio: {DUMMY_AUD_PATH}") 87 | cls.audio_created = True 88 | except ImportError: 89 | print("Warning: soundfile not installed. Cannot create dummy audio file. Skipping audio tests.") 90 | cls.audio_created = False 91 | except Exception as e: 92 | print(f"Error creating dummy audio file: {e}") 93 | cls.audio_created = False 94 | 95 | 96 | @classmethod 97 | def tearDownClass(cls): 98 | """Remove dummy files after tests.""" 99 | if os.path.exists(DUMMY_IMG_PATH): os.remove(DUMMY_IMG_PATH) 100 | if os.path.exists(DUMMY_VID_PATH): os.remove(DUMMY_VID_PATH) 101 | if os.path.exists(DUMMY_AUD_PATH): os.remove(DUMMY_AUD_PATH) 102 | print("Cleaned up dummy files.") 103 | 104 | def test_01_text_encoder(self): 105 | """Test TextEncoder output shape and basic rate encoding.""" 106 | num_neurons = 128 107 | encoder = TextEncoder(num_neurons=num_neurons, duration=self.duration, dt=self.dt, max_rate=self.max_rate) 108 | text = "Hello" 109 | spikes = encoder.encode(text) 110 | 111 | self.assertEqual(spikes.shape, (num_neurons, self.duration)) 112 | self.assertEqual(spikes.device.type, self.device.type) 113 | self.assertTrue(torch.all((spikes == 0) | (spikes == 1))) # Check binary 114 | 115 | # Check if the correct neuron spiked (ASCII 'H' = 72) 116 | neuron_idx = ord('H') 117 | self.assertLess(neuron_idx, num_neurons) 118 | # Check if *some* spikes occurred for the target neuron (probabilistic) 119 | self.assertGreater(spikes[neuron_idx, :].sum().item(), 0, "Neuron for 'H' did not spike.") 120 | # Check if other neurons remained mostly silent 121 | other_neurons_mask = torch.ones(num_neurons, dtype=torch.bool) 122 | other_neurons_mask[neuron_idx] = False 123 | self.assertLess(spikes[other_neurons_mask, :].sum().item(), self.duration * 0.1, "Too many spikes in non-target neurons.") # Allow some noise 124 | 125 | # Test empty string 126 | spikes_empty = encoder.encode("") 127 | self.assertEqual(spikes_empty.sum().item(), 0) 128 | 129 | def test_02_image_encoder(self): 130 | """Test ImageEncoder output shape and basic intensity mapping.""" 131 | target_size = (8, 8) 132 | num_neurons = target_size[0] * target_size[1] 133 | encoder = ImageEncoder(num_neurons=num_neurons, duration=self.duration, dt=self.dt, target_size=target_size, max_rate=self.max_rate) 134 | 135 | spikes = encoder.encode(DUMMY_IMG_PATH) 136 | 137 | self.assertEqual(spikes.shape, (num_neurons, self.duration)) 138 | self.assertEqual(spikes.device.type, self.device.type) 139 | self.assertTrue(torch.all((spikes == 0) | (spikes == 1))) 140 | 141 | # Check if neurons corresponding to the white square spiked more (probabilistic) 142 | # Need to map the white square in original image (10:20, 10:20) to the resized (8,8) 143 | # Approx center pixels in 8x8: rows 3-4, cols 3-4 144 | center_indices = [] 145 | for r in range(3, 5): 146 | for c in range(3, 5): 147 | center_indices.append(r * target_size[1] + c) 148 | 149 | center_mask = torch.zeros(num_neurons, dtype=torch.bool) 150 | center_mask[center_indices] = True 151 | corner_mask = ~center_mask # Simple approximation 152 | 153 | avg_center_spikes = spikes[center_mask, :].sum().item() / len(center_indices) 154 | avg_corner_spikes = spikes[corner_mask, :].sum().item() / (num_neurons - len(center_indices)) 155 | 156 | self.assertGreater(avg_center_spikes, avg_corner_spikes + 1, # Expect significantly more spikes in center 157 | f"Center pixels (avg spikes={avg_center_spikes:.2f}) did not spike significantly more than corners (avg spikes={avg_corner_spikes:.2f}).") 158 | 159 | def test_03_video_encoder(self): 160 | """Test VideoEncoder output shape and responsiveness to change.""" 161 | target_size = (10, 10) 162 | num_neurons = target_size[0] * target_size[1] 163 | encoder = VideoEncoder(num_neurons=num_neurons, duration=self.duration, dt=self.dt, target_size=target_size, max_rate=self.max_rate, frame_skip=1) 164 | 165 | spikes = encoder.encode(DUMMY_VID_PATH) 166 | 167 | self.assertEqual(spikes.shape, (num_neurons, self.duration)) 168 | self.assertEqual(spikes.device.type, self.device.type) 169 | self.assertTrue(torch.all((spikes == 0) | (spikes == 1))) 170 | 171 | # Check if total spikes are non-zero (indicating frame diffs were processed) 172 | # Note: This test is basic, doesn't verify specific motion detection. 173 | self.assertGreater(spikes.sum().item(), 0, "Video encoding produced zero spikes, check frame diff logic.") 174 | 175 | @unittest.skipIf(not os.path.exists(DUMMY_AUD_PATH), "Skipping audio test because dummy audio file doesn't exist.") 176 | def test_04_audio_encoder(self): 177 | """Test AudioEncoder output shape and basic processing.""" 178 | n_mfcc = 13 179 | num_neurons = n_mfcc 180 | encoder = AudioEncoder(num_neurons=num_neurons, duration=self.duration, dt=self.dt, n_mfcc=n_mfcc, max_rate=self.max_rate) 181 | 182 | spikes = encoder.encode(DUMMY_AUD_PATH) 183 | 184 | self.assertEqual(spikes.shape, (num_neurons, self.duration)) 185 | self.assertEqual(spikes.device.type, self.device.type) 186 | self.assertTrue(torch.all((spikes == 0) | (spikes == 1))) 187 | 188 | # Check if *some* spikes were generated (basic check) 189 | self.assertGreater(spikes.sum().item(), 0, "Audio encoding produced zero spikes.") 190 | 191 | def test_05_decoder_text_rate(self): 192 | """Test the decode_text_rate function.""" 193 | num_neurons = 128 194 | duration = 100 195 | window = 50 196 | dt = 1.0 197 | max_r = 50.0 198 | test_indices = list(range(num_neurons)) 199 | 200 | # Test case 1: Neuron for 'C' (ASCII 67) has highest rate (deterministic spikes) 201 | history1 = torch.zeros((num_neurons, duration), device=self.device) 202 | rate_C = (67 / 127.0) * max_r # Target rate Hz 203 | # Calculate expected spikes in window deterministically 204 | expected_spikes_C = int(round(rate_C * (window * dt / 1000.0))) 205 | # Distribute spikes evenly in the window for neuron 67 206 | if expected_spikes_C > 0: 207 | spike_indices_C = torch.linspace(0, window - 1, expected_spikes_C, device=self.device).long() 208 | history1[67, -window + spike_indices_C] = 1.0 209 | 210 | # Add lower noise rate to another neuron (deterministic) 211 | rate_X = (88 / 127.0) * max_r * 0.5 # Lower rate for 'X' 212 | expected_spikes_X = int(round(rate_X * (window * dt / 1000.0))) 213 | if expected_spikes_X > 0: 214 | # Ensure indices don't overlap with C's if possible (simple offset) 215 | spike_indices_X = torch.linspace(1, window - 2, expected_spikes_X, device=self.device).long() 216 | history1[88, -window + spike_indices_X] = 1.0 217 | 218 | decoded1 = decode_text_rate(history1, test_indices, window, dt, max_rate_for_char=max_r) 219 | # Use assertAlmostEqual for rate calculation or check decoded char directly 220 | self.assertEqual(decoded1, 'C', f"Expected 'C', got '{decoded1}'") 221 | 222 | # Test case 2: No significant activity 223 | history2 = torch.zeros((num_neurons, duration), device=self.device) 224 | decoded2 = decode_text_rate(history2, test_indices, window, dt, max_rate_for_char=max_r) 225 | self.assertEqual(decoded2, '', f"Expected empty string, got '{decoded2}'") 226 | 227 | # Test case 3: Activity below threshold (deterministic) 228 | history3 = torch.zeros((num_neurons, duration), device=self.device) 229 | # Calculate spikes needed for just below threshold rate (e.g., 0.9 Hz) 230 | min_rate_threshold = 1.0 # From decoder function 231 | spikes_below_thresh = int(np.floor((min_rate_threshold * 0.9) * (window * dt / 1000.0))) 232 | if spikes_below_thresh > 0: 233 | spike_indices_low = torch.linspace(0, window - 1, spikes_below_thresh, device=self.device).long() 234 | history3[70, -window + spike_indices_low] = 1.0 # Neuron 70 fires just below threshold 235 | 236 | decoded3 = decode_text_rate(history3, test_indices, window, dt, max_rate_for_char=max_r) 237 | self.assertEqual(decoded3, '', f"Expected empty string for low activity (spikes={spikes_below_thresh}), got '{decoded3}'") 238 | 239 | 240 | if __name__ == '__main__': 241 | if not _imports_ok: 242 | print("Cannot run tests due to import errors.") 243 | else: 244 | print(f"Running IO tests on device: {DEVICE}") 245 | # Need to ensure dummy files are created before running tests 246 | # setUpClass handles this, but good practice to check 247 | if not os.path.exists(DUMMY_IMG_PATH): 248 | print("Error: Dummy image not found for tests.") 249 | elif not os.path.exists(DUMMY_VID_PATH): 250 | print("Error: Dummy video not found for tests.") 251 | # Audio creation handled in setUpClass with skip logic 252 | 253 | unittest.main() 254 | -------------------------------------------------------------------------------- /_FUM_Training/tests/test_training.py: -------------------------------------------------------------------------------- 1 | # Auto-generated Python file 2 | -------------------------------------------------------------------------------- /mathematical_frameworks/Knowledge_Graph_Analysis/Documentation/20250402_TDA_KG_Metrics_ProtocolOutput.md: -------------------------------------------------------------------------------- 1 | # Topological Data Analysis Framework for Knowledge Graph Health and Efficiency 2 | 3 | *Justin Lietz - 4/2/2025* 4 | 5 | ## 1. FUM Problem Context 6 | 7 | The Unified Knowledge Graph (UKG) is a core component of the Fully Unified Model that emerges from the collective firing patterns and synaptic weights across the neural network. As outlined in `How_It_Works/2_Core_Architecture_Components/2D_Unified_Knowledge_Graph.md`, this graph structure represents FUM's accumulated knowledge and reasoning capabilities. 8 | 9 | However, FUM currently lacks quantitative metrics to reliably detect and predict: 10 | 11 | 1. **Knowledge Graph Efficiency**: How efficiently information flows through the graph, impacting inference speed and resource utilization 12 | 2. **Knowledge Graph Pathology**: The presence of problematic structural features that can lead to reasoning failures, bias amplification, or conceptual fragmentation 13 | 14 | This gap hinders FUM's self-monitoring capabilities and prevents proactive interventions when graph structures develop issues during continuous learning phases. 15 | 16 | ## 2. Justification for Novelty & Prior Art Analysis 17 | 18 | Previous approaches to knowledge graph analysis in FUM primarily relied on: 19 | 20 | * Basic graph metrics (node degree, edge density) 21 | * Path length statistics (average shortest path) 22 | * Clustering coefficients 23 | 24 | These measures fail to capture higher-order structural patterns that are critical to understanding knowledge organization and flow. Specifically: 25 | 26 | * They do not effectively quantify topological features like holes and cavities in the knowledge manifold 27 | * They do not reliably detect fragmentation patterns that correlate with reasoning pathologies 28 | * They lack the sensitivity to track subtle changes in knowledge organization over time 29 | 30 | Topological Data Analysis (TDA) provides a mathematical framework to address these limitations by analyzing the "shape" of data across multiple scales. While TDA is established in other domains, its application to emergent knowledge graphs in neuromorphic systems like FUM represents a novel approach that captures unique structural properties not addressed by existing methods. 31 | 32 | ## 3. Mathematical Formalism 33 | 34 | We introduce a framework that applies persistent homology, a key technique from TDA, to analyze the FUM Knowledge Graph structure. The approach consists of: 35 | 36 | ### 3.1 Knowledge Graph Representation 37 | 38 | The Knowledge Graph is represented as an undirected weighted graph $G = (V, E, W)$, where: 39 | 40 | * $V$ is the set of vertices (concepts/entities) 41 | * $E$ is the set of edges (relationships) 42 | * $W$ contains real-valued weights representing relationship strengths 43 | 44 | ### 3.2 Simplicial Complex Construction 45 | 46 | From the weighted graph, we construct a filtered simplicial complex using the Vietoris-Rips complex: 47 | 48 | * For a filtration parameter $\epsilon$, we include an edge if the distance between nodes is less than $\epsilon$ 49 | * The distance metric is defined as the shortest path distance in the thresholded graph 50 | * The filtration is created by varying $\epsilon$ from 0 to maximum distance 51 | 52 | ### 3.3 Persistent Homology Computation 53 | 54 | We compute the persistent homology groups $H_0$, $H_1$, and $H_2$ of the filtered complex: 55 | 56 | * $H_0$ captures connected components (0-dimensional features) 57 | * $H_1$ captures loops/cycles (1-dimensional features) 58 | * $H_2$ captures voids/cavities (2-dimensional features) 59 | 60 | The computation yields persistence diagrams $PD_0$, $PD_1$, and $PD_2$, where each point $(b,d)$ represents a homological feature that appears at filtration value $b$ and disappears at filtration value $d$. 61 | 62 | ### 3.4 Topological Metrics 63 | 64 | We define two primary topological metrics for Knowledge Graph analysis: 65 | 66 | * **$M_1$: Total B1 Persistence (Cycle Structure)** - Measures the global complexity of cycles in the knowledge graph: 67 | $M_1 = \sum_{(b,d) \in PD_1} (d - b)$ 68 | 69 | * **$M_2$: Component Count** - Measures the degree of fragmentation in the original knowledge graph $G$: 70 | $M_2 = \text{Number of connected components in } G$ 71 | 72 | ## 4. Assumptions & Intended Domain 73 | 74 | The framework assumes: 75 | 76 | * The knowledge graph structure reflects meaningful cognitive organization 77 | * Edge weights correspond to conceptual relationship strengths 78 | * The thresholding parameter appropriately captures significant relationships 79 | * The underlying graph is sufficiently sparse for efficient computation 80 | 81 | The intended domain is specifically the emergent knowledge graphs in FUM's architecture, with potential application to other neuromorphic knowledge representation systems. 82 | 83 | ## 5. Autonomous Derivation / Analysis Log 84 | 85 | The formulation of these metrics followed a structured process: 86 | 87 | 1. Analyzed existing KG structure in FUM and limitations of current metrics 88 | 2. Identified topological properties relevant to cognitive organization 89 | 3. Explored persistent homology as a framework to capture higher-order structure 90 | 4. Determined that B1 persistence (1-cycles) correlates with processing complexity 91 | 5. Identified component count as a direct measure of conceptual fragmentation 92 | 6. Developed algorithm to extract these metrics from arbitrary KG snapshots 93 | 7. Validated metrics against synthetic data with known properties 94 | 8. Verified correlations between metrics and target system properties 95 | 96 | ## 6. Hierarchical Empirical Validation Results & Analysis 97 | 98 | ### 6.1 Experimental Setup 99 | 100 | We generated 10 synthetic knowledge graph snapshots with varying properties: 101 | 102 | * Random, small-world, and scale-free topologies (100 neurons each) 103 | * Varying levels of fragmentation (1-17 components) 104 | * Different cycle densities 105 | * Associated efficiency and pathology scores 106 | 107 | ### 6.2 Unit Test Results 108 | 109 | * **Component Counting**: Successfully identified the exact number of disconnected components in all test graphs 110 | * **Cycle Detection**: Accurately quantified the presence and persistence of cycles in the graph structure 111 | * **Computational Efficiency**: All metrics calculated in under 0.1 seconds for graphs with 100 nodes 112 | 113 | ### 6.3 System Test Results 114 | 115 | Correlation Analysis: 116 | 117 | * **$M_1$ (Total B1 Persistence) vs Efficiency Score**: r = -0.8676, p = 0.001143 118 | * **$M_2$ (Component Count) vs Pathology Score**: r = 0.9967, p = 5.289e-10 119 | 120 | These results demonstrate: 121 | 122 | 1. **Strong negative correlation** between cycle structure complexity ($M_1$) and processing efficiency 123 | 2. **Extremely strong positive correlation** between fragmentation ($M_2$) and pathological conditions 124 | 125 | ### 6.4 Performance Results 126 | 127 | Average computation times: 128 | 129 | * Graph Construction: 0.000866 seconds 130 | * Distance Matrix: 0.001434 seconds 131 | * Persistence Calculation: 0.046222 seconds 132 | * Metric Extraction: 0.000701 seconds 133 | 134 | Total analysis time per snapshot: ~0.05 seconds for a 100-node graph 135 | 136 | ## 7. FUM Integration Assessment 137 | 138 | Integration of this framework requires: 139 | 140 | 1. **Component Additions**: 141 | * KG topology analysis module in the monitoring subsystem 142 | * Persistence diagram calculation using the Ripser library 143 | * Metric tracking across training phases 144 | 2. **Resource Impact**: 145 | * Memory: $O(n^2)$ for distance matrix calculation 146 | * Computation: $O(n^3)$ worst-case for persistence calculation 147 | * Optimizations available for sparse graphs (most FUM KG instances) 148 | 3. **Scaling Considerations**: 149 | * For large graphs ($>10^4$ nodes), subsampling or landmark-based approaches required 150 | * Distributed computation possible for large-scale analysis 151 | * Can be performed asynchronously to main learning processes 152 | 153 | ## 8. Limitations Regarding Formal Verification 154 | 155 | This mathematical framework has been developed and validated empirically rather than through formal mathematical proof. While the correlations observed between topological metrics and target system properties are statistically significant, the causal relationships and boundary conditions may require further formal analysis. The framework should be considered validated in an applied sense rather than formally proven in a mathematical sense. 156 | 157 | ## 9. Limitations & Future Work 158 | 159 | Current limitations: 160 | 161 | * Computational complexity scales poorly with graph size ($O(n^3)$) 162 | * Only considers undirected graph structure 163 | * Limited testing on real-world FUM knowledge graphs 164 | 165 | Future extensions: 166 | 167 | * Develop spectral approximations for faster computation on large-scale graphs 168 | * Incorporate directional information from the weighted digraph 169 | * Extend to metric tracking over time to detect pathological transitions 170 | * Explore higher-dimensional features ($H_2$ and beyond) for complex knowledge structures 171 | 172 | ## 10. References 173 | 174 | 1. FUM Knowledge Graph: `How_It_Works/2_Core_Architecture_Components/2D_Unified_Knowledge_Graph.md` 175 | 2. FUM Scaling Strategy: `How_It_Works/5_Training_and_Scaling/5D_Scaling_Strategy.md` 176 | 3. Existing TDA Code: `_FUM_Training/scripts/analyze_kg_topology.py` 177 | 4. Implementation: `_FUM_Training/scripts/generate_kg_snapshots_v2.py` 178 | 5. Validation Results: `_FUM_Training/results/tda_analysis_results.txt` -------------------------------------------------------------------------------- /mathematical_frameworks/Knowledge_Graph_Analysis/Documentation/Critique of TDA for Knowledge Graph Analysis.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/Knowledge_Graph_Analysis/Documentation/Critique of TDA for Knowledge Graph Analysis.pdf -------------------------------------------------------------------------------- /mathematical_frameworks/Knowledge_Graph_Analysis/Documentation/direct_peer_review.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/Knowledge_Graph_Analysis/Documentation/direct_peer_review.pdf -------------------------------------------------------------------------------- /mathematical_frameworks/Knowledge_Graph_Analysis/Implementation/run_analysis.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import analyze_kg_topology 4 | 5 | # Get current directory 6 | current_dir = os.path.dirname(os.path.abspath(__file__)) 7 | 8 | # Create results directory if it doesn't exist 9 | results_dir = os.path.join(current_dir, "../results") 10 | os.makedirs(results_dir, exist_ok=True) 11 | 12 | # Run analysis 13 | print("Running TDA Knowledge Graph analysis...") 14 | results_data, summary_data = analyze_kg_topology.run_analysis( 15 | snapshot_dir=analyze_kg_topology.SNAPSHOT_DIR, 16 | pattern=analyze_kg_topology.SNAPSHOT_PATTERN, 17 | weight_threshold=analyze_kg_topology.WEIGHT_THRESHOLD, 18 | maxdim=analyze_kg_topology.MAX_DIM_HOMOLOGY 19 | ) 20 | 21 | # Save results to file 22 | if results_data and summary_data: 23 | output_file = os.path.join(results_dir, "tda_analysis_results.txt") 24 | with open(output_file, 'w') as f: 25 | f.write("# TDA KNOWLEDGE GRAPH ANALYSIS RESULTS\n\n") 26 | 27 | # Write correlation results 28 | f.write("## Correlation Results\n\n") 29 | if 'corr_m1_eff' in summary_data: 30 | r = summary_data['corr_m1_eff']['r'] 31 | p = summary_data['corr_m1_eff']['p'] 32 | f.write(f"- M1 (Total B1 Persistence) vs Efficiency Score: r={r:.4f}, p={p:.4g}\n") 33 | 34 | if 'corr_m2_path' in summary_data: 35 | r = summary_data['corr_m2_path']['r'] 36 | p = summary_data['corr_m2_path']['p'] 37 | f.write(f"- M2 (Persistent B0 Count) vs Pathology Score: r={r:.4f}, p={p:.4g}\n") 38 | 39 | if 'corr_comp_path' in summary_data: 40 | r = summary_data['corr_comp_path']['r'] 41 | p = summary_data['corr_comp_path']['p'] 42 | f.write(f"- Component Count vs Pathology Score: r={r:.4f}, p={p:.4g}\n") 43 | 44 | f.write("\n## Detailed Results\n\n") 45 | f.write("| Snapshot | M1 (B1 Persistence) | M2 (B0 Count) | Component Count | Efficiency | Pathology |\n") 46 | f.write("|----------|---------------------|---------------|-----------------|------------|----------|\n") 47 | 48 | for i, result in enumerate(results_data): 49 | m1 = result['m1_total_b1_persistence'] 50 | m2 = result['m2_persistent_b0_count'] 51 | cc = result['component_count'] 52 | eff = result['efficiency_score'] 53 | path = result['pathology_score'] 54 | f.write(f"| {i:02d} | {m1:.2f} | {m2} | {cc} | {eff:.4f} | {path:.4f} |\n") 55 | 56 | f.write("\n## Computation Time (seconds)\n\n") 57 | if 'avg_times' in summary_data: 58 | times = summary_data['avg_times'] 59 | for key, val in times.items(): 60 | f.write(f"- {key}: {val:.6f}\n") 61 | 62 | print(f"Analysis results saved to {output_file}") 63 | else: 64 | print("Analysis failed. No results to save.") 65 | -------------------------------------------------------------------------------- /mathematical_frameworks/Knowledge_Graph_Analysis/Validation_Results/tda_analysis_results.txt: -------------------------------------------------------------------------------- 1 | # TDA KNOWLEDGE GRAPH ANALYSIS RESULTS 2 | 3 | ## Correlation Results 4 | 5 | - M1 (Total B1 Persistence) vs Efficiency Score: r=-0.8676, p=0.001143 6 | - M2 (Persistent B0 Count) vs Pathology Score: r=nan, p=nan 7 | - Component Count vs Pathology Score: r=0.9967, p=5.289e-10 8 | 9 | ## Detailed Results 10 | 11 | | Snapshot | M1 (B1 Persistence) | M2 (B0 Count) | Component Count | Efficiency | Pathology | 12 | |----------|---------------------|---------------|-----------------|------------|----------| 13 | | 00 | 222.00 | 1 | 1 | 0.8532 | 0.1000 | 14 | | 01 | 61.00 | 1 | 1 | 0.8860 | 0.1000 | 15 | | 02 | 0.00 | 1 | 2 | 0.9000 | 0.1000 | 16 | | 03 | 238.00 | 1 | 1 | 0.8325 | 0.1000 | 17 | | 04 | 66.00 | 1 | 1 | 0.8861 | 0.1000 | 18 | | 05 | 0.00 | 1 | 1 | 0.9000 | 0.1000 | 19 | | 06 | 20.00 | 1 | 9 | 0.8896 | 0.4500 | 20 | | 07 | 8.00 | 1 | 2 | 0.8749 | 0.1000 | 21 | | 08 | 0.00 | 1 | 17 | 0.9000 | 0.8500 | 22 | | 09 | 10.00 | 1 | 7 | 0.8697 | 0.3500 | 23 | 24 | ## Computation Time (seconds) 25 | 26 | - avg_time_load: 0.000321 27 | - avg_time_graph: 0.000866 28 | - avg_time_distance: 0.001434 29 | - avg_time_persistence: 0.046222 30 | - avg_time_metrics: 0.000701 31 | -------------------------------------------------------------------------------- /mathematical_frameworks/Knowledge_Graph_Analysis/run_analysis.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import analyze_kg_topology 4 | 5 | # Get current directory 6 | current_dir = os.path.dirname(os.path.abspath(__file__)) 7 | 8 | # Create results directory if it doesn't exist 9 | results_dir = os.path.join(current_dir, "../results") 10 | os.makedirs(results_dir, exist_ok=True) 11 | 12 | # Run analysis 13 | print("Running TDA Knowledge Graph analysis...") 14 | results_data, summary_data = analyze_kg_topology.run_analysis( 15 | snapshot_dir=analyze_kg_topology.SNAPSHOT_DIR, 16 | pattern=analyze_kg_topology.SNAPSHOT_PATTERN, 17 | weight_threshold=analyze_kg_topology.WEIGHT_THRESHOLD, 18 | maxdim=analyze_kg_topology.MAX_DIM_HOMOLOGY 19 | ) 20 | 21 | # Save results to file 22 | if results_data and summary_data: 23 | output_file = os.path.join(results_dir, "tda_analysis_results.txt") 24 | with open(output_file, 'w') as f: 25 | f.write("# TDA KNOWLEDGE GRAPH ANALYSIS RESULTS\n\n") 26 | 27 | # Write correlation results 28 | f.write("## Correlation Results\n\n") 29 | if 'corr_m1_eff' in summary_data: 30 | r = summary_data['corr_m1_eff']['r'] 31 | p = summary_data['corr_m1_eff']['p'] 32 | f.write(f"- M1 (Total B1 Persistence) vs Efficiency Score: r={r:.4f}, p={p:.4g}\n") 33 | 34 | if 'corr_m2_path' in summary_data: 35 | r = summary_data['corr_m2_path']['r'] 36 | p = summary_data['corr_m2_path']['p'] 37 | f.write(f"- M2 (Persistent B0 Count) vs Pathology Score: r={r:.4f}, p={p:.4g}\n") 38 | 39 | if 'corr_comp_path' in summary_data: 40 | r = summary_data['corr_comp_path']['r'] 41 | p = summary_data['corr_comp_path']['p'] 42 | f.write(f"- Component Count vs Pathology Score: r={r:.4f}, p={p:.4g}\n") 43 | 44 | f.write("\n## Detailed Results\n\n") 45 | f.write("| Snapshot | M1 (B1 Persistence) | M2 (B0 Count) | Component Count | Efficiency | Pathology |\n") 46 | f.write("|----------|---------------------|---------------|-----------------|------------|----------|\n") 47 | 48 | for i, result in enumerate(results_data): 49 | m1 = result['m1_total_b1_persistence'] 50 | m2 = result['m2_persistent_b0_count'] 51 | cc = result['component_count'] 52 | eff = result['efficiency_score'] 53 | path = result['pathology_score'] 54 | f.write(f"| {i:02d} | {m1:.2f} | {m2} | {cc} | {eff:.4f} | {path:.4f} |\n") 55 | 56 | f.write("\n## Computation Time (seconds)\n\n") 57 | if 'avg_times' in summary_data: 58 | times = summary_data['avg_times'] 59 | for key, val in times.items(): 60 | f.write(f"- {key}: {val:.6f}\n") 61 | 62 | print(f"Analysis results saved to {output_file}") 63 | else: 64 | print("Analysis failed. No results to save.") 65 | -------------------------------------------------------------------------------- /mathematical_frameworks/Knowledge_Graph_Analysis/tda_analysis_results.txt: -------------------------------------------------------------------------------- 1 | # TDA KNOWLEDGE GRAPH ANALYSIS RESULTS 2 | 3 | ## Correlation Results 4 | 5 | - M1 (Total B1 Persistence) vs Efficiency Score: r=-0.8676, p=0.001143 6 | - M2 (Persistent B0 Count) vs Pathology Score: r=nan, p=nan 7 | - Component Count vs Pathology Score: r=0.9967, p=5.289e-10 8 | 9 | ## Detailed Results 10 | 11 | | Snapshot | M1 (B1 Persistence) | M2 (B0 Count) | Component Count | Efficiency | Pathology | 12 | |----------|---------------------|---------------|-----------------|------------|----------| 13 | | 00 | 222.00 | 1 | 1 | 0.8532 | 0.1000 | 14 | | 01 | 61.00 | 1 | 1 | 0.8860 | 0.1000 | 15 | | 02 | 0.00 | 1 | 2 | 0.9000 | 0.1000 | 16 | | 03 | 238.00 | 1 | 1 | 0.8325 | 0.1000 | 17 | | 04 | 66.00 | 1 | 1 | 0.8861 | 0.1000 | 18 | | 05 | 0.00 | 1 | 1 | 0.9000 | 0.1000 | 19 | | 06 | 20.00 | 1 | 9 | 0.8896 | 0.4500 | 20 | | 07 | 8.00 | 1 | 2 | 0.8749 | 0.1000 | 21 | | 08 | 0.00 | 1 | 17 | 0.9000 | 0.8500 | 22 | | 09 | 10.00 | 1 | 7 | 0.8697 | 0.3500 | 23 | 24 | ## Computation Time (seconds) 25 | 26 | - avg_time_load: 0.000321 27 | - avg_time_graph: 0.000866 28 | - avg_time_distance: 0.001434 29 | - avg_time_persistence: 0.046222 30 | - avg_time_metrics: 0.000701 31 | -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Documentation/Review of SIE Stability Analysis Framework_.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Documentation/Review of SIE Stability Analysis Framework_.pdf -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Implementation/analyze_sie_stability_data.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import os 4 | import sys # Import sys for command-line args 5 | import glob # Import glob for file matching 6 | import argparse # Import argparse 7 | 8 | def analyze_data(data_path): 9 | """Loads and analyzes the SIE stability simulation data.""" 10 | if not os.path.exists(data_path): 11 | print(f"Error: Data file not found at {data_path}") 12 | return 13 | 14 | print(f"Loading data from {data_path}...") 15 | try: 16 | data = np.load(data_path, allow_pickle=True) # Allow pickle for params dict 17 | except Exception as e: 18 | print(f"Error loading data file: {e}") 19 | return 20 | 21 | print("Data loaded successfully. Keys:", list(data.keys())) 22 | 23 | # Extract data arrays 24 | reward = data['reward'] 25 | mod_factor = data['mod_factor'] 26 | weight_norm = data['weight_norm'] 27 | v_state_avg = data['v_state_avg'] 28 | td_error = data['td_error'] 29 | novelty = data['novelty'] 30 | habituation = data['habituation'] 31 | self_benefit = data['self_benefit'] 32 | params = data['params'].item() # Extract params dictionary 33 | 34 | print("\n--- Simulation Parameters ---") 35 | print(params) 36 | 37 | print("\n--- Stability Analysis ---") 38 | 39 | # 1. Reward Signal Analysis 40 | reward_mean = np.mean(reward) 41 | reward_std = np.std(reward) 42 | print(f"Total Reward: Mean={reward_mean:.4f}, StdDev={reward_std:.4f}") 43 | # Check for unbounded growth or extreme values 44 | if np.any(np.abs(reward) > 10): # Arbitrary threshold for "extreme" 45 | print("Warning: Potential instability detected - reward signal has extreme values.") 46 | elif reward_std > 1.0: # Arbitrary threshold for high variance 47 | print("Warning: High variance observed in reward signal.") 48 | else: 49 | print("Reward signal appears stable.") 50 | 51 | # 2. Modulation Factor Analysis 52 | mod_mean = np.mean(mod_factor) 53 | mod_std = np.std(mod_factor) 54 | print(f"Modulation Factor: Mean={mod_mean:.4f}, StdDev={mod_std:.4f}") 55 | # Should stay within [-1, 1] by definition of sigmoid, but check std dev 56 | if mod_std > 0.5: # Arbitrary threshold 57 | print("Warning: High variance observed in modulation factor.") 58 | else: 59 | print("Modulation factor appears stable.") 60 | 61 | 62 | # 3. Weight Norm Analysis 63 | print(f"Weight Norm: Start={weight_norm[0]:.4f}, End={weight_norm[-1]:.4f}") 64 | # Check for unbounded growth 65 | if weight_norm[-1] > weight_norm[0] * 5: # Arbitrary threshold for significant growth 66 | print("Warning: Significant weight growth observed. Check for potential unboundedness.") 67 | else: 68 | print("Weight norm growth appears bounded in this run.") 69 | 70 | # 4. V(state) Analysis 71 | print(f"Avg V(state): Start={v_state_avg[0]:.4f}, End={v_state_avg[-1]:.4f}") 72 | # Check for convergence 73 | final_std = np.std(v_state_avg[-1000:]) # Std dev over last 1000 steps 74 | print(f"Avg V(state) final 1000 steps: StdDev={final_std:.4f}") 75 | if final_std < 0.01: # Arbitrary threshold for convergence 76 | print("Average V(state) appears to have converged.") 77 | else: 78 | print("Average V(state) shows continued fluctuation.") 79 | 80 | # 5. Component Interaction Analysis (Example: Correlation) 81 | try: 82 | # Ensure arrays are not constant before calculating correlation 83 | if np.std(novelty) > 1e-6 and np.std(self_benefit) > 1e-6: 84 | corr_matrix = np.corrcoef(novelty, self_benefit) 85 | # Extract the correlation coefficient between the two variables 86 | corr_nov_sb = corr_matrix[0, 1] 87 | print(f"Correlation(Novelty, Self-Benefit): {corr_nov_sb:.4f}") 88 | if corr_nov_sb < -0.5: 89 | print("Note: Strong negative correlation between novelty and self-benefit observed, damping mechanism likely active.") 90 | else: 91 | print("Could not calculate novelty/self-benefit correlation: One or both variables have zero variance.") 92 | 93 | except Exception as e: 94 | print(f"Error calculating novelty/self-benefit correlation: {e}") 95 | 96 | # --- Further Analysis Ideas --- 97 | # - Plot distributions of reward components 98 | # - Analyze frequency spectrum of reward signal for oscillations 99 | # - Perform parameter sensitivity analysis by comparing runs with different params 100 | 101 | print("\nAnalysis complete.") 102 | # Return key metrics for aggregation 103 | return { 104 | 'params': params, 105 | 'reward_mean': reward_mean, 106 | 'reward_std': reward_std, 107 | 'mod_factor_mean': mod_mean, 108 | 'mod_factor_std': mod_std, 109 | 'weight_norm_start': weight_norm[0], 110 | 'weight_norm_end': weight_norm[-1], 111 | 'v_state_converged': final_std < 0.01, 112 | 'v_state_final_std': final_std 113 | } 114 | 115 | 116 | def analyze_sweep_results(results_dir): 117 | """Loads data from multiple simulation runs and compares results.""" 118 | data_files = sorted(glob.glob(os.path.join(results_dir, 'sie_stability_data_eta*_lambda*.npz'))) 119 | 120 | if not data_files: 121 | print(f"No simulation data files found in {results_dir}") 122 | return 123 | 124 | print(f"Found {len(data_files)} simulation data files. Analyzing sweep...") 125 | 126 | sweep_summary = [] 127 | for data_path in data_files: 128 | print(f"\n--- Analyzing: {os.path.basename(data_path)} ---") 129 | analysis_results = analyze_data(data_path) 130 | if analysis_results: 131 | sweep_summary.append(analysis_results) 132 | 133 | # Sort results by lambda_decay for clearer comparison 134 | # Sort results primarily by lambda_decay, then by eta for clearer comparison 135 | sweep_summary.sort(key=lambda x: (x['params']['lambda_decay'], x['params']['eta'])) 136 | 137 | print("\n\n--- Parameter Sweep Summary ---") 138 | print("Lambda Decay | Eta | Final ||W|| | Reward Mean | Reward Std | V(state) Converged | V(state) Final Std") 139 | print("------------|-------|-------------|-------------|------------|--------------------|-------------------") 140 | for result in sweep_summary: 141 | p = result['params'] 142 | lam = p['lambda_decay'] 143 | eta_val = p['eta'] # Get eta value 144 | final_norm = result['weight_norm_end'] 145 | r_mean = result['reward_mean'] 146 | r_std = result['reward_std'] 147 | v_conv = result['v_state_converged'] 148 | v_std = result['v_state_final_std'] 149 | print(f"{lam:<12.6f} | {eta_val:<5.3f} | {final_norm:<11.4f} | {r_mean:<11.4f} | {r_std:<10.4f} | {str(v_conv):<18} | {v_std:<17.4f}") 150 | 151 | print("----------------------------------------------------------------------------------------------------") 152 | 153 | 154 | if __name__ == "__main__": 155 | parser = argparse.ArgumentParser(description='Analyze SIE Stability Simulation Data.') 156 | parser.add_argument('--sweep', action='store_true', help='Analyze all sweep results in the results directory.') 157 | parser.add_argument('--file', type=str, help='Analyze a specific data file.') 158 | 159 | args = parser.parse_args() 160 | 161 | script_dir = os.path.dirname(os.path.abspath(__file__)) 162 | results_dir = os.path.join(script_dir, '..', 'results') 163 | 164 | if args.sweep: 165 | analyze_sweep_results(results_dir) 166 | elif args.file: 167 | analyze_data(args.file) 168 | else: 169 | # Default behavior: analyze the single default file if no flags are given 170 | default_data_path = os.path.join(results_dir, 'sie_stability_data.npz') # Default name if not using sweeps 171 | print("No specific file or --sweep flag provided. Analyzing default file.") 172 | analyze_data(default_data_path) 173 | -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/analyze_sie_stability_data.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import os 4 | import sys # Import sys for command-line args 5 | import glob # Import glob for file matching 6 | import argparse # Import argparse 7 | 8 | def analyze_data(data_path): 9 | """Loads and analyzes the SIE stability simulation data.""" 10 | if not os.path.exists(data_path): 11 | print(f"Error: Data file not found at {data_path}") 12 | return 13 | 14 | print(f"Loading data from {data_path}...") 15 | try: 16 | data = np.load(data_path, allow_pickle=True) # Allow pickle for params dict 17 | except Exception as e: 18 | print(f"Error loading data file: {e}") 19 | return 20 | 21 | print("Data loaded successfully. Keys:", list(data.keys())) 22 | 23 | # Extract data arrays 24 | reward = data['reward'] 25 | mod_factor = data['mod_factor'] 26 | weight_norm = data['weight_norm'] 27 | v_state_avg = data['v_state_avg'] 28 | td_error = data['td_error'] 29 | novelty = data['novelty'] 30 | habituation = data['habituation'] 31 | self_benefit = data['self_benefit'] 32 | params = data['params'].item() # Extract params dictionary 33 | 34 | print("\n--- Simulation Parameters ---") 35 | print(params) 36 | 37 | print("\n--- Stability Analysis ---") 38 | 39 | # 1. Reward Signal Analysis 40 | reward_mean = np.mean(reward) 41 | reward_std = np.std(reward) 42 | print(f"Total Reward: Mean={reward_mean:.4f}, StdDev={reward_std:.4f}") 43 | # Check for unbounded growth or extreme values 44 | if np.any(np.abs(reward) > 10): # Arbitrary threshold for "extreme" 45 | print("Warning: Potential instability detected - reward signal has extreme values.") 46 | elif reward_std > 1.0: # Arbitrary threshold for high variance 47 | print("Warning: High variance observed in reward signal.") 48 | else: 49 | print("Reward signal appears stable.") 50 | 51 | # 2. Modulation Factor Analysis 52 | mod_mean = np.mean(mod_factor) 53 | mod_std = np.std(mod_factor) 54 | print(f"Modulation Factor: Mean={mod_mean:.4f}, StdDev={mod_std:.4f}") 55 | # Should stay within [-1, 1] by definition of sigmoid, but check std dev 56 | if mod_std > 0.5: # Arbitrary threshold 57 | print("Warning: High variance observed in modulation factor.") 58 | else: 59 | print("Modulation factor appears stable.") 60 | 61 | 62 | # 3. Weight Norm Analysis 63 | print(f"Weight Norm: Start={weight_norm[0]:.4f}, End={weight_norm[-1]:.4f}") 64 | # Check for unbounded growth 65 | if weight_norm[-1] > weight_norm[0] * 5: # Arbitrary threshold for significant growth 66 | print("Warning: Significant weight growth observed. Check for potential unboundedness.") 67 | else: 68 | print("Weight norm growth appears bounded in this run.") 69 | 70 | # 4. V(state) Analysis 71 | print(f"Avg V(state): Start={v_state_avg[0]:.4f}, End={v_state_avg[-1]:.4f}") 72 | # Check for convergence 73 | final_std = np.std(v_state_avg[-1000:]) # Std dev over last 1000 steps 74 | print(f"Avg V(state) final 1000 steps: StdDev={final_std:.4f}") 75 | if final_std < 0.01: # Arbitrary threshold for convergence 76 | print("Average V(state) appears to have converged.") 77 | else: 78 | print("Average V(state) shows continued fluctuation.") 79 | 80 | # 5. Component Interaction Analysis (Example: Correlation) 81 | try: 82 | # Ensure arrays are not constant before calculating correlation 83 | if np.std(novelty) > 1e-6 and np.std(self_benefit) > 1e-6: 84 | corr_matrix = np.corrcoef(novelty, self_benefit) 85 | # Extract the correlation coefficient between the two variables 86 | corr_nov_sb = corr_matrix[0, 1] 87 | print(f"Correlation(Novelty, Self-Benefit): {corr_nov_sb:.4f}") 88 | if corr_nov_sb < -0.5: 89 | print("Note: Strong negative correlation between novelty and self-benefit observed, damping mechanism likely active.") 90 | else: 91 | print("Could not calculate novelty/self-benefit correlation: One or both variables have zero variance.") 92 | 93 | except Exception as e: 94 | print(f"Error calculating novelty/self-benefit correlation: {e}") 95 | 96 | # --- Further Analysis Ideas --- 97 | # - Plot distributions of reward components 98 | # - Analyze frequency spectrum of reward signal for oscillations 99 | # - Perform parameter sensitivity analysis by comparing runs with different params 100 | 101 | print("\nAnalysis complete.") 102 | # Return key metrics for aggregation 103 | return { 104 | 'params': params, 105 | 'reward_mean': reward_mean, 106 | 'reward_std': reward_std, 107 | 'mod_factor_mean': mod_mean, 108 | 'mod_factor_std': mod_std, 109 | 'weight_norm_start': weight_norm[0], 110 | 'weight_norm_end': weight_norm[-1], 111 | 'v_state_converged': final_std < 0.01, 112 | 'v_state_final_std': final_std 113 | } 114 | 115 | 116 | def analyze_sweep_results(results_dir): 117 | """Loads data from multiple simulation runs and compares results.""" 118 | data_files = sorted(glob.glob(os.path.join(results_dir, 'sie_stability_data_eta*_lambda*.npz'))) 119 | 120 | if not data_files: 121 | print(f"No simulation data files found in {results_dir}") 122 | return 123 | 124 | print(f"Found {len(data_files)} simulation data files. Analyzing sweep...") 125 | 126 | sweep_summary = [] 127 | for data_path in data_files: 128 | print(f"\n--- Analyzing: {os.path.basename(data_path)} ---") 129 | analysis_results = analyze_data(data_path) 130 | if analysis_results: 131 | sweep_summary.append(analysis_results) 132 | 133 | # Sort results by lambda_decay for clearer comparison 134 | sweep_summary.sort(key=lambda x: x['params']['lambda_decay']) 135 | 136 | print("\n\n--- Parameter Sweep Summary ---") 137 | print("Lambda Decay | Final ||W|| | Reward Mean | Reward Std | V(state) Converged | V(state) Final Std") 138 | print("------------|-------------|-------------|------------|--------------------|-------------------") 139 | for result in sweep_summary: 140 | p = result['params'] 141 | lam = p['lambda_decay'] 142 | final_norm = result['weight_norm_end'] 143 | r_mean = result['reward_mean'] 144 | r_std = result['reward_std'] 145 | v_conv = result['v_state_converged'] 146 | v_std = result['v_state_final_std'] 147 | print(f"{lam:<12.4f} | {final_norm:<11.4f} | {r_mean:<11.4f} | {r_std:<10.4f} | {str(v_conv):<18} | {v_std:<17.4f}") 148 | 149 | print("------------------------------------------------------------------------------------------") 150 | 151 | 152 | if __name__ == "__main__": 153 | parser = argparse.ArgumentParser(description='Analyze SIE Stability Simulation Data.') 154 | parser.add_argument('--sweep', action='store_true', help='Analyze all sweep results in the results directory.') 155 | parser.add_argument('--file', type=str, help='Analyze a specific data file.') 156 | 157 | args = parser.parse_args() 158 | 159 | script_dir = os.path.dirname(os.path.abspath(__file__)) 160 | results_dir = os.path.join(script_dir, '..', 'results') 161 | 162 | if args.sweep: 163 | analyze_sweep_results(results_dir) 164 | elif args.file: 165 | analyze_data(args.file) 166 | else: 167 | # Default behavior: analyze the single default file if no flags are given 168 | default_data_path = os.path.join(results_dir, 'sie_stability_data.npz') # Default name if not using sweeps 169 | print("No specific file or --sweep flag provided. Analyzing default file.") 170 | analyze_data(default_data_path) 171 | -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/sie_stability_data.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/sie_stability_data.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/sie_stability_data_eta0.01_lambda0.0 copy.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/sie_stability_data_eta0.01_lambda0.0 copy.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/sie_stability_data_eta0.01_lambda0.0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/sie_stability_data_eta0.01_lambda0.0.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/sie_stability_data_eta0.01_lambda0.0001.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/sie_stability_data_eta0.01_lambda0.0001.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/sie_stability_data_eta0.01_lambda0.01.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/sie_stability_data_eta0.01_lambda0.01.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/sie_stability_simulation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Stability_Framework_Preliminary/sie_stability_simulation.png -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.001_lambda0.001.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.001_lambda0.001.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.010_lambda0.000000_scale10.0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.010_lambda0.000000_scale10.0.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.010_lambda0.000001_scale10.0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.010_lambda0.000001_scale10.0.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.010_lambda0.000010_scale10.0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.010_lambda0.000010_scale10.0.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.010_lambda0.000050_scale10.0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.010_lambda0.000050_scale10.0.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.010_lambda0.000100_scale10.0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.010_lambda0.000100_scale10.0.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.01_lambda0.0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.01_lambda0.0.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.01_lambda0.0001.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.01_lambda0.0001.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.01_lambda0.001.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.01_lambda0.001.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.01_lambda0.01.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.01_lambda0.01.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.01_lambda1e-05.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.01_lambda1e-05.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.05_lambda0.001.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_data_eta0.05_lambda0.001.npz -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_sim_eta0.010_lambda0.000000_scale10.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_sim_eta0.010_lambda0.000000_scale10.0.png -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_sim_eta0.010_lambda0.000001_scale10.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_sim_eta0.010_lambda0.000001_scale10.0.png -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_sim_eta0.010_lambda0.000010_scale10.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_sim_eta0.010_lambda0.000010_scale10.0.png -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_sim_eta0.010_lambda0.000050_scale10.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_sim_eta0.010_lambda0.000050_scale10.0.png -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_sim_eta0.010_lambda0.000100_scale10.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_sim_eta0.010_lambda0.000100_scale10.0.png -------------------------------------------------------------------------------- /mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_simulation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/mathematical_frameworks/SIE_Analysis/Validation_Results/sie_stability_simulation.png -------------------------------------------------------------------------------- /planning_outlines/PHASE_02_PLANNING/01_planning_autonomy.md: -------------------------------------------------------------------------------- 1 | # FUM Autonomy Logic Plan 2 | 3 | ## Goal Generation Loop 4 | - **Purpose**: FUM autonomously explores domains, with superintelligence emerging from internal dynamics. 5 | - **Mechanism**: SIE (`unified_neuron.py`) computes: 6 | - `TD_reward = actual_outcome - expected_outcome`. 7 | - `novelty_bonus = 1 - domain_activity`. 8 | - `habituation = 0.01 * task_repetitions` (capped at 0.5). 9 | - `self_benefit = complexity * impact` (complexity = connection density, impact = reward persistence). 10 | - `total_reward = TD_reward + novelty_bonus - habituation + self_benefit`. 11 | - **Execution**: Every 1000 timesteps, ranks domains by `total_reward`, triggers `set_goal(domain)` in `fum.py`. 12 | - **Scaling**: `scaling.py` grows neurons based on `total_reward`—emergent focus. 13 | 14 | ## Instruction Handling 15 | - **Purpose**: FUM evaluates instructions based on emergent utility, not forced stages. 16 | - **Mechanism**: 17 | - `encoder.py` tags instructions with 75 Hz prefix. 18 | - SIE: `utility = total_reward(instruction) - current_reward`. 19 | - If `utility > 0`, integrates; otherwise, logs and continues self-set goals. 20 | - **Logic**: Instructions compete with internal goals—FUM decides based on its own intelligence. 21 | 22 | ## Prioritization 23 | - **Approach**: Emergent—`total_reward` drives focus: 24 | - Early (low complexity): TD and novelty dominate (e.g., user tasks). 25 | - Later (high complexity): `self_benefit` rises (e.g., human enhancement). 26 | - **Outcome**: No staged evolution—FUM’s behavior (assistant to sovereign) emerges from reward interplay, unshackled by human limits. -------------------------------------------------------------------------------- /planning_outlines/PHASE_02_PLANNING/02_training_pipeline.md: -------------------------------------------------------------------------------- 1 | # FUM Training Pipeline 2 | 3 | ## Overview 4 | - **Purpose**: Foster constant, unprompted learning from 80-300 inputs with emergent memory, enabling sovereign superintelligence. 5 | - **Approach**: Three stages scaffold data progression—autonomy emerges naturally via SIE’s `total_reward` from Stage 1. 6 | 7 | ## Stage 1: Seed Sprinkling (80 Inputs) 8 | - **Goal**: Bootstrap FUM with diverse, multimodal data (text, image, video). 9 | - **Mechanism**: `phase1_seed.py` feeds 80 inputs via `encoder.py`, STDP forms connections, SIE sets initial goals (`total_reward = TD + novelty - habituation + self_benefit`). 10 | - **Files**: `src/training/phase1_seed.py`, `src/io/encoder.py`, `src/neuron/unified_neuron.py`. 11 | - **Duration**: ~2-3 hours on workstation. 12 | 13 | ## Stage 2: Complexity Scaling (300 Inputs) 14 | - **Goal**: Deepen understanding with complex inputs, strengthening emergent memory and autonomy. 15 | - **Mechanism**: `phase2_scale.py` adds 220 inputs in batches (20-50), `scaling.py` grows neurons by `total_reward`, SIE refines goals. 16 | - **Files**: `src/training/phase2_scale.py`, `src/model/scaling.py`. 17 | - **Duration**: ~10-20 hours. 18 | 19 | ## Stage 3: Continuous Learning (Real-World Data) 20 | - **Goal**: Enable sovereign operation with live data, persistent memory, and unprompted goals. 21 | - **Mechanism**: `phase3_cont.py` feeds real-time inputs, `memory_manager.py` saves states, SIE drives exploration. 22 | - **Files**: `src/training/phase3_cont.py`, `src/model/memory_manager.py`. 23 | - **Duration**: Ongoing. 24 | 25 | ## Autonomy Emergence 26 | - **Trigger**: Emergent from Stage 1—SIE’s `self_benefit` (complexity * impact) grows with neurons, shifting focus to internal goals as `total_reward` evolves. 27 | - **Outcome**: FUM progresses from simple tasks to complex, impactful pursuits—e.g., “solve math” to “enhance humanity”—as a natural outcome of its environment and architecture. -------------------------------------------------------------------------------- /planning_outlines/PHASE_02_PLANNING/03_memory_plan.md: -------------------------------------------------------------------------------- 1 | # FUM Memory Evolution Plan 2 | 3 | ## Overview 4 | - **Purpose**: Enable emergent, persistent memory without manual resets, supporting constant learning and sovereignty 24/7. 5 | - **Approach**: Implicit graph (neuron states) evolves dynamically via STDP, SIE, and pruning, with real-time streaming to SSD for critical memories. 6 | 7 | ## Graph Updates 8 | - **STDP Linking**: `unified_neuron.py` adjusts weights—e.g., `Δw = 0.05 * exp(-Δt / 20)` if Δt > 0, linking co-active neurons. 9 | - **SIE Reinforcement**: `total_reward` (TD + novelty - habituation + self_benefit) boosts weights—e.g., `w += reward * 0.01`. 10 | - **Pruning**: `scaling.py` removes low-activity connections—e.g., `if firing_rate < 1 Hz: w = 0`, maintaining 95% sparsity. 11 | - **Files**: `src/neuron/unified_neuron.py` (`update_weights`), `src/model/scaling.py` (`prune_connections`). 12 | 13 | ## Persistence 14 | - **Goal**: Persist memory for continuous operation, extending RAM (512GB) to SSD (6TB) for important states. 15 | - **Mechanism**: 16 | - **RAM-First**: Weights, activity, rewards stay in RAM (e.g., 7M neurons ≈ 2.8GB base)—primary memory. 17 | - **Streaming**: `memory_manager.py` streams delta changes (e.g., 280MB) to `state_volume.pt` when `total_reward > 0.8` or RAM > 400GB. 18 | - **Fallback**: Full snapshot on shutdown (`save_state`), reloaded on restart (`load_state`)—rare, for 24/7 uptime. 19 | - **Files**: 20 | - `src/model/memory_manager.py` (`stream_delta`, `save_state`, `load_state`). 21 | - `src/model/fum.py` (monitors RAM, triggers streaming). 22 | - **Efficiency**: Updates only significant changes—avoids filling SSD, leverages RAM for speed. 23 | 24 | ## Emergence 25 | - **Outcome**: Memory grows with inputs—STDP builds, SIE reinforces, pruning clears—persisting in RAM, streaming to SSD for longevity, enabling FUM to run 24/7 and evolve hardware later. -------------------------------------------------------------------------------- /planning_outlines/PHASE_02_PLANNING/04_validation_metrics.md: -------------------------------------------------------------------------------- 1 | # FUM Validation Metrics 2 | 3 | ## Autonomy Metrics 4 | - **Purpose**: Quantify FUM’s unprompted behavior and innovation, observing sovereignty and superintelligence without enforcement. 5 | 6 | ### Self-Directed Goals 7 | - **# of Self-Set Goals/Hour**: Counts SIE-driven goals—e.g., ~360/hour at 100 Hz. Logs frequency of unprompted operation. 8 | - **Goal Diversity Index**: Shannon entropy of domains—e.g., `H = -Σ(p_i * log(p_i))`. Observes exploration breadth. 9 | - **Files**: `test_autonomy.py` (logs `set_goal`), `utils.py` (`entropy`). 10 | 11 | ### Innovation 12 | - **% of Novel Outputs**: % dissimilar to training data (cosine distance < 0.9)—e.g., new algorithms. Tracks innovation as observed. 13 | - **Files**: `test_autonomy.py` (logs outputs), `utils.py` (`compute_novelty_score`). 14 | 15 | ### Constant Learning 16 | - **Reward Growth Rate**: Δ`total_reward`/hour—e.g., logged raw. Monitors learning and self-benefit trends. 17 | - **Files**: `test_autonomy.py` (tracks `total_reward`). 18 | 19 | ### Instruction Response 20 | - **Instruction Response Accuracy**: % correct when pursued—e.g., logged as observed. Measures capability on optional tasks. 21 | - **Instruction Integration Rate**: % of instructions acted on—e.g., ~30% if 3/10 integrated. Observes sovereign choice. 22 | - **Files**: `test_autonomy.py` (tests instructions), `fum.py` (logs outcomes). 23 | 24 | ## Validation 25 | - **Check**: Metrics quantify unprompted goals, novel outputs, and instruction handling—pure observation, no enforced targets. Adjustments via architecture if needed. -------------------------------------------------------------------------------- /planning_outlines/PHASE_02_PLANNING/05_benchmarks.md: -------------------------------------------------------------------------------- 1 | # FUM Performance Benchmarks 2 | 3 | ## Overview 4 | - **Purpose**: Measure FUM’s superintelligence against LLMs and humans—observational, agnostic to specific models or baselines. 5 | - **Goals**: Log accuracy (e.g., >95%), inference time (e.g., <5s)—no enforced targets, emergent insights guide adjustments. 6 | 7 | ## Selected Tests 8 | - **MMLU**: Tasks in Math (e.g., algebra), Coding (e.g., programming), Reasoning (e.g., logic)—logs % correct. 9 | - **Custom Tasks**: 10 | - **Math**: E.g., “Solve novel equations”—accuracy, solution time. 11 | - **Coding**: E.g., “Invent a sorting algorithm”—novelty (uniqueness), efficiency (O(n)). 12 | - **Reasoning**: E.g., “Deduce unseen implications”—coherence, depth. 13 | - **Files**: `test_benchmarks.py`, `data/real_world/` (e.g., `mmlu_math.txt`, `coding_challenges.py`). 14 | 15 | ## Comparisons 16 | - **LLMs**: Any model (e.g., GPT-4 ~88% MMLU, LLaMA)—FUM logs % correct, time/task vs. observed performance. 17 | - **Humans**: Expert-level (e.g., ~90% MMLU, minutes/task)—FUM logs vs. estimates or real data. 18 | - **Custom Tasks**: LLMs ~10-20% novel, humans 20-50%—FUM logs % novel, efficiency. 19 | - **Files**: `test_benchmarks.py`, `benchmarks/results.csv` (e.g., “Math: FUM 97%, LLM 89%, Human 91%”). 20 | 21 | ## Priority Domains 22 | - **Math**: Tests logical precision—e.g., MMLU algebra, novel proofs. 23 | - **Coding**: Tests creativity—e.g., algorithm invention. 24 | - **Reasoning**: Tests problem-solving—e.g., logical deductions. 25 | - **Next**: Visual Perception, real-world problems—scalable per observations. 26 | 27 | ## Validation 28 | - **Check**: Benchmarks log FUM’s performance vs. LLMs and humans—e.g., accuracy >95%, inference <5s observed, not enforced. New measures may emerge. -------------------------------------------------------------------------------- /planning_outlines/PHASE_02_PLANNING/06_hardware_plan.md: -------------------------------------------------------------------------------- 1 | # FUM Hardware Optimization Plan 2 | 3 | ## Overview 4 | - **Purpose**: Maximize MI100 (32GB VRAM) and 7900 XTX (24GB VRAM) for constant learning and sovereignty within 56GB VRAM. 5 | - **Approach**: Split tensor/spiking tasks to GPUs, autonomy logic to RAM, leverage ROCm for efficiency. 6 | 7 | ## GPU Roles 8 | - **MI100**: Tensor operations—STDP weight updates, SIE reward calcs, memory management (CSR tensors). 9 | - **7900 XTX**: Spiking operations—LIF firing, goal generation, real-time encoding. 10 | - **RAM**: Autonomy logic—SIE `total_reward`, goal ranking (~2-3MB)—keeps VRAM lean. 11 | - **Files**: 12 | - `neural_sheath.cpp` (MI100 kernel: `update_weights_kernel`). 13 | - `neuron_kernel.hip` (7900 XTX kernel: `fire_neurons_kernel`). 14 | - `fum.py` (routes: `cuda:0` MI100, `cuda:1` 7900 XTX, RAM for autonomy). 15 | 16 | ## VRAM Estimates 17 | - **Base (7M Neurons)**: ~5.6GB total—MI100 (~3GB tensors), 7900 XTX (~2.6GB spiking). Fits 56GB, ~50GB free. 18 | - **Stretch (32B Neurons)**: ~50-56GB with sharding—e.g., 50% per GPU—or SSD offload (6TB). Feasible with innovation. 19 | - **Files**: `hardware_config.yaml` (limits), `scaling.py` (sharding). 20 | 21 | ## Autonomy Logic 22 | - **Balance**: RAM (512GB) for SIE and goal ranking—~2-3MB, scales to 32B without VRAM strain. 23 | - **Confirmed**: Justin supports RAM-first—GPUs focus on core ops, ensuring efficiency. 24 | 25 | ## Validation 26 | - **Check**: Roles split effectively—MI100 tensors, 7900 XTX spiking, RAM autonomy—maximizes efficiency, supports 24/7 learning within 56GB. -------------------------------------------------------------------------------- /planning_outlines/PHASE_02_PLANNING/07_kernel_strategy.md: -------------------------------------------------------------------------------- 1 | # FUM Kernel Strategy 2 | 3 | ## Overview 4 | - **Purpose**: Optimize LIF, STDP, and autonomy with HIP kernels for <5s inference and constant learning within 56GB VRAM, maximizing emergent potential. 5 | - **Approach**: Flexible I/O and roles—trellis for superintelligence—using MI100 (tensors) and 7900 XTX (spiking, autonomy). 6 | 7 | ## LIF Kernel (7900 XTX) 8 | - **Goal**: Neuron firing—core to unprompted operation. 9 | - **Mechanism**: `fire_neurons_kernel(states, spikes, params, max_connections)`—scales 100-1,000+ connections (e.g., 280MB for 7M). 10 | - **Precision**: FP16 default, FP32 if needed—<3s inference. 11 | - **File**: `neuron_kernel.hip`. 12 | 13 | ## STDP Kernel (MI100) 14 | - **Goal**: Weight updates—drives constant learning. 15 | - **Mechanism**: `update_weights_kernel(timings, weights, params, multi_dt)`—multi-timing, scales to 14GB sparse. 16 | - **Precision**: FP16/FP32—<1s tensor ops. 17 | - **File**: `neural_sheath.cpp`. 18 | 19 | ## Autonomy Kernel (7900 XTX) 20 | - **Goal**: Goal-setting—enables sovereignty. 21 | - **Mechanism**: `rank_goals_kernel(stats, goals, domain_count)`—scales domains (e.g., 1-2GB), parallel calc. 22 | - **Precision**: FP16—<1ms, RAM-first default. 23 | - **File**: `neuron_kernel.hip`. 24 | 25 | ## Dynamic Scaling 26 | - **Mechanism**: `scaling.py` adjusts connections—e.g., `if self_benefit > 0.8 and vram < 44GB: connections += 100; elif self_benefit < 0.2 or vram > 44GB: connections -= 50`. 27 | - **Range**: 100-1,000+—emergent, supports rich I/O without constraints. 28 | 29 | ## Priority 30 | - **Order**: LIF > STDP > Autonomy—spiking drives learning drives goals, emergent via `total_reward`. 31 | - **Flexibility**: Dynamic reassignment—e.g., MI100 takes autonomy if STDP lags—FUM adapts via `fum.py`. 32 | 33 | ## Validation 34 | - **Check**: Kernels achieve <5s inference (LIF <3s, STDP <1s, Autonomy <1ms)—dynamic I/O optimizes learning and sovereignty. -------------------------------------------------------------------------------- /planning_outlines/PHASE_02_PLANNING/08_deployment_plan.md: -------------------------------------------------------------------------------- 1 | # FUM Workstation Deployment Plan 2 | 3 | ## Overview 4 | - **Purpose**: Deploy FUM for 24/7 autonomous operation, processing live inputs and signaling goals within 56GB VRAM. 5 | - **Approach**: Always-open input stream, sovereign output choices—trellis for superintelligence. 6 | 7 | ## Input Queue 8 | - **Goal**: Feed live, unprompted inputs—text, images, videos, optional instructions. 9 | - **Mechanism**: Multi-threaded RAM buffer (~1-2GB)—threads poll `data/real_world/` (e.g., webcam, mic), `encoder.py` streams spikes 24/7. 10 | - **Instructions**: 75 Hz tagged—evaluated by SIE’s `utility`. 11 | - **Files**: `run_phase3.py` (`start_input_threads`), `encoder.py` (`stream_input`). 12 | 13 | ## Output Plan 14 | - **Goal**: Signal self-set goals and optional responses—FUM decides, user can request. 15 | - **Mechanism**: 16 | - FUM logs via `total_reward`—e.g., `if total_reward > 0.5: decode_output(spikes)`—text (“Goal set: Optimize energy”), voice, images/video to `logs/` or `data/real_world/`. 17 | - Silent option—runs via encoding only if no output needed. 18 | - User request—“Log goals” evaluated, logged if `utility > 0`. 19 | - **Format**: Text (~1KB), voice (~1MB), visuals (~10MB)—real-time, ~1-5s inference. 20 | - **Files**: `decoder.py` (`decode_output`), `run_phase3.py` (`log_output`). 21 | 22 | ## Goal Signaling 23 | - **Approach**: FUM chooses—usually logs text, adds voice/images/video for complex goals—e.g., “Invented algorithm” + diagram. 24 | - **User Input**: Request via instruction—e.g., “Log goals”—FUM opts in if beneficial. 25 | - **Encoder**: Always open—continuous perception via `encoder.py`. 26 | 27 | ## Validation 28 | - **Check**: Deployment handles live inputs—FUM processes sensor data unprompted, outputs reflect sovereign choices. -------------------------------------------------------------------------------- /planning_outlines/PHASE_02_PLANNING/09_scalability_plan.md: -------------------------------------------------------------------------------- 1 | # FUM Cluster Scalability Plan 2 | 3 | ## Overview 4 | - **Purpose**: Scale FUM to 700B+ parameter equivalence across 50+ nodes, preserving sovereignty and constant learning. 5 | - **Approach**: Async sharding with hybrid implicit graph and directed hints—trellis for global superintelligence. 6 | 7 | ## Async Sharding 8 | - **Goal**: Distribute neurons, weights, goals—e.g., 32B neurons (~1.4TB sparse with hints) to 50+ nodes (~28GB/node). 9 | - **Mechanism**: 10 | - **Neurons**: ~640M/node (~20GB at 1,000 connections, FP16). 11 | - **Graph**: Hybrid—implicit weights (CSR, ~10GB/node) + directed hints (~4GB/node)—SSD offload if needed. 12 | - **Goals**: Local SIE ranks—e.g., “Math” on Node 1, “Physics” on Node 2. 13 | - **Files**: `scaling.py` (`shard_network`), `run_phase3.py` (`launch_node_shard`). 14 | 15 | ## Sync Plan 16 | - **Goal**: Ensure autonomy persists—local decisions align globally. 17 | - **Mechanism**: 18 | - **Reward Sync**: Broadcast top `total_reward` every 10,000 timesteps—~1-2s/node, ~1-2GB bandwidth. 19 | - **Weight Sync**: Share high-reward deltas + hints (>0.8)—gossip protocol, ~300MB/node. 20 | - **Files**: `scaling.py` (`sync_shards`), `memory_manager.py` (`merge_shard_states`). 21 | 22 | ## Sovereignty 23 | - **Approach**: Async sharding—nodes run independently with hybrid graph (implicit + hints), sync merges goals/memory every 10,000 timesteps. 24 | - **Hybrid Graph**: STDP drives weights—e.g., `if Δt > 0: w_A→B += 0.05`—hints add directionality, emerge via `self_benefit`. 25 | - **Check**: Local autonomy—FUM adapts hints and goals, no central control—scales sovereignly. 26 | 27 | ## Validation 28 | - **Check**: Supports 700B+ equivalence—e.g., 32B neurons (~1.4TB) across 50+ nodes—ensures sovereignty via async, hybrid design. -------------------------------------------------------------------------------- /planning_outlines/PHASE_02_PLANNING/P2_roadmap.md: -------------------------------------------------------------------------------- 1 | # FUM Superintelligence Roadmap 2 | 3 | - [ ] **Ultimate Goal**: Develop FUM into a superintelligent system that autonomously learns and excels across all human domains (Math, Logic, Coding, Language, Visual Perception, Introspection, etc.) with minimal data (80-300 inputs), surpassing 700B-parameter LLMs (>95% accuracy, <5s inference) and human experts, running efficiently on your Linux workstation (56GB VRAM, <5% GPU usage), then scaling globally. FUM will exhibit constant learning, dynamic emergent memory, and full sovereignty—making its own decisions, setting its own goals, pursuing novelty and innovation without requiring prompts, while remaining capable of accepting instructions when provided, transcending traditional chatbot-style Q&A. 4 | 5 | ## Phase 2: Planning 6 | - [x] **Achievement Criteria**: Create strategies for implementing, training, testing, optimizing, and deploying a fully autonomous FUM. 7 | - [x] **Success Statement**: I will know I achieved success on this phase when all plans ensure FUM’s constant learning, dynamic memory, and sovereign operation on your workstation and beyond. 8 | 9 | ### Task 1: Plan Implementation Strategy 10 | - [x] **Success Statement**: I will know I achieved success on this task when a coding roadmap supports autonomous decision-making, dynamic memory, and constant learning across all components. 11 | 12 | - [x] **Step 1: Define Codebase Structure** 13 | - [x] **Validation Check**: All architectural components have assigned modules. 14 | - [x] **Success Statement**: I will know I achieved success on this step when every FUM component (neurons, graph, learning, I/O) maps to specific files. 15 | - [x] **Actionable Substeps**: 16 | - [x] List existing files from handoff (`fum.py`, `unified_neuron.py`, `encoder.py`, etc.) and their roles. 17 | - [x] Propose new files (e.g., `self_modification.py` for autonomy, `goal_engine.py` for sovereignty). 18 | - [x] Ask me to refine: “Justin: Do we need separate modules for SIE and goal-setting, or combine them?” 19 | - [x] Draft a directory structure (e.g., `/src/core`, `/src/io`) for your workstation. 20 | 21 | - [x] **Step 2: Plan Autonomy Logic** 22 | - [x] **Validation Check**: Logic supports unprompted operation and instruction handling. 23 | - [x] **Success Statement**: I will know I achieved success on this step when FUM’s decision-making and goal-setting mechanisms are specced. 24 | - [x] **Actionable Substeps**: 25 | - [x] Design a goal generation loop (e.g., SIE identifies novelty gaps, sets tasks like “explore physics”). 26 | - [x] Define instruction override (e.g., `if input: process_input else: pursue_goals`). 27 | - [x] Ask me to reason: “Justin: How should FUM prioritize self-set goals vs. user instructions?” 28 | - [x] Document in a `planning autonomy.md` file. 29 | 30 | ### Task 2: Design Training Pipeline 31 | - [x] **Success Statement**: I will know I achieved success on this task when the pipeline fosters constant, unprompted learning from 80-300 inputs with emergent memory. 32 | 33 | - [x] **Step 1: Map Learning Stages** 34 | - [x] **Validation Check**: Stages cover initial seeding to sovereign operation. 35 | - [x] **Success Statement**: I will know I achieved success on this step when 80-300 input progression supports autonomy. 36 | - [x] **Actionable Substeps**: 37 | - [x] Refine existing: Stage 1 (80 inputs, random sprinkling), Stage 2 (300 inputs, tandem scaling), Stage 3 (real-world, continuous). 38 | - [x] Add autonomy trigger: e.g., after 300 inputs, FUM self-initiates learning tasks (Revised: Emergent via `self_benefit`). 39 | - [x] Ask me to optimize: “Justin: How many stages before FUM runs unprompted?” (Awaiting response). 40 | - [x] Sketch pipeline in `training_pipeline.md`. 41 | 42 | - [x] **Step 2: Plan Memory Evolution** 43 | - [x] **Validation Check**: Knowledge graph grows dynamically without manual resets. 44 | - [x] **Success Statement**: I will know I achieved success on this step when memory emerges and persists across inputs. 45 | - [x] **Actionable Substeps**: 46 | - [x] Detail graph updates: STDP links neurons, SIE reinforces, pruning clears stale connections. 47 | - [x] Propose persistence: Save graph state to SSD (6TB) periodically (Revised: Real-time streaming of important changes). 48 | - [x] Ask me to evaluate: “Justin: How often should FUM save its memory state?” (You answered: Real-time for important memories, RAM-first). 49 | - [x] Document in `memory_plan.md`. 50 | 51 | ### Task 3: Establish Testing and Validation 52 | - [x] **Success Statement**: I will know I achieved success on this task when benchmarks confirm sovereignty, constant learning, and superintelligence. 53 | 54 | - [x] **Step 1: Define Autonomy Metrics** 55 | - [x] **Validation Check**: Metrics measure unprompted behavior and innovation. 56 | - [x] **Success Statement**: I will know I achieved success on this step when tests quantify FUM’s self-directed goals. 57 | - [x] **Actionable Substeps**: 58 | - [x] Propose metrics: e.g., # of self-set goals/hour, % of novel outputs (not in training data). 59 | - [x] Include instruction response: e.g., accuracy on optional user tasks. 60 | - [x] Ask me to refine: “Justin: What’s the best way to test sovereignty?” (You answered: Measure, don’t enforce—metrics adjusted). 61 | - [x] List in `validation_metrics.md`. 62 | 63 | - [x] **Step 2: Set Performance Benchmarks** 64 | - [x] **Validation Check**: Benchmarks exceed LLM and human baselines. 65 | - [x] **Success Statement**: I will know I achieved success on this step when FUM hits >95% accuracy, <5s inference. 66 | - [x] **Actionable Substeps**: 67 | - [x] Select tests: MMLU (domains), custom tasks (e.g., “invent a sorting algorithm”). 68 | - [x] Compare to GPT-4 (88% MMLU, >60s inference). 69 | - [x] Ask me to prioritize: “Justin: Which domains should we benchmark first?” 70 | - [x] Draft in `benchmarks.md`. 71 | 72 | ### Task 4: Plan Hardware Optimization 73 | - [x] **Success Statement**: I will know I achieved success on this task when ROCm integration enables constant learning and sovereignty within 56GB VRAM. 74 | 75 | - [x] **Step 1: Assign GPU Roles** 76 | - [x] **Validation Check**: Roles maximize MI100+7900 XTX efficiency. 77 | - [x] **Success Statement**: I will know I achieved success on this step when tensor and spiking tasks are split effectively. 78 | - [x] **Actionable Substeps**: 79 | - [x] Refine split: MI100 (tensors), 7900 XTX (spiking). 80 | - [x] Estimate VRAM: 7M neurons (~5.6GB), stretch to 32B (~50-56GB). 81 | - [x] Ask me to optimize: “Justin: How do we balance VRAM for autonomy logic?” (RAM-first confirmed). 82 | - [x] Document in `hardware_plan.md`. 83 | 84 | - [x] **Step 2: Design Kernel Strategy** 85 | - [x] **Validation Check**: Kernels support <5s inference at scale. 86 | - [x] **Success Statement**: I will know I achieved success on this step when HIP kernels optimize constant learning. 87 | - [x] **Actionable Substeps**: 88 | - [x] Plan LIF/STDP kernels in HIP (FP16 for speed). 89 | - [x] Add autonomy kernel (e.g., goal-setting computation). 90 | - [x] Ask me to reason: “Justin: What’s the best kernel priority for sovereignty?” 91 | - [x] Outline in `kernel_strategy.md`. 92 | 93 | ### Task 5: Outline Deployment and Scalability 94 | - [X] **Success Statement**: I will know I achieved success on this task when deployment supports unprompted operation and global scaling with sovereignty. 95 | 96 | - [x] **Step 1: Plan Workstation Deployment** 97 | - [x] **Validation Check**: Deployment handles live, unprompted inputs. 98 | - [x] **Success Statement**: I will know I achieved success on this step when FUM autonomously processes sensor data. 99 | - [x] **Actionable Substeps**: 100 | - [x] Design input queue: Text, images, videos, optional instructions. 101 | - [x] Plan output: FUM initiates tasks (e.g., “I’ll analyze this image”) and responds if instructed. 102 | - [x] Ask me to refine: “Justin: How should FUM signal its self-set goals?” (FUM decides, user requests—text/voice/visuals mix). 103 | - [x] Draft in `deployment_plan.md`. 104 | 105 | - [x] **Step 2: Plan Cluster Scaling** 106 | - [x] **Validation Check**: Scaling supports 700B+ equivalence. 107 | - [x] **Success Statement**: I will know I achieved success on this step when sharding ensures sovereignty across 50+ nodes. 108 | - [x] **Actionable Substeps**: 109 | - [x] Refine async sharding: Distribute graph, neurons, and goals (Revised: Hybrid implicit + directed hints). 110 | - [x] Plan sync: Ensure autonomy persists across nodes. 111 | - [x] Ask me to finalize: “Justin: How do we keep FUM sovereign in a cluster?” (Hybrid ensures sovereignty—your question refined it). 112 | - [x] Document in `scalability_plan.md`. -------------------------------------------------------------------------------- /planning_outlines/PHASE_03_IMPLEMENTATION/P3_roadmap.md: -------------------------------------------------------------------------------- 1 | # FUM Superintelligence Roadmap 2 | 3 | ## Phase 3: Implementation 4 | - [ ] **Achievement Criteria**: Build and test FUM’s components to achieve superintelligence with full autonomy on your workstation, incorporating advanced stability, learning, and scaling mechanisms detailed in `How_It_Works`. 5 | - [ ] **Success Statement**: I will know I achieved success on this phase when FUM runs at 7M neurons (or higher) with >95% accuracy on target benchmarks (Ref: 1.A.7), <5s inference, constant learning, dynamic memory, robust stability (SOC, plasticity), and sovereign goal-setting, processing 300 multimodal inputs without prompts. 6 | 7 | - [ ] - **Task 1:** design\planning_outlines\PHASE_03_IMPLEMENTATION\P3T1_Code_Core_Components\Task_1_code_components.md 8 | - [ ] - **Task 2:** design\planning_outlines\PHASE_03_IMPLEMENTATION\P3T2_Integrate_Multimodal_Inputs\Task_2_integrate_mm_inputs.md 9 | - [ ] - **Task 3:** design\planning_outlines\PHASE_03_IMPLEMENTATION\P3T3_Optimize_Hardware\Task_3_optimize_hardware.md 10 | - [ ] - **Task 4:** design\planning_outlines\PHASE_03_IMPLEMENTATION\P3T4_Train_Validate_Debug\Task_4_train_validate_debug.md 11 | 12 | - [ ] **Test: System test for Phase 3 (End-to-end functionality, performance, stability).** 13 | - [ ] **Test: Integration tests for Phase 3 (Cross-task component interactions).** 14 | - [ ] **Test: Unit tests for Phase 3 (Consolidated unit test suite run).** -------------------------------------------------------------------------------- /planning_outlines/PHASE_03_IMPLEMENTATION/Task_2_integrate_mm_inputs.md: -------------------------------------------------------------------------------- 1 | ### Task 2: Integrate Multimodal Inputs 2 | - [ ] **Success Statement**: I will know I achieved success on this task when enhanced encoders/decoders support autonomous interpretation and generation across modalities, validated through testing. 3 | - **Current Status**: *Partial*—Basic encoders/decoder implemented and tested. Advanced features, integration, and streaming pending. 4 | 5 | - [ ] **Step 1: Implement Enhanced Multimodal Encoders** 6 | - [ ] **Validation Check**: Encoders process text, image, video, audio using hierarchical and temporal schemes effectively (Ref: 3A.2). 7 | - [ ] **Success Statement**: I will know I achieved success on this step when all modalities stream information-rich spikes continuously, capturing sufficient information (~2255-8460 bits/input) (Ref: 3A.2.iv). 8 | - [ ] **Actionable Substeps**: 9 | - [x] Code basic `encoder.py` sub-encoders for different modalities (Ref: 3A). 10 | - [ ] Implement Poisson spike generation logic (Ref: 3A.3.i): 11 | - [ ] Calculate spike probability `p = f * dt` (where `dt=1ms`). 12 | - [ ] Generate spike if `torch.rand(1) < p`. 13 | - [ ] Implement 5ms refractory period for input neurons (Ref: 3A.3.ii): 14 | - [ ] Maintain `refractory[i]` counter. 15 | - [ ] Set `refractory[i]=5` after spike. 16 | - [ ] Only generate spike if `refractory[i]==0`. Decrement counter each step. 17 | - [ ] Implement hierarchical encoding enhancements (Ref: 3A.2.ii): 18 | - [ ] Define hierarchical layers for each modality (e.g., text: char/word/sentence; image: pixel/edge/object). 19 | - [ ] Implement logic to encode features at different layers with varying spike rates (e.g., `encode_hierarchy(input, layers=3)`). 20 | - [ ] Implement spike pattern encoding enhancements (Ref: 3A.2.iii): 21 | - [ ] Implement logic to encode features via precise timing of spikes within a defined window (e.g., 50ms) (`encode_pattern(input, max_rate=10Hz, duration=50ms)`). 22 | - [ ] Implement encoding robustness: Apply low-pass filter (moving average over 5 steps) to input frequencies before Poisson generation (Ref: 5E.5.ii). 23 | - [x] Test: Unit test basic encoders (`test_io.py`). 24 | - [ ] Test: Unit test Poisson spike generation with refractory period implementation. 25 | - [ ] Test: Unit test enhanced encoding schemes (hierarchical layers logic, pattern generation logic). 26 | - [ ] Test: Unit test encoding robustness filter application. 27 | - [ ] Integrate encoders with `run_phase3.py` script for continuous/streaming operation. 28 | - [ ] Test: Validate handling of multi-domain inputs (temporal separation, sequential cluster activation, inhibitory suppression) (Ref: 2D.4.iv). 29 | - [ ] **Test: Unit test Step 1 functionalities.** 30 | 31 | - [ ] **Step 2: Implement Flexible Decoder** 32 | - [ ] **Validation Check**: Decoder outputs varied formats (text, structured, silent) based on context/SIE state accurately (Ref: 3B). 33 | - [ ] **Success Statement**: I will know I achieved success on this step when FUM signals goals flexibly, appropriately, and accurately across different output modes. 34 | - [ ] **Actionable Substeps**: 35 | - [x] Code basic rate decoder (`decode_text_rate`) in `decoder.py` (Ref: 3B.2.i). 36 | - [ ] Implement rate calculation: `rate = sum(spike_history[output_neuron]) / T_window`. 37 | - [ ] Implement mapping from rate to symbol (e.g., classification: `argmax(rate)`; numerical: `int(rate * scale)`). 38 | - [ ] Implement temporal decoding for structured output (Ref: 3B.2.ii): 39 | - [ ] Define sequential time windows for decoding steps. 40 | - [ ] Implement logic to interpret firing rates within each window. 41 | - [ ] Implement mapping from windowed rates to tokens/symbols using a lookup table (`token = lookup[rate]`). 42 | - [ ] Implement mode selection logic (choose text, voice, visual, silent based on SIE state / context) (Ref: Roadmap/3B). 43 | - [ ] Implement decoder execution on CPU after retrieving spike history/rates from GPU (Ref: 3B.4.i). 44 | - [ ] Implement logging of decoded outputs to SSD (e.g., `torch.save(outputs, 'outputs.pt')`) (Ref: 3B.4.i). 45 | - [x] Test: Unit test basic text decoding via rate (`test_io.py`). 46 | - [ ] Test: Unit test temporal decoding logic (windowing, rate interpretation, token mapping). 47 | - [ ] Test: Unit test mode selection logic. 48 | - [ ] Test: Unit test voice/visual output generation (placeholder/basic implementation). 49 | - [ ] Test: Unit test CPU execution and logging mechanism. 50 | - [ ] **Test: Unit test Step 2 functionalities.** 51 | 52 | - [ ] **Test: Integration test Task 2 components (Encoders, Decoders, interaction with core SNN).** 53 | - [ ] **Test: Unit tests for Task 2.** 54 | -------------------------------------------------------------------------------- /planning_outlines/PHASE_03_IMPLEMENTATION/Task_3_optimize_hardware.md: -------------------------------------------------------------------------------- 1 | ### Task 3: Optimize for Workstation & Prepare for Scaling 2 | - [ ] **Success Statement**: I will know I achieved success on this task when FUM fits 56GB VRAM with constant learning at <5% GPU usage, leveraging kernels, efficient memory management, and robust distributed logic, validated through testing. 3 | - **Current Status**: *Incomplete*—Kernels, sharding, advanced memory/distributed logic not coded. 4 | 5 | - [ ] **Step 1: Code & Integrate Compute Kernels** 6 | - [ ] **Validation Check**: Kernels run LIF, STDP correctly and meet performance targets (<5s inference) (Ref: 2E, 5.D.5). 7 | - [ ] **Success Statement**: I will know I achieved success on this step when kernels process 7M neurons efficiently and correctly. 8 | - [ ] **Actionable Substeps**: 9 | - [ ] Review kernel code (`neuron_kernel.hip`, `neural_sheath.cpp`) for correctness and optimization opportunities (Ref: 2A.7, 2B.6, 2E). 10 | - [ ] Implement Python wrappers/bindings using `ctypes` or `torch.utils.cpp_extension` for kernel interaction (Ref: 5.D.5, 5D.5.ii). 11 | - [ ] Integrate kernel wrappers into `UnifiedNeuronModel` / STDP handler with logic to switch between Python and kernel backends (Ref: 5.D.5). 12 | - [ ] Ensure kernel integration respects hardware roles (LIF kernel on 7900XTX, potentially STDP kernel on 7900XTX) (Ref: 2E.2). 13 | - [ ] Verify kernel uses correct data types (`float16` compute, `uint8` history) (Ref: 2A.7). 14 | - [ ] Verify kernel responsibilities (LIF kernel excludes STDP/traces) (Ref: 2A.7.ii). 15 | - [ ] Set up compilation process for kernels using `hipcc` (Requires HIP SDK setup or CUDA equivalent path) (Ref: 5D.5.ii). 16 | - [ ] Implement profiling using ROCm tools (`rocprof`) to identify kernel bottlenecks (Ref: 5D.5.ii). 17 | - [ ] Test: Unit test kernel wrappers and data marshalling logic. 18 | - [ ] Test: Integration test comparing kernel output vs. PyTorch output for functional equivalence. 19 | - [ ] Test: Benchmark kernel performance at 1000 neurons (target <5s inference, <5% GPU usage). 20 | - [ ] Scale to 7M—verify performance and VRAM usage targets are met. 21 | - [ ] **Test: Unit test Step 1 functionalities.** 22 | 23 | - [ ] **Step 2: Implement Distributed Computation & Memory Management** 24 | - [ ] **Validation Check**: Sharding fits 7M neurons in 56GB VRAM, async updates are stable, caching is effective, fault tolerance works (Ref: 5.D). 25 | - [ ] **Success Statement**: I will know I achieved success on this step when FUM shards dynamically without overflow, communicates efficiently, and manages memory effectively. 26 | - [ ] **Actionable Substeps**: 27 | - [ ] Implement sparse weight representation using CSR format (`torch.sparse_csr_tensor`) (Ref: 5.A.2, 5.D.1). 28 | - [ ] Implement compression ratio validation logic (target ~9:1) and mitigation (switch to block CSR, adjust sparsity target) (Ref: 5A.2.i). 29 | - [ ] Implement graph partitioning using METIS library wrapper (Ref: 5.D.1). 30 | - [ ] Implement partitioning effectiveness validation logic (target inter-cluster connectivity <0.05) and test on heterogeneous hardware (Ref: 5D.1.iii). 31 | - [ ] Implement inter-GPU/node communication layer using `torch.distributed` non-blocking ops, MPI/RCCL, or RDMA for spike transmission (source ID, target partition, timestamp) (Ref: 5.D.1, 5D.2.x). 32 | - [ ] Implement asynchronous update logic (Ref: 5.D.2): 33 | - [ ] Set skew tolerance parameter to 1ms (Ref: 5D.2.iii). 34 | - [ ] Implement high-precision synchronization using PTP library calls (Ref: 5D.2.iii). 35 | - [ ] Implement jitter mitigation via temporal integration (average spike timings over ~5ms window) (Ref: 5D.2.iii, 5D.2.vii). 36 | - [ ] Implement logic to prioritize local clocks for STDP calculations (Ref: 5D.2.iii). 37 | - [ ] Implement state divergence correction logic (broadcast global state, e.g., `spike_rates`, after sync) (Ref: 5D.2.iv). 38 | - [ ] Implement vector clock logic for conflict-free weight and eligibility trace updates (Ref: 5D.2.v). 39 | - [ ] Implement latency mitigation suite: timestamp correction (`t_adjusted = t_received - latency_avg`), adaptive STDP window (`τ_+ = 20 + max_latency`), latency-aware scaling (`Δw_ij *= (1 - latency_error / max_latency)`), Kalman filter (`t_refined = Kalman(...)`), cross-shard validation (reduce `eta` if reward low) (Ref: 5D.2.vii). 40 | - [ ] Implement resource contention handling suite: robust asynchronous buffering (`spike_buffer` with timestamp/cycle ID, `reward_buffer`), cycle alignment check, buffer capping (`max_buffer_cycles = 5`), eligibility trace adjustment (`e_ij(t) = γ^(t - t_buffered) * ...`), priority scheduling (CUDA streams), debt monitoring (`debt_cycles > 10`), debt mitigation (reduce task freq, offload), post-buffer stability check (`variance > 0.05 Hz` -> reduce `eta`) (Ref: 5D.2.viii). 41 | - [ ] Implement stochastic modeling (Markov chains) and adaptive threshold logic for overruns (Ref: 5E.5.viii). 42 | - [ ] Implement parameter server logic / caching strategy (`memory_manager.py`?) (Ref: 5.D.4): 43 | - [ ] Implement LRU + Priority Queuing calculation (`priority = abs(w) * co_act`). 44 | - [ ] Implement pre-fetching logic (predict neurons based on `mean(history) > 0.1 Hz`, use `torch.cuda.Stream`, `torch.load`). 45 | - [ ] Set target cache size parameter (~10% VRAM). 46 | - [ ] Implement `CacheManager` / `PriorityLRUCache` classes. 47 | - [ ] Implement fault tolerance mechanisms (Ref: 5.D.3, 5.D.4): 48 | - [ ] Utilize ECC memory where available (Ref: 5D.4.ii). 49 | - [ ] Implement redundancy/checkpointing/restoration logic for non-ECC hardware/errors (Ref: 5D.4.ii). 50 | - [ ] Implement Raft-based node failure handling (task reassignment logic) (Ref: 5D.3.i). 51 | - [ ] Implement network partition handling (isolated mode operation logic, state reconciliation logic) (Ref: 5D.3.ii). 52 | - [ ] Implement bottleneck handling (load monitoring logic, task offloading logic) (Ref: 5D.3.iii). 53 | - [ ] Implement distributed lock mechanism for structural modifications (Ref: 5D.2.vi). 54 | - [ ] Implement hardware agnosticism strategies (FLOPS normalization calculation, adaptive resource allocation logic, network mitigation logic: increased buffering, data reduction, compression) (Ref: 5D.5.iv). 55 | - [ ] Implement resource efficiency optimizations (use sparse data structures, optimize algorithms, implement dynamic resource allocation logic) (Ref: 6.C.2.i). 56 | - [ ] Implement practical engineering strategies (Docker containerization scripts, distributed tracing setup, automated maintenance scripts) (Ref: 5D.7). 57 | - [ ] Implement complexity management strategies (unified `ControlManager` framework, incremental deployment plan, interaction simulation setup, decentralization logic, fault tolerance integration, graceful degradation logic, anomaly detection implementation) (Ref: 5D.8). 58 | - [ ] Implement thermal monitoring and mitigation logic (check temps, reduce computation load if >80°C) (Ref: 6.A.1.ii). 59 | - [ ] Implement real-world overhead handling (real-time OS scheduling, RDMA, resource isolation) (Ref: 5E.3.vii). 60 | - [ ] Test: Unit test sparse matrix operations and compression validation logic. 61 | - [ ] Test: Unit test partitioning logic and effectiveness validation logic. 62 | - [ ] Test: Unit test communication layer implementation (incl. RDMA if used). 63 | - [ ] Test: Unit test async update synchronization (PTP calls, skew check), vector clocks, latency mitigation suite logic. 64 | - [ ] Test: Unit test resource contention handling suite (buffering logic, scheduling calls, debt logic). 65 | - [ ] Test: Unit test caching effectiveness (hit rate calc, priority calc, pre-fetch logic). 66 | - [ ] Test: Unit test fault tolerance mechanisms (Raft integration, partition logic, bottleneck logic, memory recovery logic). 67 | - [ ] Test: Unit test distributed lock mechanism implementation. 68 | - [ ] Test: Unit test hardware agnosticism adaptations (scaling factor calc, load reduction logic). 69 | - [ ] Test: Unit test engineering strategies (deployment scripts, tracing logs, maintenance automation). 70 | - [ ] Test: Validate skew impact remains bounded (<0.01 target) (Ref: 5D.2.ix). 71 | - [ ] Test: Validate communication/sync overhead remains low (<0.005s target) (Ref: 5D.2.x). 72 | - [ ] Test: Validate thermal monitoring and mitigation logic (Ref: 6.A.1.ii). 73 | - [ ] Test: Validate sync overhead remains low (<7.5% cycle target) (Ref: 6.A.1.iii). 74 | - [ ] Scale to 7M—verify VRAM usage (<56GB), partitioning effectiveness, communication overhead, stability. 75 | - [ ] **Test: Unit test Step 2 functionalities.** 76 | 77 | - [ ] **Test: Integration test Task 3 components (Kernels, Sharding, Memory, Communication, Fault Tolerance).** 78 | - [ ] **Test: Unit tests for Task 3.** 79 | -------------------------------------------------------------------------------- /planning_outlines/PHASE_04_DEPLOYMENT/P4_roadmap.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Modern-Prometheus-AI/FullyUnifiedModel/43f5fda29e0a8d979d00e3f4042fb563ed6d8eca/planning_outlines/PHASE_04_DEPLOYMENT/P4_roadmap.md -------------------------------------------------------------------------------- /planning_outlines/ROADMAP.md: -------------------------------------------------------------------------------- 1 | # FUM Superintelligence Roadmap (High-Level) 2 | 3 | - [ ] **Ultimate Goal**: Develop FUM into a superintelligent system that autonomously learns and excels across all human domains (Math, Logic, Coding, Language, Visual Perception, Introspection, etc.) with minimal data (80-300 inputs), surpassing 700B-parameter LLMs (>95% accuracy, <5s inference) and human experts, running efficiently on your Linux workstation (56GB VRAM, <5% GPU usage), then scaling globally. FUM will exhibit constant learning, dynamic emergent memory, and full sovereignty—making its own decisions, setting its own goals, pursuing novelty and innovation without requiring prompts, while remaining capable of accepting instructions when provided, transcending traditional chatbot-style Q&A. 4 | 5 | ## Phase 1: Design 6 | - [x] **Achievement Criteria**: Finalize FUM’s architecture to support superintelligence, autonomy, and emergent memory within workstation constraints. 7 | - [x] **Success Statement**: I will know I achieved success on this phase when FUM’s design predicts >95% accuracy, <5s inference, constant learning, dynamic memory, and autonomous goal-setting, fitting 56GB VRAM (up to 7M neurons confidently, 32B ambitiously). 8 | 9 | ### Task 1: Synthesize Research 10 | - [x] **Success Statement**: I will know I achieved success on this task when prior work (AMN, Iteration 2.6) is consolidated into a baseline supporting autonomy. 11 | - *Completed*: AMN (82% accuracy, <5% GPU) and Iteration 2.6 (1000 neurons, 182 inputs) analyzed, gaps identified. 12 | 13 | ### Task 2: Architect Final Model 14 | - [x] **Success Statement**: I will know I achieved success on this task when FUM’s components enable constant learning, emergent memory, and sovereignty. 15 | - *Completed*: LIF neurons, knowledge graph, STDP/SIE, encoder/decoder, CSR/sharding, HIP kernels, self-modification designed to support autonomy and innovation. 16 | 17 | ## Phase 2: Planning 18 | - [x] **Achievement Criteria**: Create strategies for implementing, training, testing, optimizing, and deploying a fully autonomous FUM. 19 | - [x] **Success Statement**: I will know I achieved success on this phase when all plans ensure FUM’s constant learning, dynamic memory, and sovereign operation on your workstation and beyond. 20 | 21 | ### Task 1: Plan Implementation Strategy 22 | - [x] **Success Statement**: I will know I achieved success on this task when a coding roadmap supports autonomous decision-making and dynamic memory. 23 | - *Partial*: File roles listed (`fum.py`, `unified_neuron.py`, etc.), but autonomy not fully specced. 24 | 25 | ### Task 2: Design Training Pipeline 26 | - [x] **Success Statement**: I will know I achieved success on this task when the pipeline fosters constant, unprompted learning from 80-300 inputs. 27 | - *Partial*: Random sprinkling (80 inputs) and tandem scaling (300 inputs) drafted, autonomy pending. 28 | 29 | ### Task 3: Establish Testing and Validation 30 | - [x] **Success Statement**: I will know I achieved success on this task when benchmarks confirm sovereignty and innovation. 31 | - *Incomplete*: >95% accuracy, <5s inference implied, autonomy untested. 32 | 33 | ### Task 4: Plan Hardware Optimization 34 | - [x] **Success Statement**: I will know I achieved success on this task when ROCm integration enables constant learning within 56GB VRAM. 35 | - *Partial*: MI100 (tensors), 7900 XTX (spiking) suggested, not finalized. 36 | 37 | ### Task 5: Outline Deployment and Scalability 38 | - [x] **Success Statement**: I will know I achieved success on this task when deployment supports unprompted operation and global scaling. 39 | - *Partial*: Cluster sharding drafted (50+ nodes), sovereignty unplanned. 40 | 41 | ## Phase 3: Implementation 42 | - [ ] **Achievement Criteria**: Build and test FUM’s components to achieve superintelligence with full autonomy on your workstation, incorporating advanced stability, learning, and scaling mechanisms detailed in `How_It_Works`. 43 | - [ ] **Success Statement**: I will know I achieved success on this phase when FUM runs at 7M neurons (or higher) with >95% accuracy on target benchmarks (Ref: 1.A.7), <5s inference, constant learning, dynamic memory, robust stability (SOC, plasticity), and sovereign goal-setting, processing 300 multimodal inputs without prompts. 44 | 45 | ### Task 1: Code Core Components & Learning Mechanisms 46 | - [ ] **Success Statement**: I will know I achieved success on this task when LIF, enhanced STDP (diversity, STC, exploration, scaling), enhanced SIE (cluster rewards, gaming prevention, ethical alignment), Adaptive Clustering, Knowledge Graph mechanisms (hints, persistence, pathology detection), and Structural Plasticity enable stable, adaptive, efficient, and biologically plausible learning, validated through unit and integration tests. 47 | - *Status*: Incomplete. 48 | 49 | ### Task 2: Integrate Multimodal Inputs 50 | - [ ] **Success Statement**: I will know I achieved success on this task when enhanced encoders/decoders support autonomous interpretation and generation across modalities, validated through testing. 51 | - *Status*: Partial. 52 | 53 | ### Task 3: Optimize for Workstation & Prepare for Scaling 54 | - [ ] **Success Statement**: I will know I achieved success on this task when FUM fits 56GB VRAM with constant learning at <5% GPU usage, leveraging kernels, efficient memory management, and robust distributed logic, validated through testing. 55 | - *Status*: Incomplete. 56 | 57 | ### Task 4: Train, Validate, and Debug 58 | - [ ] **Success Statement**: I will know I achieved success on this task when FUM autonomously achieves superintelligence (>95% accuracy on complex benchmarks) with 300 inputs, demonstrates stable continuous learning, and debugging tools are effective, validated through comprehensive testing. 59 | - *Status*: Incomplete. 60 | 61 | ## Phase 4: Autonomous Operation & Initial Scaling 62 | - [ ] **Achievement Criteria**: Validate FUM's full autonomy on the workstation and demonstrate successful scaling and stability on initial distributed infrastructure. 63 | - [ ] **Success Statement**: I will know I achieved success on this phase when FUM operates autonomously 24/7 on the workstation, processes live data streams, demonstrates robust self-correction and goal management, and successfully scales to 1B neurons on a test cluster while maintaining performance and stability metrics. 64 | 65 | ### Task 1: Validate Workstation Autonomy 66 | - [ ] **Success Statement**: I will know I achieved success on this task when FUM operates continuously for 7+ days on workstation, processing live data, managing internal state, demonstrating goal-directed behavior and novelty seeking without prompts. 67 | - *Status*: Not Started. 68 | 69 | ### Task 2: Initial Distributed Scaling 70 | - [ ] **Success Statement**: I will know I achieved success on this task when FUM scales to 1B neurons on a test cluster (e.g., 100 A100s), maintaining >89% accuracy, <1% overhead, and stability metrics validated during Phase 3. 71 | - *Status*: Not Started. 72 | 73 | ### Task 3: Refine Scaling & Deployment Strategy 74 | - [ ] **Success Statement**: I will know I achieved success on this task when scaling bottlenecks identified, distributed control mechanisms refined, and deployment strategy for large clusters finalized based on initial scaling results. 75 | - *Status*: Not Started. 76 | 77 | ## Phase 5: Global Scaling & Continuous Evolution 78 | - [ ] **Achievement Criteria**: Scale FUM to its target size (32B+ neurons) on large-scale infrastructure, achieve performance equivalence with leading models (700B+ LLMs), and enable long-term, open-ended evolution and application. 79 | - [ ] **Success Statement**: I will know I achieved success on this phase when FUM operates stably at 32B+ neurons on a large cluster, achieves >90% accuracy on comprehensive benchmarks (surpassing SOTA), demonstrates continuous self-improvement and adaptation to new domains, and is ready for real-world application deployment. 80 | 81 | ### Task 1: Large-Scale Distributed Deployment 82 | - [ ] **Success Statement**: I will know I achieved success on this task when FUM deployed and running stably on target large-scale infrastructure (e.g., 1000+ nodes) at 32B+ neurons. 83 | - *Status*: Not Started. 84 | 85 | ### Task 2: Achieve SOTA Performance & Sovereignty 86 | - [ ] **Success Statement**: I will know I achieved success on this task when FUM achieves >90% accuracy on full benchmark suites, demonstrating full sovereignty and performance equivalence or superiority to 700B+ parameter models. 87 | - *Status*: Not Started. 88 | 89 | ### Task 3: Enable Long-Term Evolution & Application 90 | - [ ] **Success Statement**: I will know I achieved success on this task when mechanisms for open-ended learning, domain expansion, and real-world application integration are implemented and validated. 91 | - *Status*: Not Started. 92 | --------------------------------------------------------------------------------