sotetsuk / pgx

♟️ Vectorized RL game environments in JAX
http://sotets.uk/pgx/
Apache License 2.0
391 stars 25 forks source link

Survey on how to vectorize in other frameworks #354

Closed sotetsuk closed 1 year ago

sotetsuk commented 1 year ago

SyncVectorEnvMarkovVectorEnv を使った比較は最低限行って、rllib を使ったものも追加でやるのがいいか。

OpenSpiel

PettingZoo

sotetsuk commented 1 year ago

https://note.com/npaka/n/n5d7d235ad8bc#ccm2Q

nissymori commented 1 year ago

compile速度のbenchmarkに倣いました.

library game type n_envs steps time time per step
open_spiel go subprocess 10 1000 2.58 0.000258s
petting_zoo go subprocess 10 1000 4.22 0.000422s
open_spiel go forloop 10 1000 1.32 0.000132s
petting_zoo go forloop 10 1000 9.42 0.000942s
nissymori commented 1 year ago

open_spielとpetting zooでsubproc, forloopの速度の関係が逆なのが気になっています. stable_baselinesの実装が悪いのか, open_spielがsub_processに向いていないのか. 少し調べてみます.

sotetsuk commented 1 year ago

compile速度のbenchmarkに倣いました.

library game type n_envs steps time time per step open_spiel go subprocess 10 2.84 0.000284s
petting_zoo go subprocess 10 4.69 0.000469s
open_spiel go forloop 10 1000 1.35 0.000135s petting_zoo go forloop 10 1000 9.46 0.000946s

library game type n_envs steps time time per step
open_spiel go subprocess 10 1000 2.84 0.000284s
petting_zoo go subprocess 10 1000 4.69 0.000469s
open_spiel go forloop 10 1000 1.35 0.000135s
petting_zoo go forloop 10 1000 9.46 0.000946s

こう?まあ 0.0001 sec/step のオーダーではfor-loopの方が速く、0.000946=0.001 sec/stepのオーダーではsubprocessの方が速いって考えれば別におかしくはないと思いますけど。 でもobservationとかの転送速度とかがOpenSpielで遅くなったりしてないか確認したほうがいいかもですね。

nissymori commented 1 year ago

そうですね. 転送速度とりあえず調べてみます.

nissymori commented 1 year ago

TODO 速度比較

open spiel subproc 実装方法比較