5 ms·
Solving poker in custom WebGPU kernels
I wanted to build a poker solver that I could host for ~free. This meant running client-side, where the best browser technology is WebGPU. The tensor library I wanted did not exist, but in the LLM era we sometimes don't need libraries at all. I had Codex turn my thousands of lines of PyTorch code into custom WebGPU kernels with parity tests. Codex then spent days optimizing those kernels.
You can use the solver at https://holdem.computer https://holdem.computer, and the source is at https://github.com/phulin/poker2 https://github.com/phulin/poker2.
- deleted 2mo ago[deleted]
- bluecalm 2mo ago>>A more modern approach instead “re-solves” each spot to a limited search depth and uses a neural network as an approximation function at the depth cutoff. Both tabular (e.g. Piosolver) and neural (e.g. GTOWizard) commercial solvers are available. PioSOLVER doesn't use any abstractions or cutoff functions. It just solves the whole game without any simplifications other than allowed bet sizes. The cost is rather large RAM requirements. The advantages is that it's very precise and produces exact results for every hand (it doesn't bundle them).
- beepbooptheory 2mo agoMan was really excited for some poker-themed computer science blogging like back in the day but really I guess shoulda known huh :/.
- mncalc7 2mo agoYou should check out https://jax-js.com/ https://jax-js.com/. It has parity with quite a large surface area of Jax, and compiles natively in the browser to wasm and webGPU, entirely written in JS.
- patrickhulin 2mo agoOh, this is neat! I knew posting something that claimed a library didn't exist would inevitably surface one :)
- ryanto 2mo agoWow, this is amazing, great read too. I have a few "test spots" I like to use with solvers and yours nailed them. >A more modern approach instead “re-solves” each spot to a limited search depth and uses a neural network as an approximation function at the depth cutoff. This sounds very interesting, I'd love to hear more about it. A few years ago a wrote a solver that worked by reducing the entire game tree. It was slow, and couldn't do preflop. It sounds like these re-solves allow preflop solves with needing a massive tree?
- noname123 2mo agoQQ for all the pro players out there, for 6 or 9-ring poker, can solvers really solve every scenario - or there is simply too many permutations. The other question I have is how do human players adapt to GTO play now? Like in other games, humans have adapted to novel strategies - I'm curious for poker whether there's ways to exploit GTO solvers (ie, if you put your opponent bot on the GTO range and chase the fat tails). And is the poker community's fair play detection algorithm good enough to catch players who use solvers like chess community - or it's easy to evade by making a few deviations. Much thanks!
- ryanto 2mo ago- for 6 and 9 handed, yes they can solve any 2 player scenario you give it. you solve to some expected loss (like 1%), so it's not a perfect solve. you can solve lower, but it takes longer. in theory there are multiway hands that are unsolvable. - human players adapt to GTO by leaving the game. you are not beating a solver. solvers by their very design are unexploitable. - sites can catch players that use solvers if they care to. in my experience there are sites that care and others that dont, depends on the market. regs know who is cheating.
- fierycatnet 2mo agoNot a pro player but I do well enough recreationally in local clubs when I play. GTO in my experience is really not a threat. Most players dont play GTO and against bad players GTO is not a factor. I've played with solvers before but I see no value for my current stakes. Nor do I feel that GTO is important. Perhaps in computer simulations but... its all theoretical and just fun and games. You'd need to play HU against Phil Galfond if you want GTO to be useful but how many players will be challenged like that?
- comrh 2mo agoI also play recreationally and pretty much agree. The average person at $1/2 or $2/5 is playing on mostly emotion no where near GTO. I think it does have some benefit in how you think about the game, how to mix in bluffs, expected value, but it's not really GTO math specific and more general ideas.
- keeganpoppen 2mo ago"LLMs are just fancy autocomplete" xD
- archerx 2mo agoIt autocompleted the PyTorch library into webGPU…
- squibonpig 2mo agoOh yo sick I've been thinking about making a solver too with them being so overpriced. Will be super fun to mess with this.
- logicallee 2mo agoThis thread seems like a good thread to ask in: In the poker subreddits the rake question comes up from time to time, and with the low cost and high quality of inference I have been considering making rake-free poker. The model is a small monthly subscription like $4.99/month for low stakes $9.99/month for mid stakes, one account per player, 20 tables max. This actually would make a lot of marginally losing spots into winners, and there are a lot of coin flips where after rake both players lose. So if you keep coin flipping, you just lose over time. (But you don't want to fold and give up your equity for free either.) The thing that gives me pause is that a lot of people cheat using solvers during hands, bots, or collusion. Is there anything I could do at a practical level to keep the game fair? (no tools, no bots, no collusion.)
- bluecalm 2mo agoWith any kind of gambling site your major cost will be credit cards chargebacks and other fraud. >>Is there anything I could do at a practical level to keep the game fair? (no tools, no bots, no collusion.) You can try catching unsophisticated cheaters. It will be expensive. There isn't anything you can do about sophisticated dedicated cheaters.
- logicallee 2mo agoThanks, that's good to know.
- 7373737373 2mo agoIs it possible to have a website compute as efficiently and utilize the system it runs on as completely as a native application can? Or do browsers introduce limits?
- osti 2mo agoDo you have any numbers on the solve quality? Exploitability numbers etc.
- lazyant 2mo agoI guess I don't understand what's going on. Solver says in 1-2 to raise 85% of hands to 6 as SM. Then the response by BB is to raise to 18 with 98% of hands!?