IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Mojo function

derive_prologue_from_program

derive_prologue_from_program(program: PipelineProgram, config: PipelineConfig, sched: ScheduleConfig = ScheduleConfig(scheduling=SchedulingStrategy.IDENTITY, sched_barrier_mask=85, auto_waits=True, drain_lgkm_mask=0, auto_drain=False, lds_contention_penalty=0, wait_lgkm_first=8, wait_vm_last=6, lgkm_per_load_a=0, lgkm_per_load_b=0, lgkm_after_last=False, minimal_barriers=False, omit_mma_set_prio=False, max_vgpr=999999, global_before_frag=False, barrier_before_pre_ops=False, inter_block_lgkm_drain=False, partial_prologue_drain=False, wrap_waits_with_sched_barrier=False), bootstrap: List[OpDesc] = List()) -> List[ScheduleEntry]

Derive prologue from a finalized PipelineProgram.

Extracts global loads from the program's first-half blocks, groups them by buffer stage (0 vs 1), and emits the standard prologue sequence: stage-0 loads at K0 β†’ wait_vm(0) β†’ barrier β†’ stage-1 loads at K1 β†’ wait_vm(0)

When sched.partial_prologue_drain is True, the inter-stage wait_vm(0) + barrier and the trailing wait_vm(0) are skipped β€” all prefetches issue continuously, and the framework instead appends the schedule's bootstrap_frags() paired with partial wait_vm(N) + barrier drains so each bootstrap frag-load fires after exactly the prefetch it depends on has completed (the rest stay in flight for the first main-loop iter).

Per-frag wait values are derived from cumulative prefetch vm_cost: the i-th bootstrap frag drains down to leave total_vm - sum(prefetch_vm_costs[:i+1]) outstanding.

This replaces default_prologue_double_buffer() for schedules that build a PipelineProgram. The advantage is that the prologue is always consistent with the kernel body's actual load distribution (after CSP reordering and redistribution), rather than scanning raw body ops independently.

Returns:

List[ScheduleEntry]