|
|
| GptModel (const GptModel &)=delete |
|
| GptModel (GptModel &&)=default |
|
const GptConfig & | getConfig () const noexcept |
|
GptModel & | operator= (const GptModel &)=delete |
|
GptModel & | operator= (GptModel &&)=default |
| void | saveCheckpoint (const std::filesystem::path &path, SerializationMode mode=SerializationMode::Checkpoint) const |
| | Write a Mila-native archive that fromCheckpoint() can restore.
|
| std::string | toString () const override |
| | Human-readable summary of this model's configuration.
|
|
| LanguageModel (const LanguageModel &)=delete |
|
| LanguageModel (LanguageModel &&)=default |
|
std::vector< std::string > | componentPaths () const |
| | Every observable component path, for choosing a pattern or diagnosing a zero.
|
| GenerateStatus | generate (std::span< const int32_t > prompt_tokens, const std::function< void(int32_t)> &on_token, const GenerateParams ¶ms={}, std::stop_token stop={}) |
| | Generate tokens from a prompt, streaming each through on_token.
|
| size_t | observe (std::string_view pattern, Compute::ComputePassMask passes, Compute::ActivationObserver sink) |
| | Watch activations flowing through matching components on matching passes.
|
|
LanguageModel & | operator= (const LanguageModel &)=delete |
|
LanguageModel & | operator= (LanguageModel &&)=default |
| void | save (const std::filesystem::path &path) const |
| | Write this model's live weights as a safetensors weights file.
|
| void | seedSampler (uint64_t seed) |
| | Seed the sampler's RNG for reproducible generation.
|
|
void | stopObserving () |
| | Detach every observer and clear the sink. A probe that outlives its question costs.
|
| std::string | weightQuantizationScheme () const |
| | The scheme name save records for these weights, e.g.
|
|
| Model (const Model &)=delete |
|
| Model (Model &&)=default |
|
DeviceId | getDeviceId () const noexcept |
| | The device this model runs on.
|
|
MemoryStats | getMemoryStats () const |
| | Current memory allocation breakdown for this model.
|
| RuntimeMode | getRuntimeMode () const noexcept |
| | The runtime mode this model was constructed for.
|
| bool | isEval () const noexcept |
| | True if this model is currently in eval sub-state.
|
| bool | isInferenceMode () const noexcept |
| | True if this model was constructed for inference.
|
| bool | isTrainingMode () const noexcept |
| | True if this model was constructed for training.
|
|
Model & | operator= (const Model &)=delete |
|
Model & | operator= (Model &&)=default |
| void | setEval (bool eval) |
| | Toggle eval sub-state for this model.
|
| void | train () |
| | Run the training loop for this model.
|
|
| int32_t | eosToken () const noexcept override |
| | GPT-2 end-of-text token id.
|
| dim_t | maxSequenceLength () const noexcept override |
| | Maximum sequence length from GPT config.
|
| GenerateStatus | onGenerating (std::span< const int32_t > prompt_tokens, const std::function< void(int32_t)> &on_token, const GenerateParams ¶ms, std::stop_token stop) override |
| | Prefill + KV-cache decode loop with per-token streaming.
|
| void | onTraining () override |
| | Training loop – not yet implemented for GptModel.
|
| dim_t | vocabSize () const noexcept override |
| | Vocabulary size from GPT config.
|
| | LanguageModel (std::unique_ptr< LanguageModelNetwork< TDeviceType, TPrecision > > network, RuntimeMode runtime_mode, Serialization::WeightsMetadata source_metadata={}, WeightQuantization weight_quantization=WeightQuantization::None, int fp4_group_size=128) |
| int32_t | awaitSampledToken () |
| | Block until the last enqueueSampleNext()'s token id is host-visible.
|
| void | enqueueSampleNext (const TensorType &logits, TokenTensor &token_out, const SamplingParams ¶ms) |
| | Enqueue a sampling step without waiting for the host readback.
|
| virtual float | finalLogitSoftcap () const noexcept |
| | Optional final-logit softcap the sampler applies (0 disables).
|
|
const LanguageModelNetwork< TDeviceType, TPrecision > & | getNetwork () const noexcept |
|
LanguageModelNetwork< TDeviceType, TPrecision > & | getNetwork () noexcept |
| int32_t | sampleNext (const TensorType &logits, TokenTensor &token_out, const SamplingParams ¶ms) |
| | Sample the next token from a logits row on the device.
|
|
virtual std::unordered_set< int32_t > | stopTokens () const |
| | Model (std::unique_ptr< NetworkType > network, RuntimeMode runtime_mode) |
| | Construct with a fully built network and runtime mode.
|
template<
DeviceType TDeviceType,
TensorDataType TPrecision>
requires PrecisionSupportedOnDevice<TPrecision, TDeviceType>
class Mila::Dnn::GptModel< TDeviceType, TPrecision >
GPT inference model.
Owns a loaded, built GptTransformer and exposes generate() for autoregressive text generation.
Construction is only possible via load() or fromCheckpoint(). The network is always in a built, weights-loaded, inference-mode state when generation is called.