Interpreting batch size parameter in constraints

Hi all,

Regarding the batch size parameter that is used in Modulus constraints, I’ll use an example from the aneurysm tutorial:

from the python script:

outlet = PointwiseBoundaryConstraint(
    outvar={"p": 0},

and from the config file:
outlet: 650

I understand (I think) that this batch size is the number of points sampled on the constraint (in this case the outlet boundary). The points are randomly sampled on the boundary. Are they randomly sampled once, and the same points used in all training epochs; or are they re-sampled periodically? If the former, is there a way to force resampling during training? This would allow greater coverage over the boundary while keeping the number of points (and memory usage) down.

On a related note: if I want to sample a very large number of points in the volume (PointwiseInteriorConstraint) I’m likely to run out of memory if all the points are used at once. Is there a way to force mini-batch sampling of that large number of points?

Likely the answer to one of these questions also answers the other. I couldn’t derive a satisfactory answer by perusing either the documentation or the source.


Hi @uribarri

Thanks for your interest in Modulus. The batch number is the number of points per iteration used for that particular constraint. There are actually two parameters in the constraints that govern the total number of points used in one epoch (side note, Modulus is centered around iterations not epochs):

batch_size : int
        Batch size used in training.
batch_per_epoch : int = 1000
        If `fixed_dataset=True` then the total number of points generated

The second parameter listed tells modulus how many batches are in a epoch of this constraint. By default its 1000, so in the example you gave the total number of points used to train the model for the outlet is 650k (650*1000).

The comment in the docstring answers the second part of your question. The fixed_dataset parameter, when set to False, will cause the constraint continuously sample points for training from a geometry object. This methodology isn’t used a lot since for most cases the entire training dataset can be stored in memory.

Hi @ngeneva ,

Thanks for your answer, which addressed all my questions. I was able to try out your suggestions and they seemed to work. I appreciate it.

On a related note, when fixed_dataset=False, the resampling of the training points generates a lot of messages in the console, such as the below, which makes following the progress of the training very difficult. Is there a way of suppressing those status messages?


Spherical Inside/Outside took: 0.000417707
[OptiX][ 4][  DISK CACHE]: Closed database: "/var/tmp/OptixCache_root/optix7cache.db"
[OptiX][ 4][  DISK CACHE]:     Cache data size: "29.2 KiB"
Timing for computeSignedField: 0.0308755s
Timing for computeSignedDistanceField: 0.0472712s
NUM Triangles: 52664
Timing for Build CPAT Model (build bvh): 0.0154761s
Timing for cpatResultsToArrays: 1.112e-05s
Timing for cpatDistanceField: 0.0160666s
Timing for computeDistanceField: 0.0160728s
[OptiX][ 4][       KNOBS]: All knobs on default.

[OptiX][ 4][  DISK CACHE]: Opened database: "/var/tmp/OptixCache_root/optix7cache.db"
[OptiX][ 4][  DISK CACHE]:     Cache data size: "29.2 KiB"
Timing for optixAccelBuild: 0.000104571s
Timing for buildAccelStructure: 0.00059272s
[OptiX][ 4][   DISKCACHE]: Cache hit for key: ptx-6835-key2d969543357fdcfff15750597ae49b71-sm_86-rtc1-drv510.47.03
[OptiX][ 4][COMPILE FEEDBACK]: Info: Pipeline has 1 module(s), 2 entry function(s), 5 trace call(s), 0 continuation callable call(s), 0 direct callable call(s), 9 basic block(s) in entry functions, 256 instruction(s) in entry functions, 7 non-entry function(s), 53 basic block(s) in non-entry functions, 627 instruction(s) in non-entry functions

Hi @uribarri

Great, glad things are cleared up for you. Those messages are from PySDF for sampling points via OptiX. Presently there’s not a way to suppress those via Modulus at this time.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.