liangsu9988 commited on
Commit
5e8586f
·
verified ·
1 Parent(s): 12b8c99

Restore package README; record v2 verdict and structural downgrade

Browse files
Files changed (2) hide show
  1. README.md +24 -25
  2. benchmarks/RESULTS.md +20 -9
README.md CHANGED
@@ -1,33 +1,32 @@
1
- # pi052 Training Optimization Workspace
2
 
3
- This workspace records the pi052 training optimization plan, baseline tests,
4
- profiles, and environment notes. It is intentionally separate from the
5
- `lerobot/` source tree so optimization experiments do not mix with upstream
6
- code changes.
7
 
8
- Current policy:
9
 
10
- - Main test machine: RTX 5080 server at `internal.mindon.tech:20001`.
11
- - Thor server is parked for now; it is not the training test target.
12
- - Hugging Face Jobs are a final validation path only, and only A100 is planned.
13
- - HF Jobs budget target: keep early validation under a few dozen dollars.
14
- - Prefer China-friendly mirrors and ModelScope for downloads.
15
 
16
- Directory layout:
 
 
 
 
17
 
18
- - `docs/`: plans, environment records, and test protocols.
19
- - `scripts/`: helper scripts for remote setup, probing, and later test runs.
20
- - `results/`: JSON/CSV/text outputs from tests.
21
- - `profiles/`: torch profiler traces and summaries.
22
- - `env/`: requirements and environment lock notes.
23
 
24
- No pi052 model code should be edited from this workspace directly. Source
25
- changes should happen in `../lerobot/` after the baseline tests are in place.
26
 
27
- Primary planning documents:
 
 
 
 
 
 
28
 
29
- - `docs/plan.md`: phase-level strategy.
30
- - `docs/proof_tests.md`: exact tests and proof thresholds before coding.
31
- - `docs/baseline_tests.md`: shorter baseline checklist.
32
- - `docs/status.md`: what has already been prepared.
33
- - `docs/proof_results_initial.md`: first synthetic proof-test results.
 
1
+ # flashrt-flex-attention-train
2
 
3
+ FlexAttention replacement training package for PI-style dual-expert
4
+ transformers.
 
 
5
 
6
+ Hub repo: `flashrt/flashrt-flex-attention-train`
7
 
8
+ ## Public API
 
 
 
 
9
 
10
+ - `flex_attention`
11
+ - `flex_attention_forward`
12
+ - `reference_flex_attention`
13
+ - `build_block_sparse_bool_masks`
14
+ - `backend_marker`
15
 
16
+ ## Scope
 
 
 
 
17
 
18
+ This package locks the public Tensor API and correctness harness for a native
19
+ replacement of the PI052 FlexAttention/SDPA attention path:
20
 
21
+ - prefix self-attention rows
22
+ - action-to-prefix rows plus block-diagonal action rows
23
+ - `head_dim=256`
24
+ - BF16 forward/backward through PyTorch autograd fallback
25
+ - detached-prefix semantics for action rows reading prefix K/V
26
+ - prefix mask, prefix padding mask, action block mask, and action padding mask
27
+ - automatic SDPA fallback for unsupported shapes
28
 
29
+ The current implementation is the SDPA-backed training reference. It is meant
30
+ to be the stable integration target for native CUDA fwd/bwd kernels; no native
31
+ performance claim is made until the benchmark gates in `VALIDATION.md` pass on
32
+ both A100 and RTX 5090.
 
benchmarks/RESULTS.md CHANGED
@@ -64,16 +64,27 @@ CUDA with no dropout, SDPA elsewhere.
64
  (128x128 for P>=896-class shapes).
65
  - A100/H100/H200: SDPA path (see the verdict table).
66
 
67
- ## Next levers (not yet implemented)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
- 1. Structural 3-GEMM split: the prefix part computes a dense P x P even
70
- though the (att=0 rows x att=1 cols) quadrant is fully masked
71
- (~20% wasted FLOPs at p700) and the action part's cross-chunk block
72
- is near-empty. Splitting Q into (group-0, group-1, action) rows cuts
73
- both.
74
- 2. Custom autograd saving bf16 probabilities only (halves saved-activation
75
- bytes and backward traffic).
76
- 3. Native CUDA fused kernel: manual sits at ~20% of bf16 peak on the
77
  5090 (harness-inclusive); an FA2-style specialized kernel
78
  (D=256, GQA, prefix-dense + action-block) targeting 40-50% would be
79
  another ~2x. Entry per house rules: only after 1-2 are in and the
 
64
  (128x128 for P>=896-class shapes).
65
  - A100/H100/H200: SDPA path (see the verdict table).
66
 
67
+ ## Measured and closed follow-up levers (2026-07-09)
68
+
69
+ 1. **bf16-saved-p custom autograd (`manual_attention_part_v2`): REJECTED
70
+ end-to-end.** Against the EAGER composed part it wins 1.32-1.48x
71
+ fwd+bwd (fused softmax-gradient chain) — but the production form is
72
+ the composed part under `torch.compile`, where AOTAutograd's
73
+ partitioner already generates a fused backward and manages what gets
74
+ saved; the hand-written Function blocks that whole-graph treatment
75
+ and measured slower on the real model (text step 341.6 vs 333.3 ms
76
+ on a 5090). The symbol stays exported for API stability and as the
77
+ documented negative. Lesson (third time this project): compare
78
+ against the PRODUCTION form of the baseline, not its eager form.
79
+ 2. **Structural 3-GEMM split: DOWNGRADED.** The synthetic harness's
80
+ half/half att pattern overstates it — on the real model, flow-step
81
+ prefixes are fully bidirectional (no maskable quadrant) and text-step
82
+ causal spans vary per sample (no uniform split). The remaining
83
+ uniform win is the action cross-chunk block (~7% of attention
84
+ FLOPs); not scheduled.
85
 
86
+ ## Next levers (not yet implemented)
87
+ 1. Native CUDA fused kernel: manual sits at ~20% of bf16 peak on the
 
 
 
 
 
 
88
  5090 (harness-inclusive); an FA2-style specialized kernel
89
  (D=256, GQA, prefix-dense + action-block) targeting 40-50% would be
90
  another ~2x. Entry per house rules: only after 1-2 are in and the