2021-05-03 05:40:00 +02:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2021 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_GPT_OPTS_H
|
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
namespace ircd::gpt::model
|
|
|
|
{
|
|
|
|
struct decoder;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-05-03 05:40:00 +02:00
|
|
|
/// Task Options Page
|
|
|
|
///
|
|
|
|
/// The option block is directly shared with task software as constant data.
|
|
|
|
/// This stucture and its mutable companion in `task.h` determine the outcome
|
|
|
|
/// of the next execution cycle; options are immutable to device software but
|
|
|
|
/// may be changed by the host between executions cycles if desired.
|
|
|
|
///
|
|
|
|
struct ircd_gpt_opts
|
|
|
|
{
|
2022-06-20 03:59:29 +02:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
ircd_gpt_opts() noexcept;
|
2021-05-03 05:40:00 +02:00
|
|
|
#endif
|
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
//
|
|
|
|
// Frontside
|
|
|
|
//
|
2021-05-03 05:40:00 +02:00
|
|
|
|
2021-05-14 14:50:45 +02:00
|
|
|
/// Seed for the task's PRNG.
|
|
|
|
ulong seed;
|
|
|
|
|
2021-05-03 05:40:00 +02:00
|
|
|
/// Flip random coins over the top k logits each round. Setting to 1
|
|
|
|
/// deterministically selects the top logit.
|
|
|
|
uint top_k;
|
|
|
|
|
2021-09-17 17:21:20 +02:00
|
|
|
/// Flip a random coin between 0 and top_p ( = 90 = 0.9) for logit select.
|
2022-06-20 03:59:29 +02:00
|
|
|
float top_p;
|
2021-09-17 17:21:20 +02:00
|
|
|
|
2021-09-18 08:27:23 +02:00
|
|
|
/// Registers the top n result logits in the ctrl block each cycle.
|
|
|
|
uint top_n;
|
|
|
|
|
|
|
|
/// Number of target labels to register results for in the ctrl block.
|
|
|
|
uint labels;
|
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// Number of pages available after the control block for the frame log.
|
|
|
|
uint frames;
|
|
|
|
|
|
|
|
/// Limit number of output tokens. Default of -1; other halting conditions
|
|
|
|
/// will be used.
|
2022-07-02 03:50:20 +02:00
|
|
|
int limit;
|
2022-06-20 03:59:29 +02:00
|
|
|
|
|
|
|
/// Bitbar toggling various debug modes.
|
2021-09-18 08:27:23 +02:00
|
|
|
uint debug;
|
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// Accepting condition codes.
|
|
|
|
ushort accept[4][8] __attribute__((aligned(4)));
|
|
|
|
|
|
|
|
//
|
|
|
|
// Backside
|
|
|
|
//
|
|
|
|
|
|
|
|
/// Samples per step.
|
|
|
|
uint batch_size;
|
|
|
|
|
|
|
|
/// Training steps
|
|
|
|
uint training_steps;
|
|
|
|
|
|
|
|
/// Validation steps
|
|
|
|
uint validation_steps;
|
|
|
|
|
|
|
|
/// Testing steps
|
|
|
|
uint testing_steps;
|
|
|
|
|
|
|
|
/// Learning rate
|
|
|
|
float alpha;
|
|
|
|
|
|
|
|
/// Decay rate
|
|
|
|
float beta[2];
|
|
|
|
|
|
|
|
/// Denorm smoothing
|
|
|
|
float epsilon;
|
|
|
|
|
|
|
|
/// Tuning convergence rate
|
|
|
|
float lambda;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Model dimensions
|
|
|
|
//
|
|
|
|
|
|
|
|
/// Number of possible target n-grams.
|
|
|
|
uint logits;
|
2021-05-03 05:40:00 +02:00
|
|
|
|
|
|
|
/// Specifies the token buffer size in tokens.
|
|
|
|
uint buffer_tokens;
|
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// Specifies the token context size in tokens.
|
|
|
|
uint context_tokens;
|
|
|
|
|
2022-01-23 20:02:22 +01:00
|
|
|
/// Decoding layers.
|
|
|
|
uint layers;
|
|
|
|
|
|
|
|
/// SIMD lane count.
|
|
|
|
uint lanes;
|
|
|
|
|
2021-05-03 05:40:00 +02:00
|
|
|
/// Embedding vector elements
|
|
|
|
uint embed_elems;
|
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// (computed) `embed_elems` / `lanes`
|
|
|
|
uint embed_width;
|
|
|
|
|
2021-09-17 08:03:44 +02:00
|
|
|
/// Cross-attention dimension
|
|
|
|
uint attn_rank;
|
|
|
|
|
2021-05-03 05:40:00 +02:00
|
|
|
/// Attention unit fcon width multiple
|
|
|
|
uint attn_mult;
|
|
|
|
|
|
|
|
/// (computed) attention unit width multiple
|
|
|
|
uint attn_elems;
|
|
|
|
|
|
|
|
/// (computed) Attention unit X dimension
|
2022-06-20 03:59:29 +02:00
|
|
|
uint attn_fcon_width;
|
2021-05-03 05:40:00 +02:00
|
|
|
|
|
|
|
/// (computed) Attention unit Y dimension
|
2022-06-20 03:59:29 +02:00
|
|
|
uint attn_fcon_height;
|
2021-05-03 05:40:00 +02:00
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// (computed) Attention unit X dimension
|
|
|
|
uint attn_proj_width;
|
2021-05-03 05:40:00 +02:00
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// (computed) Attention unit Y dimension
|
|
|
|
uint attn_proj_height;
|
2021-05-03 05:40:00 +02:00
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// (computed) Packed attention array total element count
|
|
|
|
uint attn_self_elems;
|
2021-05-03 05:40:00 +02:00
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// MLP unit fcon width multiple
|
|
|
|
uint ffnn_mult;
|
2021-05-03 05:40:00 +02:00
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// (computed) FFNN unit width multiple
|
|
|
|
uint ffnn_elems;
|
2021-05-14 14:50:45 +02:00
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// (computed) MLP backend X dimension
|
|
|
|
uint ffnn_fcon_width;
|
2021-05-03 05:40:00 +02:00
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// (computed) MLP backend Y dimension
|
|
|
|
uint ffnn_fcon_height;
|
2021-05-03 05:40:00 +02:00
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// (computed) MLP backend X dimension
|
|
|
|
uint ffnn_proj_width;
|
2021-05-03 05:40:00 +02:00
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
/// (computed) MLP backend Y dimension
|
|
|
|
uint ffnn_proj_height;
|
2021-05-03 05:40:00 +02:00
|
|
|
}
|
|
|
|
__attribute__((aligned(4096)));
|
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
#if defined(__cplusplus)
|
2021-05-03 05:40:00 +02:00
|
|
|
namespace ircd::gpt
|
|
|
|
{
|
2021-05-14 14:50:45 +02:00
|
|
|
using opts = ::ircd_gpt_opts;
|
2021-05-03 05:40:00 +02:00
|
|
|
}
|
2022-06-20 03:59:29 +02:00
|
|
|
#endif
|
2021-05-03 05:40:00 +02:00
|
|
|
|
2022-06-20 03:59:29 +02:00
|
|
|
#if defined(__cplusplus)
|
2021-05-03 05:40:00 +02:00
|
|
|
static_assert(sizeof(struct ircd_gpt_opts) == 4096);
|
2022-06-20 03:59:29 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__cplusplus) && defined(__GLIBCXX__)
|
2021-05-03 05:40:00 +02:00
|
|
|
static_assert(std::is_standard_layout<struct ircd_gpt_opts>::value);
|
|
|
|
#endif
|