Possible to access an instance's transformation matrix from a ray generation program?

In my ray generation program, I would like to sample points on a geometric instance so that I can launch rays from it in my ray generation program. But the problem is I only know the coordinates in object space and I need world space coordinates for a ray generation program.

So for example, let’s say you had thousands of rectangular light sources in a scene and want to launch rays from them (note that the lights need to be instances too since I want to intersect rays with them). I don’t want to have to pass the four vertices for each instance via a buffer or variable because that will waste a ton of memory. I already have set the transformation matrix for each instance, so that gives all the information I need. Ideally, I would like to query the transformation matrix for each instance in my ray generation program so I can use it to transform sampled points into world coordinates. However rtTransform* is not supported within ray generation programs for obvious reasons. Is there any other way to get an instance’s transformation matrix from within a ray generation program? The only way I can think of would be to launch a ray that I know will hit only the instance, then sample the rectangle from the hit program where I can use rtTransform*, but this would be very computationally wasteful.

The only way I can think of is to pass the extra buffer of data about instances, as you described above. Yes, it duplicates memory that is also stored somewhere in the OptiX scene, but is it enough memory to matter for your app? Can you compress the description of the geometry instances somewhat? In the rectangular light example, you could probably describe a light using less than 12 full floats, for example.

I’m also curious: is the cost of transferring the buffer of lights/instances to the device significant, compared to the time it takes to run the OptiX programs? What if you generated all rays on the host and passed them to the device, how does that time compare to the tracing time?