Skip to content

Commit 4291c35

Browse files
authored
Merge pull request #626 from FinlaySanders/5c-nethack
5c nethack
2 parents 3dd5e7d + 7a27e93 commit 4291c35

16 files changed

Lines changed: 2973 additions & 949 deletions

File tree

config/default.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ vtrace_c_clip = 1.0
107107
prio_alpha = 0.8
108108
prio_beta0 = 0.2
109109

110+
# Verb-eps exploration floor (experimental, Nethack; see src/algo.cu). 0 = off.
111+
verb_eps = 0.0
112+
verb_eps_anneal_start = 0.4
113+
verb_eps_anneal_end = 1.0
114+
110115
[sweep]
111116
metric = score
112117
metric_distribution = linear

config/nethack.ini

Lines changed: 65 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,114 @@
11
[base]
22
env_name = nethack
33
reset_every_horizon = 0
4-
async = 1
4+
async = 0
55

66
[vec]
7-
total_agents = 256
7+
total_agents = 512
88
num_buffers = 4
9-
#num_threads = 8
109
num_threads = 32
11-
action_mask_size = 690
10+
action_mask_size = 734
1211

1312
[env]
14-
gold_coef = 1
15-
exp_coef = 0.0222526733
16-
descent_coef = 4.57267237
17-
xp_coef = 0.648124218
18-
scout_coef = 0.1
19-
hp_coef = 0.00617194036
20-
hunger_coef = 0.01
21-
illegal_penalty = -0.01
22-
death_penalty = -0.112676442
13+
gold_coef = 0.021659979757862095
14+
exp_coef = 0.08341832601491733
15+
descent_coef = 1.0
16+
xp_coef = 0.5926087261188399
17+
scout_coef = 0.025
2318
ac_coef = 1.0
24-
heal_coef = 0.001
25-
status_coef = 0.0116204191
19+
death_penalty = -0.8209825710553373
20+
21+
# flags
22+
# scout reward scales with xp level relative to depth; <= 0 disables
23+
scout_ready = 1.0
24+
# fraction of protection-spell AC excluded from the ac reward; 1 = armor only
25+
ac_nospell = 1.0
26+
# 1 removes the verb from the action space
27+
mask_search20 = 0
28+
mask_run = 0
2629

2730
[policy]
2831
hidden_size = 512
2932
num_layers = 3
3033

3134
[train]
32-
#total_timesteps = 166275056
33-
total_timesteps = 4_000_000_000
34-
minibatch_size = 16384
35-
horizon = 512
36-
learning_rate = 0.00175767997
37-
gamma = 0.993521929
38-
gae_lambda = 0.611256123
39-
replay_ratio = 2.42882919
40-
clip_coef = 0.478926629
41-
vf_coef = 2.29309034
42-
vf_clip_coef = 3.19970345
43-
max_grad_norm = 1.43588173
44-
ent_coef = 0.0192690529
45-
beta1 = 0.9694917707305044
46-
beta2 = 0.9475724955192064
47-
eps = 0.0001
48-
prio_alpha = 0.931300879
49-
prio_beta0 = 0.885229468
35+
total_timesteps = 247765094
36+
minibatch_size = 32768
37+
horizon = 64
38+
learning_rate = 0.011854702184553156
39+
momentum = 0.805399553172738
40+
verb_eps = 0.01
41+
verb_eps_anneal_start = 0.4
42+
verb_eps_anneal_end = 1.0
43+
gamma = 0.9973714278257158
44+
gae_lambda = 0.7339946788354172
45+
replay_ratio = 1.036717410123433
46+
clip_coef = 1.0
47+
vf_coef = 1.8486010633248169
48+
vf_clip_coef = 4.624607731543118
49+
max_grad_norm = 0.902165688849037
50+
ent_coef = 0.008389210353641681
51+
beta1 = 0.805399553172738
52+
beta2 = 0.999139492311758
53+
eps = 1e-14
54+
vtrace_rho_clip = 2.770648671516198
55+
vtrace_c_clip = 4.5026502564349595
56+
prio_alpha = 0.6754855924309153
57+
prio_beta0 = 0.8672463883417074
5058

5159
[sweep]
52-
metric = max_depth
60+
metric = score
5361

5462
[sweep.train.total_timesteps]
5563
distribution = log_normal
5664
min = 1.5e8
5765
max = 4e8
5866
scale = time
5967

60-
[sweep.env.gold_coef]
68+
[sweep.env.exp_coef]
6169
distribution = log_normal
62-
min = 0.001
63-
max = 1.0
70+
min = 0.01
71+
max = 0.1
6472
scale = auto
6573

66-
[sweep.env.exp_coef]
74+
[sweep.env.gold_coef]
6775
distribution = log_normal
68-
min = 0.01
69-
max = 10.0
76+
min = 0.001
77+
max = 0.1
7078
scale = auto
7179

7280
[sweep.env.descent_coef]
73-
distribution = log_normal
74-
min = 0.5
75-
max = 10.0
81+
distribution = uniform
82+
min = 0.0
83+
max = 1.0
7684
scale = auto
7785

7886
[sweep.env.xp_coef]
79-
distribution = log_normal
80-
min = 0.05
87+
distribution = uniform
88+
min = 0.0
8189
max = 1.0
8290
scale = auto
8391

8492
[sweep.env.scout_coef]
8593
distribution = log_normal
86-
min = 0.0001
94+
min = 0.001
8795
max = 0.1
8896
scale = auto
8997

90-
[sweep.env.hp_coef]
91-
distribution = log_normal
92-
min = 0.0005
93-
max = 0.06
94-
scale = auto
95-
96-
[sweep.env.hunger_coef]
97-
distribution = log_normal
98-
min = 0.01
99-
max = 0.25
100-
scale = auto
101-
102-
[sweep.env.illegal_penalty]
103-
distribution = uniform
104-
min = -0.01
105-
max = 0.0
106-
scale = auto
107-
10898
[sweep.env.death_penalty]
10999
distribution = uniform
110100
min = -1.0
111101
max = 0.0
112102
scale = auto
113103

114-
[sweep.env.heal_coef]
115-
distribution = log_normal
116-
min = 0.001
117-
max = 0.1
118-
scale = auto
119-
120-
[sweep.env.status_coef]
121-
distribution = log_normal
122-
min = 0.01
123-
max = 1.0
124-
scale = auto
125-
126-
[sweep.env.ac_coef]
127-
distribution = log_normal
128-
min = 0.01
129-
max = 0.5
130-
scale = auto
104+
#[sweep.train.verb_eps]
105+
#distribution = log_normal
106+
#min = 0.0005
107+
#max = 0.02
108+
#scale = auto
109+
110+
#[sweep.train.verb_eps_anneal_start]
111+
#distribution = uniform
112+
#min = 0.2
113+
#max = 0.8
114+
#scale = auto

ocean/nethack/README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# NetHack
22

33
PufferLib environment for NetHack 3.6.6 over
4-
[fast-nle](https://github.com/FinlaySanders/fast-nle): 22-verb factored
5-
action space (verb, item slot, direction), legality masking,
4+
[fast-nle](https://github.com/FinlaySanders/fast-nle): 26-verb factored
5+
action space (verb, item slot, direction, spell slot), legality masking,
66
decomposed-score reward, custom CUDA encoder/decoder (`ocean/nethack/nethack.cu`).
77

88
## Setup
@@ -39,11 +39,8 @@ Interactive controls (default when stdin is a TTY):
3939
| `Shift+Space` | hold advances at **20 Hz** (fallback: hold `S`) |
4040
| `q` / `Esc` | quit |
4141

42-
Weight resolution: `NH_WEIGHTS` if set, else the highest-step checkpoint in
43-
the **most recently written** run under `checkpoints/nethack/`, else
44-
`resources/nethack/nethack_weights.bin`. (Global max-step is wrong after a
45-
role switch — a mature monk 2B run outranks a fresh valk 200M run.) Set
46-
`NH_SEED` to replay a seed.
42+
Weight resolution: `NH_WEIGHTS` if set, else the checked-in
43+
`resources/nethack/nethack_weights.bin`. Set `NH_SEED` to replay a seed.
4744

4845
```bash
4946
./nethack 10000 0 # headless 10k steps (prints avg_score / avg_max_depth)

ocean/nethack/depth.ini

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# async depth config: sweep-derived depth-seeking rewards (descent-dominated,
2+
# soft death penalty) on the async trainer. To use: copy to config/depth.ini,
3+
# then ./puffer train depth
4+
[base]
5+
env_name = nethack
6+
reset_every_horizon = 0
7+
async = 1
8+
9+
[vec]
10+
total_agents = 256
11+
num_buffers = 4
12+
num_threads = 32
13+
action_mask_size = 734
14+
15+
[env]
16+
gold_coef = 1.0
17+
exp_coef = 0.0222526733
18+
descent_coef = 4.57267237
19+
xp_coef = 0.648124218
20+
scout_coef = 0.1
21+
ac_coef = 0.0
22+
death_penalty = -0.112676442
23+
24+
# flags
25+
# scout reward scales with xp level relative to depth; <= 0 disables
26+
scout_ready = 0.0
27+
# fraction of protection-spell AC excluded from the ac reward; 1 = armor only
28+
ac_nospell = 1.0
29+
# 1 removes the verb from the action space
30+
mask_search20 = 0
31+
mask_run = 0
32+
33+
[policy]
34+
hidden_size = 512
35+
num_layers = 3
36+
37+
[train]
38+
total_timesteps = 247765094
39+
minibatch_size = 16384
40+
horizon = 512
41+
learning_rate = 0.00175767997
42+
anneal_lr = 1
43+
min_lr_ratio = 0.0
44+
momentum = 0.9694917707305044
45+
verb_eps = 0.005
46+
verb_eps_anneal_start = 0.4
47+
verb_eps_anneal_end = 1.0
48+
gamma = 0.993521929
49+
gae_lambda = 0.611256123
50+
replay_ratio = 2.42882919
51+
clip_coef = 0.478926629
52+
vf_coef = 2.29309034
53+
vf_clip_coef = 3.19970345
54+
max_grad_norm = 1.43588173
55+
ent_coef = 0.0192690529
56+
anneal_ent_coef = 0
57+
min_ent_coef_ratio = 0.1
58+
beta1 = 0.9694917707305044
59+
beta2 = 0.9475724955192064
60+
eps = 0.0001
61+
vtrace_rho_clip = 1.0
62+
vtrace_c_clip = 1.0
63+
prio_alpha = 0.931300879
64+
prio_beta0 = 0.885229468

ocean/nethack/fs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static void nethack_touch(const char* path) {
1919
}
2020

2121
static void nethack_rm_rf(const char* path, int depth) {
22-
if (depth > 3) return; // vardir trees are at most base/env/save/files
22+
if (depth > 3) return; // vardir trees are at most base/env/save/files
2323
DIR* d = opendir(path);
2424
if (d) {
2525
struct dirent* e;
@@ -82,7 +82,7 @@ static int nethack_make_vardir(const char* source_hackdir, char* out_buf, size_t
8282

8383
// fail fast on a dangling nhdat symlink: symlink(2) would succeed and the
8484
// error surface later as a cryptic init_dungeons panic
85-
char resolved[4096]; // realpath(3) requires a PATH_MAX buffer
85+
char resolved[4096]; // realpath(3) requires a PATH_MAX buffer
8686
if (realpath(src, resolved) == NULL || access(resolved, R_OK) != 0) {
8787
fprintf(stderr,
8888
"nethack: NETHACKDIR misconfigured — no readable nhdat at %s (%s).\n"

0 commit comments

Comments
 (0)