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

Bug when resetting and executing transfer mechanism on different passes #3142

Open
jongkeesbj opened this issue Dec 11, 2024 · 0 comments
Open

Comments

@jongkeesbj
Copy link
Collaborator

There is a difference in Python mode and compiled mode, which I assume reflects a bug on the compiled side or at least an unimplemented feature that does not throw up a warning message:

When a transfer mechanism has reset_stateful_function_when=pnl.AtTrialStart() but is scheduled to only execute on a later pass, for example pass 5, then python mode will appropriately reset the mechanism at pass 0 and execute the mechanism at pass 5.

In compiled mode, however, the reset does not happen on pass 0 but instead on pass 5 when the mechanism executes. A reproducible example is posted below.

import psyneulink as pnl

# Note, my_input is scheduled to only execute on pass 5!
my_input = pnl.TransferMechanism(
    input_shapes=2,
    integrator_mode=True,
    integration_rate=1,
    reset_stateful_function_when=pnl.AtTrialStart()
)

my_lca = pnl.LCAMechanism(
    input_shapes=2,
    termination_threshold=10,
    termination_measure=pnl.TimeScale.TRIAL,
    execute_until_finished=False
)

my_gate = pnl.ProcessingMechanism(input_shapes=2)

comp = pnl.Composition()
comp.add_linear_processing_pathway([my_input, my_lca, my_gate])

comp.scheduler.add_condition(
    my_input, pnl.AtPass(5)
)

comp.scheduler.add_condition(
    my_lca, pnl.Always()
)

comp.scheduler.add_condition(
    my_gate, pnl.WhenFinished(my_lca)
)

print('Python Mode: ')
comp.run([[1, 0], [0, 1]])
print(comp.results)

comp.reset(clear_results=True)

print('Compiled Mode: ')
comp.run([[1, 0], [0, 1]], execution_mode=pnl.ExecutionMode.LLVMRun)
print(comp.results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant