Spectrum Patcher (Max):
MaxSpectrumPatcher is intended to reduce the number of full model calculations during sampling. It keeps a short history of real model results, fits a Chebyshev-polynomial forecast to that history, and uses the forecast on selected later steps. This may reduce computation, but a forecast can differ from a fresh model result and affect the image. The supplied source also contains implementation issues that appear to prevent the node from operating as intended; the settings below describe its intended behavior, not a verified performance improvement.
Spectrum Patcher (Max) Input Parameters:
model
The model to patch. The node clones this model and installs a wrapper that decides whether to run the model or use a forecast during sampling. This is a required MODEL input; it has no numeric minimum, maximum, or default.
w
Controls the blend used on forecast steps. At the default of 0.5, the result is an equal mix of the forecast and the most recent real model result. At 0.0, it reuses that real result; at 1.0, it uses only the forecast. Intermediate values shift the balance between stability from the last real result and responsiveness to the forecast. This setting does not change real-model steps. Minimum: 0.0; maximum: 1.0; default: 0.5; step: 0.01.
m
Sets the number of terms in the Chebyshev forecast. More terms allow a more flexible fit to recent results, but can also make forecasts more sensitive when only a few real results are available. The node retains up to the greater of two results or m + 1 results for its fit. Minimum: 1; maximum: 16; default: 4; step: 1.
lam
Sets the strength of the forecast fit’s regularization, which discourages excessively large fitted coefficients. Larger values constrain the fit more; smaller values let it follow the cached results more closely. This affects forecast calculations, not the result returned on a real-model step. Minimum: 0.0; maximum: 100.0; default: 0.1; step: 0.001.
window_size
Sets the interval used to select real-model steps. With 1, every step runs the real model, so the node does not use forecast passes. With larger values, the node aims to run the real model at indexed steps divisible by this setting; it also runs real passes while fewer than two results are cached and falls back to them in certain failure cases. A larger interval can mean fewer real calculations, but more reliance on forecasts. Minimum: 1; maximum: 32; default: 2; step: 1.
Spectrum Patcher (Max) Output Parameters:
model
The cloned MODEL with the node’s sampling wrapper attached. Connect this output wherever your workflow expects a model. It represents a patched model, not an image or a completed sampling result. If the wrapper cannot produce a usable forecast during a pass, its code attempts to call the real model instead; however, the implementation issue noted below may occur before that fallback is available.
Spectrum Patcher (Max) Usage Tips:
- Start with
window_sizeset to1when diagnosing behavior. This requests a real model pass at every step, though it does not bypass the state-initialization issue in the supplied source. - Once the implementation works, try the defaults,
w=0.5,m=4,lam=0.1, andwindow_size=2, then compare results against an unpatched model using the same sampling settings. - Increase
window_sizecautiously if your priority is fewer real-model passes. If results change too much, reduce it before adjusting the forecast fit. - Use a smaller
wwhen you want forecast steps to stay closer to the last real result; use a largerwonly after checking that the forecasts produce acceptable images. - Keep
mmodest when there are few real passes. Adjustlamif the forecast appears too sensitive or too constrained, and compare actual outputs rather than assuming one setting will suit every workflow.
Spectrum Patcher (Max) Common Errors and Solutions:
TypeError: object of type 'Field' has no len()
- Explanation: In the supplied source,
_SpectrumStateusesfield(default_factory=list)but is not decorated with@dataclass. Its cache therefore appears to remain aFieldobject, and the wrapper tries to measure its length on the first pass. - Solution: Have the node implementation corrected so
_SpectrumStateis a dataclass, or so its cache lists are initialized explicitly. Changing node settings will not fix this source-code issue.
AttributeError: 'Field' object has no attribute 'clear'
- Explanation: The same state-initialization issue can surface when the wrapper attempts to reset its cache.
- Solution: Correct
_SpectrumStateinitialization in the node source. If you do not maintain the node, report the error and the supplied class definition to its maintainer.
Forecasts are never used
- Explanation: The supplied context references
_normalize_to_unit_intervalbut does not provide its implementation. If it is also absent from the installed code, fitting the forecast raises an error that the node catches internally; later passes then fall back to the real model. Settingwindow_sizeto1also intentionally prevents forecast passes. - Solution: Check that the installed node includes
_normalize_to_unit_intervaland that the state-initialization issue is fixed. For a forecast test, usewindow_sizegreater than1; the supplied excerpt alone cannot establish whether the helper exists elsewhere in the installed code.
ValueError: degree must be >= 1
- Explanation: The Chebyshev fitting helper requires at least one term. The node interface restricts
mto1or greater, and the patch method also clamps it, so this message should not arise from a valid setting through this node. - Solution: Keep
mwithin its displayed range. If the error persists, check whether it comes from a modified implementation or another node calling the helper directly.
ValueError: Y must be [N, D] with same N as Phi
- Explanation: The fitting helper requires the cached model results and timestep history to contain matching numbers of entries. The node catches fitting errors and disables its forecast rather than displaying this message directly during normal use.
- Solution: If you see this message in a modified version, check how that version builds and resets its cached history. Report the error with the sampling workflow to the node maintainer.
Forecast result is not finite
- Explanation: The code checks for invalid forecast numbers and runs the real model for that pass instead. This is a fallback condition in the source, not a specified on-screen error message.
- Solution: If you observe unexpected slowdowns or unstable results after the implementation issues are fixed, try a smaller
m, a largerlam, or a smallerwindow_size, and compare with the unpatched model.
