There is no direct relation between spid and kpid.
They are both ways of uniquely identifying a session, but for different purposes. The spid is a number between 1 and <max user connections>; when a client connects to ASE, the connection is assigned a free spid number (if all available user connections are already in use, then you cannot connect). The spid is not unique over time, since it is recycled: after session 23 disconnects, a subsequent new connection can be assigned spid 23 again.
The kpid (Kernel Process ID) is an internally-assigned number, used for internal purposes, and is generated in a different way.
It would go too far here to discuss deeper aspects of the kpid. For those interested in more background and ways in which the kpid can be used, see chapter 13 of my book 'Tips, Tricks & Recipes for Sybase ASE' (www.sypron.nl/ttr).