In a houdini Karma XPU material you can reference the ZDepth (and many other cool ray features) using the kma_rayimport node, depth is the ray:hitPz variable #houdini#tip
to output any shader/node output as a custom AOV, you can plug it into a Karma_AOV node, give it a name, set filter type, then plug that into the "next" input of the final Material_Outputs_and_AOVs node in the Karma Material Builder. #houdini#tip
Then to render the custom AOV, In the Karma Render Settings node, Image Output > AOVs (render vars) > Extra Render Vars > add new var and name it with the custom name defined in the Karma AOV node in the material #houdini#tip#karma#XPU#solaris
oh and finally, to debug your AOV pass in the solaris / karma XPU viewport, On the right sidepanel in the viewport there is a Render Outputs button, that lets you pick which AOV to preview in viewport #houdini#solaris#karmaXPU