Simple Answer "How many pies must I leave with ...?" There is no unique answer, but most simply, leave home with no pies. Details below.
Original conditions
From the original question: "The trolls can't give you half a cake back. It is unhygienic and disgusting." Since the trolls can only adjust your number of pies by integer amounts, just start with any number of whole pies to reach grandma's with a whole number of pies. Since the trolls give you back 1 whole pie after taking some number of yours, you will have at least 1 pie to present at grandma's.
Fractional pies
If trolls can give potions of a pie back, and assuming they can subdivide pies into any real number, you can still start with any real number of pies and reach grandma's with a whole number of pies.
Suppose you start with $p$ pies. You leave
bridge 1 with $\frac{p}{2^1} + \frac{2^1 - 1}{2^0}$ pies,
bridge 2 with $\frac{p}{2^2} + \frac{2^2 - 1}{2^1}$ pies,
and in general,
bridge $n$ with $\frac{p}{2^n} + \frac{2^n - 1}{2^{n-1}}$ pies.
In the limit as $n$ tends to infinity, you end up with exactly 2 pies when you reach grandma's, regardless of how many pies you started with, whether positive, negative, fractional, or real. In the case of negative pies (you borrowed them), your pie debt transferred to the trolls, piecemeal ... your friends might not be happy to get those pies back under those conditions.
Conveniently, you can still start out with zero pies. If the tolls work the same manner going home, you'll even end up with two pies for yourself when you get home :) .
Different tolls
The final part of the question changes the toll so that crossing the bridge with $p$ pies, you leave the bridge with $\frac{p}{k}+1$ pies, for some $k$. (Note: previously, $k=2$.)
Solving the power series expansion and leaving home with $p$ pies, you leave bridge $n$ with $\frac{p}{k^n} + \frac{k^n - 1}{k^{n-1} (k-1)}$ pies.
In the limit as $n$ tends to infinity, you end up with $\frac{k}{k-1}$ pies at grandma's house. If $k \neq 2$, you don't get to grandma's house with a whole number of pies, regardless of how many pies you left home with. So you might as well leave home with no pies if $k \neq 2$.