AGENT SKILL

palm-modeling

Operate the PaLM transformer core in palm-rlhf-pytorch: construction, loss/generation checks, LoRA finetuning scopes, flash-attention choices, and reference-only pretraining.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
palm-modeling
license
MIT
metadata
{ "disco-role": "operating" }
description
Operate the PaLM transformer core in palm-rlhf-pytorch: construction, loss/generation checks, LoRA finetuning scopes, flash-attention choices, and reference-only pretraining.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

PaLM Modeling

Use this sub-skill when a task is about the package's base PaLM transformer rather than reward models or policy-optimization trainer loops.

Route Here For

  • Constructing a PaLM model for autoregressive language modeling or non-causal embedding use.
  • Running a tiny loss/backward/logits/embedding/generation smoke check with scripts/tiny_palm_smoke.py.
  • Understanding PaLM.forward, PaLM.generate, sampling helpers, embedding/logit return modes, save/load, dropout changes, and LoRA finetune scopes.
  • Deciding whether to enable flash_attn=True; this package uses PyTorch scaled-dot-product attention, not the external flash-attn package.
  • Adapting the repository's PaLM pretraining flow as a reference-only recipe without running the expensive source training script.

Do Not Use This For

  • Reward scoring, binned rewards, prompt masks, or implicit process rewards; route those to the reward-modeling sub-skill.
  • PPO, GRPO, TPO, FlowRL, RLHFTrainer, or post-training loops; route those to the policy-optimization sub-skill.
  • Full-scale enwik8 training or benchmark-quality model recovery. This sub-skill covers mechanics and bounded checks, not long training.

Start Here

  1. For API facts and shapes, read references/api-reference.md.
  2. For the distilled pretraining recipe and why the original training flow is reference-only, read references/pretraining-workflows.md.
  3. For common failures, read references/troubleshooting.md.
  4. To verify an installed package quickly, run the bundled helper instead of any source-repo script:
python sub-skills/palm-modeling/scripts/tiny_palm_smoke.py --device auto --check-lora

If running from inside this sub-skill directory, use:

python scripts/tiny_palm_smoke.py --device auto --check-lora

Operating Notes

  • Prefer device-neutral examples: create a torch.device, move model and tensors with .to(device), and avoid README-style unconditional .cuda() calls on CPU hosts.
  • Keep generation targets explicit: generate(seq_len, prompt=...) treats seq_len as the target total length. With the default return_seq_without_prompt=True, the returned tensor is only the generated suffix of length seq_len - prompt_len when seq_len > prompt_len.
  • Use palm.palm_parameters() for base pretraining optimizers and palm.finetune_parameters(scope) only after creating a matching LoRA scope.
  • flash_attn=True compares the torch SDPA backend, not a separate flash-attn dependency. Treat it as an optional acceleration choice.
  • The base model can return logits, embeddings, or both; use the tiny smoke helper to confirm the shapes before debugging a larger workflow.
  • The source training recipe is reference-only because it is long-running and depends on a missing extra in the repository metadata.

Common Prompt Patterns

  • "Build a small causal LM smoke test" → use the bundled tiny smoke helper.
  • "Check generation length or logits shape" → use return_logits_with_embedding=True or return_seq_without_prompt=False.
  • "Add and merge a LoRA scope" → create a fresh unique scope, train only finetune_parameters(scope), then merge intentionally.
  • "Should I set flash_attn=True?" → yes only when you are intentionally comparing the SDPA path.
  • "Can I run the pretraining script unchanged?" → not as a default runtime workflow; treat it as reference-only and note the missing lion_pytorch extra.

Quick Decision Points

  • If the task is about next-token loss or embedding shapes, use a tiny PaLM smoke before anything larger.
  • If the task is about device portability, use .to(device) in examples and avoid unconditional .cuda() calls.
  • If the task is about LoRA parameters, keep base and adapter optimizers separate unless you explicitly want a merged model.
  • If the task is about pretrained weights, remember the repository does not ship a checkpoint.
  • If the task is about long training, point the user to the pretraining reference and explain that it is not a smoke path.

Tiny Verification Checklist

A correct tiny check should:

  • instantiate a very small PaLM on the selected device;
  • compute a scalar loss and call backward();
  • confirm logits shape (batch, seq_len, num_tokens);
  • confirm embedding shape (batch, seq_len, dim);
  • confirm suffix length seq_len - prompt_len when the prompt is omitted from the return;
  • optionally add, use, remove, and merge a LoRA scope.

Related Files

  • references/api-reference.md for verified signatures and generation semantics.
  • references/pretraining-workflows.md for the distilled training recipe and why it is reference-only.
  • references/troubleshooting.md for CPU/device, flash-attn, generation, and LoRA issues.
  • scripts/tiny_palm_smoke.py for the safe runnable smoke check.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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).

★ 351