get_node_resources(). Check the package’s entry in test_state_lint.py. Its UNPORTED list names the legacy packages, and the lint refuses get_node_resources() in a ported file. For a new model, use declare_state.
Identify the resource
Start at the model’sget_node_resources(). Each NodeResourceSpec names a resource_key, the nodes sharing the resource, and any dependencies. A paged attention spec and a positions spec both depend on their KV pool. A worker binds only the resources its node declares. The YAML’s resources: overrides use those same keys.
Most legacy specs have a counterpart in the state contract. Check the geometry and lifetime before replacing one. These examples need particular care:
A non-causal read between two spans pairs a request’s query span with its own key span. When batching requests, preserve both identities. A custom bounded read may need source, relative bias, or another field outside the declared window’s default behavior. Resource specifications
Trace a step
declare_step names the operation for each resource key, such as a KV write and the attention over it. Read the actual engine step before changing a model that implements speculative verification. GLM-5.2’s verifier can commit an entire draft block and then use correct_len before the next admission to remove its rejected suffix. Both the KV cache and its position counter must move. Performing the correction between admission and commit leaves an inconsistent reservation. KV manager · GLM implementation
A step that combines prefill and decode may run different kernels for each sub-batch. The spec’s combined_splits() describes that split. If a replacement merges the rows into one plan, check the per-row positions and output order against separate runs.
Follow the binding
Find where the submodule and its layers take their resource handles. An older attention layer can bind a label for the step and set the layer index before calling its attention wrapper. A fused writer can askkv.write_target(layer_idx, label) for the layer’s NHD pages, the destination slots, and the number of real tokens to write. A padded capture must stop writing at that count. Consult the legacy forward helpers before changing an index or replacing a resource call.
A recurrent pool needs a separate slot per live row and a sink for padding when its gather/scatter helpers require one. A cacheless attention reads the current step’s ragged plan. A sequence shard supplies scatter and gather with the label of the split. Each of these has a distinct lifetime. Reuse an existing bound state operation when it expresses the same operation.
Preserve layouts and captures
Legacy models return akv_layout per label in process_prompt. The modern counterpart is state_layout. Carry over the prompt spans, which writes commit, growth per loop, scratch space, and the maximum retained length. A model that can stop short of its maximum iterations may reserve less than the loop limit suggests.
For a packed piecewise capture, an old ragged spec can supply attn_key to obtain the default non-causal row layout. A port that declares the segments explicitly must reproduce their lengths and labels, including padding. Compare the effective spec and per-walk steps before checking numerical output. State port equivalence tests