mstar.model.omnivoice.components.unmask

mstar.model.omnivoice.components.unmask#

The unmask step: CFG scoring, confidence ranking, and the reveal schedule.

An exact port of OmniVoice’s _predict_tokens_with_scoring and the schedule arithmetic inside _generate_iterative (omnivoice/models/omnivoice.py). Parity against the reference is decided here, so the arithmetic is kept to the bit even where it could be tidied — the log_softmax is applied twice on the CFG path because the reference applies it twice, and the mask id is driven to -inf after the combine rather than before.

Nothing here touches the network or the engine; it is pure tensor math over a step’s packed logits, so the parity test can drive it directly.

Functions

build_reveal_schedule(target_len, ...)

How many of the target_len * num_codebook cells to reveal per step.

filter_top_k(logits[, ratio])

Keep the top ratio of the vocabulary, -inf elsewhere.

get_time_steps(num_step, t_shift[, t_start, ...])

The shifted timestep ramp, num_step + 1 points on [t_start, t_end].

unmask_step(logits, canvases, uncond_rows, ...)

One unmask iteration for every request of a step, batched.

mstar.model.omnivoice.components.unmask.build_reveal_schedule(target_len, num_codebook, num_step, t_shift)[source]#

How many of the target_len * num_codebook cells to reveal per step.

The per-step count follows the gap between consecutive timesteps, rounded up and clamped by what is left; the final step takes the entire remainder so the canvas is always fully revealed regardless of rounding drift.

Cached, and returning a tuple so it stays immutable: the schedule depends only on these four numbers, but forward_batched needs it on every step of every request, and recomputing it there means a linspace and a Python loop per step for a list that never changes within a request.

Parameters:
Return type:

tuple[int, …]

mstar.model.omnivoice.components.unmask.filter_top_k(logits, ratio=0.1)[source]#

Keep the top ratio of the vocabulary, -inf elsewhere.

Parameters:
Return type:

Tensor

mstar.model.omnivoice.components.unmask.get_time_steps(num_step, t_shift, t_start=0.0, t_end=1.0, device=None)[source]#

The shifted timestep ramp, num_step + 1 points on [t_start, t_end].

t_shift below 1 pushes points toward t_start, spending more of the budget at low SNR where the canvas is still mostly masked.

Parameters:
Return type:

Tensor

mstar.model.omnivoice.components.unmask.unmask_step(logits, canvases, uncond_rows, counts, generators, guidance_scale, class_temperature, layer_penalty_factor, position_temperature, audio_mask_id)[source]#

One unmask iteration for every request of a step, batched.

The reference’s scoring (_predict_tokens_with_scoring) and reveal for each request, over the step’s packed target positions at once. Each request draws from its own generator in the reference’s order (token choice, then reveal order), and its result is the reference’s arithmetic to the bit when the step’s requests share their knobs. A temperature that differs between them is divided by per position instead of as one scalar, which can round differently (CUDA divides by a scalar as a multiply by its reciprocal), so a request batched with others can then flip a reveal at a near-tie.

Parameters:
  • logits (Tensor) – [1, C, R, V]: every request’s conditional target block in order, then the unconditional blocks (PackedCanvas’s gather order).

  • canvases (list[Tensor]) – each request’s live canvas, [C, T_i]; not written.

  • uncond_rows (list[int]) – where each request’s unconditional block starts in logits, or -1 for a request with CFG off.

  • counts (list[int]) – the cells each request reveals this iteration.

  • generators (list[Generator | None]) – each request’s RNG for this iteration (None: global).

  • guidance_scale (list[float])

  • class_temperature (list[float])

  • layer_penalty_factor (list[float])

  • position_temperature (list[float])

  • audio_mask_id (int)

Returns:

the next canvases end to end, P = sum(T_i).

Return type:

[C, P]