{"id":17279019,"url":"https://github.com/tum-pbs/config","last_synced_at":"2025-04-09T22:10:53.463Z","repository":{"id":253774159,"uuid":"815039333","full_name":"tum-pbs/ConFIG","owner":"tum-pbs","description":"[ICLR2025 Spotlight] Official implementation of Conflict-Free Inverse Gradients Method","archived":false,"fork":false,"pushed_at":"2025-02-27T08:59:50.000Z","size":4198,"stargazers_count":51,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T22:10:43.434Z","etag":null,"topics":["continual-learning","deep-learning","multitask-learning","physics-informed-neural-networks","pinns"],"latest_commit_sha":null,"homepage":"https://tum-pbs.github.io/ConFIG/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tum-pbs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-14T08:13:42.000Z","updated_at":"2025-04-08T23:32:18.000Z","dependencies_parsed_at":"2025-02-20T09:41:14.319Z","dependency_job_id":null,"html_url":"https://github.com/tum-pbs/ConFIG","commit_stats":null,"previous_names":["tum-pbs/config"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tum-pbs%2FConFIG","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tum-pbs%2FConFIG/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tum-pbs%2FConFIG/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tum-pbs%2FConFIG/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tum-pbs","download_url":"https://codeload.github.com/tum-pbs/ConFIG/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119294,"owners_count":21050755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["continual-learning","deep-learning","multitask-learning","physics-informed-neural-networks","pinns"],"created_at":"2024-10-15T09:15:24.067Z","updated_at":"2025-04-09T22:10:53.443Z","avatar_url":"https://github.com/tum-pbs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\r\n  \u003cimg src=\"./docs/assets/config.png\" width=\"400\"/\u003e\r\n\u003c/h1\u003e\r\n\r\n\u003ch4 align=\"center\"\u003eOfficial implementation of Conflict-Free Inverse Gradients Method [ICLR2025 Spotlight]\u003c/h4\u003e\r\n\u003ch6 align=\"center\"\u003eTowards Conflict-free Training for Everything and Everyone!\u003c/h6\u003e\r\n\r\n\u003cp align=\"center\"\u003e\r\n  [\u003ca href=\"https://arxiv.org/abs/2408.11104\"\u003e📄 Research Paper\u003c/a\u003e]•[\u003ca href=\"https://tum-pbs.github.io/ConFIG/\"\u003e📖 Documentation \u0026 Examples\u003c/a\u003e]\r\n\u003c/p\u003e\r\n\r\n## About\r\n\r\n* **What is the ConFIG method?**\r\n\r\n​\tThe conFIG method is a generic method for optimization problems involving **multiple loss terms** (e.g., Multi-task Learning, Continuous Learning, and Physics Informed Neural Networks). It prevents the optimization from getting stuck into a local minimum of a specific loss term due to the conflict between losses. On the contrary, it leads the optimization to the **shared minimum of all losses** by providing a **conflict-free update direction.**\r\n\r\n\u003cp align=\"center\"\u003e\r\n\u003cimg src=\"docs/assets/config_illustration.png\" style=\"zoom: 33%;\" /\u003e\r\n\u003c/p\u003e\r\n\r\n* **How does the ConFIG work?**\r\n\r\n​\tThe ConFIG method obtains the conflict-free direction by calculating the inverse of the loss-specific gradients matrix:\r\n\r\n```math\r\n\\boldsymbol{g}_{ConFIG}=\\left(\\sum_{i=1}^{m} \\boldsymbol{g}_{i}^\\top\\boldsymbol{g}_{u}\\right)\\boldsymbol{g}_u,\r\n```\r\n\r\n```math\r\n\\boldsymbol{g}_u = \\mathcal{U}\\left[\r\n[\\mathcal{U}(\\boldsymbol{g}_1),\\mathcal{U}(\\boldsymbol{g}_2),\\cdots, \\mathcal{U}(\\boldsymbol{g}_m)]^{-\\top} \\mathbf{1}_m\\right].\r\n```\r\n\r\nThen the dot product between $\\boldsymbol{g}_{ConFIG}$ and each loss-specific gradient is always positive and equal, i.e., $`\\boldsymbol{g}_{i}^{\\top}\\boldsymbol{g}_{ConFIG}=\\boldsymbol{g}_{j}^{\\top}\\boldsymbol{g}_{ConFIG}\u003e 0  \\quad \\forall i,j \\in [1,m]`$​.\r\n\r\n* **Is the ConFIG computationally expensive?**\r\n\r\n​\tLike many other gradient-based methods, ConFIG needs to calculate each loss's gradient in every optimization iteration, which could be computationally expensive when the number of losses increases. However, we also introduce a **momentum-based method** where we can reduce the computational cost **close to or even lower than a standard optimization procedure** with a slight degeneration in accuracy. This momentum-based method is also applicable to other gradient-based methods.\r\n\r\n## Paper Info\r\n\r\n\u003ch4 align=\"center\"\u003eConFIG: Towards Conflict-free Training of Physics Informed Neural Networks\u003c/h4\u003e\r\n\u003ch6 align=\"center\"\u003e\u003cimg src=\"./docs/assets/TUM.svg\" width=\"16\"\u003e \u003ca href=\"https://qiauil.github.io/\"\u003eQiang Liu\u003c/a\u003e, \u003cimg src=\"./docs/assets/PKU.svg\" width=\"14\"\u003e \u003ca href=\"https://rachelcmy.github.io/\"\u003eMengyu Chu\u003c/a\u003e, and \u003cimg src=\"./docs/assets/TUM.svg\" width=\"16\"\u003e \u003ca href=\"https://ge.in.tum.de/about/n-thuerey/\"\u003eNils Thuerey\u003c/a\u003e\u003c/h6\u003e\r\n\r\n\u003ch6 align=\"center\"\u003e\r\n    \u003cimg src=\"./docs/assets/TUM.svg\" width=\"16\"\u003e Technical University of Munich\r\n    \u003cimg src=\"./docs/assets/PKU.svg\" width=\"14\"\u003e Peking University\r\n\u003c/h6\u003e\r\n\r\n***Abstract:*** The loss functions of many learning problems contain multiple additive terms that can disagree and yield conflicting update directions. For Physics-Informed Neural Networks (PINNs), loss terms on initial/boundary conditions and physics equations are particularly interesting as they are well-established as highly difficult tasks. To improve learning the challenging multi-objective task posed by PINNs, we propose the ConFIG method, which provides conflict-free updates by ensuring a positive dot product between the final update and each loss-specific gradient. It also maintains consistent optimization rates for all loss terms and dynamically adjusts gradient magnitudes based on conflict levels. We additionally leverage momentum to accelerate optimizations by alternating the back-propagation of different loss terms. The proposed method is evaluated across a range of challenging PINN scenarios, consistently showing superior performance and runtime compared to baseline methods. We also test the proposed method in a classic multi-task benchmark, where the ConFIG method likewise exhibits a highly promising performance. \r\n\r\n***Read from:*** [[Arxiv](https://arxiv.org/abs/2408.11104)]\r\n\r\n***Cite as:*** \r\n\r\n```latex\r\n@inproceedings{Liu2024ConFIG,\r\n  author = {Qiang Liu and Mengyu Chu and Nils Thuerey},\r\n  title = {ConFIG: Towards Conflict-free Training of Physics Informed Neural Networks},\r\n  booktitle = {The Thirteenth International Conference on Learning Representations},\r\n  year={2024},\r\n  url={https://arxiv.org/abs/2408.11104},\r\n}\r\n```\r\n\r\n## Installation\r\n\r\n* Install through `pip`: `pip install conflictfree`\r\n* Install from repository online: `pip install git+https://github.com/tum-pbs/ConFIG`\r\n* Install from repository offline: Download the repository and run `pip install .` or `install.sh` in terminal.\r\n* Install from released wheel: Download the wheel and run `pip install conflictfree-x.x.x-py3-none-any.whl` in terminal.\r\n\r\n## Usage\r\n\r\nFor a muti-loss optimization, you can simply use ConFIG method as follows:\r\n\r\nWithout `ConFIG`:\r\n\r\n```python\r\noptimizer=torch.Adam(network.parameters(),lr=1e-3)\r\nfor input_i in dataset:\r\n    losses=[]\r\n    optimizer.zero_grad()\r\n    for loss_fn in loss_fns:\r\n        losses.append(loss_fn(network,input_i))\r\n    torch.cat(losses).sum().backward()\r\n    optimizer.step()\r\n```\r\n\r\nWith `ConFIG`:\r\n\r\n```python\r\nfrom conflictfree.grad_operator import ConFIG_update\r\nfrom conflictfree.utils import get_gradient_vector,apply_gradient_vector\r\noptimizer=torch.Adam(network.parameters(),lr=1e-3)\r\nfor input_i in dataset:\r\n    grads=[]\r\n    for loss_fn in loss_fns:\r\n    \toptimizer.zero_grad()\r\n    \tloss_i=loss_fn(input_i)\r\n        loss_i.backward()\r\n        grads.append(get_gradient_vector(network)) #get loss-specfic gradient\r\n    g_config=ConFIG_update(grads) # calculate the conflict-free direction\r\n    apply_gradient_vector(network,g_config) # set the conflict-free direction to the network\r\n    optimizer.step()\r\n```\r\n\r\nMore details and examples can be found in our [doc page](https://tum-pbs.github.io/ConFIG/).\r\n\r\nTo reproduce the result in our paper, please check the [experiments](https://github.com/tum-pbs/ConFIG/tree/main/experiments) folder.\r\n\r\n## Additional Info\r\nThis project is part of the physics-based deep learning topic in [**Physics-based Simulation group**](https://ge.in.tum.de/) at TUM.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftum-pbs%2Fconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftum-pbs%2Fconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftum-pbs%2Fconfig/lists"}