In the first hash round for ECMP, the algorithm parses down the label stack and after it reaches the bottom, it checks the next nibble. If the nibble value is 4, it assumes it is an IPv4 packet. If the nibble value is 6, it assumes it is an IPv6 packet. In both cases, the result of the label hash is fed into another hash along with source and destination address fields in the IP packet header. Otherwise, it uses the label stack hash already calculated for the ECMP path selection.
If there are more than five labels in the stack, the algorithm also uses the result of the label hash for the ECMP path selection.
The second round of hashing for LAG re-uses the net result of the first round of hashing. This means IPv6 packets continue to be hashed on label stack only.