Newer devices and newer OSs can do some recognition device-side-only. But many features, and certainly anything through the older HomePods, requires cloud assistance.
Apple introduced voice processing on the devices with iOS 15 (that's the current version if you are not so familiar with the system.) Older versions of iOS required an internet connection for any voice command. This works on all but the oldest supported devices (which are ~iPhone 6), from what I remember.
This article has a good overview: https://appleinsider.com/articles/21/08/02/how-to-use-siri-o...