models-and-mcts
Inspects and debugs MuZero General networks, tensor shapes, support transforms, GameHistory stacking, and MCTS behavior.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- models-and-mcts
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Inspects and debugs MuZero General networks, tensor shapes, support transforms, GameHistory stacking, and MCTS behavior.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/network-and-mcts-reference.md10.1 KB
- 参考文档references/tensor-shapes-and-support.md7.5 KB
- 参考文档references/troubleshooting.md8.2 KB
- 脚本scripts/model_mcts_smoke.py14.4 KB
03 SKILL.md 正文
Models and MCTS
Use this sub-skill when a task is about MuZero General's model stack or search internals: FC vs ResNet construction, initial_inference / recurrent_inference, support scalar transforms, GameHistory stacking, legal-action masking, root Dirichlet noise, Node / MinMaxStats, or MCTS search-path behavior.
Fast route
-
Read network-and-mcts-reference.md for the architecture factory, verified method signatures, inference outputs, node expansion, MinMaxStats, and search/backpropagation logic.
-
Read tensor-shapes-and-support.md before debugging observation rank, stacked observations, hidden-state/action tensors, policy/value/reward support vectors, or FC-vs-ResNet shape differences.
-
Read troubleshooting.md when there is a shape assertion, empty or illegal legal action list, support-size mismatch, device mismatch, DataParallel confusion, or MCTS runtime blow-up.
-
Run the bundled checker for safe API/tensor validation, not training:
python sub-skills/models-and-mcts/scripts/model_mcts_smoke.py --case both --num-simulations 1Useful checker options:
--case cartpole-fc|tictactoe-resnet|both|custom,--game-module games.tictactoe,--network config|fullyconnected|resnet,--device cpu|cuda|auto,--stacked-observations N,--legal-actions 0,1,--add-exploration-noise, and--json.
Scope and routing boundaries
This sub-skill owns:
models.MuZeroNetwork(config)factory behavior forconfig.network == "fullyconnected"and"resnet".- FC/ResNet config fields that affect model construction and tensor shapes.
initial_inference(observation)andrecurrent_inference(hidden_state, action)output meanings and dimensions.models.scalar_to_support/models.support_to_scalarvalue and reward transforms.self_play.MCTS.run,Node,MinMaxStats,GameHistory.get_stacked_observations, legal-action root masking, Dirichlet root exploration, and one-/two-player value sign handling.- CPU/GPU basics for model/search tensor placement.
Route elsewhere when the task is primarily about:
- Observation/action/player field authoring or custom game wrappers: read sibling sub-skill
games-and-configsat../games-and-configs/SKILL.mdfirst, then return here for tensor/search debugging. - CLI, Ray workers, training loops, replay/trainer orchestration, or TensorBoard runtime: read
training-and-cliat../training-and-cli/SKILL.md. - Loading checkpoints, inspecting saved weights, plotting diagnostics, or determining checkpoint/model compatibility: read
checkpoints-and-diagnosticsat../checkpoints-and-diagnostics/SKILL.md.
Minimal debugging pattern
- Validate the game config fields first:
observation_shape,action_space,players,stacked_observations,network,support_size, and the FC/ResNet layer fields. - Use
model_mcts_smoke.pywith CPU defaults to isolate pure tensor/API issues before involving Ray self-play or training. - For custom games, stage the bundled source with
scripts/stage_muzero_source.py, add the module to that staged copy, then use--repo-root <staged-source> --case custom --game-module <module> --network config; use--legal-actionsto reproduce empty/illegal-action failures deliberately. - If the smoke passes but training fails, cross-link to
training-and-cli; if loading weights fails before the smoke, cross-link tocheckpoints-and-diagnostics.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).