Skip to main content

Nvidia Modulus Symbolic(Modulus Sym) Workflow and Example

A typical workflow followed when developing in Modulus Sym.

flow.png

Hydra

HydraThis is a configuration package builtdesigned intoto empower users in configuring hyperparameters. These hyperparameters determine the structure and training behavior of neural networks. Users can conveniently set these hyperparameters using YAML configuration files, a human-readable text format. Hydra plays the role of the first component initiated when addressing a problem with Modulus Sym. It letswields usersinfluence setacross hyperparametersall (parametersaspects that determine the neural network’s structure and govern its training) using configuration files in YAML (a standard human-readable text format). Hydra is the first component to be initialized when solving a problem usingof Modulus Sym. It directly influences all Modulus Sym components.

Geometry and Data 

Modulus Sym providesoffers botha dual approach for solving physics simulation challenges – a blend of physics-informedbased knowledge and data-driven machine learninglearning. solutions for physics simulation problems. AllBoth these solutionsapproaches dependrevolve onaround expressingtransforming the physics problem asinto a mathematical optimization problem.puzzle. The mathematicalcore optimizationof this problem is,exists in turn, posed onwithin a particularspecific geometry and/orand set of data.dataset. Modulus Sym’Sym provides a flexible geometry modulemodule, letsallowing users to either buildcreate a new geometry from scratch using primitives,basic shapes or import an existing geometrygeometries from a mesh. ForIn scenarios involving data-driven problems,solutions, Modulus Sym hasoffers multiplediverse methodsways forto accessingaccess data, including standard in-memory datasets asand wellresource-efficient as lazy lazy-loading methods for large-scalehandling extensive datasets.

Nodes

InWithin Modulus Sym, Nodes representplay a key role by representing components that will be executed induring the forward pass duringof training. A Node may wrapencapsulates a torch.nn.ModuleModule, andproviding provides additional information regarding its needed input and output variables.details. This letsattribute enables Modulus Sym buildto construct execution graphs and automatically fill in missing componentselements, toessential computefor requiredcomputing necessary derivatives. Nodes maycan containencompass modelsvarious or functionselements, such as PyTorch neural networks thatnatively are builtintegrated into Modulus Sym, user-defined PyTorch networks, feature transformations, orand even equations.

Domain

The Domain holdsis a central role by encompassing not only all the Constraints asbut wellalso assupplementary additionalelements componentsessential needed infor the training process.journey. These additionalsupplementary components includeconsist of Inferencers, Validators, and Monitors. WhenAs developingdevelopers inengage with Modulus Sym, the Constraints thatdefined by the user defines are thenseamlessly addedintegrated tointo the training DomainDomain. toThis createcombinated results in the formation of a collectioncomprehensive assembly of training objectives.objectives, laying the foundation for a cohesive and purposeful training process.

Constraints

Constraints areserve as the training objectivesgoals. in Modulus Sym. AEach Constraint containsencompasses the loss function,function and a setcollection of Nodes fromNodes, which Modulus Sym buildsutilizes to construct a computational graph for execution. ManyNumerous physical problemschallenges needrequire multiple training objectives into ordercomprehensively fordefine the problemproblem. Constraints play a pivotal role in structuring such scenarios, offering the mechanism to beestablish wellthese defined.intricate Constraintsproblem provide the means for setting up such problems.setups.

Inferencers

An Inferencer executesprimarily justperforms the forward pass of a set of Nodes. During training, Inferencers maycan be usedemployed duringto evaluate training to assess training quantitiesmetrics or getobtain predictions for visualization or deployment.deployment Hydrapurposes. configuration settings control theThe frequency at which Inferencers are called.invoked is governed by Hydra configuration settings.

Validators

Validators workfunction likesimilarly Inferencers,to Inferencers but also takeincorporate validation data. TheyTheir quantifyrole involves quantifying the model's accuracy of the model during training,training by validatingcomparing it against physical resultsoutcomes producedgenerated bythrough somealternative othermethods. method.This (“Validation”"validation" herephase means the part of “verification and validation” that checksverifies whether Modulus Sym meets its operational requirements,requirements by comparing theits computed simulation results thatto Modulusestablished Sym computes against some “known good” result.)

Monitors

Monitors alsofunction worksimilarly liketo Inferencers,Inferencers but also calculate specific measures instead of fields. These measures may beencompass global quantities such aslike total energy,energy or local probesmeasurements such aslike pressure in front of a bluff body.body (A “bluff body” is a kind ofdistinctive shape with specialunique fluid dynamics properties.)attributes). Monitors are automaticallyseamlessly addedintegrated tointo Tensorboard results for viewing.easy visualization. Furthermore, Monitor resultsoutcomes can also be exported to a text file in comma-separated values (CSV) format.

Solver

A Solver isstands anas instance of thea core component within Modulus SymSym, trainer.responsible Itfor implementsimplementing the optimization loop and managesoverseeing the training process. ABy taking a predefined Domain, the Solver takes a defined Domain and callsorchestrates the execution of Constraints, Inferencers, Validators, and Monitors whenas required.needed. DuringIn oneeach iteration, the Solver will computecalculates the globaloverall loss from all Constraints and then optimizerefines any trainable models present inwithin the Nodes providedassociated towith the Constraints.

Modulus Sym Development Workflow

The key steps of general workflow include:

  • "Load Hydra": Initialize Hydra using the Modulus Sym main decorator to read in the YAML configuration file.

  • "Load Datasets": Load data if needed.

  • "Define Geometry": Define the geometry of the system if needed.

  • "Create Nodes": Create any Nodes required, such as the neural network model.

  • "Create Domain": Create a training Domain object.

  • "Create Constraint" and "Add Constraint to Domain"

  • "Create {Validator, Inferencer, Monitor}" and "Add {Validator, Inferencer, Monitor} to Domain": Create any Inferencers, Validators or Monitors needed, and add them to the Domain.

  • "Create Solver": Initialize a Solver with the populated training Domain.

  • "Run Solver": Run the Solver. The resulting training process optimizes the neural network to solve the physics problem.

Modulus Training

Screenshot from 2023-08-09 11-28-30.png

• Modulus allowsenables forthe representation of complex problems to be described throughusing sets of constraintsconstraints, (serving as training objectives)objectives.
MultipleIn nodes/constraints, the integration of multiple nodes or models can be combined in constraintsallows for learningthe differentacquisition of diverse loss functions—ranging from data-driven orto physics-driven lossin functionsnature.
ExportingSeamlessly resultsexporting the outcomes of the trained modelmodels to visualization software isbecomes theneffortlessly effortlessachievable with ModulusModulus.