architecture-and-loading
Operate Baichuan-7B architecture, local source loading, tiny synthetic forward checks, Hugging Face inference loading, and generation/cache preparation.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- architecture-and-loading
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Operate Baichuan-7B architecture, local source loading, tiny synthetic forward checks, Hugging Face inference loading, and generation/cache preparation.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/troubleshooting.md6.4 KB
- 参考文档references/workflows.md10.0 KB
- 脚本scripts/local_model_smoke.py10.3 KB
03 SKILL.md 正文
Architecture and Loading
Use this sub-skill when the user asks to load or inspect Baichuan-7B model code, reason about BaiChuanConfig defaults, construct BaiChuanForCausalLM, run a tiny local forward smoke, understand generate()/cache preparation, or debug attention/head shape constraints.
Route here for
- Loading Baichuan-7B or compatible local weights with Hugging Face
AutoTokenizer/AutoModelForCausalLMandtrust_remote_code=True. - Inspecting the local classes
BaiChuanConfig,Model,Attention,DecoderLayer, andBaiChuanForCausalLM. - Running a safe config-only smoke that needs no official 7B weights, no datasets, and no network.
- Explaining generation preparation:
past_key_values,attention_mask,position_ids,use_cache, and newer Transformers generation warnings. - Diagnosing invalid
hidden_size/num_attention_headscombinations or direct attention-mask shape errors.
Do not route here for
- C-Eval/MMLU benchmark data, scoring commands, or result files: use sibling
evaluation-workflows. - DeepSpeed pretraining, corpus shards, tokenizer placement for training, hostfiles, or cluster launch commands: use sibling
pretraining-and-deepspeed. - General package installation decisions that affect multiple workflows: start at the parent root skill and shared troubleshooting.
Operating map
- For a quick answer, read workflows first.
- For local source verification, run scripts/local_model_smoke.py with
--repo-root /path/to/Baichuan-7B. - For known failures, read local troubleshooting, then escalate cross-cutting install/backend issues to shared troubleshooting.
- For broader API placement, use the parent Baichuan-7B repo skill and shared API reference.
Minimal safe smoke
python sub-skills/architecture-and-loading/scripts/local_model_smoke.py --repo-root /path/to/Baichuan-7B
Expected coverage: local source import, tiny BaiChuanConfig, eval-mode BaiChuanForCausalLM forward, logits shape (1, 4, 32), finite causal-LM loss, cache-aware prepare_inputs_for_generation, invalid head-divisibility failure, and has_generate reporting.
Add --cuda only when the user explicitly wants a CUDA availability/allocation check; it does not download or run the real 7B model.
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).