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

naive_program method from Program.py file incompatible with tiled crossbars #49

Closed
Philippe-Drolet opened this issue Jun 11, 2021 · 2 comments · Fixed by #52
Closed
Assignees
Labels
bug Something isn't working

Comments

@Philippe-Drolet
Copy link
Contributor

Hello,

I am trying to run the patch_model function with a simple MNIST NN (only linear layers) using the naive_program function as a programming routine but it crashes because of a "too many values to unpack" error stemming from the "point" parameter fed to the naive_program method that is a three element tuple while it expects a two element one. This error only happens with tiled crossbars (cause of the three element tuple) and with transistor set to False.

File "C:\Users\Phili\Documents\Ecole\UdeS\Memtorch\custom_MemTorch\memtorch\bh\crossbar\Crossbar.py", line 334, in init_crossbar
crossbars[0].write_conductance_matrix(
File "C:\Users\Phili\Documents\Ecole\UdeS\Memtorch\custom_MemTorch\memtorch\bh\crossbar\Crossbar.py", line 208, in write_conductance_matrix
self.devices = programming_routine(
File "C:\Users\Phili\Documents\Ecole\UdeS\Memtorch\custom_MemTorch\memtorch\bh\crossbar\Program.py", line 56, in naive_program
row, column = point
ValueError: too many values to unpack (expected 2)

Here are the execution parameters being fed to the patch_model:
patched_model = patch_model(copy.deepcopy(network),
memristor_model=memtorch.bh.memristor.Data_Driven,
memristor_model_params= reference_memristor_params_dd,
module_parameters_to_patch=[torch.nn.Linear],
mapping_routine=naive_map,
transistor=False,
programming_routine=memtorch.bh.crossbar.Program.naive_program,
tile_shape=(128,128),
max_input_voltage=1.0,
ADC_resolution=8,
ADC_overflow_rate=0.,
quant_method='linear')

Was it intended for the user to write his/her own programming routine? Thank you,

Philippe

@coreylammie
Copy link
Owner

Hi @Philippe-Drolet,

Thank you for raising this! Your interpretation is correct- naive_program in Program.py is indeed a fully-functional exemplar programming routine. More complex programming routines can be defined externally, that for instance, reduce the amplitude of the applied voltage over time, or apply more complex logic to program devices more effectively.

I can confirm this is indeed a bug. I'll look into this tomorrow and will provide an update when a fix is integrated and naive_program can be used with tiled crossbars.

Kind Regards,

Corey.

@coreylammie coreylammie added the bug Something isn't working label Jun 13, 2021
@coreylammie coreylammie self-assigned this Jun 13, 2021
@coreylammie
Copy link
Owner

This should now be fixed in #52. Please note that, depending on the simulation timestep used and other device parameters, operation may be quite slow. I have opened another issue (#53) to parallelize/optimize device simulation logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants