Phase B Contract Baseline

This page is generated by scripts/generate_phase_b_contract_docs.py.

  • Source of truth: docs/phase_b_graph_contract.json
  • Sync check: scripts/check_phase_b_contract_sync.py

Phase B Graph Contract (Auto-generated)

  • Contract version: phase_b_v0.2.8
  • As-of date: 2026-04-09
  • Source of truth: docs/phase_b_graph_contract.json
  • CI sync checker: python scripts/check_phase_b_contract_sync.py

Graph Support Scope

Op Rank DType Layout Shape Constraint
matmul in(2,2)->out(2) float32,float64 contiguous A[m,k], B[k,n], Out[m,n]
vector_add in(any,any)->out(any) float32,float64 contiguous in0.shape == in1.shape == out.shape
matrix_sub / matrix_div in(2,2)->out(2) float32,float64 contiguous in0.shape == in1.shape == out.shape
attention_forward in(2,2,2)->out(2) float32 contiguous q.shape == k.shape == v.shape == out.shape
conv2d_nchw3x3 in(4,4[,1])->out(4) float32 contiguous x[N,C,H,W], w[OC,C,3,3], out_h=(H+2pad_h-3)/stride_h+1, out_w=(W+2pad_w-3)/stride_w+1, optional bias[OC], optional apply_relu
conv2d_nchw3x3s1p1 in(4,4[,1])->out(4) float32 contiguous fixed stride/pad path equivalent to conv2d_nchw3x3(stride=1,pad=1)
qkv_pack_repeat in(4)->out(2,2,2) float32 contiguous flatten conv output, truncate/repeat into q/k/v with identical [seq,head_dim] shapes
relu in(any)->out(any) float32,float64 contiguous out.shape == in.shape

Fallback Reason Codes

Reason Code Description
fallback_preferred_unsupported preferred backend is not supported by schema
fallback_preferred_unavailable preferred backend is declared but not currently available
fallback_planner_optimized planner selected non-preferred backend to reduce boundary/sync churn
graph_engine_not_lightning graph execution requested but route_policy.graph resolved to non-lightning engine; deterministic eager fallback
graph_shape_unsupported graph execution requested but shape/kernel contract is outside graph-supported conv->attn path; deterministic eager fallback
torch_unavailable_fallback torch route requested but torch runtime unavailable; deterministic lightning fallback

Validation Passes

  • schema_contract
  • topology
  • alias_lifetime
  • layout_flow
  • backend_capability

Numerical Tolerances

DType atol rtol
float32 0.0001 0.0001
float64 1e-08 1e-08

CI Constants (Phase B)

Section Key Value
graph_eager_ab warmup 4
graph_eager_ab iters 12
graph_eager_ab trace_iters 6
graph_eager_ab fusion_cost_min_speedup 1.01
graph_eager_ab min_host_dispatch_reduction_rate_pct 25.0
graph_eager_ab min_chained_latency_reduction_pct 15.0
graph_eager_ab max_unsupported_ratio_pct 40.0
fusion_pilot max_fused_over_unfused_conv 1.15
fusion_pilot max_fused_over_unfused_matmul 1.9
fusion_pilot max_fused_over_unfused_attention 2.2
planner_cache target_min_hit_rate_pct 50.0
phase_b_exit_audit min_graph_pipeline_adoption_rate_pct 100.0
phase_b_exit_audit allow_chain_latency_not_applicable True
phase_b_exit_audit required_graph_benches ['matmul_matrix_sub', 'conv_attention_torchstrong_nchw', 'matmul_bias_relu_fusion_path']