Skip to content

Commit 2564763

Browse files
authored
Merge pull request #621 from FinlaySanders/nethack
Merging this here, will pull it on to 5c and test there
2 parents 373723f + 82fddbc commit 2564763

20 files changed

Lines changed: 4246 additions & 2107 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,5 @@ pufferlib/ocean/impulse_wars/benchmark/
172172
resources/drive/data/*
173173
resources/drive/binaries/*
174174

175+
vendor/nle/
176+
vendor/fast-nle/

build.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,20 @@ elif [ "$ENV" = "impulse_wars" ]; then
119119
LINK_ARCHIVES+=("./$BOX2D_NAME/libbox2d.a")
120120
elif [ "$ENV" = "nethack" ]; then
121121
SRC_DIR="ocean/$ENV"
122-
NLE_DIR="vendor/nle"
123-
NLE_REPO="https://github.com/liujonathan24/NetHack.git"
122+
NLE_DIR="vendor/fast-nle"
123+
NLE_REPO="https://github.com/FinlaySanders/fast-nle.git"
124124
if [ ! -d "$NLE_DIR/src" ]; then
125-
echo "Cloning modified NLE from $NLE_REPO ..."
125+
echo "Cloning fast-nle from $NLE_REPO ..."
126126
git clone --depth 1 "$NLE_REPO" "$NLE_DIR"
127127
fi
128-
NETHACK_LIB_DIR="$(pwd)/$NLE_DIR/src/build"
128+
NETHACK_LIB_DIR="$(pwd)/$NLE_DIR/build"
129129
if [ ! -f "$NETHACK_LIB_DIR/libnethack.so" ]; then
130130
echo "Building libnethack.so ..."
131-
make -C "$NETHACK_LIB_DIR" nethack -j$(nproc)
131+
cmake -S "$NLE_DIR" -B "$NETHACK_LIB_DIR" -DCMAKE_BUILD_TYPE=Release
132+
cmake --build "$NETHACK_LIB_DIR" --target nethack -j$(nproc)
132133
fi
133-
INCLUDES+=(-I./$NLE_DIR/include)
134+
INCLUDES+=(-I./$NLE_DIR/include
135+
-I./$NLE_DIR/build/_deps/deboost_context-src/include)
134136
EXTRA_LDFLAGS+=(-L"$NETHACK_LIB_DIR" -lnethack -Wl,-rpath,"$NETHACK_LIB_DIR" -ldl)
135137
elif [ -d "ocean/$ENV" ]; then
136138
SRC_DIR="ocean/$ENV"

config/nethack.ini

Lines changed: 89 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,129 @@
11
[base]
22
env_name = nethack
3+
cudagraphs = 2
34

45
[vec]
5-
total_agents = 4096
6-
num_buffers = 2
7-
num_threads = 16
8-
seed = 73
6+
total_agents = 512
7+
num_buffers = 4
8+
num_threads = 32
99

1010
[env]
11-
# Reward shaping. Each coef is independently toggleable: set to 0 to disable
12-
# the term. See ocean/nethack/REWARDS.md for the recipe + future candidates.
13-
# CLI: --env.score-coef, --env.descent-coef, --env.scout-coef, --env.illegal-penalty
14-
score_coef = 0.01
15-
descent_coef = 10.0
16-
scout_coef = 0.1
17-
illegal_penalty = -0.1
11+
gold_coef = 0.03540707780083026
12+
exp_coef = 0.25886063598802184
13+
descent_coef = 1.8884272008758112
14+
xp_coef = 0.28073502137812123
15+
scout_coef = 0.01689042846824247
16+
hp_coef = 0.018973887012487405
17+
hunger_coef = 0.023586377138546992
18+
illegal_penalty = -0.006951422236819335
19+
death_penalty = -0.6335992931154887
20+
ac_coef = 0.01
21+
heal_coef = 0.001
22+
status_coef = 0.01
1823

1924
[policy]
2025
hidden_size = 512
21-
num_layers = 4
22-
expansion_factor = 2
26+
num_layers = 3
27+
expansion_factor = 1
2328

2429
[train]
25-
gpus = 1
26-
seed = 42
27-
total_timesteps = 1443360107
28-
learning_rate = 0.00224872
29-
anneal_lr = 1
30-
min_lr_ratio = 0
31-
gamma = 0.99816
32-
gae_lambda = 0.696214
33-
replay_ratio = 2.2381
34-
clip_coef = 0.20
35-
vf_coef = 0.1
36-
vf_clip_coef = 0.01
37-
max_grad_norm = 1.14364
38-
ent_coef = 0.10
39-
beta1 = 0.981226
40-
beta2 = 0.994178
41-
eps = 1.82223e-06
30+
total_timesteps = 179_453_112
4231
minibatch_size = 32768
43-
horizon = 256
44-
vtrace_rho_clip = 3.24229
45-
vtrace_c_clip = 3.95664
46-
prio_alpha = 1
47-
prio_beta0 = 0.555562
48-
env = 0
32+
horizon = 64
33+
learning_rate = 0.013102893141695623
34+
gamma = 0.995330546979216
35+
gae_lambda = 0.7296684290473575
36+
replay_ratio = 1.393745327111498
37+
clip_coef = 1
38+
vf_coef = 2.967784385898158
39+
vf_clip_coef = 4.084322349420867
40+
max_grad_norm = 1.0968230967915535
41+
ent_coef = 0.005217403062762164
42+
beta1 = 0.8250073190394559
43+
beta2 = 0.9935894811507382
44+
eps = 3.82673948478513e-13
45+
vtrace_rho_clip = 3.8767312776569813
46+
vtrace_c_clip = 4.60481789092722
47+
prio_alpha = 0.7459213056962047
48+
prio_beta0 = 0.7387749352151263
4949

5050
[sweep]
51-
method = Random
52-
metric = depth
53-
goal = maximize
54-
downsample = 4
55-
max_runs = 2
56-
gpus = 1
57-
max_suggestion_cost = 1500
58-
59-
[sweep.env.score_coef]
51+
metric = score
52+
53+
[sweep.train.total_timesteps]
54+
distribution = log_normal
55+
min = 1.5e8
56+
max = 4e8
57+
scale = time
58+
59+
[sweep.env.gold_coef]
6060
distribution = log_normal
6161
min = 0.001
62-
mean = 0.01
63-
max = 0.1
62+
max = 1.0
63+
scale = auto
64+
65+
[sweep.env.exp_coef]
66+
distribution = log_normal
67+
min = 0.01
68+
max = 10.0
6469
scale = auto
6570

6671
[sweep.env.descent_coef]
67-
distribution = uniform
68-
min = 0.0
69-
mean = 10.0
70-
max = 50.0
72+
distribution = log_normal
73+
min = 0.5
74+
max = 10.0
75+
scale = auto
76+
77+
[sweep.env.xp_coef]
78+
distribution = log_normal
79+
min = 0.05
80+
max = 1.0
7181
scale = auto
7282

7383
[sweep.env.scout_coef]
74-
distribution = uniform
75-
min = 0.0
76-
mean = 0.1
77-
max = 2.0
84+
distribution = log_normal
85+
min = 0.0001
86+
max = 0.1
7887
scale = auto
7988

80-
[sweep.env.illegal_penalty]
81-
distribution = uniform
82-
min = -2.0
83-
mean = -0.5
84-
max = 0.0
89+
[sweep.env.hp_coef]
90+
distribution = log_normal
91+
min = 0.0005
92+
max = 0.06
8593
scale = auto
8694

87-
[sweep.train.learning_rate]
95+
[sweep.env.hunger_coef]
8896
distribution = log_normal
89-
min = 0.0001
90-
mean = 0.002
91-
max = 0.01
97+
min = 0.01
98+
max = 0.25
9299
scale = auto
93100

94-
[sweep.train.gamma]
101+
[sweep.env.illegal_penalty]
95102
distribution = uniform
96-
min = 0.99
97-
mean = 0.998
98-
max = 0.9999
103+
min = -0.01
104+
max = 0.0
99105
scale = auto
100106

101-
[sweep.train.gae_lambda]
107+
[sweep.env.death_penalty]
102108
distribution = uniform
103-
min = 0.5
104-
mean = 0.7
105-
max = 0.99
109+
min = -1.0
110+
max = 0.0
106111
scale = auto
107112

108-
[sweep.train.ent_coef]
113+
[sweep.env.heal_coef]
109114
distribution = log_normal
110115
min = 0.001
111-
mean = 0.1
112-
max = 0.5
116+
max = 0.1
113117
scale = auto
114118

115-
[sweep.train.max_grad_norm]
116-
distribution = uniform
117-
min = 0.1
118-
mean = 1.0
119-
max = 3.0
119+
[sweep.env.status_coef]
120+
distribution = log_normal
121+
min = 0.01
122+
max = 1.0
123+
scale = auto
124+
125+
[sweep.env.ac_coef]
126+
distribution = log_normal
127+
min = 0.01
128+
max = 0.5
120129
scale = auto

0 commit comments

Comments
 (0)