René's URL Explorer Experiment


Title: [Bug]: TorchSim backend returns NaN on some structures · Issue #162 · microsoft/mattersim · GitHub

Open Graph Title: [Bug]: TorchSim backend returns NaN on some structures · Issue #162 · microsoft/mattersim

X Title: [Bug]: TorchSim backend returns NaN on some structures · Issue #162 · microsoft/mattersim

Description: Contact Details gael.huynh@uclouvain.be Bug Description Some structures seems to return NaN when using the TorchSim backend while using Potential.predict_properties works perfectly fine. Note that this error only occurs for some structur...

Open Graph Description: Contact Details gael.huynh@uclouvain.be Bug Description Some structures seems to return NaN when using the TorchSim backend while using Potential.predict_properties works perfectly fine. Note that ...

X Description: Contact Details gael.huynh@uclouvain.be Bug Description Some structures seems to return NaN when using the TorchSim backend while using Potential.predict_properties works perfectly fine. Note that ...

Mail addresses
gael.huynh@uclouvain.be

Opengraph URL: https://github.com/microsoft/mattersim/issues/162

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: TorchSim backend returns NaN on some structures","articleBody":"### Contact Details\n\ngael.huynh@uclouvain.be\n\n### Bug Description\n\nSome structures seems to return NaN when using the TorchSim backend while using `Potential.predict_properties` works perfectly fine. Note that this error only occurs for some structures (see example below where only 1 structure presents this issue).\n\n### MatterSim Version\n\n1.2.5\n\n### Python Version\n\n3.12.12\n\n### Reproduction Steps\n\n1. Install dependencies `pip install mattersim==1.2.5`\n2. Run the code below\n3. The second structure should return NaN values when using the TorchSim backend\n\n```py\nimport numpy as np\nimport requests\nimport torch\nfrom mattersim.forcefield.potential import Potential\nfrom pymatgen.core import Structure\n\n\ndef fetch_alexandria_entry(id_string):\n    url = f\"https://alexandria.icams.rub.de/pbe/v1/structures/{id_string}\"\n\n    response = requests.get(url)\n    response.raise_for_status()\n    data = response.json()[\"data\"]\n    attrs = data[\"attributes\"]\n\n    return Structure(\n        lattice=attrs[\"lattice_vectors\"],\n        species=attrs[\"species_at_sites\"],\n        coords=attrs[\"cartesian_site_positions\"],\n        coords_are_cartesian=True,\n    )\n\n\ndef direct_inference(model, structures):\n    from mattersim.datasets.utils.build import build_dataloader\n    from pymatgen.io.ase import AseAtomsAdaptor\n\n    adapter = AseAtomsAdaptor()\n    atoms = [adapter.get_atoms(struct) for struct in structures]\n\n    dataloader = build_dataloader(atoms, only_inference=True)\n    predictions = model.predict_properties(\n        dataloader,\n        include_forces=True,\n        include_stresses=True,\n    )\n\n    return predictions\n\n\ndef torchsim_inference(model, structures):\n    import torch_sim as ts\n    from mattersim.torchsim import get_torchsim_wrapper\n\n    device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n    wrapper = get_torchsim_wrapper(model, device=device)\n\n    state = ts.static(structures, model=wrapper)\n    return state\n\n\ndef main():\n    alexandria_ids = [\"agm003221802\", \"agm006228157\"]\n    structures = [fetch_alexandria_entry(id) for id in alexandria_ids]\n\n    model = Potential.from_checkpoint(\n        load_path=\"mattersim-v1.0.0-1M\", load_training_state=False\n    )\n\n    results = torchsim_inference(model, structures)\n    for i in range(len(structures)):\n        for key, prop in results[i].items():\n            if torch.isnan(prop).any():\n                print(f\"NaN value found in {key} for structure {i} (TorchSim)\")\n\n    results = direct_inference(model, structures)\n    for i in range(len(structures)):\n        for key, prop in zip([\"energy\", \"forces\", \"stress\"], results[i]):\n            if np.isnan(prop).any():\n                print(f\"NaN value found in {key} for structure {i} (ASE)\")\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Expected Behavior\n\nI would expect the TorchSim backend to return the same values as `Potential.predict_properties` and to not return NaN values on valid structures.\n\n### Actual Behavior\n\nSome structures will return NaN properties when using TorchSim.\n\n### Error Logs\n\n```python\n\n```\n\n### Code of Conduct\n\n- [x] I agree to follow the project's Code of Conduct","author":{"url":"https://github.com/akwarii","@type":"Person","name":"akwarii"},"datePublished":"2026-06-09T09:47:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/162/mattersim/issues/162"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b76386a8-ae66-e3f9-3106-f67a2c1ed89b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE8BA:3CD7FF:581D5B:7B65A5:6A4BCC93
html-safe-noncec692419ee8bb08117a9307a5bf335dbec7288713453fe4297cd6577ebf3bcdf8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOEJBOjNDRDdGRjo1ODFENUI6N0I2NUE1OjZBNEJDQzkzIiwidmlzaXRvcl9pZCI6IjQ3MTI0MjMxNDU1Njg4NjE2MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac45f0fcfcdf5268d3bfbe51bde1674b70c7490b5cbb29f78b34d7d78cca30d932
hovercard-subject-tagissue:4620863512
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/mattersim/162/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3e32304d28e22080732db83a482b6fb2d930d83747dd0de1e752d8a0534e5866/microsoft/mattersim/issues/162
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3e32304d28e22080732db83a482b6fb2d930d83747dd0de1e752d8a0534e5866/microsoft/mattersim/issues/162
og:image:altContact Details gael.huynh@uclouvain.be Bug Description Some structures seems to return NaN when using the TorchSim backend while using Potential.predict_properties works perfectly fine. Note that ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameakwarii
hostnamegithub.com
expected-hostnamegithub.com
None14aa00ce5bdb34d0eefb5facbffd7de9e144c688d8a93ef8df902d5f94b51dd7
turbo-cache-controlno-preview
go-importgithub.com/microsoft/mattersim git https://github.com/microsoft/mattersim.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id853204060
octolytics-dimension-repository_nwomicrosoft/mattersim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id853204060
octolytics-dimension-repository_network_root_nwomicrosoft/mattersim
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release58b8f89190447502561829f30862aa0a99d53367
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoft/mattersim/issues/162#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmattersim%2Fissues%2F162
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fmattersim%2Fissues%2F162
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2Fmattersim
Reloadhttps://github.com/microsoft/mattersim/issues/162
Reloadhttps://github.com/microsoft/mattersim/issues/162
Reloadhttps://github.com/microsoft/mattersim/issues/162
Please reload this pagehttps://github.com/microsoft/mattersim/issues/162
microsoft https://github.com/microsoft
mattersimhttps://github.com/microsoft/mattersim
Notifications https://github.com/login?return_to=%2Fmicrosoft%2Fmattersim
Fork 91 https://github.com/login?return_to=%2Fmicrosoft%2Fmattersim
Star 571 https://github.com/login?return_to=%2Fmicrosoft%2Fmattersim
Code https://github.com/microsoft/mattersim
Issues 3 https://github.com/microsoft/mattersim/issues
Pull requests 2 https://github.com/microsoft/mattersim/pulls
Discussions https://github.com/microsoft/mattersim/discussions
Actions https://github.com/microsoft/mattersim/actions
Projects https://github.com/microsoft/mattersim/projects
Models https://github.com/microsoft/mattersim/models
Security and quality 0 https://github.com/microsoft/mattersim/security
Insights https://github.com/microsoft/mattersim/pulse
Code https://github.com/microsoft/mattersim
Issues https://github.com/microsoft/mattersim/issues
Pull requests https://github.com/microsoft/mattersim/pulls
Discussions https://github.com/microsoft/mattersim/discussions
Actions https://github.com/microsoft/mattersim/actions
Projects https://github.com/microsoft/mattersim/projects
Models https://github.com/microsoft/mattersim/models
Security and quality https://github.com/microsoft/mattersim/security
Insights https://github.com/microsoft/mattersim/pulse
[Bug]: TorchSim backend returns NaN on some structureshttps://github.com/microsoft/mattersim/issues/162#top
bugSomething isn't workinghttps://github.com/microsoft/mattersim/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/akwarii
akwariihttps://github.com/akwarii
on Jun 9, 2026https://github.com/microsoft/mattersim/issues/162#issue-4620863512
bugSomething isn't workinghttps://github.com/microsoft/mattersim/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.