{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/scaling-physics-informed-hard-constraints","title":"Scaling physics-informed hard constraints with mixture-of-experts","arxiv_id":"2402.13412","date":"2024-02-20","proceeding":null,"authors":["Nithin Chalapathi","Yiheng Du","Aditi Krishnapriyan"],"abstract":"Imposing known physical constraints, such as conservation laws, during neural network training introduces an inductive bias that can improve accuracy, reliability, convergence, and data efficiency for modeling physical dynamics. While such constraints can be softly imposed via loss function penalties, recent advancements in differentiable physics and optimization improve performance by incorporating PDE-constrained optimization as individual layers in neural networks. This enables a stricter adherence to physical constraints. However, imposing hard constraints significantly increases computational and memory costs, especially for complex dynamical systems. This is because it requires solving an optimization problem over a large number of points in a mesh, representing spatial and temporal discretizations, which greatly increases the complexity of the constraint. To address this challenge, we develop a scalable approach to enforce hard physical constraints using Mixture-of-Experts (MoE), which can be used with any neural network architecture. Our approach imposes the constraint over smaller decomposed domains, each of which is solved by an \"expert\" through differentiable optimization. During training, each expert independently performs a localized backpropagation step by leveraging the implicit function theorem; the independence of each expert allows for parallelization across multiple GPUs. Compared to standard differentiable optimization, our scalable approach achieves greater accuracy in the neural PDE solver setting for predicting the dynamics of challenging non-linear systems. We also improve training stability and require significantly less computation time during both training and inference stages.","url_abs":"https://arxiv.org/abs/2402.13412v1","url_pdf":"https://arxiv.org/pdf/2402.13412v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"scaling-physics-informed-hard-constraints","repo_url":"https://github.com/ask-berkeley/physics-nns-hard-constraints","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"jax","reach":{"status":"ok"}}],"tasks":[{"task_slug":"inductive-bias","task_name":"Inductive Bias"},{"task_slug":"mixture-of-experts","task_name":"Mixture-of-Experts"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2402.13412","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.13412"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/ask-berkeley/physics-nns-hard-constraints","reach":{"status":"ok"}}],"summary":{"ran":7,"unverified":2},"by_repo_kind":{"official":{"samples":9,"ran":7,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":9,"samples":[{"code_sha256_prefix":"49fb4d19879a0a90","entry":"convert_dict_to_tuples","repo":"ask-berkeley/physics-nns-hard-constraints","repo_kind":"official","path":"resume.py","file_url":"https://github.com/ask-berkeley/physics-nns-hard-constraints/blob/HEAD/resume.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"49fb4d19879a0a90"}},{"code_sha256_prefix":"b525083279ecffac","entry":"double_vmap","repo":"ask-berkeley/physics-nns-hard-constraints","repo_kind":"official","path":"neptune/models/fno2d.py","file_url":"https://github.com/ask-berkeley/physics-nns-hard-constraints/blob/HEAD/neptune/models/fno2d.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b525083279ecffac"}},{"code_sha256_prefix":"0708e0c2961b937e","entry":"lp_norm","repo":"ask-berkeley/physics-nns-hard-constraints","repo_kind":"official","path":"neptune/losses/mse.py","file_url":"https://github.com/ask-berkeley/physics-nns-hard-constraints/blob/HEAD/neptune/losses/mse.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0708e0c2961b937e"}},{"code_sha256_prefix":"448357e9dda4fede","entry":"reweight_matrix","repo":"ask-berkeley/physics-nns-hard-constraints","repo_kind":"official","path":"neptune/models/constraints/hard_constraint.py","file_url":"https://github.com/ask-berkeley/physics-nns-hard-constraints/blob/HEAD/neptune/models/constraints/hard_constraint.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"448357e9dda4fede"}},{"code_sha256_prefix":"6957e51bf9fb6be1","entry":"run_conv","repo":"ask-berkeley/physics-nns-hard-constraints","repo_kind":"official","path":"neptune/models/fno3d.py","file_url":"https://github.com/ask-berkeley/physics-nns-hard-constraints/blob/HEAD/neptune/models/fno3d.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6957e51bf9fb6be1"}},{"code_sha256_prefix":"a6a01f81f216d47c","entry":"split_prng_key","repo":"ask-berkeley/physics-nns-hard-constraints","repo_kind":"official","path":"neptune/models/model_utils.py","file_url":"https://github.com/ask-berkeley/physics-nns-hard-constraints/blob/HEAD/neptune/models/model_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a6a01f81f216d47c"}},{"code_sha256_prefix":"0acc1636c3fa1a80","entry":"triple_vmap","repo":"ask-berkeley/physics-nns-hard-constraints","repo_kind":"official","path":"neptune/models/fno3d.py","file_url":"https://github.com/ask-berkeley/physics-nns-hard-constraints/blob/HEAD/neptune/models/fno3d.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0acc1636c3fa1a80"}},{"code_sha256_prefix":"0839759e88bf2562","entry":"dict_to_model_config","repo":"ask-berkeley/physics-nns-hard-constraints","repo_kind":"official","path":"neptune/models/model_builder.py","file_url":"https://github.com/ask-berkeley/physics-nns-hard-constraints/blob/HEAD/neptune/models/model_builder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0839759e88bf2562"}},{"code_sha256_prefix":"6ec0dd5d77d8e238","entry":"get_model_config","repo":"ask-berkeley/physics-nns-hard-constraints","repo_kind":"official","path":"neptune/models/model_builder.py","file_url":"https://github.com/ask-berkeley/physics-nns-hard-constraints/blob/HEAD/neptune/models/model_builder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6ec0dd5d77d8e238"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}