Skip to content

Conversation

@brownbaerchen
Copy link
Contributor

This includes a very short tutorial for how to use PyTorch tensors in pySDC. The tutorial shows how to train a network to the result of an implicit Euler solve in pySDC.

Very much work in progress! I made the datatype slightly more robust. But it's pretty messy, honestly. numpy has unary functions that cover basic arithmetic, but I didn't find the tensor counterpart fast enough. So I overloaded some dunder functions such that the communicator attribute is not lost during arithmetic. Not great.

I added a test that makes sure the error of the model prediction to the truth is below some threshold. However, the learning is not deterministic, afaik. I chose pretty large tolerances and the test has not failed on me, but it may be flaky. I suggest we don't worry about this now, but keep it in mind and remove if necessary. @aqibrahimbt, any advice?

@danielru, after the workflow is complete, the website is generated as an artifact that you can download. Please have a look if this is good for you. I am not known for making great advertisements...

@pancetta, I am not sure if I did everything correctly with the website. Locally it looked good, but please double check that I added the right files in the right places.

@pancetta pancetta requested a review from danielru April 24, 2024 08:25
@pancetta
Copy link
Member

LGTM, thanks!

@brownbaerchen brownbaerchen merged commit d785a01 into Parallel-in-Time:master May 6, 2024
@brownbaerchen brownbaerchen deleted the pytorch_tutorial branch May 6, 2024 12:58
brownbaerchen added a commit to brownbaerchen/pySDC that referenced this pull request Aug 22, 2025
#!!!!!!!!!! WARNING: RUFF FAILED !!!!!!!!!!: 

#pySDC/projects/GPU/analysis_scripts/compare_RBC3D.py:418:9: E722 Do not use bare `except`
#    |
Parallel-in-Time#416 |                 k[_s > 1e-16], _s[_s > 1e-16], color=last_line.get_color(), ls=last_line.get_linestyle(), label=label
Parallel-in-Time#417 |             )
Parallel-in-Time#418 |         except:
#    |         ^^^^^^ E722
Parallel-in-Time#419 |             pass
#    |
#
#pySDC/projects/GPU/analysis_scripts/compare_RBC3D.py:517:5: F841 Local variable `Delta_Nu` is assigned to but never used
#    |
Parallel-in-Time#515 |     t = data['t']
Parallel-in-Time#516 |     avg_Nu = np.array([np.mean(Nu[40 : 40 + i + 1]) for i in range(len(Nu[40:]))])
Parallel-in-Time#517 |     Delta_Nu = np.array([abs(avg_Nu[i + 1] - avg_Nu[i]) for i in range(len(avg_Nu) - 1)])
#    |     ^^^^^^^^ F841
Parallel-in-Time#518 |     # ax.plot(data['t'][40:-1], Delta_Nu / avg_Nu[:-1])
Parallel-in-Time#519 |     # ax.plot(data['t'], np.abs(avg_Nu - avg_Nu[-1]) / avg_Nu[-1])
#    |
#    = help: Remove assignment to unused variable `Delta_Nu`:
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

Successfully merging this pull request may close these issues.

2 participants