Add Craftax-Classic env to Ocean#531
Merged
jsuarez5341 merged 2 commits intoPufferAI:4.0from Apr 18, 2026
Merged
Conversation
Single-header per-env port of Craftax-Classic (Matthews et al. ICML 2024),
following the ocean/drmario template.
ocean/craftax/craftax.h struct + c_init/reset/step/close/render,
AVX-512 Perlin worldgen, per-tile mob
occupancy bitmaps
ocean/craftax/binding.c OBS_SIZE=1345, NUM_ATNS=1, ACT_SIZES={17},
my_init, my_log
config/ocean/craftax.ini minimal (matches post-drmario template)
Observation: 1345 float32 (7x9 tiles x 21 channels + 22 scalar), matches
the JAX Craftax-Classic-Symbolic-v1 layout exactly.
Action: 1 discrete in [0, 17).
Log: perf (= achievements/22), score, episode_return, episode_length,
plus one counter per achievement.
Training sanity (RTX PRO 6000 Blackwell, 30s, default config):
SPS: 2.5M at 99% GPU utilization
perf: 0.69 (15/22 achievements unlocked)
episode_return: 14.1, avg episode length 312
Agent cleanly learns wood -> table -> wood_pick -> wood_sword -> plant,
progresses to drink, collect_stone, defeat_zombie. No NaN/divergence.
AVX-512 in generate_world is enabled via function-level
__attribute__((target(...))), so the env itself does not require any
build.sh changes.
Derived from github.com/Infatoshi/craftax.c (standalone C/AVX-512 port,
47.8M SPS env-only bench). The Ocean port strips that project's batched
OpenMP harness since vecenv.h already OMPs across env instances.
Mirror the existing cuDNN fallback block for NCCL. When NCCL is provided
by the nvidia-nccl-cu12 wheel in the active venv rather than a system
install, the build otherwise fails with
src/pufferlib.cu:5:10: fatal error: nccl.h: No such file or directory
Same search pattern as cuDNN: check common system paths first, then
fall back to python -c "import nvidia.nccl".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Single-header port of Craftax-Classic (Matthews et al., ICML 2024).
Follows the
ocean/drmariotemplate:craftax.h+binding.c+config/ocean/craftax.ini.Observation: 1345 float32 (7x9 tiles x 21 channels one-hot + 22 scalar) — matches the JAX
Craftax-Classic-Symbolic-v1layout exactly.Action: 1 discrete in
[0, 17)(noop, 4 moves, do, sleep, 4 place, 3 make-pick, 3 make-sword).Log:
perf = achievements/22,score,episode_return,episode_length, plus one counter per achievement.Training sanity
RTX PRO 6000 Blackwell, ~30 seconds of training, default config from this PR:
Agent cleanly learns wood → table → wood_pick → wood_sword → plant, progresses to drink / collect_stone / defeat_zombie. No NaN / divergence.
Implementation notes
__attribute__((target(...))), so the env itself requires no build.sh flag changes.craftax.cproject, so no per-env vs batched rework was needed.Commits
Future work
Happy to follow up in separate PRs:
Both are noted here rather than shipped so the env PR stays minimal.
Provenance
Derived from https://github.com/Infatoshi/craftax.c (standalone C/AVX-512 port, 47.8M SPS env-only bench). The Ocean port strips that project's batched-OpenMP harness since `src/vecenv.h` already OMPs across env instances.