#4 -- your suction side connections, possibly to a skimmer and a main drain. You can find out, but rotating the valve to block each pipe in succession.

#6 -- your pressure side connections, possibly to two in-wall returns. Check, as above.

#8 -- no clue.

It's also possible, that #4 & 6 allow you to switch from spa to pool, and vice versa.