PeakRatioModel¶
Qualified name: algan.rendering.memory\_model.PeakRatioModel
- class PeakRatioModel(seed, safety=1.25)[source]¶
Bases:
objectMeasured bound on an out-of-arena transient build’s peak.
The scene merge and the vertex projection build out of place in pool headroom, before and outside the render arena, so the arena’s high-water mark cannot see them and
ChunkMemoryModeldoes not cover them. Their peak does scale with the packed inputs they read, though, and that size is known before the build runs – so the same measure-and-reuse approach applies, against input bytes instead of frame counts.The bound used to be a pure multiplier: worst recently observed
peak / inputs, seeded by a guess (6.0 for the merge, 8.0 for the projection). A ratio has no intercept, and these builds have a large one – kernel workspaces and allocator growth that a small build pays in full. A job’s first merge is typically its smallest, so it measured ratios above 20x, and every batch for the nextmemory_model_historybuilds was then throttled to a twentieth of the headroom it actually had. Hence the affine reading: the fixed part is charged once instead of to every byte.Under-reserving here is recovered – the caller catches the build’s out-of-memory and shrinks the window – while over-reserving silently costs batch size for the rest of the job, so the fit deliberately leans on measurement rather than on worst-case extrapolation. The out-of-memory handler stays the backstop either way: torch’s counters cannot see Taichi’s separate pool, so no measurement here is a hard bound.
Reads and writes may come from different threads: with prefetch-gpu-prep the batch-prep worker predicts a build’s peak while the render thread observes an un-overlapped build’s. A full
maxlendeque evicts from the front on append, which invalidates concurrent iterators, so observations take a lock readers also hold while reducing the samples. The lock is contention-free at this call rate (a few builds per batch).Methods
describeThe fitted fixed part, for tests that pin the fit's shape.
is_calibratedLargest input size whose predicted peak fits
budget_bytes.observeBytes a build reading
input_bytesis expected to peak at.Attributes
seedsafety- max_inputs_for(budget_bytes)[source]¶
Largest input size whose predicted peak fits
budget_bytes.The caller sizes frame windows, and input bytes scale with frames while the fixed part does not – so a window cannot be scaled by the prediction, only by the part of it the window controls. Reading the budget back through the line is what separates the two.