If you set your RayTracingAccelerationStructure to ManagementMode.Automatic, your any hit shaders will not be called at all.
You need to use Manual mode + AddInstance with flags/settings that will allow anyhit shaders. Or have the material set to "RenderType"="Transparent". If you have issues, set that tag on all passes! I found that if the first (raster) pass is "RenderType"="Opaque" then my anyhit shader still won’t be called on my raytrace pass! (Unity 2021.2.7f1)
Really wish that was documented somewhere (obvious?) before spending so long figuring it out.
In Unity 2022, a new function called RayTracingAccelerationStructure.CullInstances was added. It offers many filtering and culling parameters. You can for example specify which materials are considered transparent or alpha tested and it can do efficient SIMD/multithreaded culling. It’s orders of magnitude faster than adding Renderers one by one using AddInstance.