force selected pipeline stages in throughput mode
Validate Operations / validate-operations (push) Has been cancelled

increase throughput scheduler budget
add experimental throughput auto mode
This commit is contained in:
NiccoloN
2026-11-02 12:08:33 +01:00
parent 4168b588fa
commit 4a1fe710b2
35 changed files with 2047 additions and 398 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ Boolean switches default to off unless stated otherwise.
| `--maccel=PIM` | Select the PIM accelerator. |
| `--EmitSpatial`, `--EmitPim`, `--EmitPimBufferized`, `--EmitPimCodegen` | Stop at a pipeline stage; default: codegen. |
| `--core-count=N`, `--crossbar-size=N`, `--crossbar-count=N` | Required hardware resources; crossbars are square. |
| `--pipeline=N` | Static queue-aware throughput selection for final codegen with N > 1; intermediate targets retain the original schedule. Default: 1 (latency PEFT). |
| `--pipeline=N\|auto` | Default: 1 (latency PEFT). N > 1 requires exactly N nonempty compute stages. `auto` compares stage counts with static queue-aware throughput costs. Auto requires final codegen; numeric intermediate targets use the initialized schedule. |
| `--pim-target-config=PATH` | Target cost/topology configuration; resources must match hardware flags. Default: built-in model. |
| `--pim-memory-report=summary\|none` | Memory report at `reports/memory_report.txt`; default: `summary`. |
| `--pim-only-codegen` | Run the codegen tail on bufferized Pim IR. |
+22 -1
View File
@@ -138,7 +138,10 @@ remain approximations, not extra inferred memory traffic.
adjustment between physical execution cost and nominal volume priority, scaling
it by chunk lanes. Initialization uses nominal priorities; transposes count as
bulk moves there. One joint prefix/resource DP constructs the initial partition.
Bounded beam refinement changes partitions and their core allocations together.
Bounded incumbent/frontier refinement changes partitions and core allocations together.
Numeric depths require exactly that many nonempty compute stages throughout both DPs,
packing, refinement, and realization. Auto uses the same optimizer across a bounded
stage-count domain; all depths share the queue-evaluation budget.
Queue-aware Spatial evaluation scores every admitted physical placement. PEFT,
final schedule evaluation, and reported per-core demand use physical estimates.
These quantities must not be substituted for measured simulator periods.
@@ -255,3 +258,21 @@ Storage costs `O(P+R+G D)` for bounded generation count `G`, plus bounded recurr
Reports separate extraction, expansion, and queue-analysis times.
Fingerprints compare memory and blocking-operation order, without addresses or work between requests.
Equal fingerprints therefore do not prove equal request readiness or timing.
### Shared automatic-depth initialization
`PipelinePartitionTable` owns the ordered segment costs and joint prefix/resource
states. Automatic depth shares integer-core segment curves across its depth
initializations. Each depth samples its original bounded resource grid.
Its reserved-core count changes that grid, so identical DP states are not available across depths.
Both modes use the same recurrence, legality checks, and constructive packing
implementation.
Ordered cost curves share threshold scans. Scalar queries retain their original
cost and placement decisions. Compact plans retain the constructive core count
before spare cores are assigned. Minimum-resource completion uses the same
shared scalar-equivalent curves.
Automatic-depth initialization reports separate grouping, segment packing,
DP-state evaluation, and physical placement. Fixed-depth initialization remains
inside the candidate-generation timing. The complete queue model determines
eligibility and final selection. Initialization priorities are search costs, not timing bounds.
+117 -27
View File
@@ -1,7 +1,7 @@
# Spatial scheduling
`prepareSpatialSchedules` constructs the shared `ComputeGraph`. Latency mode
uses PEFT. For `--pipeline > 1`, the PIM compiler selects among bounded pipeline
uses PEFT. For `--pipeline > 1` or `--pipeline=auto`, the PIM compiler selects among bounded pipeline
candidates with static queue-aware Spatial execution analysis. Pipeline mode does not run PEFT.
See [implementation notes](scheduling-implementation.md) for fragment-view eligibility,
@@ -68,10 +68,12 @@ every physical core count for each segment. This preserves feasibility over
the segment assignments found by the constructive packers, independently of
resource quantization. Packing failure remains a bounded-search limitation,
not proved hardware infeasibility.
The seed minimizes maximum stage packing/dependency priority over the legal
active-stage counts within the configured depth. These priorities provide
a starting point, not a timing guarantee. Refinement can remove stage boundaries.
No empty stage is inserted between dependent operations.
For numeric depths greater than one, initialization requires exactly that many
nonempty compute stages. Both prefix DPs enforce this requirement. Insufficient
groups, resources, or legal stage cuts produce a diagnostic. A configured stage
array does not establish active compute stages; realization verifies actual
compute assignments and physical-core ownership. Packing priorities provide
a starting point, not a timing guarantee.
Every proposed partition receives a minimax core budget for its changed stages.
Unchanged stages retain their budgets. The allocator builds
@@ -87,14 +89,26 @@ retained assignment.
Task reordering cannot discard the initial partition's constructive capacity evidence.
This evidence does not prove final backend legality.
Refinement uses a beam of two schedules ranked by the larger queue estimate.
Its ordered neighborhood moves operation groups across adjacent stage boundaries,
inserts a boundary, or removes consecutive boundaries.
Refinement preserves contiguous groups in the initialization's topological order.
Coalescing compacts later stages. Each changed block redistributes its core pool.
Refinement retains the best evaluated schedule separately from expansion state.
Its ordered neighborhood moves operation groups across adjacent stage boundaries.
Only automatic depth search can insert or remove boundaries. Fixed-depth moves
preserve every required compute stage. Refinement preserves contiguous groups
in the initialization's topological order. Each changed block redistributes its
core pool. A depth change recomputes the allocation for its complete partition.
Core coordinates also transfer powers of two between stages, including one core.
These moves cross packing plateaus within a bounded number of evaluations.
The configured pipeline depth and total physical resources remain fixed.
Numeric pipeline depth and total physical resources remain fixed.
Automatic search changes depth within the same physical resource budget.
Exact-depth feasible schedule sets are not nested. Discrete placement, packing,
boundary transfers and restart synchronization can make the optimum output
interval non-unimodal in depth. A bounded search adds optimization error at each
depth. A poor initialized or refined schedule therefore cannot exclude nearby
depths. Numeric-depth results and automatic-search results do not establish a
global optimum over depths or placements.
Complete-state queue intervals use integer elapsed times and generation counts,
with a final floating-point division. Their precision is independent of the
one-nanosecond MCR diagnostic bracket.
A cheap proxy ranks the neighborhood before physical packing and queue analysis.
It uses ordered-packing curves, dependency spans and aggregate shared-memory demand.
@@ -104,15 +118,22 @@ Processor service and critical recurrence contributions guide ties toward affect
The PIM adapter supplies target-neutral processor guidance from the shared periodic
graph. PIM timing semantics remain outside Spatial.
The optimizer evaluates at most thirty-two complete Spatial queue costs and attempts
at most 128 constructive allocations and physical packings.
The optimizer evaluates at most sixty-four complete Spatial queue costs and attempts
at most 256 constructive allocations and physical packings.
The shortlist contains at most 128 proposals. Initialization retains at most sixteen
spare-core units. The packing-cost cache retains at most 256 ordered task lists.
Each round evaluates at most two new placements.
Each retained parent receives one queue-evaluation opportunity per round.
The first round can evaluate two neighbors of its single parent.
The two best evaluated schedules form the next beam.
The expansion frontier contains the best unexhausted schedule and one best-first
exploration schedule. Exploration uses waves of `ceil(sqrt(B))` expansions for
queue budget `B`, then ages that schedule behind less-expanded schedules. This
allows bounded lookahead through worse intermediate states while retaining the
best incumbent. At budget 64, the wave has eight expansions.
The two frontier slots do not change final selection.
All evaluated schedules remain available for final comparison.
Search stops at the evaluation or
packing budget, or when the beam's legal unvisited neighborhood is exhausted.
packing budget, or when all retained states have exhausted their legal neighborhood.
Canonical stage/budget vectors, physical core order and evaluation index break
ties deterministically. Actual physical placements, including inactive-core
stage identities, are deduplicated. The final 2.1% near-equivalence policy compares
@@ -120,8 +141,8 @@ the retained queue estimates. There are no independent legacy, sharing-aware,
allocator-only or boundary-shift candidate-generation policies.
Unavailable timing, unsupported static forms or unproved recurrence explicitly
stop a costed search. They are not silently discarded. One operation group or
one distinct neighborhood schedule skips optional queue comparison and lowers
stop a costed search. They are not silently discarded. One fixed-depth operation group or
one distinct fixed-depth neighborhood schedule skips optional queue comparison and lowers
once. Final backend resource retries remain restricted to already costed schedules.
`ComputeGraph` retains physical publication and consumer identities separately
@@ -175,8 +196,10 @@ The analysis brackets the maximum cycle ratio within one nanosecond. It tests
edge delays `w - II*d`, sweeping the distance-zero DAG between recurrence
relaxations. A positive predecessor cycle can terminate an infeasible probe early.
The final witness pass retains the full relaxation procedure and deterministic
witness selection. At most `R+1` sweeps detect a positive cycle, where `R` counts
positive-distance edges. Bisection uses at most 64 tests. Timing outside the
witness selection. Contiguous adjacency offsets preserve the original edge order.
Probes reuse one flattened DAG edge order. Recurrence arithmetic and witness
tie-breaking remain unchanged. At most `R+1` sweeps detect a positive cycle,
where `R` counts positive-distance edges. Bisection uses at most 64 tests. Timing outside the
supported numeric range produces an explicit unavailable result. A predecessor
cycle supplies a witness, including delay, iteration distance, cores, and links.
Detailed witness output is limited to 128 edges; totals cover the entire cycle.
@@ -311,10 +334,11 @@ The standalone frontend retains the recurrence witness. Neither analysis changes
## Default throughput selection
Full PIM code generation uses Spatial-only queue-aware selection for `--pipeline > 1`.
Full PIM code generation uses Spatial-only queue-aware selection for `--pipeline > 1` and `--pipeline=auto`.
Latency PEFT and `--pim-only-codegen` retain their existing behavior.
Intermediate emission retains the initialized schedule and stops at its requested stage.
Its schedule can differ from the final program.
Its schedule can differ from the final program. Automatic depth requires full
code generation and is rejected for intermediate emission.
The compiler performs these steps:
@@ -324,13 +348,14 @@ The compiler performs these steps:
4. Realize each admitted schedule in an independent clone of the prepared checkpoint.
5. Query the target adapter over realized Spatial IR, then release the clone.
6. Require supported static forms, available costs, and proved modeled recurrence.
7. Refine a two-schedule beam within thirty-two total queue evaluations.
7. Refine the incumbent and exploration frontier within sixty-four total queue evaluations.
8. Apply the existing 2.1% near-equivalence rule to the evaluated schedules.
9. Realize the selected schedule again from the unchanged checkpoint.
10. Lower, allocate, verify, and emit only the selected program.
A single candidate skips event extraction, queue analysis, recurrence proof, and comparison.
A single fixed-depth candidate skips event extraction, queue analysis, recurrence proof, and comparison.
It is realized and lowered once, even when optional timing is unavailable.
Auto still validates its p1 queue cost when no pipeline candidate can be initialized.
No rejected candidate enters PIM IR or instruction generation during cost evaluation.
Constants and weights remain shared immutable attributes in the MLIR context.
Candidate operations, communication plans, and synchronization state remain independent.
@@ -386,6 +411,44 @@ Final instruction generation uses the normal compiler timing report.
Explicit Spatial exports and IR dumps reconstruct pre-lowering artifacts for the selected schedule.
They do not change the emitted program. Diagnostic MLIR dumps elide large constants and are not lossless checkpoints.
### Fixed and automatic depth
`--pipeline=1` retains latency PEFT, including its existing instruction program.
`--pipeline=N`, for N greater than one, requires exactly N nonempty compute stages.
Every stage has physical cores. Boundary refinement cannot remove a required stage.
The compiler rejects infeasible exact depths instead of compacting stages.
`--pipeline=auto` compares steady-state output intervals with the same queue model
and final selection policy. Its p1 candidate uses the original PEFT schedule.
Auto adds the existing stage-zero restart barrier to the PEFT placement. This
protects changing input generations without changing numeric p1 latency compilation.
The queue model repeats that synchronized program; its cost is not single-inference latency.
If PEFT initialization fails, the report records that construction failure and
starts from a constructively feasible pipeline schedule. This is not proof that
all possible p1 placements are infeasible.
The legal ordered-prefix graph bounds the maximum depth, together with the
physical-core count. Auto shares segment packing curves and graph constraints
across depth initializations. Each depth retains its resource grid and
deterministic DP tie order. Reserved-core counts change those grids, so their
DP states cannot be reused unchanged across depths. Minimum-resource completion
reuses the shared integer-core cost curves.
Auto initialization covers depth 2 and the maximum depth, then bisects the
largest remaining depth gap. Ties prefer the shallower gap. At most
`min(1+ceil(log2(D-1)), D-1, floor(B/2))` pipeline seeds are constructed for
maximum depth D and queue budget B. Failed depth initializations are reported;
they do not invalidate feasible depths. All seeds and refinements share
sixty-four complete queue evaluations and the same incumbent/frontier policy.
Untested depths and unexplored neighbors remain explicit search limitations.
This bounded search does not prove a global optimum.
An unavailable cost or unproved recurrence for an admitted schedule stops comparison.
Only the final selected program enters PIM lowering.
`pipeline_selection.json` records requested and selected depths, explored depths,
per-depth initialization status, active stage identities, queue costs, search parents,
expansion counts, budgets, and the termination reason.
### Static analysis, diagnostics, and external validation
Production decisions use the input graph, compiler options, physical plans, and configured target parameters only.
@@ -398,18 +461,45 @@ Optional diagnostics expose resource work, recurrence, and ordered-request finge
Offline Pimsim fast-mode runs validate predictions and emitted programs.
Simulator measurements never enter production selection.
For `C <= 32` candidates, scheduling metadata uses `O(C(T+P))` storage for `T` compute instances and `P` cores.
Placement deduplication costs `O(C²(T+P))` time. The beam retains at most two schedules.
For `C <= 64` candidates, scheduling metadata uses `O(C(T+P))` storage for `T` compute instances and `P` cores.
Placement identities require `O(C(T+P))` storage; ordered-set deduplication compares
identities in `O((T+P) log C)` time per insertion. The active frontier has at most two schedules.
Auto adds `O(G²)` time and `O(G)` space for its legal depth upper bound.
For G operation groups, S numeric stages, P cores, and U spare-core units
(at most sixteen), the numeric quality DP has `O(S G² U²)` transitions and
`O(G² U + S G U)` storage. Minimum-resource completion can require `O(G² P)`
packing queries and `O(S G²)` transitions.
Auto shares segment curves across its depth initializations. Ordered minimax
queries reuse threshold scans and monotone neighboring-core bounds. Curves query only the
union of core counts used by the selected depth grids. Feasibility completion
computes missing integer-core costs lazily, with the same constructive packer.
Constructive unordered packing remains necessary when ordered packing fails. Illegal stage segments
have no packing queries. For maximum depth D, all depth-specific resource grids
have `O(L D G² U²)` DP transitions in total for L initialized depths.
Segment costs require at most `O(G² P Kpack)` constructive query work, with
reused ordered-threshold scans reducing repeated scalar searches.
Peak storage is `O(G² P + D G U + L T)` for T compute instances, plus packing
scratch. Uninitialized depths do not allocate DP states.
Each initialized depth retains a compact assignment and its constructive core
counts. The shared table is released before queue evaluation.
Depth seed reconstruction does not rerun packing-cost construction or the DP.
Profiles report segment work, DP transitions, threshold scans, and physical
initialization separately.
A round streams legal boundary and core moves into a shortlist of at most `2C`.
Each parent builds stage resource and dependency summaries in `O(T+E+P)` time and storage.
Unchanged-stage packing costs use an `O(SP)` cache. Changed task lists are not cached.
Exact packing costs and resource lower bounds share a search-local cache of at most
256 ordered task lists, independent of the queue budget. The immutable task costs,
weights and target fix each query. LRU eviction changes recomputation only.
For maximum list length T, the cache uses `O(256(T+P))` storage and
`O(T log 256)` lookup time; eviction scans at most 256 entries.
Each parent proposes `O(G + S² log P)` group, cut, and core moves.
For `M` proposed assignments, cheap allocation and scoring cost
`O(M (T log T + S P + E + F + S Kpack))`, plus bounded shortlist comparisons,
where `Kpack` is one existing ordered-packing query's cost.
Constructive allocation builds at most `S P` ordered-packing queries per admitted
partition. The graph and weight indices are reused. Search performs at most
128 physical packings; queue costs remain capped at thirty-two.
256 physical packings; queue costs remain capped at sixty-four.
Recurrence guidance uses the shared bounded maximum-cycle-ratio solver.
Candidate realization and extraction are sequential; complete candidate modules are not retained.
Normal successful compilation performs one candidate-specific backend lowering.