When I use my iphone 17pro to set up my new 18 pro, do they have the same version of the OS?
No.
The 18 Pro will be running iOS 27, but you can use an iPhone 17 that is running iOS 26 or iOS 18 to set up the iPhone 18 Pro.
Where you can run into some snags though, would be a situation where you have updated the iPhone 17 to an iOS version that is higher than the version that came installed on the iPhone 18.
For example, say 3 months from now you have updated your iPhone 17 to run iOS 27.3. But, you buy a new iPhone 18 that comes with iOS 27.1 installed. In that case, you would have to update the iPhone 18 to the current iOS 27.3.....then....set up the iPhone 18.
The bottom line and simplest thing to remember......if you plan to buy the iPhone 18 soon......do not update your iPhone 17 to iOS 27. Wait until after you have set up the new iPhone 18 to then update the iPhone 17 if you want it to run iOS 27.