Create a module with payload size less than the max size used in the ptx

I try to create a module from a ptx which includes many kernels for multiple pipelines. Each pipeline’s requirement for payload/attribute size are different. In this case the current OptiX seem not to allow me to create a module with payload/attribute size smaller than the maximum size used in the ptx even if I don’t use a kernel with the maximum size in the final pipeline.
The error is:
Error: Requested 4 payload values in optixSetPayload but only 3 are configured in the pipeline

Is there any way to avoid this restriction?

This is maybe rather a potential request than a question.
If so my request will be:
Is it possible to defer the above error evaluation to when linking a pipeline instead of when creating a module?
Or is there some reason that that evaluation should be here?
It seems possible to generate multiple pipelines with different payload/attribute size from single DXIL library with DXR (while I’m not sure how correspondence between OptiX’ and DXR’ objects is.)


Interesting, I wasn’t aware of that check, but I also never put programs with different pipeline compile options into the same module.

It makes sense because that prevents including programs using more payload or attribute registers into a pipeline which doesn’t support that number. I’ll check with engineering what’s the exact reason.

I don’t think that the code generation for the individual modules with the different compile options will be moved out to the pipeline link step. That would break your control over what happens when in this explicit API.

The reasonable workaround and generally recommended approach inside the application would be to separate the code affected by the different pipeline compile options into separate modules.
The individual modules for pipelines with different OptixPipelineCompileOptions will need to call optixModuleCreateFromPTX for each of the settings anyway and then it makes sense to make the CUDA source code as small as possible and not include programs which aren’t used inside a pipeline.

Initial module compilation with cold OptiX program cache is expected to be faster when not having many small functions in a huge file. It makes sense to split the modules into such logical partitions alone for that reason.

Thanks for the quick reply and some reasoning!