modelopt.torch.distill.bypass#

bypass(student, teacher, train_dataloader, config=None, *, validation_dataloader=None)#

Optimize IQ native scales on streamed frozen teacher boundary inputs.

Finalization commits boundaries in order, so a failure there may leave earlier boundaries committed. Caller modes and teacher gradient flags are restored on every exit.

Parameters:
  • student (Module) – Existing ModelOpt IQ PTQ model; frozen formats may coexist.

  • teacher (Module) – Separate original-weight callable with matching boundary paths.

  • train_dataloader – Unique sample batches that exactly fill each global update. Dict batches may carry a boolean/integer valid_mask, loss_mask or 2D attention_mask; nonzero marks a valid token. The HF adapter also derives default validity from _packed_seq_ids, where zero denotes padding.

  • config – A BypassConfig, a dict, or None for the defaults.

  • validation_dataloader – Optional held-out batches for finalized-student valid-token MSE.

Return type:

Module

For HF PTQ, use TransformersBypassAdapter.weight_patterns with the same selectors to obtain ordinary ModelOpt weight_quantizer globs before quantizing the student. These patterns exclude frozen routing gates.

Returns:

The supplied student, finalized for ordinary ModelOpt save/export.

Parameters:
  • student (Module)

  • teacher (Module)

Return type:

Module