Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to v0.4.11, fix tests related to numpy2 & add Newton's law of cooling example #539

Merged
merged 56 commits into from
Feb 5, 2025
Merged
Changes from 8 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
dd92a43
Update to v0.4.11
pgleeson May 1, 2024
fba5c46
Merge pull request #532 from ModECI/nml_examples
pgleeson May 15, 2024
5287b12
Regenerated
pgleeson May 23, 2024
dc9448e
Newton's Law of Cooling Example
rimjhimittal May 30, 2024
9d6dde9
fixing some indentation issue
rimjhimittal May 30, 2024
b6b7bf3
black formatted
rimjhimittal May 30, 2024
1b181c6
Update README.md
rimjhimittal Jun 3, 2024
d82719d
Update README.md
rimjhimittal Jun 3, 2024
7cc4341
Uploading the notebook
rimjhimittal Jun 3, 2024
c53c9dc
fix end-of-file
rimjhimittal Jun 3, 2024
0eac2be
Remove pin to grpcio-tools==1.42.0
pgleeson Jun 5, 2024
ed34981
Test psyneulink on py3.11
pgleeson Jun 6, 2024
f1bba2a
all changes made
rimjhimittal Jun 7, 2024
7819333
Merge pull request #533 from rimjhimittal/newton
pgleeson Jun 7, 2024
394496d
Merge branch 'development' into test_versions
pgleeson Jun 13, 2024
88f8353
Merge branch 'test_versions' into nml_examples
pgleeson Jun 13, 2024
f8f8635
Merge pull request #534 from ModECI/test_versions
pgleeson Jun 13, 2024
575403c
Fix typo & regenerate files
pgleeson Jun 14, 2024
7eb4ca8
Merge branch 'development' into nml_examples
pgleeson Jun 14, 2024
1e6e643
Switched RLC Circuit Example
rimjhimittal Jun 14, 2024
c29534f
changes
rimjhimittal Jun 18, 2024
98ecf2e
Ensure numpy<2.0.0 in tests, due to lingering issues with other modul…
pgleeson Jun 18, 2024
59aebdd
Merge pull request #537 from ModECI/nml_examples
pgleeson Jun 18, 2024
9d83492
Merge remote-tracking branch 'upstream/development' into rlc-circuit
rimjhimittal Jun 21, 2024
7089a76
graph issue
rimjhimittal Jul 4, 2024
fb6b15d
Regenerated neuroml files
pgleeson Aug 20, 2024
5eff07d
Add workflow for test_all.sh
pgleeson Aug 20, 2024
0f0d1e7
Test this branch too
pgleeson Aug 20, 2024
351b507
Test on py3.10; update to make neuroml export dimensionally consistent
pgleeson Aug 20, 2024
926b904
Regenerate
pgleeson Aug 20, 2024
9d45150
Restructure all to include dev dependencies
pgleeson Aug 20, 2024
9b0eabf
Fix to find neuron
pgleeson Aug 21, 2024
d8a6cf4
fixed plot error
rimjhimittal Aug 21, 2024
8414d16
Add pre-commit to dev
pgleeson Aug 21, 2024
4ff45cc
Merge branch 'rlc-circuit' of github.com:rimjhimittal/MDF into nml_ex…
pgleeson Aug 21, 2024
a175578
Regenerated image files & fix formatting
pgleeson Aug 21, 2024
9dc3dce
Move neuron...
pgleeson Aug 21, 2024
31b626a
Temp partial fix for parametercondition issue
pgleeson Aug 21, 2024
d7a7557
Catch exit code non 0 in pre-commit
pgleeson Aug 21, 2024
205ffe3
Don't show rlc plot in test
pgleeson Aug 27, 2024
9c6610e
Regenerated with latest neuroml packages
pgleeson Nov 13, 2024
251a59f
Update README.md
pgleeson Dec 11, 2024
e5e911d
Fix formatting
pgleeson Dec 11, 2024
4d75b4b
Test specific psyneulink version
pgleeson Dec 11, 2024
acc49ba
Merge pull request #540 from ModECI/benchmarking
pgleeson Dec 18, 2024
f93e6f3
Merge branch 'development' into nml_examples
pgleeson Dec 18, 2024
601690d
Remove upper pin on PNL, add lower pin.
davidt0x Jan 8, 2025
a21e314
Merge pull request #541 from ModECI/fix/pnl_pin
davidt0x Jan 9, 2025
b4f3ef1
Remove upper pin on pytorch.
davidt0x Jan 15, 2025
c650f5b
Fix for new pytorch.
davidt0x Jan 15, 2025
63ee3cf
Replace torch.onnx._export call with torch.onnx.export
davidt0x Jan 15, 2025
7c3129c
black
davidt0x Jan 15, 2025
cc9a796
Merge pull request #542 from ModECI/fix/pytorch_pin
davidt0x Jan 22, 2025
f3896b7
Merge branch 'development' into nml_examples
pgleeson Feb 4, 2025
6374fd4
Limit torchvision
pgleeson Feb 4, 2025
5f442aa
Merge pull request #538 from ModECI/nml_examples
pgleeson Feb 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/MDF/abcd_torch.py
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ def forward(self, input: torch.Tensor):

# Export the model
fn = "ABCD_from_torch.onnx"
torch_out = torch.onnx._export(
torch.onnx.export(
m_abcd, # model being run
input, # model input (or a tuple for multiple inputs)
fn, # where to save the model (can be a file or file-like object)
16 changes: 8 additions & 8 deletions examples/PsyNeuLink/stroop_conflict_monitoring.py
Original file line number Diff line number Diff line change
@@ -5,14 +5,14 @@

# Construct the color naming pathway:
color_input = pnl.ProcessingMechanism(
name="color_input", size=2
name="color_input", input_shapes=2
) # Note: default function is Linear
color_input_to_hidden_wts = np.array([[2, -2], [-2, 2]])
color_hidden = pnl.ProcessingMechanism(
name="color_hidden", size=2, function=pnl.Logistic(bias=-4)
name="color_hidden", input_shapes=2, function=pnl.Logistic(bias=-4)
)
color_hidden_to_output_wts = np.array([[2, -2], [-2, 2]])
output = pnl.ProcessingMechanism(name="OUTPUT", size=2, function=pnl.Logistic)
output = pnl.ProcessingMechanism(name="OUTPUT", input_shapes=2, function=pnl.Logistic)
color_pathway = [
color_input,
color_input_to_hidden_wts,
@@ -22,10 +22,10 @@
]

# Construct the word reading pathway (using the same output_layer)
word_input = pnl.ProcessingMechanism(name="word_input", size=2)
word_input = pnl.ProcessingMechanism(name="word_input", input_shapes=2)
word_input_to_hidden_wts = np.array([[3, -3], [-3, 3]])
word_hidden = pnl.ProcessingMechanism(
name="word_hidden", size=2, function=pnl.Logistic(bias=-4)
name="word_hidden", input_shapes=2, function=pnl.Logistic(bias=-4)
)
word_hidden_to_output_wts = np.array([[3, -3], [-3, 3]])
word_pathway = [
@@ -37,8 +37,8 @@
]

# Construct the task specification pathways
task_input = pnl.ProcessingMechanism(name="task_input", size=2)
task = pnl.LCAMechanism(name="TASK", size=2, initial_value=[0.5, 0.5])
task_input = pnl.ProcessingMechanism(name="task_input", input_shapes=2)
task = pnl.LCAMechanism(name="TASK", input_shapes=2, initial_value=[0.5, 0.5])
task_color_wts = np.array([[4, 4], [0, 0]])
task_word_wts = np.array([[0, 0], [4, 4]])
task_color_pathway = [task_input, task, task_color_wts, color_hidden]
@@ -53,7 +53,7 @@
name="CONTROL",
objective_mechanism=pnl.ObjectiveMechanism(
name="Conflict Monitor",
function=pnl.Energy(size=2, matrix=[[0, -2.5], [-2.5, 0]]),
function=pnl.Energy(input_shapes=2, matrix=[[0, -2.5], [-2.5, 0]]),
monitor=output,
),
default_allocation=[0.5],
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ package_dir =

[options.extras_require]
psyneulink =
psyneulink<=0.15.1.0
psyneulink>=0.15.3

neuroml =
pyNeuroML>=1.0.10
@@ -92,7 +92,7 @@ optional =
Jinja2<3.1
torchviz
netron
torch<2.2.0,>=1.11.0
torch>=1.11.0
torchvision
h5py

13 changes: 12 additions & 1 deletion src/modeci_mdf/interfaces/pytorch/importer.py
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

Mike He, "From Models to Computation Graphs (Part I)", https://ad1024.space/articles/22
"""

import inspect
import logging

@@ -13,6 +14,7 @@

import torch


# We need to monkey patch the torch._C.Node class to add a __getitem__ method
# This is for torch 2.0
# From https://github.com/openai/CLIP/issues/79#issuecomment-1624202950
@@ -523,7 +525,16 @@ def pytorch_to_mdf(
# Call out to a part of the ONNX exporter that simiplifies the graph before ONNX export.
from torch.onnx.utils import _model_to_graph
from torch.onnx import TrainingMode
from torch.onnx.symbolic_helper import _set_opset_version

# Seems they got rid of _set_opset_version in 2.2 or something, can't find a better way to do this
try:
from torch.onnx.symbolic_helper import _set_opset_version
except ImportError:

def _set_opset_version(version):
from torch.onnx._globals import GLOBALS

GLOBALS.export_onnx_opset_version = version

try:
from torch.onnx.symbolic_helper import _export_onnx_opset_version