Training neural networks with elastic architectures

The training system addresses the lack of comprehensive architectural elasticity in neural networks by implementing elasticity across multiple dimensions, resulting in subnetworks with enhanced performance and deployment flexibility.

WO2026246849A1PCT designated stage Publication Date: 2026-11-26GDM HOLDING LLC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/US2026/029500
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2025-05-22
Filing Date
2026-05-22
Publication Date
2026-11-26

AI Technical Summary

Technical Problem

Existing methods for training neural networks lack comprehensive architectural elasticity, particularly in attention mechanisms and network depth, leading to suboptimal performance and deployment issues in latency-sensitive applications.

Method used

Implement a training system that provides architectural elasticity across multiple dimensions, including model embedding, depth, attention, and mixture-of-experts layers, using strategies like efficient update, loss weighting, co-distillation, and tail-patching to create diverse subnetworks tailored to various hardware and performance targets.

Benefits of technology

Enables the generation of subnetworks with improved inference efficiency, reduced memory footprint, lower latency, and enhanced hardware compatibility, allowing efficient deployment across heterogeneous devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure US2026029500_26112026_PF_FP_ABST
    Figure US2026029500_26112026_PF_FP_ABST
Patent Text Reader

Abstract

Methods, systems, and apparatus, including computer programs encoded on a computer storage medium, for training an elastic neural network having an elastic architecture defined by multiple architectural dimensions. After training, multiple configurations of the elastic neural network having different model sizes can be extracted without any further training. Particularly, each architectural dimension has a respective set of possible sizes, each of which is associated with a respective nested subset of the network parameters of the elastic neural network along the dimension. By selecting a combination of sizes that includes a respective size for each of the architectural dimensions, a neural network having a corresponding size is defined. For example, the architectural dimensions can include the dimensionality of an embedding space, the number of active layer blocks, the number of attention heads of a given attention layer, or the number of experts of a given mixture-of-experts layer, of the neural network.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] Attorney Docket No. 45288-0651WO1

[0002] TRAINING NEURAL NETWORKS WITH ELASTIC ARCHITECTURES

[0003] CROSS-REFERENCE TO RELATED APPLICATIONS

[0004] [1] This application claims priority to Indian Application No. 202511049314, filed on May 22, 2025. The disclosure of the prior application is considered part of the disclosure of this application, and is incorporated in its entirety into this application.

[0005] BACKGROUND

[0006] [2] This specification relates to processing data using machine learning models.

[0007] [3] Machine learning models receive an input and generate an output, e.g., a predicted output, based on the received input. Some machine learning models are parametric models and generate the output based on the received input and on values of the parameters of the model.

[0008] [4] Some machine learning models are deep models that employ multiple layers of models to generate an output for a received input. For example, a deep neural network is a deep machine learning model that includes an output layer and one or more hidden layers that each apply a non-linear transformation to a received input to generate an output.

[0009] SUMMARY

[0010] [5] This specification describes a training system implemented as computer programs on one or more computers in one or more locations that can train an elastic neural network on a training dataset to perform a machine learning task. These and other features of the training system described herein are summarized below.

[0011] [6] In one aspect, a method performed by one or more computers is provided, the method comprising: obtaining a training dataset for training an elastic neural network having an elastic architecture defined by a plurality of architectural dimensions; receiving an input specifying: (i) a respective set of sizes of each of the plurality of architectural dimensions of the elastic architecture, and (ii) a plurality of configurations of the elastic neural network, each configuration being specified by, for each architectural dimension, a respective size selected from the respective set of sizes of the architectural dimension; initializing a set of network parameters shared between the plurality of configurations of the elastic neural network, wherein, for each architectural dimension, each respective size is associated with a respective subset of the set of network parameters along the architectural dimension, and the respective subset of network parameters is a subset of the respective subset of network parameters associated with each size in the set of sizes of the architectural dimension that is larger than theAttorney Docket No. 45288-0651WO1

[0012] respective size; and training the set of network parameters shared between the plurality of configurations of the elastic network on the training dataset.

[0013] [7] In some implementations of the method, the plurality of configurations of the elastic neural network comprises: a main configuration of the elastic neural network, the main configuration having the elastic architecture configured with, for each architectural dimension, the largest respective size in the respective set of sizes of the architectural dimension; and a plurality of auxiliary configurations of the elastic neural network, each auxiliary configuration having the elastic architecture configured differently than the main configuration.

[0014] [8] In some implementations of the method, initializing the set of network parameters of the plurality of configurations of the elastic neural network comprises: receiving a pre-trained neural network having the main configuration; and initializing the set of network parameters as a set of pre-trained network parameters of the pre-trained neural network.

[0015] [9] In some implementations of the method, the method further includes: receiving a pretraining dataset the pre-trained neural network was pre-trained on; and augmenting the training dataset with one or more batches of network inputs sampled from the pre-training dataset.

[0016]

[0010] In some implementations of the method, training the set of network parameters of the plurality of configurations of the elastic neural network on the training dataset comprises, at each of a plurality of training iterations: sampling, from the training dataset, a batch of network inputs; receiving a respective current value of each network parameter belonging to the set of network parameters; parametrizing the main configuration of the elastic neural network with the respective current value of each network parameter belonging to the set of network parameters; sampling, from a probability distribution over the plurality of auxiliary configurations, one of the plurality of auxiliary configurations of the elastic neural network; generating the sampled auxiliary configuration of the elastic neural network; parametrizing the auxiliary configuration with the respective current value of each network parameter belonging to the respective subset of the set of network parameters associated with the auxiliary configuration; and jointly training the main and auxiliary configurations of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set of network parameters.

[0017]

[0011] In some implementations of the method, training the set of network parameters of the plurality of configurations of the elastic neural network on the training dataset comprises, at each of a plurality of training iterations: sampling, from the training dataset, a batch of network inputs; receiving a respective current value of each network parameter belonging to the set of network parameters; parametrizing the main configuration of the elastic neural network withAttorney Docket No. 45288-0651WO1

[0018] the respective current value of each network parameter belonging to the set of network parameters; determining whether a criterion for training any one of the plurality of auxiliary configurations is satisfied at the training iteration; if the criterion is not satisfied at the training iteration: training the main configuration of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set network parameters; and if the criterion is satisfied at the training iteration: sampling, from a probability distribution over the plurality of auxiliary configurations, one of the plurality of auxiliary configurations of the elastic neural network; generating the sampled auxiliary configuration of the elastic neural network; parametrizing the auxiliary configuration with the respective current value of each network parameter belonging to the respective subset of the set of network parameters associated with the auxiliary configuration; and jointly training the main and auxiliary configurations of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set of network parameters.

[0019]

[0012] In some implementations of the method, the probability distribution is a uniform distribution over the plurality of auxiliary configurations.

[0020]

[0013] In some implementations of the method, determining whether the criterion for training the set of auxiliary configurations of the elastic neural network is satisfied at the training iteration comprises: determining whether a threshold number of the plurality of training iterations has elapsed since any one of the plurality of auxiliary configurations of the elastic neural network was jointly trained with the main configuration of the elastic neural network.

[0021]

[0014] In some implementations of the method, the threshold number of training iterations has a value of two or more.

[0022]

[0015] In some implementations of the method, the threshold number of training iterations has a value in a range from two to five.

[0023]

[0016] In some implementations of the method, at each of the plurality of training iterations, training the main configuration of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set of network parameters comprises: for each network input in the batch: processing the network input, using the main configuration of the elastic neural network parametrized with the respective current value of each network parameter belonging to the set of network parameters, to generate a respective main network output for the network input; and computing a respective main objective term measuring an error between: (i) the respective main network output for the network input, and (ii) a respective target output for the network input; computing, with respectAttorney Docket No. 45288-0651WO1

[0024] to each network parameter belonging to the set of network parameters, a respective gradient of a main objective comprising the respective main objective term for each network input in the batch; and updating, using the respective gradient of the main objective, the respective current value of each network parameter belonging to the set of network parameters.

[0025]

[0017] In some implementations of the method, at each of the plurality of training iterations, jointly training the main and auxiliary configurations of the elastic neural network on the batch of network inputs to update the current values of the set network parameters comprises: for each network input in the batch: processing the network input, using the auxiliary configuration of the elastic neural network parametrized with the respective current value of each network parameter belonging to the respective subset of network parameters associated with the auxiliary configuration, to generate a respective auxiliary network output for the network input; computing a respective auxiliary objective term measuring an error between: (i) the respective auxiliary network output for the network input, and (ii) the respective target output for the network input; and computing a respective co-distillation objective term measuring an error between: (i) a respective set of outputs generated by the main configuration when processing the network input, and (ii) a respective set of outputs generated by the auxiliary configuration when processing the network input; computing, with respect to each network parameter belonging to the set of network parameters, a respective gradient of a total objective comprising: the main objective; an auxiliary objective comprising the respective auxiliary objective term for each network input in the batch; and a co-distillation objective comprising the respective co-distillation objective term for each network input in the batch of network inputs; and updating, using the respective gradient of the total objective, the respective current value of each network parameter belonging to the set of network parameters.

[0026]

[0018] In some implementations of the method, updating, using the respective gradient of the total objective, the respective current value of each network parameter belonging to the set of network parameters comprises: updating, using the respective gradient of the total objective, the respective current value of each network parameter belonging to the set of network parameters; or updating, using the respective gradient of the total objective, the respective current value of each network parameter belonging to the set of network parameters other than the respective subset of network parameters associated with the auxiliary configuration.

[0027]

[0019] In some implementations of the method, for each network input in the batch, the respective co-distillation objective term measures an error between: (i) a respective set of intermediate outputs generated by a respective intermediate layer of the main configuration when processing the respective network input, and (ii) a respective set of intermediate outputsAttorney Docket No. 45288-0651WO1

[0028] generated by a corresponding intermediate layer of the auxiliary configuration when processing the respective network input.

[0029]

[0020] In some implementations of the method, the respective intermediate layer of each of the main and auxiliary configurations of the elastic neural network is a last respective layer in the configuration.

[0030]

[0021] In some implementations of the method, the total objective function comprises a summation of: the main objective multiplied by a main penalty parameter; the auxiliary objective multiplied by a respective auxiliary penalty parameter associated with the auxiliary configuration of the elastic neural network; and the co-distillation objective multiplied by a respective co-distillation penalty parameter associated with the auxiliary configuration of the elastic neural network.

[0031]

[0022] In some implementations of the method, at each of the plurality of training iterations, jointly training the main and auxiliary configurations of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set of network parameters comprises: processing the batch of network inputs using one or more of the main or auxiliary configurations of the elastic neural network to generate a respective set of candidate network outputs for each network input in the batch; and obtaining a respective reward for each candidate network output in the respective set of candidate network outputs for each network input in the batch; computing, with respect to each network parameter belonging to the set of network parameters, a respective gradient of a reinforcement learning objective comprising the respective rewards for each network input in the batch of network inputs; and updating, using the respective gradient of the reinforcement learning objective, the respective current value of each network parameter belonging to the set of network parameters.

[0032]

[0023] In some implementations of the method, the reinforcement learning objective comprises one or more reinforcement objective terms that each depend on an anchor neural network, and wherein the anchor neural network is a pre-trained instance of the main configuration of the elastic neural network.

[0033]

[0024] In some implementations of the method, processing the batch of network inputs using one or more of the main or auxiliary configurations of the elastic neural network to generate the respective set of candidate network outputs for each network input in the batch comprises: processing each network input in a subset of the batch of network inputs, using the main configuration of the elastic neural network, to generate the respective set of candidate network outputs for the network input in the batch; and processing each network input in a complementAttorney Docket No. 45288-0651WO1

[0034] of the subset of the batch of network inputs, using the auxiliary configuration of the elastic neural network, to generate the respective set of candidate network outputs for the network input in the batch.

[0035]

[0025] In some implementations of the method, processing the batch of network inputs using one or more of the main or auxiliary configurations of the elastic neural network to generate the respective set of candidate network outputs for each network input in the batch comprises, for each network input in the batch: processing the network input, using the main configuration of the elastic neural network, to generate a subset of the respective set of candidate outputs for the network input; and processing the network input, using the auxiliary configuration of the elastic neural network, to generate a complement of the subset of the respective set of candidate outputs for the network input.

[0036]

[0026] In some implementations of the method, the elastic neural network comprises a plurality of active layer blocks each configured to: receive a block input embedding belonging to a model embedding space; and process the block input embedding to generate a block output embedding belonging to the model embedding space.

[0037]

[0027] In some implementations of the method, the plurality of architectural dimensions defining the elastic architecture of the elastic neural network comprises: a model dimension defining a dimensionality of the model embedding space of the elastic architecture.

[0038]

[0028] In some implementations of the method, the plurality of architectural dimensions defining the elastic architecture of the elastic neural network comprises: a model depth defining a total number of the plurality of active layer blocks in the elastic neural network.

[0039]

[0029] In some implementations of the method, the plurality of active layer blocks is organized in a residual sequence comprising, for each active layer block: a respective additive gate immediately following the active layer block; and a respective skip connection between: (i) an input of the active layer block, and (ii) the respective additive gate.

[0040]

[0030] In some implementations of the method, for each active layer block that is not a first of the plurality of active layer blocks in the residual sequence, the block input embedding of the active layer block comprises a summation of: the block input embedding of a layer block preceding the active layer block in the residual sequence; and the block output embedding of the layer block preceding the active layer block in the residual sequence.

[0041]

[0031] In some implementations of the method, each active layer block in the elastic neural network comprises an attention layer configured to: receive a layer input embedding belonging to the model embedding space; for each of a plurality of attention heads: apply a respective set of input projection matrices to the layer input embedding to generate a respective set ofAttorney Docket No. 45288-0651WO1

[0042] attention input embeddings each belonging to an attention embedding space; and apply a respective attention mechanism over the respective set of attention input embeddings to generate a respective attention output embedding belonging to the attention embedding space; concatenate the respective attention output embeddings for each of the plurality of attention heads to generate a multi -head attention output embedding; and apply an output projection matrix to the multi-head attention output embedding to generate a layer output embedding belonging to the model embedding space.

[0043]

[0032] In some implementations of the method, the plurality of architectural dimensions defining the elastic architecture of the elastic neural network comprises: an attention dimension defining a dimensionality of the attention embedding space of the attention layer of each active layer block in the elastic neural network.

[0044]

[0033] In some implementations of the method, the plurality of architectural dimensions defining the elastic architecture of the elastic neural network comprises: an attention depth defining a total number of the plurality of attention heads of the attention layer of each layer block in the elastic neural network.

[0045]

[0034] In some implementations of the method, for each of the plurality of attention heads of the attention layer of each active layer block in the elastic neural network: the respective set of input projection matrices comprises a respective triplet of a query value projection matrix, a key value projection matrix, and a value projection matrix, and the respective set of attention input embeddings comprises a respective triplet of a query, a key, and a value.

[0046]

[0035] In some implementations of the method, the multi-head attention output embedding of the attention layer of each active layer block in the elastic neural network has a same dimensionality as the dimensionality of the attention embedding space of the attention layer.

[0047]

[0036] In some implementations of the method, each active layer block in the elastic neural network further comprises a mixture-of-experts layer configured to: receive a layer input embedding belonging to the model embedding space; process the layer input embedding, using a router, to generate a respective probability for each of a plurality of experts; process the layer input embedding, using each of the plurality of experts, to generate a respective expert output embedding belonging to the model embedding space; multiply, for each of the plurality of experts, the respective expert output embedding by the respective probability for the expert; sum the respective expert output embeddings multiplied by the respective probabilities for each of the plurality of experts to generate a layer output embedding belonging to the model embedding space.Attorney Docket No. 45288-0651WO1

[0048]

[0037] In some implementations of the method, the mixture-of-experts layer of each active layer block is a mixture-of-experts feedforward layer, and the plurality of experts of the mixture-of-experts feedforward layer is a plurality of feedforward experts each configured to: receive the layer input embedding belonging to the model embedding space; apply a respective input projection matrix to the layer input embedding to generate a respective pre-activated embedding belonging to a feedforward embedding space; apply a respective activation function over the respective pre-activated embedding to generate a respective activated embedding belonging to the feedforward embedding space; and apply a respective output projection matrix to the respective activated embedding to generate the respective expert output embedding belonging to the model embedding space.

[0049]

[0038] In some implementations of the method, the plurality of architectural dimensions defining the elastic architecture of the elastic neural network comprises: a feedforward dimension defining a dimensionality of the feedforward embedding space of the mixture-of-experts feedforward layer of each active layer block in the elastic neural network.

[0050]

[0039] In some implementations of the method, the plurality of architectural dimensions defining the elastic architecture of the elastic neural network comprises: a feedforward depth defining a total number of the plurality of feedforward experts of the mixture-of-experts feedforward layer of each active layer block in the elastic neural network.

[0051]

[0040] In some implementations of the method, the respective activation function of each of the plurality of feedforward experts of the mixture-of-experts feedforward layer of each active layer block in the elastic neural network is a Rectified Linear Unit, a Gaussian error Linear Unit, or a swish function.

[0052]

[0041] In some implementations of the method, each active layer block in the elastic neural network is a transformer layer block.

[0053]

[0042] In some implementations of the method, each transformer layer block in the elastic neural network comprises: the attention layer; a first additive gate immediately following the attention layer; a first skip connection between: (i) an input of the attention layer, and (ii) the first additive gate; a first normalization layer immediately following the first additive gate; the mixture-of-experts feedforward layer immediately following the first normalization layer; a second additive gate immediately following the mixture-of-experts feedforward layer; a second skip connection between: (i) an input of the mixture-of-experts feedforward layer, and (ii) the second additive gate; and a second normalization layer immediately following the second additive gate.Attorney Docket No. 45288-0651WO1

[0054]

[0043] In some implementations of the method, each transformer layer block in the elastic neural network comprises: a first normalization layer; the attention layer immediately following the first normalization layer; a first additive gate immediately following the attention layer; a first skip connection between: (i) an input of the first normalization layer, and (ii) the first additive gate; a second normalization layer immediately following the first additive gate; the mixture-of-experts feedforward layer immediately following the second normalization layer; a second additive gate immediately following the mixture-of-experts feedforward layer; and a second skip connection between: (i) an input of the second normalization layer, and (ii) the second additive gate.

[0055]

[0044] In some implementations of the method, the first and second normalization layers of each transformation layer block in the elastic neural network is a layer normalization layer, a root mean square normalization layer, a batch normalization layer, a weight normalization layer, or a group normalization layer.

[0056]

[0045] In some implementations of the method, the elastic neural network comprises: an input subnetwork configured to: receive a network input for the elastic neural network; and process the network input to generate an input embedding belonging to the model embedding space; a residual network immediately following the input subnetwork, the residual network comprising the plurality of active layer blocks; an additive gate immediately following the residual network; a skip connection between: (i) an input of the residual network, and (ii) the additive gate; and an output subnetwork immediately following the additive gate, the output subnetwork configured to: receive an output embedding belonging to the model embedding space; and process the output embedding to generate a network output for the elastic neural network.

[0057]

[0046] In some implementations of the method, the method further comprises, after training the set of network parameters shared between the plurality of configurations of the elastic neural network on the training dataset: receiving a query specifying: (i) a network input for the elastic neural network, and (ii) a target configuration in the plurality of configurations of the elastic neural network; generating the target configuration of the elastic neural network; parametrizing the target configuration of the elastic neural network with trained values of the respective subset of network parameters associated with the target configuration; and processing the network input, using the target configuration of the elastic neural network in accordance with the trained values of the subset of network parameters associated with the target configuration, to generate a network output for the network input.

[0058]

[0047] In some implementations of the method, the network input is a multi-modal input, the network output is a multi-modal output, or both.Attorney Docket No. 45288-0651WO1

[0059]

[0048] In some implementations of the method, the network input comprises one or more of: an input image, an input video, an input audio waveform, or an input text sequence.

[0060]

[0049] In some implementations of the method, the neural network comprises an observation characterizing a state of an environment being interacted with by an agent, and the network output defines an action to be performed by the agent in response to the observation.

[0061]

[0050] In some implementations of the method, the network input comprises an input text sequence comprising a respective input text token at each of a plurality of input positions, and the network output comprises a prediction of a text token that follows the input text token at a last of the plurality of input positions.

[0062]

[0051] In some implementations of the method, the method further comprises: generating an output text token using the network output; appending the output text token to the input text sequence; and processing the network input comprising the input text sequence appended with the output text token, using the target configuration of the elastic neural network, to generate a network output comprising a prediction of a text token that follows the output text token appended to the input text sequence.

[0063]

[0052] In a second aspect, a method performed by one or more computers is provided, the method comprising: receiving a query specifying: (i) a network input for an elastic neural network, and (ii) a target configuration in a plurality of configurations of the elastic neural network; generating the target configuration of the elastic neural network; and processing the network input, using the target configuration of the elastic neural network, to generate a network output for the network input, wherein a set of network parameters shared between the plurality of configurations of the elastic neural network has been trained via the respective method of the first aspect in any one of its abovementioned implementations.

[0064]

[0053] In a third aspect, a method performed by one or more computers is provided, the method comprising: receiving a query specifying: (i) a network input for an elastic neural network, and (ii) a target configuration in a plurality of configurations of the elastic neural network; generating the target configuration of the elastic neural network; and processing the network input, using the target configuration of the elastic neural network, to generate a network output for the network input, wherein a set of network parameters shared between the plurality of configurations of the elastic neural network has been trained via operations comprising: obtaining a training dataset for training the elastic neural network, the elastic neural network having an elastic architecture defined by a plurality of architectural dimensions; receiving an input specifying: (i) a respective set of sizes of each of the plurality of architectural dimensions of the elastic architecture, and (ii) the plurality of configurations of the elastic neural network,Attorney Docket No. 45288-0651WO1

[0065] each configuration being specified by, for each architectural dimension, a respective size selected from the respective set of sizes of the architectural dimension; initializing the set of network parameters shared between the plurality of configurations of the elastic neural network, wherein, for each architectural dimension, each respective size is associated with a respective subset of the set of network parameters along the architectural dimension, and the respective subset of network parameters is a subset of the respective subset of network parameters associated with each size in the set of sizes of the architectural dimension that is larger than the respective size; and training the set of network parameters shared between the plurality of configurations of the elastic neural network on the training dataset.

[0066]

[0054] In a fourth aspect, a system is provided, the system comprising: one or more computers; and one or more storage devices communicatively coupled to the one or more computers, wherein the one or more storage devices store instructions that, when executed by the one or more computers, cause the one or more computers to perform operations of the respective method of the first, second, or third aspects in any one of its abovementioned implementations.

[0067]

[0055] In a fifth aspect, one or more non-transitory computer storage media is provided, the one or more non-transitory computer storage media storing instructions that, when executed by one or more computers, cause the one or more computers to perform operations of the respective method of the first, second, or third aspects in any one of its abovementioned implementations.

[0068]

[0056] In a sixth aspect, a method performed by one or more computers is provided, the method comprising: obtaining a set of network parameters for an elastic neural network having an elastic architecture defined by a plurality of architectural dimensions, wherein for each architectural dimension, a plurality of potential sizes is defined, each potential size being associated with a respective subset of a complete set of shared network parameters for the elastic neural network, and wherein the respective subset of network parameters for any given potential size is a subset of the respective subset of network parameters associated with each larger potential size for that architectural dimension; receiving a query specifying: (i) a network input, and (ii) a target configuration for the elastic neural network, the target configuration being specified by, for each architectural dimension, a selected potential size; generating the target configuration by selecting, for each architectural dimension, the respective subset of the obtained set of network parameters corresponding to the selected potential size for that architectural dimension; and processing the network input, using the generated target configuration parameterized with its selected subsets of network parameters, to generate a network output.Attorney Docket No. 45288-0651WO1

[0069]

[0057] In some implementations of the method, obtaining the set of network parameters comprises: providing an initial subset of the complete set of shared network parameters; and in response to the initial subset being insufficient for the target configuration, dynamically retrieving an additional subset of network parameters such that the combination of the initial and additional subsets forms the set of network parameters used for generating the target configuration.

[0070]

[0058] In a seventh aspect, one or more non-transitory computer-readable media storing a set of network parameters for an elastic neural network is provided, wherein: the elastic neural network has an elastic architecture defined by a plurality of architectural dimensions; for each architectural dimension of the plurality of architectural dimensions, a plurality of supported sizes are defined, for which corresponding parameters are included in the stored set of network parameters; each supported size in the plurality of supported sizes for an architectural dimension is associated with a respective subset of the stored set of network parameters along that architectural dimension; the respective subset of network parameters associated with any given supported size for an architectural dimension is a subset of the respective subset of network parameters associated with each supported size for that architectural dimension that is larger than the given supported size; and the stored set of network parameters, when used to parameterize a selected configuration of the elastic neural network specified by a supported size for each architectural dimension, enables the selected configuration to process a network input to generate a network output.

[0071]

[0059] In some implementations of the one or more non-transitory computer-readable media, the elastic architecture further defines, for each architectural dimension, a complete set of architectural sizes for the elastic neural network; and the plurality of supported sizes for each architectural dimension, for which corresponding parameters are included in the stored set of network parameters, comprises all sizes in the complete set of architectural sizes for that architectural dimension.

[0072]

[0060] In some implementations of the one or more non-transitory computer-readable media, the elastic architecture is derived from a larger elastic architecture that defines, for each architectural dimension, a complete set of architectural sizes; and the plurality of supported sizes for at least one architectural dimension, for which corresponding parameters are included in the stored set of network parameters, constitutes a proper subset of the complete set of architectural sizes defined by the larger elastic architecture for that architectural dimension.

[0073]

[0061] Particular embodiments of the subject matter described in this specification can be implemented so as to realize one or more of the following advantages.Attorney Docket No. 45288-0651WO1

[0074]

[0062] In general, the elastic neural network (or “ENN”) described herein is a neural network having an architecture designed to dynamically adjust its network topology and parameterization thereof at inference or training time e.g., based on constraints such as latency, energy, and / or hardware limitations. Such an architecture is referred to herein as an “elastic architecture”. Consequently, the adjusted network may make better use of computer resources and / or meet constraints such as latency while providing the functions required of it. For example, the elastic neural network can have an elastic architecture corresponding to a unit cell that is expanded or repeated along each architectural dimension, e.g., including width, depth, resolution, kernel size, capacity and / or number of layers, layer blocks, and / or subnetworks of the unit cell. Moreover, rather than training multiple, separate neural networks for different deployment settings, the training system described herein can train the elastic neural network once. The elastic neural network can then be “sliced” or scaled into multiple different configurations having different model sizes without needing to further train the neural network. This may reduce the resources to train neural networks substantially, avoiding duplicative efforts to train across various topologies.

[0075]

[0063] Particularly, each architectural dimension of the elastic architecture has a respective set of possible sizes, each of which is associated with a respective nested subset of the set of network parameters of the elastic neural network along the architectural dimension. By selecting a combination of sizes that includes a respective size for each of the architectural dimensions, a configuration of the elastic neural network having a corresponding size is defined. For example, the architectural dimensions can include one or more of: the dimensionality of an embedding space of the elastic neural network, the total number of active layer blocks in the elastic neural network, the dimensionality of an embedding space of a given attention layer in the elastic neural network, the total number of attention heads of the given attention layer, the dimensionality of an embedding space of a given mixture-of-experts layer in the elastic neural network, or the total number of experts of the given mixture-of-experts layer.

[0076]

[0064] Thus, implementations of the training system and the elastic neural network can be utilized for conditional computation and subnetwork extraction, allowing each configuration of the elastic neural network to be optimized for a respective set of hardware devices and / or constraints, e.g., with no additional overhead during training of the elastic neural network. Such implementations have several advantages including one or more of: (i) efficiency, as the training system can train the elastic neural network with a fixed compute budget for the largest subnetwork, and extract tens, hundreds, thousands, or more smaller subnetworks (e.g., thatAttorney Docket No. 45288-0651WO1

[0077] would involve a prohibitively large compute budget if each subnetwork were individually trained); (ii) efficacy, as the elastic neural network can adapt to resource-scarce computing environments (e.g., edge devices, mobile devices, and / or application-specific integrated circuits); (iii) scalability, as the elastic neural network can be implemented with various resource-performance tradeoffs; or (iv) flexibility, as the training system can train the elastic neural network to perform machine learning tasks for each subnetwork size without retraining for each task. In this way, embodiments of the present disclosure may enable the configuration of a single machine learning model that may be efficiently deployed across heterogenous hardware devices having disparate characteristics such as memory, energy and latency constraints. Consequently, embodiments may provide the ability to adapt to resource-scarce computing devices (e.g., edge devices, mobile devices, ASICs) while retaining an architecture able to take advantage of more resource-rich environments.

[0078]

[0065] The details of one or more embodiments of the subject matter of this specification are set forth in the accompanying drawings and the description below. Other features, aspects, and advantages of the subject matter will become apparent from the description, the drawings, and the claims.

[0079] BRIEF DESCRIPTION OF THE DRAWINGS

[0080]

[0066] FIG. 1A is a schematic diagram depicting an example of an elastic neural network having an elastic architecture. The elastic neural network includes an input subnetwork, a residual network, and an output subnetwork.

[0081]

[0067] FIG. IB is a schematic diagram depicting an example of the residual network including a sequence of residual layer blocks.

[0082]

[0068] FIG. 2A is a schematic diagram depicting an example of a residual layer block of a first type including an attention layer, a first normalization layer, a mixture-of-experts feedforward layer, and a second normalization layer in a first configuration.

[0083]

[0069] FIG. 2B is a schematic diagram depicting an example of a residual layer block of a second type including the attention layer, the first normalization layer, the mixture-of-experts feedforward layer, and the second normalization layer in a second configuration.

[0084]

[0070] FIG. 3 is a schematic diagram depicting an example of the attention layer having multiple attention heads.

[0085]

[0071] FIG. 4A is a schematic diagram depicting an example of the mixture-of-experts feedforward layer including a router and multiple feedforward neurons.Attorney Docket No. 45288-0651WO1

[0086]

[0072] FIG. 4B is a schematic diagram depicting an example of a feedforward neuron (or “expert”) of the mixture-of-experts feedforward layer.

[0087]

[0073] FIG. 5 is a schematic diagram depicting an example of the elastic neural architecture having multiple architectural dimensions each with a respective set of possible sizes.

[0088]

[0074] FIG. 6A is a schematic diagram depicting an example of the set of possible sizes of one of the architectural dimensions of the elastic neural architecture, which is associated with a set of nested subsets of a set of network parameters of the elastic neural network along the architectural dimension.

[0089]

[0075] FIG. 6B is a schematic diagram depicting an example of a Cartesian product between the respective sets of nested subsets associated with two of the architectural dimensions of the elastic neural architecture.

[0090]

[0076] FIG. 7 is a schematic diagram depicting an example of a training system configured to train the set of network parameters of the elastic neural network on a training dataset.

[0091]

[0077] FIG. 8 is a flow diagram of an example process for training an elastic neural network.

[0092]

[0078] FIG. 9 is a flow diagram of an example process for generating a network output using a target configuration of an elastic neural network.

[0093]

[0079] FIG. 10 is a flow diagram of an example process for generating a network output using a target configuration of an elastic neural network.

[0094]

[0080] Like reference numbers and designations in the various drawings indicate like elements.

[0095] DETAILED DESCRIPTION

[0096]

[0081] Elastic neural network training and inference can involve deriving multiple subnetworks from a single, larger parent network. The MatFormer framework is one example of such elastic training and inference adapted to large-scale Transformer-based models, e.g., encompassing both decoder-only large language models (“LLMs”) and vision encoders. The MatFormer framework is described in Kudugunta, Sneha, Aditya Kusupati, Tim Dettmers, Kaifeng Chen, Inderjit Dhillon, Yulia Tsvetkov, Hannaneh Hajishirzi, Sham Kakade, Ali Farhadi, and Prateek Jain, “Matformer: Nested transformer for elastic inference,” arXiv preprint arXiv:2310.07707 (2023), which is incorporated by reference in its entirety for all purposes. MatFormer’ s methodology involves optimizing a few predefined target architectural granularities (e.g., corresponding to 1 Billion, 2 Billion, or 4 Billion parameters) within the larger model’s structure, demonstrating that these specific subnetworks can achieve accuracy levels comparable to their independently trained counterparts. Furthermore, MatFormer employs a layer-wise “Mix‘n’Match” strategy during inference, enabling sampling ofAttorney Docket No. 45288-0651WO1

[0097] intermediate model configurations along the accuracy-versus-computational cost Pareto frontier spanned by the fixed granularities, thereby generating numerous (e.g., tens of) performant subnetworks from a few (e.g., three) explicit training targets.

[0098]

[0082] However, a limitation of the MatF ormer approach is that its architectural elasticity was strictly confined to the feedforward network (“FFN”) sub-blocks within each Transformer layer block. Elasticity was not implemented for other components, such as the attention mechanisms or the overall network depth. This FFN-only elasticity, while enabling accurate subnetworks, often leads to suboptimal inference performance profiles. Specifically, the lack of elasticity in attention mechanisms can result in unnecessarily high memory footprints for smaller subnetworks, and the fixed network depth can prevent the generation of submodels optimally tuned for low-latency requirements. These limitations hinder efficient deployment, particularly in latency-sensitive, high-throughput scenarios common in web-scale applications. Therefore, there remains a need for a method that provides more comprehensive architectural elasticity in elastic neural networks beyond FFNs to address these performance and deployment bottlenecks.

[0099]

[0083] The present disclosure introduces systems and methods for training elastic neural networks, e.g., generative elastic neural networks such as elastic Large Language Models, with comprehensive architectural elasticity, representing a significant advancement over prior art approaches like MatF ormer that limited elasticity primarily to Feed-Forward Network (FFN) blocks. The system and techniques described can enable the generation of diverse subnetworks from a single trained parent model, where these subnetworks exhibit superior deployment characteristics, including improved inference efficiency, reduced memory footprint, lower latency, and enhanced hardware compatibility.

[0100]

[0084] One aspect of the systems and methods described herein involves implementing a nested network parameter structure across multiple architectural dimensions of an elastic architecture simultaneously. These architectural dimensions can include one or more of

[0085] Model Embedding Dimension: Elasticity in the elastic neural network’s core embedding dimension. This inherently governs the dimensionality of downstream components in the transformer, including FFNs, thus subsuming the FFN-only elasticity of prior methods as a specific instance.

[0101]

[0086] Model Depth: Elasticity in the total number of active Transformer layers. This allows for the extraction of shallower subnetworks, e.g., specifically optimized for low-latency inference, addressing a key deficiency of fixed-depth approaches for web-scale deployment.Attorney Docket No. 45288-0651WO1

[0102]

[0087] Attention Embedding Dimension: Elasticity in a given attention layer’s embedding dimension.

[0103]

[0088] Attention Depth: A nested structure for the number of attention heads within the multihead attention (“MHA”) mechanism of a given attention layer. For example, this can directly enable the extraction of subnetworks with reduced memory requirements for the attention keyvalue (“KV”) cache, a capability absent in prior FFN-only elastic methods.

[0104]

[0089] Feedforward Embedding Dimension: Elasticity in a given Mixture-of-Experts (“MoE”) layer’s embedding dimension.

[0105]

[0090] Feedforward Depth: A nested structure for the number of experts of a given MoE layer. For example, this allows for the extraction of smaller, efficient MoE subnetworks, and facilitating the design of high-efficiency drafter models for speculative decoding.

[0106]

[0091] By providing elasticity along one or more of these multiple architectural dimensions, the systems and methods described herein can allow for the creation of a rich set of subnetworks tailored to diverse hardware and performance targets. It will be understood that elasticity may be implemented along any single one of these architectural dimensions independently of the others, or along any combination of two or more of these dimensions. The variation across each dimension may be implemented independently to offer particular technical characteristics (e.g. related to processing speed or memory consumption) without inextricably linking one dimension’s elasticity to another.

[0107]

[0092] Another aspect of the systems and methods described herein involves a training algorithm for efficiently training the elastic neural network. Implementations of the training algorithm can include one or more of, implemented either independently of each other or in combination:

[0108]

[0093] Efficient Update Strategy: An efficient sampling strategy during training, where the main configuration of the elastic neural network having the largest model size is updated at each training iteration, while nested, auxiliary configurations of the elastic neural network are sampled and updated less frequently (e.g., at approximately 50% of the training iterations). For example, this sampling strategy can balance training stability and subnetwork quality. More details for the efficient update strategy are described below in connection with FIG. 8.

[0109]

[0094] Loss Weighting Scheme: A weighting scheme for the objectives of sampled auxiliary configurations (e.g., penalty parameters in range from 0.2 to 0.5). For example, this allows control over the trade-off between the performance of the main configuration and the various auxiliary configurations. More details for the loss weighting scheme are described below in connection with FIG. 8.Attorney Docket No. 45288-0651WO1

[0110]

[0095] Relaxed MoE Routing Constraint: For MoE architectures, relaxing a constraint that embeddings are routed through corresponding nested experts in the main and sampled auxiliary configurations, e.g., improving flexibility and / or model quality. In some implementations, the system can relax the MoE routing constraint by allowing the main model and the submodels to route token embeddings independently. Instead of forcing the submodel to use nested versions of the exact same experts chosen by the main model, the routing mechanisms can be decoupled. For example, the main model can route a token to experts 20, 35, and 40, while the submodel can route that same token to different experts, such as experts 24, 50, and 72.

[0111]

[0096] Co-Distillation Objective: Incorporating a co-distillation objective between outputs (e.g., logits) of the main and sampled auxiliary configurations. For example, this can significantly enhance the model quality of the auxiliary configurations with little or no additional computational overhead. More details for the co-distillation objective are described below in connection with FIG. 8.

[0112]

[0097] Tail-Patching Conversion Technique: A “tail-patching” technique, enabling a pretrained, non-elastic neural network to be efficiently converted into the elastic neural network, e.g., while using a fraction (e.g., approximately 10%) of the original pre-training data. Instead of starting from scratch to train the elastic neural network, the system can start with a pretrained, non-elastic neural network. The system can perform a short, final training phase (thus “tail-patching”) using only a fraction of the original training data. During this short training phase, the system can apply the described elastic training techniques, such as the efficient update strategy and co-distillation loss. Therefore, the short training phase effectively “patches” the pre-trained, non-elastic neural network and results in a trained elastic neural network. More details for the tail-patching conversion technique are described below in connection with FIG. 8.

[0113]

[0098] Implementations of the systems and methods described herein for training the elastic neural network and generating configurations of the elastic neural network can be effectively applied during post-training phases, such as Supervised Fine-Tuning (“SFT”) and Reinforcement Learning from Human Feedback (“RLHF”), to produce instruction-following and preference-aligned configurations of the elastic neural network.

[0114]

[0099] Application to SFT generally involves extending the training algorithm to a fine-tuning training dataset for a downstream task.

[0115]

[0100] Application to RLHF, which typically utilizes both a policy model (being updated) and an anchor neural network (providing reference probabilities, e.g., for Kullback-Leibler (“KL”)Attorney Docket No. 45288-0651WO1

[0116] constraints), includes several implementations when applied to the framework of the elastic neural network. Such implementations can include one or more of:

[0117]

[0101] RLHF Policy Generation Sampling Strategy: Generating responses or completions by sampling approximately equally from both the main configuration and one or more auxiliary configurations sampled during the generation phase of RLHF.

[0118]

[0102] Exclusive Main Model Anchor: Utilizing the main configuration as the anchor neural network for calculating RLHF updates (e.g., for the KL penalty term applied to each auxiliary configuration being updated).

[0119]

[0103] These features and other features are described in more detail below.

[0120]

[0104] FIG. 1A is a schematic diagram depicting an example of an elastic neural network 10 having an elastic architecture, e.g., the elastic neural network architecture 500 in FIG. 5. The elastic neural network 10 includes an input subnetwork 25, a residual network 50, and an output subnetwork 75. The elastic neural network 10 can be implemented as computer programs on one or more computers in one or more locations in which the systems, components, and techniques described herein are implemented. More details for the elastic neural network 10 are described in connection with FIG. 8, FIG. 9, and FIG. 10.

[0121]

[0105] At a high-level, the elastic neural network 10 is configured to: receive a network input 12; and process the network input 12 to generate a network output 14 for the network input 12.

[0122]

[0106] In some implementations, the network input 12 includes an input sequence (X), given as X = X1,X2, ...,XL~), including a respective input token (X ) at each of multiple input positions i = 1,2, ...,L, where L is the length of the input sequence. On the other hand, the network output 14 can be any desired network output, e.g., a score, a classification, or a regression output.

[0123]

[0107] In some implementations, the respective input token at each input position of the input sequence is a respective discrete input token, e.g., a text token belonging to a discrete vocabulary of text tokens. For example, the input sequence can be a sequence of input text tokens describing, e.g., in a natural language, a machine learning task to be performed by the elastic neural network 10.

[0124]

[0108] In some implementations, the respective input token at each input position of the input sequence is a respective continuous input token. For example, the input sequence or each continuous input token in the input sequence can represent a data item such as an image, a video, an audio waveform, e.g., where the input sequence or continuous input token is generated as output by an encoder (e.g., an encoder neural network) processing the data item.Attorney Docket No. 45288-0651WO1

[0125] For example, the input sequence can represent a stack of input images, and the respective continuous input token at each input position of the input sequence can represent a respective input image in the stack. As another example, the input sequence can represent an input video, and the respective continuous input token at each input position of the input sequence can represent a respective frame of the input video. As yet another example, the input sequence can represent an input audio waveform, and the respective continuous input token at each input position of the input sequence can represent a respective sample of the input audio waveform.

[0126]

[0109] In some implementations, the respective input token at each input position in the input sequence is a respective discrete input token or a respective continuous input token. For example, the input sequence can be a multi-modal input sequence including a sequence of input text tokens appended with a respective continuous input token representing each of one or more data items, where the sequence of text tokens describes, e.g., in a natural language, a machine learning task to be performed on the one or more data items. As another example, the input sequence can be a multi-modal input sequence including a sequence of input text tokens appended with a sequence of continuous input tokens representing a data item, where the sequence of text tokens describes, e.g., in a natural language, a machine learning task to be performed on the data item.

[0127] [HO] In some implementations, the input sequence is a long-range sequence. For example, the input sequence can be a sequence of 2000 or more tokens, 4000 or more tokens, 8000 or more tokens, 16000 or more tokens, 32000 or more tokens, 64000 or more tokens, or 128000 or more tokens.

[0128] [Hl] In some implementations, the elastic neural network 10 can be referred to as an autoregressive neural network, that is, because the elastic neural network 10 auto-regressively generates an output sequence (Y), given as Y = (Y^^, ..., Ym), by repeatedly updating and reprocessing the input sequence for each of multiple output positions j = 1,2,

[0129]

[0130] where m is the length of the output sequence. The output sequence includes a respective output token (Yj) at each output position. The elastic neural network 10 can auto-regressively generate the output sequence by generating the respective output token at each output position in the output sequence conditioned on an input sequence that represents a current input sequence Xj = (Xo, i-.j-i) f°r the output position. That is, the input sequence includes an initial input sequence (Xo) appended with any output tokens Y1.j_1= (

[0131]

[0132] Yj^, that precede the output token (Yj), i.e., the output tokens that have already been generated for any previousAttomey Docket No. 45288-0651WO1

[0133] output positions in the output sequence that precede the particular output position of the particular token.

[0134]

[0112] In some implementations, the elastic neural network 10 can generate the output sequence iteratively, e.g., one output token at a time, using an auto-regressive sampling procedure. In some implementations, for each j-th output position in the output sequence, the elastic neural network 10 processes a network input 12 including the input sequence for the output position to generate a network output 14 including a score distribution Oj = Pj = P( )) over a vocabulary of tokens of a tokenizer. For example, the score distribution can be a probability distribution over a set of logits, where the set of output logits includes a respective output logit for each token in the vocabulary. As another example, the score distribution can be a probability distribution over a set of continuous output tokens (or “soft” tokens), where the set of continuous output tokens includes a respective continuous output token for each token in the vocabulary. The elastic neural network 10 then samples the output token })~P(X) for the j-th output position from the score distribution. The elastic neural network 10 subsequently updates the input sequence by appending the output token thereto,

[0135]

[0136] Xj -> A)+1= (A),=(A'o, K1;7). The elastic neural network 10 then reprocesses a network input 12 including the updated input sequence, as described above, to generate a network output 14 including a score distribution O

[0137]

[0138] ;+1= PJ+1over the vocabulary for the (j + l)-th output position, and thereafter samples the output token Yj+1~Pj+1at the output position from the score distribution. The elastic neural network 10 can perform this process repeatedly until an end-of-sentence (“EOS”) token Ym= YE0Sis reached, terminating the auto-regressive sampling procedure. The elastic neural network 10 then returns the output sequence (K), including each output token generated during the auto-regressive sampling procedure, which is given as Y = K1;m= (K1(Y2, ..., Ym

[0113] FIG. IB is a schematic diagram depicting an example of the residual network 50 including a sequence of residual layer blocks 55.1, 55.2, ..., 55. DL (collectively, “residual layer block(s) 55”). More details for the residual network 50 are described in connection with FIG.

[0139] 8.

[0140]

[0114] FIG. 2A is a schematic diagram depicting an example of a residual layer block 55A of a first type including an attention layer 100, a first normalization layer 150A, a mixture-of-experts feedforward layer 200, and a second normalization layer 150B in a first configuration. More details for the residual layer block 55A are described in connection with FIG. 8.

[0141]

[0115] FIG. 2B is a schematic diagram depicting an example of a residual layer block 55B of a second type including the attention layer 100, the first normalization layer 150A, the mixture-Attorney Docket No. 45288-0651WO1

[0142] of-experts feedforward layer 200, and the second normalization layer 150B in a second configuration. More details for the residual layer block 55B are described in connection with FIG. 8.

[0143]

[0116] FIG. 3 is a schematic diagram depicting an example of the attention layer 100 having multiple attention heads. The attention layer 100 includes input projection matrices 110.Q.1, 110.K.1, and 110.V.1, an attention mechanism 120, a concatenation layer 125, and an output linear projection layer that includes an output projection matrix 130. More details for the attention layer 100 are described in connection with FIG. 8.

[0144]

[0117] FIG. 4A is a schematic diagram depicting an example of the mixture-of-experts (MoE) feedforward layer 200 including a router 210 and multiple feedforward neurons 220.1, 220.2, ..., 220. DE (collectively, “ feedforward neuron(s) 220”). More details for the mixture-of-experts feedforward layer 200 are described in connection with FIG. 8.

[0145]

[0118] FIG. 4B is a schematic diagram depicting an example of a feedforward neuron (or “expert”) 220 of the mixture-of-experts (MoE) feedforward layer 200. The feedforward neuron includes an input linear projection layer that includes an input projection matrix 222, an activation function 224, and an output linear projection layer that includes an output projection matrix 226. More details for the feedforward neuron (or “expert”) 220 are described in connection with FIG. 8.

[0146]

[0119] FIG. 5 is a schematic diagram depicting an example of the elastic neural network architecture 500 having multiple architectural dimensions each with a respective set of possible sizes. The elastic neural network architecture 500 can include a residual network architecture 50A, an attention layer architecture 100A, and a MoE feedforward layer architecture 200A. The residual network architecture 50A can have a model dimension DM (as shown in FIGs.

[0147] 2A-2B) and a model depth dimension DL (as shown in FIG. 1). The attention layer architecture 100A can have an attention dimension DA and an attention depth Du(as shown in FIG. 3). The MoE feedforward layer architecture 200 A can have a Feed-Forward Network (FFN) dimension DF (as shown in FIG. 4B) and a FFN depth DE (as shown in FIG. 4A). More details for the multiple architectural dimensions are described in connection with FIG. 8.

[0148]

[0120] FIG. 6A is a schematic diagram depicting an example of the set of possible sizes of one of the architectural dimensions of the elastic neural network architecture 500, which is associated with a set of nested subsets of a set of network parameters 15 (as shown in FIG. 7) of the elastic neural network 10 (as shown in FIG. 1) along the architectural dimension.Attorney Docket No. 45288-0651WO1

[0149]

[0121] FIG. 6B is a schematic diagram depicting an example of a Cartesian product between the respective sets of nested subsets associated with two of the architectural dimensions of the elastic neural network architecture 500.

[0150]

[0122] FIG. 7 is a schematic diagram depicting an example of a training system 300 configured to train the set of network parameters 15 (e.g., network parameters 15.t at training iteration t and network parameters 15.(t+l) at training iteration (t+1)) of the elastic neural network 10 on a training dataset 310 to configure the elastic neural network 10 to perform a set of one or more machine learning tasks defined by the training dataset 310. The training system 300 is an example of a system implemented as computer programs on one or more computers in one or more locations in which the systems, components, and techniques described below are implemented.

[0151]

[0123] For example, the training system 300 can generate batches 312 of training data from the training dataset 310. The training system 300 can perform the training at t=l to T iterations. At each iteration t, the training system 300 can train the elastic neural network 10 using one or more batches 312. t. The training system 300 can parametrize the elastic neural network 10 using the network parameters 15.t at the current iteration t to generate the main configuration 10.N. The training system 300 can sample the probability distribution 320 over a plurality of auxiliary configurations to generate an auxiliary configuration 10. i.

[0152]

[0124] At iteration t, the batch 312. t of training data includes samples 314. t.l, ..., 314. t.b, ..., 314.t.B. Each sample can include a network input 12 and a network output 14. For example, the sample 314. t.b can include a target output 14*.t.b and a network input 12. t.b. The training system 300 can generate a predicted network output 12.N.t.b by processing the network input 12. t.b using the main configuration 10.N. The training system 300 can generate a main objective term 332.N.t.b using the network output 12.N.t.b and the target output 14*. t.b. The training system can generate a main objective 334.N.t for the samples b=l to B.

[0153]

[0125] The system 300 can generate a predicted network output 12. i. t.b by processing the network input 12. t.b using the auxiliary configuration 10. i. The system 300 can generate an auxiliary objective term 332. i .t.b using the network output 12. i. t.b and the target output 14*. t.b. The system 300 can generate an auxiliary objective 334. i.t for the samples 1 to B. In some implementations, the system 300 can generate a co-distillation objective term 333.N.i.t.b and a co-distillation objective 335.N.i.t. The system 300 can generate a total objective 330.N.i.t, e.g., using one or more of the main objective 334.N.t, the auxiliary objective 334. i.t, and the co-distillation objective 335.N.i.t. The system 300 can generate updated parameters for the elasticAttorney Docket No. 45288-0651WO1

[0154] neural network 10 using the total objective 33O.N.i.t. For example, the system can generate the network parameters 15.(t+1) for the next iteration (t+1) for the elastic neural network 10.

[0155]

[0126] More details for training an elastic neural network are described in connection with FIG. 8.

[0156]

[0127] FIG. 8 is a flow diagram of an example process 800 for training an elastic neural network. For convenience, the process 800 will be described as being performed by a system of one or more computers located in one or more locations. For example, the training system 300 of FIG. 7, appropriately programmed in accordance with this specification, can perform the process 800.

[0157]

[0128] The system obtains a training dataset for training an elastic neural network having an elastic architecture defined by a plurality of architectural dimensions (802). For example, referring to FIG. 7, the training system 300 obtains a training dataset 310 for training an elastic neural network 10 (as shown in FIG. 1A) to determine a set of network parameters 15 for the elastic neural network 10. The elastic neural network 10 can be defined by a plurality of architectural dimensions as shown in FIG. 5. For example, the elastic neural network 10 can have an elastic neural network architecture 500 defined by one or more of: a model dimension DM, a model depth dimension DL, an attention dimension DA, an attention depth DH, a Feed-Forward Network (FFN) dimension DF, and a FFN depth DE.

[0158]

[0129] In some implementations, the elastic neural network can include a plurality of active layer blocks each configured to: receive a block input embedding belonging to a model embedding space; and process the block input embedding to generate a block output embedding belonging to the model embedding space. For example, in FIG. IB, the elastic neural network can include a plurality of active layer blocks, e.g., the residual layer blocks 55. In FIG. 2A and FIG. 2B, each residual layer block 55 is configured to receive a block input embedding having a dimension DM belonging to a model embedding space and process the block input embedding to generate a block output embedding having a dimension DM belonging to the same model embedding space.

[0159]

[0130] In some implementations, the plurality of architectural dimensions defining the elastic architecture of the elastic neural network can include a model dimension defining a dimensionality of the model embedding space of the elastic neural network. For example, the model dimension DM in FIG. 5 can define a dimensionality of the model embedding space of the elastic neural network 10. For example, in FIG. 2A and 2B, the model dimension DM can define a dimensionality of block input embedding and a dimensionality of the block output embedding.Attorney Docket No. 45288-0651WO1

[0160]

[0131] In some implementations, the plurality of architectural dimensions defining the elastic architecture of the elastic neural network can include a model depth defining a total number of the plurality of active layer blocks in the elastic neural network. For example, the model depth dimension DL in FIG. 5 can define a total number of active layer blocks in the elastic neural network 10. In FIG. IB, the model depth dimension DL can define the total number of the plurality of residual layer blocks in the elastic neural network 10.

[0161]

[0132] In some implementations, the plurality of active layer blocks can be organized in a residual sequence. For each active layer block, the residual sequence can include: a respective additive gate immediately following the active layer block; and a respective skip connection between: (i) an input of the active layer block, and (ii) the respective additive gate. For example, in FIG. IB, for each residual layer block 55, the residual sequence can include a respective additive gate 32 immediately following the residual layer block 55; and a respective skip connection 30 between: (i) an input of the residual layer block 55, and (ii) the respective additive gate 32.

[0162]

[0133] In some implementations, for each active layer block that is not a first of the plurality of active layer blocks in the residual sequence, the block input embedding of the active layer block can include a summation of: the block input embedding of a layer block preceding the active layer block in the residual sequence; and the block output embedding of the layer block preceding the active layer block in the residual sequence. For example, in FIG. IB, for the residual layer block 55. i (wherein i=l, 2, ..., DL) that is not a first of the plurality of residual layer blocks 55 in the residual sequence, the block input embedding of the residual layer block 55. i can include a summation of: the block input embedding of a residual layer block 55.(i-1) preceding the residual layer block 55. i in the residual sequence; and the block output embedding of the layer block 55. (i-1) preceding the residual layer block 55. i in the residual sequence.

[0163]

[0134] In some implementations, each active layer block in the elastic neural network can include an attention layer. The attention layer can be configured to: receive a layer input embedding belonging to the model embedding space; for each of a plurality of attention heads: apply a respective set of input projection matrices to the layer input embedding to generate a respective set of attention input embeddings each belonging to an attention embedding space; and apply a respective attention mechanism over the respective set of attention input embeddings to generate a respective attention output embedding belonging to the attention embedding space; concatenate the respective attention output embeddings for each of the plurality of attention heads to generate a multi-head attention output embedding; and apply anAttorney Docket No. 45288-0651WO1

[0164] output projection matrix to the multi -head attention output embedding to generate a layer output embedding belonging to the model embedding space.

[0165]

[0135] For example, in FIG. 2 A and FIG. 2B, each residual layer block 55 A and 55B can include an attention layer 100. The attention layer 100 can be configured to receive a layer input embedding belonging to the model embedding space having the model dimension DM. As shown in FIG. 3, for each of a plurality of attention heads, the attention layer 100 can be configured to apply a respective set of input projection matrices 110.Q.1, 110.K.1, and 110. V.1 to the layer input embedding to generate a respective set of attention input embeddings each belonging to an attention embedding space having the attention dimension DA. The attention layer 100 can be configured to apply a respective attention mechanism 120 over the respective set of attention input embeddings to generate a respective attention output embedding belonging to the attention embedding space having the attention depth dimension DH. The attention layer 100 can be configured to concatenate, e.g., using a concatenation layer 125, the respective attention output embeddings for each of the plurality of attention heads to generate a multi -head attention output embedding. The attention layer 100 can be configured to apply an output projection matrix 130 to the multi-head attention output embedding (e.g., having dimension DH X DA) to generate a layer output embedding belonging to the model embedding space having the model dimension DM.

[0166]

[0136] In some implementations, the plurality of architectural dimensions defining the elastic architecture of the elastic neural network can include an attention dimension defining a dimensionality of the attention embedding space of the attention layer of each active layer block in the elastic neural network. For example, in FIG. 3, the attention dimension DA can define a dimensionality of the attention embedding space of the attention layer 100 of each residual layer block 55 in the elastic neural network 10.

[0167]

[0137] In some implementations, the plurality of architectural dimensions defining the elastic architecture of the elastic neural network can include an attention depth defining a total number of the plurality of attention heads of the attention layer of each layer block in the elastic neural network. For example, in FIG. 3, the attention depth DH can define a total number of the plurality of attention heads of the attention layer 100 of each layer block in the elastic neural network 10.

[0168]

[0138] In some implementations, for each of the plurality of attention heads of the attention layer of each active layer block in the elastic neural network, the respective set of input projection matrices can include a respective triplet of a query value projection matrix, a keyAttorney Docket No. 45288-0651WO1

[0169] value projection matrix, and a value projection matrix. The respective set of attention input embeddings can include a respective triplet of a query, a key, and a value.

[0170]

[0139] For example, in FIG. 3, for each of the plurality of attention heads of the attention layer 100 of each residual layer block 55 in the elastic neural network 10, the respective set of input projection matrices can include a respective triplet of a query value projection matrix 110.Q.1, a key value projection matrix 110.K.1, and a value projection matrix 110.V.1. The respective set of attention input embeddings can include a respective triplet of a query Q, a key K, and a value V.

[0171]

[0140] In some implementations, the multi-head attention output embedding of the attention layer of each active layer block in the elastic neural network can have the same dimensionality as the dimensionality of the attention embedding space of the attention layer. For example, in FIG. 3, the multi -head attention output embedding of the attention layer 100 of each residual layer block 55 in the elastic neural network 10 can have the same dimensionality DA as the dimensionality of the attention embedding space of the attention layer 100.

[0172]

[0141] In some implementations, some or all of the active layer blocks in the elastic neural network can further include a mixture-of-experts (MoE) layer. The mixture-of-experts layer can be configured to receive a layer input embedding belonging to the model embedding space. The mixture-of-experts layer can be configured to process the layer input embedding, using a router, to generate a respective probability for each of a plurality of experts. The mixture-of-experts layer can be configured to process the layer input embedding, using each of the plurality of experts, to generate a respective expert output embedding belonging to the model embedding space. The mixture-of-experts layer can be configured to multiply, for each of the plurality of experts, the respective expert output embedding by the respective probability for the expert. The mixture-of-experts layer can be configured to sum the respective expert output embeddings multiplied by the respective probabilities for each of the plurality of experts to generate a layer output embedding belonging to the model embedding space.

[0173]

[0142] For example, referring to FIG. 2 A and FIG. 2B, each residual layer block 55 A and 55B in the elastic neural network 10 can further include a mixture-of-experts feedforward layer 200. Referring to FIG. 4A, the mixture-of-experts feedforward layer 200 can be configured to receive a layer input embedding belonging to the model embedding space. The mixture-of-experts feedforward layer 200 can be configured to process the layer input embedding, using a router 210, to generate a respective probability 212.1, 212.2, ... , 212. DE for each of a plurality of experts. The mixture-of-experts feedforward layer 200 can be configured to process the layer input embedding, using each of the plurality of experts, to generate a respective expert outputAttorney Docket No. 45288-0651WO1

[0174] embedding 214.1, 214.2, ..., 214. DE belonging to the model embedding space. The mixture-of-experts feedforward layer 200 can be configured to multiply 34, for each of the plurality of experts, the respective expert output embedding 214.1, 214.2, ..., 214. DE by the respective probability 212.1, 212.2, ..., 212. DE for the expert. The mixture-of-experts layer 200 can be configured to sum the respective expert output embeddings multiplied by the respective probabilities for each of the plurality of experts to generate a layer output embedding belonging to the model embedding space.

[0175]

[0143] In some implementations, the mixture-of-experts layer of each active layer block can be a mixture-of-experts feedforward layer. The plurality of experts of the mixture-of-experts feedforward layer can be a plurality of feedforward experts. Each feedforward expert can be configured to receive the layer input embedding belonging to the model embedding space. Each feedforward expert can be configured to apply a respective input projection matrix to the layer input embedding to generate a respective pre-activated embedding belonging to a feedforward embedding space. Each feedforward expert can be configured to apply a respective activation function over the respective pre-activated embedding to generate a respective activated embedding belonging to the feedforward embedding space. Each feedforward expert can be configured to apply a respective output projection matrix to the respective activated embedding to generate the respective expert output embedding belonging to the model embedding space.

[0176]

[0144] For example, referring to FIG. 4 A and FIG. 4B, the mixture-of-experts feedforward layer 200 of each residual layer block 55 can be a mixture-of-experts feedforward layer 200. The plurality of experts of the mixture-of-experts feedforward layer 200 can be a plurality of feedforward experts, e.g., feedforward neurons 220.1, 220.2, ..., 220. DE. Each feedforward expert (e.g., the feedforward neuron 220) can be configured to receive the layer input embedding belonging to the model embedding space (e.g., a space having dimension DM). Each feedforward expert (e.g., the feedforward neuron 220) can be configured to apply a respective input projection matrix 222 to the layer input embedding to generate a respective pre-activated embedding belonging to a feedforward embedding space (e.g., a space having dimension DF). Each feedforward expert (e.g., the feedforward neuron 220) can be configured to apply a respective activation function 224 over the respective pre-activated embedding to generate a respective activated embedding belonging to the feedforward embedding space (e.g., a space having dimension DF). Each feedforward expert (e.g., the feedforward neuron 220) can be configured to apply a respective output projection matrix 226 to the respective activated embedding to generate the respective expert output embedding belonging to the model embedding space (e.g., a space having dimension DM).Attorney Docket No. 45288-0651WO1

[0177]

[0145] In some implementations, the plurality of architectural dimensions defining the elastic architecture of the elastic neural network can include a feedforward dimension defining a dimensionality of the feedforward embedding space of the mixture-of-experts feedforward layer of each active layer block in the elastic neural network. For example, the feedforward dimension DF in FIG. 5 can define a dimensionality of the feedforward embedding space of the mixture-of-experts feedforward layer 200 of each residual layer block 55 A or 55B in the elastic neural network 10.

[0178]

[0146] In some implementations, the plurality of architectural dimensions defining the elastic architecture of the elastic neural network can include a feedforward depth defining a total number of the plurality of feedforward experts of the mixture-of-experts feedforward layer of each active layer block in the elastic neural network. For example, in FIG. 4 A, the feedforward depth DE can define a total number of the plurality of feedforward experts, e.g., feedforward neurons 220, of the mixture-of-experts feedforward layer 200 of each residual layer block 55 A or 55B in the elastic neural network 10.

[0179]

[0147] In some implementations, the respective activation function of each of the plurality of feedforward experts of the mixture-of-experts feedforward layer of each active layer block in the elastic neural network can be a Rectified Linear Unit, a Gaussian error Linear Unit, or a swish function. For example, referring to FIG. 4B, the respective activation function 224 of each of the plurality of feedforward experts, e.g., feedforward neurons 220, of the mixture-of-experts feedforward layer 200 of each residual layer block 55 A or 55B in the elastic neural network 10 can be a Rectified Linear Unit, a Gaussian error Linear Unit, or a swish function.

[0180]

[0148] In some implementations, each active layer block in the elastic neural network can be a transformer layer block. For example, referring to FIG. 2 A and FIG. 2B, each residual layer block 55 A or 55B in the elastic neural network 10 can be a transformer layer block.

[0181]

[0149] In some implementations, each transformer layer block in the elastic neural network can include: the attention layer; a first additive gate immediately following the attention layer; a first skip connection between: (i) an input of the attention layer, and (ii) the first additive gate; a first normalization layer immediately following the first additive gate; the mixture-of-experts feedforward layer immediately following the first normalization layer; a second additive gate immediately following the mixture-of-experts feedforward layer; a second skip connection between: (i) an input of the mixture-of-experts feedforward layer, and (ii) the second additive gate; and a second normalization layer immediately following the second additive gate.Attorney Docket No. 45288-0651WO1

[0182]

[0150] For example, referring to FIG. 2A, each transformer layer block, e.g., the residual layer block 55A, in the elastic neural network 10 can include: the attention layer 100; a first additive gate 32.1 immediately following the attention layer 100; a first skip connection 30.1 between: (i) an input of the attention layer 100, and (ii) the first additive gate 32.1; a first normalization layer 150A immediately following the first additive gate 32.1; the mixture-of-experts feedforward layer 200 immediately following the first normalization layer 150A; a second additive gate 32.2 immediately following the mixture-of-experts feedforward layer 200; a second skip connection 30.2 between: (i) an input of the mixture-of-experts feedforward layer 200, and (ii) the second additive gate 32.2; and a second normalization layer 150B immediately following the second additive gate 32.2.

[0183]

[0151] In some implementations, each transformer layer block in the elastic neural network can include: a first normalization layer; the attention layer immediately following the first normalization layer; a first additive gate immediately following the attention layer; a first skip connection between: (i) an input of the first normalization layer, and (ii) the first additive gate; a second normalization layer immediately following the first additive gate; the mixture-of-experts feedforward layer immediately following the second normalization layer; a second additive gate immediately following the mixture-of-experts feedforward layer; and a second skip connection between: (i) an input of the second normalization layer, and (ii) the second additive gate.

[0184]

[0152] For example, referring to FIG. 2B, each transformer layer block, e.g., the residual layer block 55B, in the elastic neural network 10 can include: a first normalization layer 150A; the attention layer 100 immediately following the first normalization layer 150A; a first additive gate 32.1 immediately following the attention layer 100; a first skip connection 30.1 between: (i) an input of the first normalization layer 150A, and (ii) the first additive gate 32.1; a second normalization layer 150B immediately following the first additive gate 32.1; the mixture-of-experts feedforward layer 200 immediately following the second normalization layer 150B; a second additive gate 32.2 immediately following the mixture-of-experts feedforward layer 200; and a second skip connection 30.2 between: (i) an input of the second normalization layer 150B, and (ii) the second additive gate 32.2.

[0185]

[0153] In some implementations, the first and second normalization layers of each transformation layer block in the elastic neural network can be a layer normalization layer, a root mean square normalization layer, a batch normalization layer, a weight normalization layer, or a group normalization layer. For example, in FIG. 2 A and FIG. 2B, the first normalization layer 150A and the second normalization layer 150B of each transformationAttorney Docket No. 45288-0651WO1

[0186] layer block, e.g., the residual layer block 55A or 55B, in the elastic neural network 10 can be a layer normalization layer, a root mean square normalization layer, a batch normalization layer, a weight normalization layer, or a group normalization layer.

[0187]

[0154] In some implementations, the elastic neural network can include an input subnetwork configured to receive a network input for the elastic neural network; and process the network input to generate an input embedding belonging to the model embedding space. The elastic neural network can include a residual network immediately following the input subnetwork. The residual network can include the plurality of active layer blocks; an additive gate immediately following the residual network; a skip connection between: (i) an input of the residual network, and (ii) the additive gate. The elastic neural network can include an output subnetwork immediately following the additive gate. The output subnetwork can be configured to receive an output embedding belonging to the model embedding space; and process the output embedding to generate a network output for the elastic neural network.

[0188]

[0155] For example, referring to FIG. 1A and FIG. IB, the elastic neural network 10 can include an input subnetwork 25 configured to receive a network input 12 for the elastic neural network 10; and process the network input 12 to generate an input embedding belonging to the model embedding space. The elastic neural network 10 can include a residual network 50 immediately following the input subnetwork 25. The residual network 50 can include the plurality of residual layer blocks 55; an additive gate 32 immediately following the residual network 50; a skip connection 30 between: (i) an input of the residual network 50, and (ii) the additive gate 32. The elastic neural network 10 can include an output subnetwork 75 immediately following the additive gate 32. The output subnetwork 75 can be configured to receive an output embedding belonging to the model embedding space; and process the output embedding to generate a network output 14 for the elastic neural network 10.

[0189]

[0156] Referring to FIG. 8, the system receives an input specifying: (i) a respective set of sizes of each of the plurality of architectural dimensions of the elastic architecture, and (ii) a plurality of configurations of the elastic neural network (804). For each architectural dimension, each configuration is specified by a respective size selected from the respective set of sizes of the architectural dimension.

[0190]

[0157] For example, referring to FIG. 5, the system can receive an input specifying a respective set of sizes of each of the plurality of architectural dimensions: DM, DL, DA, DH, DF, and DE. Each architectural dimension can have a set of sizes.Attorney Docket No. 45288-0651WO1

[0191]

[0158] For example, the model dimension DM can have a set of sizes {1, 2, NM}. A size selected from the set of sizes {1, 2, NM} of the model dimension DM can be dm. For the model dimension DM, the configuration can be specified by the size dm.

[0192]

[0159] For example, the model depth dimension DL can have a set of sizes {1, 2, ..., NL}. A size selected from the set of sizes {1, 2, ..., NL} of the model depth dimension DL can be di. For the model depth dimension DL, the configuration can be specified by the size di.

[0193]

[0160] For example, the attention dimension DA can have a set of sizes {1, 2, ..., NA}. A size selected from the set of sizes {1, 2, ..., NA} of the attention dimension DA can be da. For the attention dimension DA, the configuration can be specified by the size da.

[0194]

[0161] For example, the attention depth dimension DH can have a set of sizes {1, 2, ..., NH}. A size selected from the set of sizes {1, 2, ... , NH} of the attention depth dimension DH can be dh. For the attention depth dimension DH, the configuration can be specified by the size dh.

[0195]

[0162] For example, the FFN dimension DF can have a set of sizes {1, 2, ..., NF}. A size selected from the set of sizes {1, 2, ... , NF} of the FFN dimension DF can be df. For the FFN dimension DF, the configuration can be specified by the size df.

[0196]

[0163] For example, the FFN depth dimension DE can have a set of sizes {1, 2, ..., NE}. A size selected from the set of sizes {1, 2, ..., NE} of the FFN depth dimension DE can be de. For the FFN depth dimension DE, the configuration can be specified by the size de.

[0197]

[0164] In some implementations, the plurality of configurations of the elastic neural network can include a main configuration of the elastic neural network and a plurality of auxiliary configurations of the elastic neural network. For each architectural dimension, the main configuration can have the elastic architecture configured with the largest respective size in the respective set of sizes of the architectural dimension. Each auxiliary configuration can have the elastic architecture configured differently than the main configuration.

[0198]

[0165] For example, referring to FIG. 7, the plurality of configurations of the elastic neural network 10 can include a main configuration 10.N and an auxiliary configuration 10. i. For the model dimension DM, the main configuration 10.N can have the elastic neural network architecture 500 configured with the largest size NM in the set of sizes {1, 2, ..., NM} of the model dimension DM. Similar logic can apply to the main configuration for the other architectural dimensions.

[0199]

[0166] Referring to FIG. 8, the system initializes a set of network parameters shared between the plurality of configurations of the elastic neural network (806). For each architectural dimension, each respective size is associated with a respective subset of the set of network parameters along the architectural dimension. The respective subset of network parameters isAttorney Docket No. 45288-0651WO1

[0200] a subset of the respective subset of network parameters associated with each size in the set of sizes of the architectural dimension that is larger than the respective size. For example, referring to FIG. 7, the training system 300 initialized a set of network parameters 15.t shared between the main configuration 10.N and the auxiliary configurations lO.i of the elastic neural network 10.

[0201]

[0167] In some implementations, the system can initialize the set of network parameters of the plurality of configurations of the elastic neural network by performing the following operations. The system can receive a pre-trained neural network having the main configuration. The system can initialize the set of network parameters as a set of pre-trained network parameters of the pre-trained neural network.

[0202]

[0168] For example, the system can use a tail-patching conversion technique to efficiently convert a pre-trained, non-elastic neural network into the elastic neural network, e.g., while using a fraction (e.g., approximately 10%) of the original pre-training data.

[0203]

[0169] In some implementations, the system can receive a pre-training dataset the pre-trained neural network was pre-trained on. The system can augment the training dataset with one or more batches of network inputs sampled from the pre-training dataset.

[0204]

[0170] The system trains the set of network parameters shared between the plurality of configurations of the elastic network on the training dataset (808). For example, referring to FIG. 7, the training system 300 trains the set of network parameters 15 shared between the plurality of main configurations 10.N and the auxiliary configurations lO.i of the elastic network on the training dataset 310.

[0205]

[0171] In some implementations, the system can train the set of network parameters of the plurality of configurations of the elastic neural network on the training dataset over a plurality of training iterations. At each of the plurality of training iterations, the system can perform the following operations. The system can sample, from the training dataset, a batch of network inputs. The system can receive a respective current value of each network parameter belonging to the set of network parameters. The system can parametrize the main configuration of the elastic neural network with the respective current value of each network parameter belonging to the set of network parameters. The system can sample, from a probability distribution over the plurality of auxiliary configurations, one of the plurality of auxiliary configurations of the elastic neural network.

[0206]

[0172] In some implementations, the system can use an efficient update strategy. For example, the system can use an efficient sampling strategy during training. The system can update the main configuration of the elastic neural network having the largest model size at each trainingAttorney Docket No. 45288-0651WO1

[0207] iteration. The system can sample and update the nested, auxiliary configurations of the elastic neural network less frequently (e.g., at approximately 50% of the training iterations). In some implementations, this sampling strategy can balance training stability and subnetwork quality.

[0208]

[0173] In some implementations, the probability distribution can be a uniform distribution over the plurality of auxiliary configurations. In some implementations, the probability distribution can be a non-uniform distribution over the plurality of auxiliary configurations. For example, the system can assign higher probability to larger configurations or can assign higher probabilities to smaller configurations.

[0209]

[0174] The system can generate the sampled auxiliary configuration of the elastic neural network. The system can parametrize the auxiliary configuration with the respective current value of each network parameter belonging to the respective subset of the set of network parameters associated with the auxiliary configuration. The system can jointly train the main and auxiliary configurations of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set of network parameters. In some implementations where the neural network includes MoE layers, the system can relax the MoE routing constraint by allowing the main model and auxiliary configurations to route token embeddings independently during the joint training. For example, during a given forward pass during this joint training, instead of forcing the auxiliary configuration to use nested versions of the exact same experts chosen by the main configuration, the routing mechanisms can be decoupled. For example, the main model can route a token to experts 20, 35, and 40, while the submodel can route that same token to different experts, such as experts 24, 50, and 72.

[0210]

[0175] For example, referring to FIG. 7, the training system 300 can train the elastic neural network 10 over a plurality of training iterations t = 1 to T. At iteration t, the training system 300 can sample, from the training dataset 310, a batch 312. t of network inputs. The system 300 can receive a respective current value of each network parameter belonging to the set of network parameters 15.t. The system 300 can parametrize 316 the main configuration 10.N of the elastic neural network 10 with the respective current value of each network parameter belonging to the set of network parameters 15.t. The system 300 can sample 318, from a probability distribution 320 over the plurality of auxiliary configurations, one of the plurality of auxiliary configurations lO.i of the elastic neural network. The system can generate the sampled auxiliary configuration lO.i of the elastic neural network. The system can parametrize the auxiliary configuration lO.i with the respective current value of each network parameter belonging to the respective subset of the set of network parameters 15.t associated with theAttorney Docket No. 45288-0651WO1

[0211] auxiliary configuration 10. i. The system 300 can jointly train the main configuration 10.N and the auxiliary configuration 10. i of the elastic neural network 10 on the batch 312. t of network inputs to update 322 the respective current value of each network parameter belonging to the set of network parameters 15.t to generate the set of updated network parameters 15.(t+l).

[0212]

[0176] In some implementations, at each of the plurality of training iterations, the system can perform the following operations. At each of a plurality of training iterations, the system can sample, from the training dataset, a batch of network inputs. The system can receive a respective current value of each network parameter belonging to the set of network parameters. The system can parametrize the main configuration of the elastic neural network with the respective current value of each network parameter belonging to the set of network parameters. The system can determine whether a criterion for training any one of the plurality of auxiliary configurations is satisfied at the training iteration.

[0213]

[0177] In some implementations, determining whether the criterion for training the set of auxiliary configurations of the elastic neural network is satisfied at the training iteration can include: determining whether a threshold number of the plurality of training iterations has elapsed since any one of the plurality of auxiliary configurations of the elastic neural network was jointly trained with the main configuration of the elastic neural network. In some implementations, the threshold number of training iterations can have a value of two or more. In some implementations, the threshold number of training iterations can have a value in a range from two to five.

[0214]

[0178] If the criterion is not satisfied at the training iteration, the system can train the main configuration of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set network parameters.

[0215]

[0179] If the criterion is satisfied at the training iteration, the system can sample, from a probability distribution over the plurality of auxiliary configurations, one of the plurality of auxiliary configurations of the elastic neural network. In some implementations, the probability distribution can be a uniform distribution over the plurality of auxiliary configurations. The system can generate the sampled auxiliary configuration of the elastic neural network. The system can parametrize the auxiliary configuration with the respective current value of each network parameter belonging to the respective subset of the set of network parameters associated with the auxiliary configuration. The system can jointly train the main and auxiliary configurations of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set of network parameters.Attorney Docket No. 45288-0651WO1

[0216]

[0180] In some implementations, at each of the plurality of training iterations, training the main configuration of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set of network parameters can include the following operations. For each network input in the batch, the system can process the network input, using the main configuration of the elastic neural network parametrized with the respective current value of each network parameter belonging to the set of network parameters, to generate a respective main network output for the network input. The system can compute a respective main objective term measuring an error between: (i) the respective main network output for the network input, and (ii) a respective target output for the network input. The system can compute, with respect to each network parameter belonging to the set of network parameters, a respective gradient of a main objective comprising the respective main objective term for each network input in the batch. The system can update, using the respective gradient of the main objective, the respective current value of each network parameter belonging to the set of network parameters.

[0217]

[0181] For example, referring to FIG. 7, at the training iteration t, for each network input in the batch 312. t, the training system 300 can process the network input, e.g., the samples 314.1.1, 314.t.b, ..., and 314.t.B, using the main configuration 10.N of the elastic neural network 10 parametrized with the respective current value of each network parameter 15.t belonging to the set of network parameters, to generate a respective main network output for the network input. For example, the system 300 can generate a respective main network output 12.N.t.b for the network input 12.t.b. The system 300 can compute a respective main objective term 332.N.t.b measuring an error between: (i) the respective main network output 12.N.t.b for the network input, and (ii) a respective target output 14*.t.b for the network input 12.t.b. The system 300 can compute, with respect to each network parameter belonging to the set of network parameters, a respective gradient of a main objective 334.N.t comprising the respective main objective term 332.N.t.b for each network input 12.t.b in the batch 312. t. The system 300 can update 322, using the respective gradient of the main objective 334.N.t, the respective current value of each network parameter 15.t belonging to the set of network parameters to generate the set of updated network parameters 15.(t+l).

[0218]

[0182] In some implementations, at each of the plurality of training iterations, jointly training the main and auxiliary configurations of the elastic neural network on the batch of network inputs to update the current values of the set network parameters can include the following operations. For each network input in the batch, the system can process the network input, using the auxiliary configuration of the elastic neural network parametrized with the respectiveAttorney Docket No. 45288-0651WO1

[0219] current value of each network parameter belonging to the respective subset of network parameters associated with the auxiliary configuration, to generate a respective auxiliary network output for the network input. The system can compute a respective auxiliary objective term measuring an error between: (i) the respective auxiliary network output for the network input, and (ii) the respective target output for the network input. The system can compute a respective co-distillation objective term measuring an error between: (i) a respective set of outputs generated by the main configuration when processing the network input, and (ii) a respective set of outputs generated by the auxiliary configuration when processing the network input. The system can compute, with respect to each network parameter belonging to the set of network parameters, a respective gradient of a total objective. The total objective can include: the main objective; an auxiliary objective including the respective auxiliary objective term for each network input in the batch; and a co-distillation objective including the respective codistillation objective term for each network input in the batch of network inputs. The system can update, using the respective gradient of the total objective, the respective current value of each network parameter belonging to the set of network parameters. In some implementations, by including the co-distillation objective, the system significantly enhance the model quality of the auxiliary configurations with little or no additional computational overhead.

[0220]

[0183] For example, referring to FIG. 7, at the training iteration t, for each network input 12.t.b in the batch 312. t, the system 300 can process the network input 12.t.b, using the auxiliary configuration lO.i of the elastic neural network parametrized with the respective current value of each network parameter 15.t belonging to the respective subset of network parameters associated with the auxiliary configuration lO.i, to generate a respective auxiliary network output 12.i.t.b for the network input 12.t.b. The system 300 can compute a respective auxiliary objective term 332.i.t.b measuring an error between: (i) the respective auxiliary network output 12.i.t.b for the network input 12.t.b, and (ii) the respective target output 14*.t.b for the network input 12.t.b. The system 300 can compute a respective co-distillation objective term 333.N.i.t.b measuring an error between: (i) a respective set of outputs generated by the main configuration 10.N when processing the network input 12.t.b, and (ii) a respective set of outputs generated by the auxiliary configuration lO.i when processing the network input 12.t.b. The system 300 can compute, with respect to each network parameter belonging to the set of network parameters, a respective gradient of a total objective 330.N.i.t. The total objective 330.N.i.t can include: the main objective 334.N.t; an auxiliary objective 334. i.t including the respective auxiliary objective term 332.i.t.b for each network input 12.t.b in the batch 312. t; and a co-distillation objective 335.N.i.t including the respective co-distillation objective term 333.N.i.t.bAttorney Docket No. 45288-0651WO1

[0221] for each network input 12.t.b in the batch 312. t of network inputs. The system 300 can update 322, using the respective gradient of the total objective 33O.N.i.t, the respective current value of each network parameter 15.t belonging to the set of network parameters, to generate the set of updated network parameters 15.(t+l).

[0222]

[0184] In some implementations, the system can use a loss weighting scheme. The system can compute the total objective using a weighting scheme for the objectives of sampled auxiliary configurations (e.g., penalty parameters in range from 0.2 to 0.5). For example, the total objective can be a weighted sum of the main objective and the auxiliary objective, and optionally, the co-distillation objective. This can allow control over the trade-off between the performance of the main configuration and the various auxiliary configurations.

[0223]

[0185] In some implementations, the system can update, using the respective gradient of the total objective, the respective current value of each network parameter belonging to the set of network parameters. In some implementations, the system can update, using the respective gradient of the total objective, the respective current value of each network parameter belonging to the set of network parameters other than the respective subset of network parameters associated with the auxiliary configuration.

[0224]

[0186] In some implementations, for each network input in the batch, the respective codistillation objective term can measure an error between: (i) a respective set of intermediate outputs generated by a respective intermediate layer of the main configuration when processing the respective network input, and (ii) a respective set of intermediate outputs generated by a corresponding intermediate layer of the auxiliary configuration when processing the respective network input. In some implementations, the respective intermediate layer of each of the main and auxiliary configurations of the elastic neural network can be a last respective layer in the configuration.

[0225]

[0187] In some implementations, the total objective function can include a summation of: the main objective multiplied by a main penalty parameter; the auxiliary objective multiplied by a respective auxiliary penalty parameter associated with the auxiliary configuration of the elastic neural network; and the co-distillation objective multiplied by a respective co-distillation penalty parameter associated with the auxiliary configuration of the elastic neural network.

[0226]

[0188] In some implementations, at each of the plurality of training iterations, jointly training the main and auxiliary configurations of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set of network parameters can include the following operations. The system can process the batch of network inputs using one or more of the main or auxiliary configurations of the elastic neuralAttorney Docket No. 45288-0651WO1

[0227] network to generate a respective set of candidate network outputs for each network input in the batch. The system can obtain a respective reward for each candidate network output in the respective set of candidate network outputs for each network input in the batch. The system can compute, with respect to each network parameter belonging to the set of network parameters, a respective gradient of a reinforcement learning objective including the respective rewards for each network input in the batch of network inputs. The system can update, using the respective gradient of the reinforcement learning objective, the respective current value of each network parameter belonging to the set of network parameters.

[0228]

[0189] In some implementations, the reinforcement learning objective can include one or more reinforcement objective terms that each depend on an anchor neural network. The anchor neural network can be a pre-trained instance of the main configuration of the elastic neural network.

[0229]

[0190] In some implementations, processing the batch of network inputs using one or more of the main or auxiliary configurations of the elastic neural network to generate the respective set of candidate network outputs for each network input in the batch can include the following operations. The system can process each network input in a subset of the batch of network inputs, using the main configuration of the elastic neural network, to generate the respective set of candidate network outputs for the network input in the batch. The system can process each network input in a complement of the subset of the batch of network inputs, using the auxiliary configuration of the elastic neural network, to generate the respective set of candidate network outputs for the network input in the batch.

[0230]

[0191] In some implementations, processing the batch of network inputs using one or more of the main or auxiliary configurations of the elastic neural network to generate the respective set of candidate network outputs for each network input in the batch can include the following operations. For each network input in the batch, the system can process the network input, using the main configuration of the elastic neural network, to generate a subset of the respective set of candidate outputs for the network input. The system can process the network input, using the auxiliary configuration of the elastic neural network, to generate a complement of the subset of the respective set of candidate outputs for the network input.

[0231]

[0192] FIG. 9 is a flow diagram of an example process 900 for generating a network output using a target configuration of an elastic neural network. For convenience, the process 900 will be described as being performed by a system of one or more computers located in one or more locations.Attorney Docket No. 45288-0651WO1

[0232]

[0193] The system receives a query specifying: (i) a network input for the elastic neural network, and (ii) a target configuration in the plurality of configurations of the elastic neural network (902). In some implementations, after the set of network parameters shared between the plurality of configurations of the elastic neural network is trained on the training dataset, the training system or another system can receive a query specifying: (i) a network input for the elastic neural network, and (ii) a target configuration in the plurality of configurations of the elastic neural network. For example, in FIG. 1, the system can receive a query specifying: (i) a network input 12 for the elastic neural network 10, and (ii) a target configuration in the plurality of configurations of the elastic neural network 10.

[0233]

[0194] The system generates the target configuration of the elastic neural network (904). In some implementations, the system can parametrize the target configuration of the elastic neural network with trained values of the respective subset of network parameters associated with the target configuration.

[0234]

[0195] The system processes the network input, using the target configuration of the elastic neural network, to generate a network output for the network input (906). For example, in FIG.

[0235] 1, the system can process the network input 12, using the target configuration of the elastic neural network 10, to generate a network output 14 for the network input 12. In some implementations, the system can process the network input, using the target configuration of the elastic neural network in accordance with the trained values of the subset of network parameters associated with the target configuration, to generate a network output for the network input.

[0236]

[0196] In some implementations, the network input can be a multi-modal input. In some implementations, the network output can be a multi-modal output. In some implementations, the network input can be a multi-modal input, and the network output can be a multi-modal output.

[0237]

[0197] In some implementations, the network input can include one or more of: an input image, an input video, an input audio waveform, or an input text sequence.

[0238]

[0198] In some implementations, the neural network can include an observation characterizing a state of an environment being interacted with by an agent. In some implementations, the network output can define an action to be performed by the agent in response to the observation.

[0239]

[0199] In some implementations, the network input can include an input text sequence including a respective input text token at each of a plurality of input positions. In some implementations, the network output can include a prediction of a text token that follows the input text token at a last of the plurality of input positions.Attorney Docket No. 45288-0651WO1

[0240]

[0200] In some implementations, the system can generate an output text token using the network output. The system can append the output text token to the input text sequence. The system can process the network input including the input text sequence appended with the output text token, using the target configuration of the elastic neural network, to generate a network output including a prediction of a text token that follows the output text token appended to the input text sequence.

[0241]

[0201] FIG. 10 is a flow diagram of an example process 1000 for generating a network output using a target configuration of an elastic neural network. For convenience, the process 1000 will be described as being performed by a system of one or more computers located in one or more locations.

[0242]

[0202] The system obtains a set of network parameters for an elastic neural network having an elastic architecture defined by a plurality of architectural dimensions (1002). For each architectural dimension, a plurality of potential sizes is defined.

[0243]

[0203] For example, referring to FIG. 5, the elastic neural network architecture 500 can be defined by a plurality of architectural dimensions: DM, DL, DA, DH, DF, and DE. Each architectural dimension can have a plurality of potential sizes, as described in connection with FIG. 8.

[0244]

[0204] Each potential size is associated with a respective subset of a complete set of shared network parameters for the elastic neural network. The respective subset of network parameters for any given potential size is a subset of the respective subset of network parameters associated with each larger potential size for that architectural dimension. For example, the respective subset of network parameters for a potential size {1} is a subset of the respective subset of network parameters associated with each larger potential size from the sizes {2, ..., NM} for the model dimension DM.

[0245]

[0205] In some implementations, obtaining the set of network parameters (1002) can include the following operations. The system can provide an initial subset of the complete set of shared network parameters. In response to the initial subset being insufficient for the target configuration, the system can dynamically retrieve an additional subset of network parameters such that the combination of the initial and additional subsets forms the set of network parameters used for generating the target configuration.

[0246]

[0206] The system receives a query specifying: (i) a network input, and (ii) a target configuration for the elastic neural network (1004). The target configuration is specified by, for each architectural dimension, a selected potential size.Attorney Docket No. 45288-0651WO1

[0247]

[0207] The system generates the target configuration by selecting, for each architectural dimension, the respective subset of the obtained set of network parameters corresponding to the selected potential size forthat architectural dimension (1006).

[0248]

[0208] The system processes the network input, using the generated target configuration parameterized with its selected subsets of network parameters, to generate a network output (1008).

[0249]

[0209] In some implementations, one or more non-transitory computer-readable media can store a set of network parameters for an elastic neural network. The elastic neural network can have an elastic architecture defined by a plurality of architectural dimensions. For each architectural dimension of the plurality of architectural dimensions, a plurality of supported sizes can be defined, for which corresponding parameters are included in the stored set of network parameters. Each supported size in the plurality of supported sizes for an architectural dimension can be associated with a respective subset of the stored set of network parameters along that architectural dimension. The respective subset of network parameters associated with any given supported size for an architectural dimension can be a subset of the respective subset of network parameters associated with each supported size for that architectural dimension that is larger than the given supported size. The stored set of network parameters, when used to parameterize a selected configuration of the elastic neural network specified by a supported size for each architectural dimension, can enable the selected configuration to process a network input to generate a network output.

[0250]

[0210] In some implementations, the elastic architecture can further define, for each architectural dimension, a complete set of architectural sizes for the elastic neural network. The plurality of supported sizes for each architectural dimension, for which corresponding parameters are included in the stored set of network parameters, can include all sizes in the complete set of architectural sizes for that architectural dimension.

[0251]

[0211] In some implementations, the elastic architecture can be derived from a larger elastic architecture that defines, for each architectural dimension, a complete set of architectural sizes. The plurality of supported sizes for at least one architectural dimension, for which corresponding parameters are included in the stored set of network parameters, can constitute a proper subset of the complete set of architectural sizes defined by the larger elastic architecture for that architectural dimension.

[0252]

[0212] In some implementations, referring to FIG. 1, the elastic neural network 10 is configured to perform each machine learning task in the set of machine learning tasks by processing the network input 12 to generate the network output 14. In some implementations,Attorney Docket No. 45288-0651WO1

[0253] the elastic neural network 10 is configured to perform each machine learning task in the set of machine learning tasks in accordance with a prompt included in the network input 12, where the prompt defines the machine learning task to be performed by the elastic neural network 10. For example, the prompt can be a text prompt describing the machine learning task to be performed by the elastic neural network 10.

[0254]

[0213] Some examples of machine learning tasks that the training system 300 can train the elastic neural network 10 to perform are described in the following.

[0255]

[0214] In some implementations, the elastic neural network 10 may be deployed as part of a chat bot, dialogue agent, or other software tool that receives inputs from users and provides outputs in response to the received input, e.g., as part of a conversation or dialogue. In some implementations, the network input 12 received by the elastic neural network 10 can be a user input or can be generated from a user input. In some implementations, the network output 14, e.g., an output sequence, generated by the elastic neural network 10 can be used to generate one or more responses to the user input.

[0256]

[0215] In some implementations, the elastic neural network 10 may be configured as, or include, a generative (e.g., large) language model or a multi-modal model, e.g., a visual and language model, to perform these example machine learning tasks.

[0257]

[0216] In some implementations, the machine learning task may be a neural machine translation task. For example, if the network input 12 to the elastic neural network 10 is a sequence of text, e.g., a sequence of words, phrases, characters, or word pieces, in one language, an output sequence generated, e.g., auto-regressively generated, by the elastic neural network 10 may be a translation of the sequence of text into another language, i.e., a sequence of text in the other language that is a translation of the network input 12 of text. The vocabulary for the input tokens may be words, wordpieces or characters of the first language, and the vocabulary for the output tokens may be words, wordpieces or characters of the other language. As a particular example, the machine learning task may be a multi-lingual machine translation task, where the elastic neural network 10 is configured to translate between multiple different source language - target language pairs. In this example, the source language text may be augmented with an identifier that indicates the target language into which the elastic neural network 10 should translate the source language text.

[0258]

[0217] In some implementations, the machine learning task may be automatic code generation. For example, the input tokens of the network input 12 may represent words, wordpieces or characters in a first natural language and the output tokens of an output sequence generated by the elastic neural network 10 may represent instructions in a computer programming or markupAttorney Docket No. 45288-0651WO1

[0259] language, or instructions for controlling an application program to perform a task e.g. build a data item such as an image or a web page.

[0260]

[0218] In some implementations, the machine learning task may be an audio processing task. For example, if the network input 12 to the elastic neural network 10 is a sequence representing a spoken utterance, the network output 14 generated by the elastic neural network 10 may be a score for each of a set of pieces of text, each score representing an estimated likelihood that the piece of text is the correct transcript for the utterance. As another example, if the network input 12 to the elastic neural network 10 is a sequence representing a spoken utterance, the network output 14 generated by the elastic neural network 10 can indicate whether a particular word or phrase (“hotword”) was spoken in the utterance. As another example, if the network input 12 to the elastic neural network 10 is a sequence representing a spoken utterance, the network output 14 generated by the elastic neural network 10 can be a classification of the spoken utterance into one of a plurality of categories, for example an identity of the natural language in which the utterance was spoken.

[0261]

[0219] In some implementations, the machine learning task can be a natural language processing or understanding task, e.g., an entailment task, a paraphrase task, a textual similarity task, a sentiment task, a sentence completion task, a grammaticality task, and so on, that operates on a sequence of text in some natural language.

[0262]

[0220] In some implementations, the machine learning task can be a text to speech task, where the network input 12 is text in a natural language or features of text in a natural language, and the network output 14 is a spectrogram, a waveform, or other data defining audio of the text being spoken in the natural language.

[0263]

[0221] In some implementations, the machine learning task can be a text generation task, where the network input 12 is a sequence of text, and the network output 14 is another sequence of text, e.g., a completion of the network input 12 of text, a response to a question posed in the network input 12, or a sequence of text that is about a topic specified by the network input 12 of text.

[0264]

[0222] In some implementations the network input 12 represents data to be compressed, e.g., image data, text data, audio data, or any other type of data, and the network output 14 is a compressed version of the data. The input and output tokens may each include any representation of the data to be compressed / compressed data e.g., symbols or embeddings generated / decoded by a respective neural network.

[0265]

[0223] In some implementations, the training system 300 can train the elastic neural network 10 to perform any of multiple types of image processing tasks. For the image processing task,Attorney Docket No. 45288-0651WO1

[0266] the training system 300 trains the elastic neural network 10 by receiving a network input 12 including an input image; and processing respective intensity values of pixels of pixels of the input image to generate network output 14 for the input image. The input image may be a real-world image. The input image may be an image of a real-world environment captured by a camera.

[0267]

[0224] For example, the image processing task can be an object classification task, and the network output 14 generated by the elastic neural network 10 can include a respective score for each object category in a set of object categories, where the score represents an estimated likelihood that the input image depicts an object belonging to the category. As another example, the image processing task can be an image embedding generation task, and the network output 14 generated by the elastic neural network 10 can be a numeric embedding of the input image. As yet another example, the image processing task can be an object detection task, and the network output 14 generated by the elastic neural network 10 can identify locations in the input image at which particular types of objects are depicted. As yet another example, the image processing task can be an image segmentation task and the network output 14 generated by the elastic neural network 10 can assign each pixel of the input image to a category from a set of categories. Other examples of image processing tasks include depth prediction, optical flow prediction, and so on.

[0268]

[0225] The training system 300 can train the elastic neural network 10 to perform any of multiple types of audio processing tasks.

[0269]

[0226] For example, the audio processing task can be an audio transcription task where, if the network input 12 to the elastic neural network 10 includes a sequence representing a spoken utterance, the network output 14 generated by the elastic neural network 10 can include a respective score for each piece of text in a set of pieces of text, each score representing an estimated likelihood that the piece of text is the correct transcript for the utterance. As another example, the audio processing task can be a keyword spotting task where, if the network input 12 to the elastic neural network 10 includes a sequence representing a spoken utterance, the network output 14 generated by the elastic neural network 10 can indicate whether a particular word or phrase (“hotword”) was spoken in the utterance. As another example, the audio processing task can be a language recognition task where, if the network input 12 to the elastic neural network 10 includes a sequence representing a spoken utterance, the network output 14 generated by the elastic neural network 10 can identify the natural language in which the utterance was spoken. As another example, the audio processing task can be an audioAttorney Docket No. 45288-0651WO1

[0270] classification task, e.g., identifying an audio source that generated the sequence of audio, identifying the speaker in the audio, and so on.

[0271]

[0227] The training system 300 can train the elastic neural network 10 to perform any of multiple types of score or classification tasks. For the score or classification task, the training system 300 trains the elastic neural network 10 to process a network input 12, and generate a network output 14 including a score or classification output based on the network input 12.

[0272]

[0228] For example, if the network input 12 to the elastic neural network 10 includes image or features that have been extracted from images, the network output 14 generated by the elastic neural network 10 for a given image can include a respective score for each object category in a set of object categories, with the score representing an estimated likelihood that the given image depicts an object belonging to the object category.

[0273]

[0229] As another example, if the network input 12 to the elastic neural network 10 includes Internet resources (e.g., web pages), documents, portions of documents, or features extracted from Internet resources, documents, or portions of documents, the network output 14 generated by the elastic neural network 10 for a given Internet resource, document, or portion of a document can include a respective score for each topic in a set of topics, with the score representing an estimated likelihood that the given Internet resource, document, or document portion is related to the topic.

[0274]

[0230] As another example, if the network input 12 to the elastic neural network 10 includes features of an impression context for a particular advertisement, the network output 14 generated by the elastic neural network 10 can include a score representing an estimated likelihood that the particular advertisement will be clicked on.

[0275]

[0231] As another example, if the network input 12 to the elastic neural network 10 includes features of a personalized recommendation for a user, e.g., features characterizing the context for the recommendation, e.g., features characterizing previous actions taken by the user, the network output 14 generated by the elastic neural network 10 can include a respective score for each content item in a set of content items, with the score representing an estimated likelihood that the user will respond favorably to being recommended the content item.

[0276]

[0232] As another example, if the network input 12 to the elastic neural network 10 includes input text in one language, the network output 14 generated by the elastic neural network 10 can include a respective score for each piece of text in a set of pieces of text in another language, with the score representing an estimated likelihood that the piece of text in the other language is a proper translation of the input text into the other language.Attorney Docket No. 45288-0651WO1

[0277]

[0233] As another example, if the network input 12 to the elastic neural network 10 includes a spoken utterance, a sequence of spoken utterances, or features derived from one of the two, the network output 14 generated by the elastic neural network 10 can include a respective score for each piece of text in a set of pieces of text, with the score representing an estimated likelihood that the piece of text is the correct transcript for the utterance or sequence of utterances.

[0278]

[0234] The training system 300 can train the elastic neural network 10 to perform any of multiple types of reinforcement learning tasks. For the reinforcement learning task, the training system 300 trains the elastic neural network 10 to process a network input 12 including an observation characterizing a state of the environment being interacted with by the agent, and generate a network output 14 defining an action to be performed by the agent in response to the observation.

[0279]

[0235] In some implementations, the environment is a real-world environment, the agent is a mechanical agent interacting with the real-world environment, e.g., a robot, an autonomous or semi-autonomous land, air, or sea vehicle operating in or navigating through the environment, and the actions performed by the agent are actions taken by the mechanical agent in the real-world environment to perform the task. For example, the mechanical agent may be interacting with the environment to accomplish a specific task, e.g., to locate or manipulate an object of interest in the environment, move an object of interest to a specified location in the environment, or navigate to a specified destination in the environment.

[0280]

[0236] In these implementations, the observations can include one or more of: images, object position data, or sensor data to capture observations as the agent interacts with the environment, e.g., sensor data from an actuator, an image sensor, a distance sensor, or a position sensor located on the agent. For example, in the case of a robot, the observations may include data characterizing the current state of the robot, e.g., data including one or more of: joint position, joint velocity, joint force, joint torque, or joint acceleration (e.g., gravity-compensated torque feedback), and a global or relative pose of an item held by the robot. In the case of a robot or other mechanical agent or vehicle, the observations can similarly include one or more of: the position, linear velocity, angular velocity, force, torque, or acceleration of one or more parts of the agent, and the global or relative pose of the one or more parts of the agent. The observations may be defined in 1, 2, or 3 dimensions, and may be absolute and / or relative observations. The observations may also include, for example, sensed electronic signals such as motor current or a temperature signal; and / or image or video data for example from a camera or a LIDAR sensor,Attorney Docket No. 45288-0651WO1

[0281] e.g., data from sensors of the agent or data from sensors that are located separately from the agent in the environment.

[0282]

[0237] In these implementations, the actions may be control signals to control the robot or other mechanical agent, e.g., torques for the joints of the robot or higher-level control commands, or the autonomous or semi-autonomous land, air, sea vehicle, e.g., torques to the control surface or other control elements, e.g., steering control elements of the vehicle, or higher-level control commands. The control signals can include, for example, the position, velocity, force, torque, and / or acceleration data for one or more joints of a robot or parts of another mechanical agent. Alternatively, or in addition, the control signals may include electronic control data such as motor control data, or more generally data for controlling one or more electronic devices within the environment, where the control of which influences the observation of the state of the environment. For example, in the case of an autonomous or semi-autonomous land, air, or sea vehicle, the control signals may define actions to control navigation e.g., steering, and movement e.g., braking and / or acceleration of the vehicle.

[0283]

[0238] In some implementations, the environment is implemented in a simulation of the abovedescribed real-world environment, and the agent is implemented as one or more computers interacting with the environment in the simulation. For example, the simulation may be a simulation of a robot or vehicle and the training system 300 trains the elastic neural network 10 on the simulation and then, once trained, the elastic neural network 10 can be used in the real -world.

[0284]

[0239] In some implementations, the environment is a real-world manufacturing environment for manufacturing a product, such as a chemical, biological, or mechanical product, or a food product. As used herein a “manufacturing” a product also includes refining a starting material to create a product, or treating a starting material, e.g., to remove pollutants, to generate a cleaned or recycled product. The manufacturing plant may include multiple manufacturing units such as vessels for chemical or biological substances, or machines, e.g., robots, for processing solid or other materials. The manufacturing units are configured such that an intermediate version or component of the product is moveable between the manufacturing units during manufacture of the product, e.g., via pipes or mechanical conveyance. As used herein manufacture of a product also includes manufacture of a food product by a kitchen robot.

[0285]

[0240] The agent may include an electronic agent configured to control a manufacturing unit, or a machine such as a robot, that operates to manufacture the product. That is, the agent may include a control system configured to control the manufacture of the chemical, biological, or mechanical product. For example, the control system may be configured to control one or moreAttorney Docket No. 45288-0651WO1

[0286] of the manufacturing units or machines, or to control movement of an intermediate version or component of the product between the manufacturing units or machines.

[0287]

[0241] As one example, a task performed by the agent may include a task to manufacture the product or an intermediate version or component thereof. As another example, a task performed by the agent may include a task to control, e.g., minimize, use of a resource such as a task to control electrical power consumption, or water consumption, or the consumption of any material or consumable used in the manufacturing process.

[0288]

[0242] The actions performed by the agent may include control actions to control the use of a machine or a manufacturing unit for processing a solid or liquid material to manufacture the product, or an intermediate or component thereof, or to control movement of an intermediate version or component of the product within the manufacturing environment, e.g., between the manufacturing units or machines. In general, the actions performed by the agent may be any actions that influence the observation of the state of the environment, e.g., actions configured to adjust any of the sensed parameters described below. These may include actions to adjust the physical or chemical conditions of a manufacturing unit, or actions to control the movement of mechanical parts of a machine or joints of a robot. The actions performed by the agent may include actions imposing operating conditions on a manufacturing unit or machine, or actions that result in changes to settings to adjust, control, or switch on or off the operation of a manufacturing unit or machine.

[0289]

[0243] The rewards may relate to a metric of performance of the task. For example, in the case of a task that is to manufacture a product, the metric of performance may include a metric of a quantity of the product that is manufactured, a quality of the product, a speed of production of the product, or to a physical cost of performing the manufacturing task, e.g., a metric of a quantity of energy, materials, or other resources, used to perform the task. In the case of a task that is to control use of a resource the metric of performance may include any metric of usage of the resource.

[0290]

[0244] In general, the observations of the states of the environment may include any electronic signals representing the functioning of electronic and / or mechanical items of equipment. For example, an observation of a state of the environment may be derived from observations made by sensors sensing a state of the manufacturing environment, e.g., sensors sensing a state or configuration of the manufacturing units or machines, or sensors sensing movement of material between the manufacturing units or machines. As some examples such sensors may be configured to sense mechanical movement or force, pressure, temperature; electrical conditions such as current, voltage, frequency, impedance; quantity, level, flow / movement rate orAttorney Docket No. 45288-0651WO1

[0291] flow / movement path of one or more materials; physical or chemical conditions e.g. a physical state, shape or configuration or a chemical state such as pH; configurations of the units or machines such as the mechanical configuration of a unit or machine, or valve configurations; image or video sensors to capture image or video observations of the manufacturing units or of the machines or movement; or any other appropriate type of sensor. In the case of a machine such as a robot, the observations from the sensors may include observations of position, linear velocity, angular velocity, force, torque, and / or acceleration, or pose of one or more parts of the machine, e.g., data characterizing the current state of the machine or robot or of an item held or processed by the machine or robot. The observations may also include, for example, sensed electronic signals such as motor current or a temperature signal, or image or video data for example from a camera or a LIDAR sensor. Sensors such as these may be part of or located separately from the agent in the environment.

[0292]

[0245] In some implementations, the environment is the real-world environment of a service facility including multiple items of electronic equipment, such as a server farm or data center, e.g., a telecommunications data center, or a computer data center for storing or processing data, or any service facility. The service facility may also include ancillary control equipment that controls an operating environment of the items of equipment, for example environmental control equipment such as temperature control, e.g., cooling equipment, or air flow control or air conditioning equipment such as a heater, a cooler, a humidifier, or other hardware that modifies a property of air in the real -world environment. The task may include a task to control, e.g., minimize, use of a resource, such as a task to control electrical power consumption, or water consumption. The agent may include an electronic agent configured to control operation of the items of equipment, or to control operation of the ancillary, e.g., environmental, control equipment.

[0293]

[0246] In some implementations, the environment is the real-world environment of a power generation facility e.g., a renewable power generation facility such as a solar farm or wind farm. The task may include a control task to control power generated by the facility, e.g., to control the delivery of electrical power to a power distribution grid, e.g., to meet demand or to reduce the risk of a mismatch between elements of the grid, or to maximize power generated by the facility. The agent may include an electronic agent configured to control the generation of electrical power by the facility or the coupling of generated electrical power into the grid. The actions performed by the agent may include actions to control an electrical or mechanical configuration of an electrical power generator such as the electrical or mechanical configuration of one or more renewable power generating elements e.g., to control aAttorney Docket No. 45288-0651WO1

[0294] configuration of a wind turbine or of a solar panel or panels or mirror, or the electrical or mechanical configuration of a rotating electrical power generation machine. Mechanical control actions may, for example, include actions that control the conversion of an energy input to an electrical energy output, e.g., an efficiency of the conversion or a degree of coupling of the energy input to the electrical energy output. Electrical control actions may, for example, include actions that control one or more of a voltage, current, frequency, or phase of electrical power generated.

[0295]

[0247] In the case of a task to control the delivery of electrical power to the power distribution grid, the metric of performance can relate to a measure of power transferred, or to a measure of an electrical mismatch between the power generation facility and the grid such as a voltage, current, frequency or phase mismatch, or to a measure of electrical power or energy loss in the power generation facility.

[0296]

[0248] In the case of a task to maximize the delivery of electrical power to the power distribution grid, the metric of performance may relate to a measure of electrical power or energy transferred to the grid, or to a measure of electrical power or energy loss in the power generation facility.

[0297]

[0249] In general, the observations of the states of the environment may include any electronic signals representing the electrical or mechanical functioning of power generation equipment in the power generation facility. For example, an observation of a state of the environment may be derived from observations made by any sensors sensing a physical or electrical state of equipment in the power generation facility that is generating electrical power, or the physical environment of such equipment, or a condition of ancillary equipment supporting power generation equipment. Such observations may thus include observations of wind levels or solar irradiance, or of local time, date, or season. Such sensors may include sensors configured to sense electrical conditions of the equipment such as current, voltage, power, or energy; temperature or cooling of the physical environment; fluid flow; or a physical configuration of the equipment; and observations of an electrical condition of the grid e.g., from local or remote sensors. An observation of a state of the environment may also include one or more predictions regarding future conditions of operation of the power generation equipment such as predictions of future wind levels or solar irradiance or predictions of a future electrical condition of the grid.

[0298]

[0250] As another example, the environment may be a chemical synthesis or protein folding environment, such that each state of the environment is a respective state of a protein chain or of one or more intermediates or precursor chemicals, and the agent is a computer system forAttorney Docket No. 45288-0651WO1

[0299] determining how to fold the protein chain or synthesize the chemical. In this example, the actions performed by the agent are possible folding actions for folding the protein chain or actions for assembling precursor chemicals / intermediates and the result to be achieved may include, e.g., folding the protein so that the protein is stable and so that it achieves a particular biological function or providing a valid synthetic route for the chemical. As another example, the agent may be a mechanical agent that indirectly performs or controls the protein folding actions, or chemical synthesis steps, e.g., by controlling synthesis steps selected by the system automatically without human interaction. The observations of the states of the environment may include direct or indirect observations of a state of the protein or chemical / intermediates / precursors and / or may be derived from simulation. Thus, the training system 300 may be used to train the elastic neural network 10 to automatically synthesize a protein with a particular function such as having a binding site shape, e.g., a ligand that binds with sufficient affinity for a biological effect that it can be used as a drug. For example, e.g., it may be an agonist or antagonist of a receptor or enzyme; or it may be an antibody configured to bind to an antibody target such as a virus coat protein, or a protein expressed on a cancer cell, e.g., to act as an agonist for a particular receptor or to prevent binding of another ligand and hence prevent activation of a relevant biological pathway.

[0300]

[0251] In a similar way, the environment may be a drug design environment, such that each state of the environment is a respective state of a potential pharmaceutically active compound, i.e., a drug, and the agent is a computer system for determining elements of the pharmaceutically active compound and / or a synthetic pathway for the pharmaceutically active compound. The drug / synthesis may be designed based on a reward derived from a target for the pharmaceutically active compound, for example in simulation. The agent may be, or may include, a mechanical agent that performs or controls synthesis of the pharmaceutically active compound; and hence a process as described herein may include making such a pharmaceutically active compound.

[0301]

[0252] For example, the environment may be an in-silico drug design environment, e.g., a molecular docking environment, and the agent may be a computer system for determining elements or a chemical structure of the drug. The drug may be a small molecule or biologic drug. An observation of a state of the environment may be an observation of a simulated combination of the drug and a target of the drug. An action performed by the agent may be an action to modify the relative position, pose or conformation of the drug and drug target (or this may be performed automatically) and / or an action to modify a chemical composition of the drug and / or to select a candidate drug from a library of candidates. The rewards may be definedAttorney Docket No. 45288-0651WO1

[0302] based on one or more of: a measure of an interaction between the drug and the drug target, e.g., of a fit or binding between the drug and the drug target; an estimated potency of the drug; an estimated selectivity of the drug; an estimated toxicity of the drug; an estimated pharmacokinetic characteristic of the drug; an estimated bioavailability of the drug; an estimated ease of synthesis of the drug; and one or more fundamental chemical properties of the drug. A measure of interaction between the drug and drug target may depend on, e.g., a protein-ligand bonding, van der Waal interactions, electrostatic interactions, and / or a contact surface region or energy; it may include, e.g., a docking score. Following identification of elements or a chemical structure of a drug in simulation, a method involving the training system 300 training the elastic neural network 10 to control the agent may further include making the drug. The drug may be made partly or completely by an automatic chemical synthesis system.

[0303]

[0253] In some applications, the agent may be a software agent i.e., a computer program, configured to perform a task. For example, the environment may be a circuit, or an integrated circuit design, or routing environment, and the agent may be configured to perform a design or routing task for routing interconnection lines of a circuit or of an integrated circuit e.g., an ASIC. The rewards may then be dependent on one or more routing metrics such as interconnect length, resistance, capacitance, impedance, loss, speed, or propagation delay; and / or physical line parameters such as width, thickness or geometry, and design rules. The rewards may also or instead include one or more rewards relating to a global property of the routed circuitry e.g., component density, operating speed, power consumption, material usage, a cooling requirement, level of electromagnetic emissions, and so forth. The observations may be, e.g., observations of component positions and interconnections; the actions may include component placing actions, e.g., to define a component position or orientation and / or interconnect routing actions, e.g., interconnect selection and / or placement actions. The task may be, e.g., to optimize circuit operation to reduce electrical losses, local or external interference, or heat generation, or to increase operating speed, or to minimize or optimize usage of available circuit area. A method involving the training system 300 training the elastic neural network 10 to control the agent may further include making the circuit or integrated circuit to the design, or with interconnection lines routed as determined by the method.

[0304]

[0254] In some applications, the agent is a software agent, and the environment is a real-world computing environment. In one example, the agent manages distribution of tasks across computing resources e.g., on a mobile device and / or in a data center. In these applications, the observations of the states of the environment may include observations of computing resources such as compute and / or memory capacity, or Internet-accessible resources; and the actionsAttorney Docket No. 45288-0651WO1

[0305] performed by the agent may include assigning tasks to particular computing resources. The rewards may be configured to maximize or minimize one or more of: utilization of computing resources, electrical power, bandwidth, and computation speed.

[0306]

[0255] In another example, the software agent manages the processing, e.g., via one or more real -world servers, of a queue of continuously arriving jobs. The observations may include observations of the times of departures of successive jobs, or the time intervals between the departures of successive jobs, or the time a server takes to process each job, e.g., the start and end of a range of times, or the arrival times, or time intervals between the arrivals, of successive jobs, or data characterizing the type of job(s). The actions may include actions that allocate particular jobs to particular computing resources; the reward(s) may be configured to minimize an overall queueing or processing time or the queueing or processing time for one or more individual jobs, or in general to optimize any metric based on the observations.

[0307]

[0256] As another example, the environment may include a real-world computer system or network, the observations may include any observations characterizing operation of the computer system or network, the actions performed by the software agent may include actions to control the operation e.g. to limit or correct abnormal or undesired operation e.g. because of the presence of a virus or other security breach, and the rewards may include any metric(s) that characterizing desired operation of the real-world computer system or network.

[0308]

[0257] In some applications, the environment is a real-world computing environment, and the software agent manages distribution of tasks / jobs across computing resources e.g., on a mobile device and / or in a data center. In these implementations, the observations may include observations that relate to the operation of the computing resources in processing the tasks / jobs, the actions may include assigning tasks / jobs to particular computing resources, and the rewards may relate to one or more metrics of processing the tasks / jobs using the computing resources, e.g., metrics of usage of computational resources, bandwidth, or electrical power, or metrics of processing time, or numerical accuracy, or one or more metrics that relate to a desired load balancing between the computing resources.

[0309]

[0258] In some applications, the environment is a data packet communications network environment, and the agent is part of a router to route packets of data over the communications network. The actions performed by the agent may include data packet routing actions, and the observations of the states of the environment may include, e.g., observations of a routing table which includes routing metrics such as a metric of routing path length, bandwidth, load, hop count, path cost, delay, maximum transmission unit (“MTU”), and reliability. The reward mayAttorney Docket No. 45288-0651WO1

[0310] be defined in relation to one or more of the routing metrics, e.g., configured to maximize one or more of the routing metrics.

[0311]

[0259] In some other applications, the environment is an Internet or mobile communications environment, and the agent is a software agent which manages a personalized recommendation for a user. The observations of the states of the environment may include previous actions taken by the user, e.g., features characterizing these; the actions may include actions recommending items such as content items to a user. The rewards may be configured to maximize one or more of an estimated likelihood that the user will respond favorably to being recommended the (content) item, a suitability unsuitability of one or more recommended items, a cost of the recommended item(s), and a number of recommendations received by the user, optionally within a time span.

[0312]

[0260] As a further example, the actions performed by the agent may include presenting advertisements, the observations of the states of the environment may include advertisement impressions or a click-through count or rate, and the rewards may characterize previous selections of items or content taken by one or more users.

[0313]

[0261] In some cases, the observations may include textual or spoken instructions provided to the agent by a third-party (e.g., an operator of the agent). For example, the agent may be an autonomous vehicle, and a user of the autonomous vehicle may provide textual or spoken instructions to the agent (e.g., to navigate to a particular location).

[0314]

[0262] As another example, the environment may be an electrical, mechanical, or electromechanical design environment, e.g., an environment in which the design of an electrical, mechanical, or electro-mechanical entity is simulated. The environment may be implemented in a simulation of a real-world environment in which the entity is intended to work. The task may be to design the entity. The observations may include observations that characterize the entity, i.e., observations of a mechanical shape or of an electrical, mechanical, or electromechanical configuration of the entity, or observations of parameters or properties of the entity. The actions may include actions that modify the entity, e.g., that modify one or more of the observations. The rewards may include one or more metrics of performance of the design of the entity. For example, the rewards may relate to one or more physical characteristics of the entity such as weight or strength or to one or more electrical characteristics of the entity, such as a measure of efficiency at performing a particular function for which the entity is designed. The design process may include outputting the design for manufacture, e.g., in the form of computer executable instructions for manufacturing the entity. The process may include making the entity according to the design. Thus, the design of an entity may be optimized, e.g.,Attorney Docket No. 45288-0651WO1

[0315] by reinforcement learning, and then the optimized design output for manufacturing the entity, e.g., as computer executable instructions; an entity with the optimized design may then be manufactured.

[0316]

[0263] As previously described, the environment may be a simulated environment implemented in a simulation. Generally, in the case of a simulated environment, the observations may include simulated versions of one or more of the previously described observations or types of observations, and the actions may include simulated versions of one or more of the previously described actions or types of actions. For example, the simulated environment may be a motion simulation environment, e.g., a driving simulation or a flight simulation, and the agent may be a simulated vehicle navigating through the motion simulation. In these implementations, the actions may be control inputs to control the simulated user or simulated vehicle. Generally, the agent may be implemented as one or more computers interacting with the simulated environment.

[0317]

[0264] The simulated environment may be implemented in a simulation of a particular real-world environment and agent. For example, the elastic neural network 10 may be used to select actions in the simulated environment during training or evaluation of the elastic neural network 10 and, after training, or evaluation, or both, are complete, may be deployed for controlling a real -world agent in the particular real -world environment that was the subject of the simulation. This can avoid unnecessary wear and tear on and damage to the real-world environment or real-world agent and can allow the control neural network to be trained and evaluated on situations that occur rarely or are difficult or unsafe to re-create in the real-world environment. For example, the training system 300 can partly train the elastic neural network 10 using a simulation of a mechanical agent in a particular real-world environment, and afterwards deploy the elastic neural network 10 to control the real mechanical agent in the particular real -world environment. Thus, in such cases, the observations of the simulated environment relate to the real-world environment, and the actions selected in the simulated environment relate to the actions to be performed by the mechanical agent in the real-world environment.

[0318]

[0265] In some implementations, the observations of the environment are observations of a real-world environment in which a human is performing a task, e.g., an image observation from an image sensor and / or a language observation from a speech recognition system; and the actions performed by the agent are language actions that control (instruct) the human, e.g., using natural language or images, to perform actions in the real-world environment to perform the task. A language action may be an action that outputs a natural language sentence, e.g., byAttorney Docket No. 45288-0651WO1

[0319] defining a sequence of language tokens, e.g., words or wordpieces, to be emitted at sequential timesteps.

[0320]

[0266] Thus, the agent may include a user interface device such as a digital device (a “digital assistant”), e.g., a smart speaker or smart display or other device, e.g., with a natural language input and / or output, that controls (instructs) a human user to perform a task. In general, such a digital device can be a mobile device with a natural language interface to receive natural language requests from a human user and to provide natural language responses. It may also include a vision-based input e.g., a camera and / or display screen. The digital device may include a language model or language generation neural network system either stored locally, or accessed remotely, or both. The user interface device may include, e.g., a mobile device, a keyboard (and optionally display), or a speech-based input mechanism, e.g., to input audio data characterizing a speech waveform of speech representing the input from the user in the natural or computer language, and to convert the audio data into tokens representing the speech in the natural or computer language, e.g., representing a transcription of the spoken input. The user interface device can also include a text or speech-based output, e.g., a display and / or a text-to-speech subsystem.

[0321]

[0267] Thus, in some implementations, the actions performed by the agent contribute to performing the task. A monitoring system, e.g., a video camera system, may be provided for monitoring the action (if any) which the user actually performs at each timestep in case, e.g., due to human error, it is different from the action which the training system 300 instructed the user to perform. The monitoring system can be used to determine whether the task has been completed. Training data may be collected to record the actions which the user actually performed based on the instruction. The reward for an action may be generated, for example, by comparing the action the user took with a corpus of data showing a human expert performing the task, e.g., using techniques known from imitation learning, or in some other way, e.g., using a trained reward model. The training system 300 configured in this way can learn how to guide a human to perform a task, e.g., avoiding difficult to perform actions.

[0322]

[0268] Optionally, in any of the above implementations, the observation at any given timestep may include data from a previous timestep that may be beneficial in characterizing the state of the environment at the given timestep, e.g., the action performed by the agent at the previous timestep, the reward received by the agent at the previous timestep, or both.

[0323]

[0269] This specification uses the term “configured” in connection with systems and computer program components. For a system of one or more computers to be configured to perform particular operations or actions means that the system has installed on it software, firmware,Attorney Docket No. 45288-0651WO1

[0324] hardware, or a combination of them that in operation cause the system to perform the operations or actions. For one or more computer programs to be configured to perform particular operations or actions means that the one or more programs include instructions that, when executed by data processing apparatus, cause the apparatus to perform the operations or actions.

[0325]

[0270] Embodiments of the subject matter and the functional operations described in this specification can be implemented in digital electronic circuitry, in tangibly-embodied computer software or firmware, in computer hardware, including the structures disclosed in this specification and their structural equivalents, or in combinations of one or more of them. Embodiments of the subject matter described in this specification can be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible non-transitory storage medium for execution by, or to control the operation of, data processing apparatus. The computer storage medium can be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or a combination of one or more of them. Alternatively, or in addition, the program instructions can be encoded on an artificially-generated propagated signal, e.g., a machine-generated electrical, optical, or electromagnetic signal, that is generated to encode information for transmission to suitable receiver apparatus for execution by a data processing apparatus.

[0326]

[0271] The term “data processing apparatus” refers to data processing hardware and encompasses all kinds of apparatus, devices, and machines for processing data, including by way of example a programmable processor, a computer, or multiple processors or computers. The apparatus can also be, or further include, special purpose logic circuitry, e.g., an FPGA (field programmable gate array) or an ASIC (application-specific integrated circuit). The apparatus can optionally include, in addition to hardware, code that creates an execution environment for computer programs, e.g., code that constitutes processor firmware, a protocol stack, a database management system, an operating system, or a combination of one or more of them.

[0327]

[0272] A computer program, which may also be referred to or described as a program, software, a software application, an app, a module, a software module, a script, or code, can be written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages; and it can be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment. A program may, but need not, correspond to a file in a file system. A program can be stored in a portion of a file that holds other programs or data, e.g., one or moreAttorney Docket No. 45288-0651WO1

[0328] scripts stored in a markup language document, in a single file dedicated to the program in question, or in multiple coordinated files, e.g., files that store one or more modules, subprograms, or portions of code. A computer program can be deployed to be executed on one computer or on multiple computers that are located at one site or distributed across multiple sites and interconnected by a data communication network.

[0329]

[0273] In this specification the term “engine” is used broadly to refer to a software-based system, subsystem, or process that is programmed to perform one or more specific functions. Generally, an engine will be implemented as one or more software modules or components, installed on one or more computers in one or more locations. In some cases, one or more computers will be dedicated to a particular engine; in other cases, multiple engines can be installed and running on the same computer or computers.

[0330]

[0274] The processes and logic flows described in this specification can be performed by one or more programmable computers executing one or more computer programs to perform functions by operating on input data and generating output. The processes and logic flows can also be performed by special purpose logic circuitry, e.g., an FPGA or an ASIC, or by a combination of special purpose logic circuitry and one or more programmed computers.

[0331]

[0275] Computers suitable for the execution of a computer program can be based on general or special purpose microprocessors or both, or any other kind of central processing unit. Generally, a central processing unit will receive instructions and data from a read-only memory or a random-access memory or both. The essential elements of a computer are a central processing unit for performing or executing instructions and one or more memory devices for storing instructions and data. The central processing unit and the memory can be supplemented by, or incorporated in, special purpose logic circuitry. Generally, a computer will also include, or be operatively coupled to receive data from or transfer data to, or both, one or more mass storage devices for storing data, e.g., magnetic, magneto-optical disks, or optical disks. However, a computer need not have such devices. Moreover, a computer can be embedded in another device, e.g., a mobile telephone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a Global Positioning System (GPS) receiver, or a portable storage device, e.g., a universal serial bus (USB) flash drive, to name just a few.

[0332]

[0276] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media and memory devices, including by way of example semiconductor memory devices, e.g., EPROM, EEPROM, and flash memory devices; magnetic disks, e.g., internal hard disks or removable disks; magneto-optical disks; and CD-ROM and DVD-ROM disks.Attorney Docket No. 45288-0651WO1

[0333]

[0277] To provide for interaction with a user, embodiments of the subject matter described in this specification can be implemented on a computer having a display device, e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor, for displaying information to the user and a keyboard and a pointing device, e.g., a mouse or a trackball, by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback, e.g., visual feedback, auditory feedback, or tactile feedback; and input from the user can be received in any form, including acoustic, speech, or tactile input. In addition, a computer can interact with a user by sending documents to and receiving documents from a device that is used by the user; for example, by sending web pages to a web browser on a user’s device in response to requests received from the web browser. Also, a computer can interact with a user by sending text messages or other forms of message to a personal device, e.g., a smartphone that is running a messaging application, and receiving responsive messages from the user in return.

[0334]

[0278] Data processing apparatus for implementing machine learning models can also include, for example, special-purpose hardware accelerator units for processing common and computeintensive parts of machine learning training or production, i.e., inference, workloads.

[0335]

[0279] Machine learning models can be implemented and deployed using a machine learning framework, e.g., a TensorFlow framework.

[0336]

[0280] Embodiments of the subject matter described in this specification can be implemented in a computing system that includes a back-end component, e.g., as a data server, or that includes a middleware component, e.g., an application server, or that includes a front-end component, e.g., a client computer having a graphical user interface, a web browser, or an app through which a user can interact with an implementation of the subject matter described in this specification, or any combination of one or more such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include a local area network (LAN) and a wide area network (WAN), e.g., the Internet.

[0337]

[0281] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. In some embodiments, a server transmits data, e.g., an HTML page, to a user device, e.g., for purposesAttorney Docket No. 45288-0651WO1

[0338] of displaying data to and receiving user input from a user interacting with the device, which acts as a client. Data generated at the user device, e.g., a result of the user interaction, can be received at the server from the device.

[0339]

[0282] While this specification contains many specific implementation details, these should not be construed as limitations on the scope of any invention or on the scope of what may be claimed, but rather as descriptions of features that may be specific to particular embodiments of particular inventions. Certain features that are described in this specification in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination. Moreover, although features may be described above as acting in certain combinations and even initially be claimed as such, one or more features from a claimed combination can in some cases be excised from the combination, and the claimed combination may be directed to a subcombination or variation of a subcombination.

[0340]

[0283] Similarly, while operations are depicted in the drawings and recited in the claims in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order, or that all illustrated operations be performed, to achieve desirable results. In certain circumstances, multitasking and parallel processing may be advantageous. Moreover, the separation of various system modules and components in the embodiments described above should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.

[0341]

[0284] Particular embodiments of the subject matter have been described. Other embodiments are within the scope of the following claims. For example, the actions recited in the claims can be performed in a different order and still achieve desirable results. As one example, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some cases, multitasking and parallel processing may be advantageous.

[0342]

[0285] What is claimed is:

Claims

Attorney Docket No. 45288-0651WO1CLAIMS1. A method performed by one or more computers, the method comprising:obtaining a training dataset for training an elastic neural network having an elastic architecture defined by a plurality of architectural dimensions;receiving an input specifying: (i) a respective set of sizes of each of the plurality of architectural dimensions of the elastic architecture, and (ii) a plurality of configurations of the elastic neural network, each configuration being specified by, for each architectural dimension, a respective size selected from the respective set of sizes of the architectural dimension;initializing a set of network parameters shared between the plurality of configurations of the elastic neural network,wherein, for each architectural dimension, each respective size is associated with a respective subset of the set of network parameters along the architectural dimension, and the respective subset of network parameters is a subset of the respective subset of network parameters associated with each size in the set of sizes of the architectural dimension that is larger than the respective size; andtraining the set of network parameters shared between the plurality of configurations of the elastic network on the training dataset.

2. The method of claim 1, wherein the plurality of configurations of the elastic neural network comprises:a main configuration of the elastic neural network, the main configuration having the elastic architecture configured with, for each architectural dimension, the largest respective size in the respective set of sizes of the architectural dimension; anda plurality of auxiliary configurations of the elastic neural network, each auxiliary configuration having the elastic architecture configured differently than the main configuration.

3. The method of claim 2, wherein initializing the set of network parameters of the plurality of configurations of the elastic neural network comprises:receiving a pre-trained neural network having the main configuration; and initializing the set of network parameters as a set of pre-trained network parameters of the pre-trained neural network.

4. The method of claim 3, further comprising:Attorney Docket No. 45288-0651WO1receiving a pre-training dataset the pre-trained neural network was pre-trained on; and augmenting the training dataset with one or more batches of network inputs sampled from the pre-training dataset.

5. The method of any one of claims 2-4, wherein training the set of network parameters of the plurality of configurations of the elastic neural network on the training dataset comprises, at each of a plurality of training iterations:sampling, from the training dataset, a batch of network inputs;receiving a respective current value of each network parameter belonging to the set of network parameters;parametrizing the main configuration of the elastic neural network with the respective current value of each network parameter belonging to the set of network parameters;sampling, from a probability distribution over the plurality of auxiliary configurations, one of the plurality of auxiliary configurations of the elastic neural network;generating the sampled auxiliary configuration of the elastic neural network; parametrizing the auxiliary configuration with the respective current value of each network parameter belonging to the respective subset of the set of network parameters associated with the auxiliary configuration; andjointly training the main and auxiliary configurations of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set of network parameters.

6. The method of any one of claims 2-4, wherein training the set of network parameters of the plurality of configurations of the elastic neural network on the training dataset comprises, at each of a plurality of training iterations:sampling, from the training dataset, a batch of network inputs;receiving a respective current value of each network parameter belonging to the set of network parameters;parametrizing the main configuration of the elastic neural network with the respective current value of each network parameter belonging to the set of network parameters;determining whether a criterion for training any one of the plurality of auxiliary configurations is satisfied at the training iteration;if the criterion is not satisfied at the training iteration:Attorney Docket No. 45288-0651WO1training the main configuration of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set network parameters; andif the criterion is satisfied at the training iteration:sampling, from a probability distribution over the plurality of auxiliary configurations, one of the plurality of auxiliary configurations of the elastic neural network;generating the sampled auxiliary configuration of the elastic neural network; parametrizing the auxiliary configuration with the respective current value of each network parameter belonging to the respective subset of the set of network parameters associated with the auxiliary configuration; andjointly training the main and auxiliary configurations of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set of network parameters.

7. The method of any one of claims 5-6, wherein the probability distribution is a uniform distribution over the plurality of auxiliary configurations.

8. The method of any one of claims 5-7, wherein determining whether the criterion for training the set of auxiliary configurations of the elastic neural network is satisfied at the training iteration comprises:determining whether a threshold number of the plurality of training iterations has elapsed since any one of the plurality of auxiliary configurations of the elastic neural network was jointly trained with the main configuration of the elastic neural network.

9. The method of claim 8, wherein the threshold number of training iterations has a value of two or more.

10. The method of claim 9, wherein the threshold number of training iterations has a value in a range from two to five.

11. The method of any one of claims 5-10, wherein at each of the plurality of training iterations, training the main configuration of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set of network parameters comprises:Attorney Docket No. 45288-0651WO1for each network input in the batch:processing the network input, using the main configuration of the elastic neural network parametrized with the respective current value of each network parameter belonging to the set of network parameters, to generate a respective main network output for the network input; andcomputing a respective main objective term measuring an error between: (i) the respective main network output for the network input, and (ii) a respective target output for the network input;computing, with respect to each network parameter belonging to the set of network parameters, a respective gradient of a main objective comprising the respective main objective term for each network input in the batch; andupdating, using the respective gradient of the main objective, the respective current value of each network parameter belonging to the set of network parameters.

12. The method of claim 11, wherein at each of the plurality of training iterations, jointly training the main and auxiliary configurations of the elastic neural network on the batch of network inputs to update the current values of the set network parameters comprises:for each network input in the batch:processing the network input, using the auxiliary configuration of the elastic neural network parametrized with the respective current value of each network parameter belonging to the respective subset of network parameters associated with the auxiliary configuration, to generate a respective auxiliary network output for the network input;computing a respective auxiliary objective term measuring an error between: (i) the respective auxiliary network output for the network input, and (ii) the respective target output for the network input; andcomputing a respective co-distillation objective term measuring an error between: (i) a respective set of outputs generated by the main configuration when processing the network input, and (ii) a respective set of outputs generated by the auxiliary configuration when processing the network input;computing, with respect to each network parameter belonging to the set of network parameters, a respective gradient of a total objective comprising:the main objective;an auxiliary objective comprising the respective auxiliary objective term for each network input in the batch; andAttorney Docket No. 45288-0651WO1a co-distillation objective comprising the respective co-distillation objective term for each network input in the batch of network inputs; andupdating, using the respective gradient of the total objective, the respective current value of each network parameter belonging to the set of network parameters.

13. The method of claim 12, wherein updating, using the respective gradient of the total objective, the respective current value of each network parameter belonging to the set of network parameters comprises:updating, using the respective gradient of the total objective, the respective current value of each network parameter belonging to the set of network parameters; or updating, using the respective gradient of the total objective, the respective current value of each network parameter belonging to the set of network parameters other than the respective subset of network parameters associated with the auxiliary configuration.

14. The method of any one of claims 12-13, wherein for each network input in the batch, the respective co-distillation objective term measures an error between: (i) a respective set of intermediate outputs generated by a respective intermediate layer of the main configuration when processing the respective network input, and (ii) a respective set of intermediate outputs generated by a corresponding intermediate layer of the auxiliary configuration when processing the respective network input.

15. The method of claim 14, wherein the respective intermediate layer of each of the main and auxiliary configurations of the elastic neural network is a last respective layer in the configuration.

16. The method of any one of claims 12-15, wherein the total objective function comprises a summation of:the main objective multiplied by a main penalty parameter;the auxiliary objective multiplied by a respective auxiliary penalty parameter associated with the auxiliary configuration of the elastic neural network; andthe co-distillation objective multiplied by a respective co-distillation penalty parameter associated with the auxiliary configuration of the elastic neural network.Attorney Docket No. 45288-0651WO117. The method of any one of claims 5-10, wherein at each of the plurality of training iterations, jointly training the main and auxiliary configurations of the elastic neural network on the batch of network inputs to update the respective current value of each network parameter belonging to the set of network parameters comprises:processing the batch of network inputs using one or more of the main or auxiliary configurations of the elastic neural network to generate a respective set of candidate network outputs for each network input in the batch; andobtaining a respective reward for each candidate network output in the respective set of candidate network outputs for each network input in the batch;computing, with respect to each network parameter belonging to the set of network parameters, a respective gradient of a reinforcement learning objective comprising the respective rewards for each network input in the batch of network inputs; andupdating, using the respective gradient of the reinforcement learning objective, the respective current value of each network parameter belonging to the set of network parameters.

18. The method of claim 17, wherein the reinforcement learning objective comprises one or more reinforcement objective terms that each depend on an anchor neural network, and wherein the anchor neural network is a pre-trained instance of the main configuration of the elastic neural network.

19. The method of any one of claims 17-18, wherein processing the batch of network inputs using one or more of the main or auxiliary configurations of the elastic neural network to generate the respective set of candidate network outputs for each network input in the batch comprises:processing each network input in a subset of the batch of network inputs, using the main configuration of the elastic neural network, to generate the respective set of candidate network outputs for the network input in the batch; andprocessing each network input in a complement of the subset of the batch of network inputs, using the auxiliary configuration of the elastic neural network, to generate the respective set of candidate network outputs for the network input in the batch.

20. The method of any one of claims 17-18, wherein processing the batch of network inputs using one or more of the main or auxiliary configurations of the elastic neural network toAttorney Docket No. 45288-0651WO1generate the respective set of candidate network outputs for each network input in the batch comprises, for each network input in the batch:processing the network input, using the main configuration of the elastic neural network, to generate a subset of the respective set of candidate outputs for the network input; andprocessing the network input, using the auxiliary configuration of the elastic neural network, to generate a complement of the subset of the respective set of candidate outputs for the network input.

21. The method of any one of claims 1-20, wherein the elastic neural network comprises a plurality of active layer blocks each configured to:receive a block input embedding belonging to a model embedding space; and process the block input embedding to generate a block output embedding belonging to the model embedding space.

22. The method of claim 21, wherein the plurality of architectural dimensions defining the elastic architecture of the elastic neural network comprises:a model dimension defining a dimensionality of the model embedding space of the elastic neural network.

23. The method any one of claims 21-22, wherein the plurality of architectural dimensions defining the elastic architecture of the elastic neural network comprises:a model depth defining a total number of the plurality of active layer blocks in the elastic neural network.

24. The method of anyone of claims 21-23, wherein the plurality of active layer blocks is organized in a residual sequence comprising, for each active layer block:a respective additive gate immediately following the active layer block; and a respective skip connection between: (i) an input of the active layer block, and (ii) the respective additive gate.

25. The method of claim 24, wherein for each active layer block that is not a first of the plurality of active layer blocks in the residual sequence, the block input embedding of the active layer block comprises a summation of:Attorney Docket No. 45288-0651WO1the block input embedding of a layer block preceding the active layer block in the residual sequence; andthe block output embedding of the layer block preceding the active layer block in the residual sequence.

26. The method of any one of claims 21-25, wherein each active layer block in the elastic neural network comprises an attention layer configured to:receive a layer input embedding belonging to the model embedding space;for each of a plurality of attention heads:apply a respective set of input projection matrices to the layer input embedding to generate a respective set of attention input embeddings each belonging to an attention embedding space; andapply a respective attention mechanism over the respective set of attention input embeddings to generate a respective attention output embedding belonging to the attention embedding space;concatenate the respective attention output embeddings for each of the plurality of attention heads to generate a multi-head attention output embedding; andapply an output projection matrix to the multi -head attention output embedding to generate a layer output embedding belonging to the model embedding space.

27. The method of claim 26, wherein the plurality of architectural dimensions defining the elastic architecture of the elastic neural network comprises:an attention dimension defining a dimensionality of the attention embedding space of the attention layer of each active layer block in the elastic neural network.

28. The method of any one of claims 26-27, wherein the plurality of architectural dimensions defining the elastic architecture of the elastic neural network comprises:an attention depth defining a total number of the plurality of attention heads of the attention layer of each layer block in the elastic neural network.

29. The method of any one of claims 26-28, wherein for each of the plurality of attention heads of the attention layer of each active layer block in the elastic neural network:the respective set of input projection matrices comprises a respective triplet of a query value projection matrix, a key value projection matrix, and a value projection matrix, andAttorney Docket No. 45288-0651WO1the respective set of attention input embeddings comprises a respective triplet of a query, a key, and a value.

30. The method of any one of claims 26-29, wherein the multi-head attention output embedding of the attention layer of each active layer block in the elastic neural network has a same dimensionality as the dimensionality of the attention embedding space of the attention layer.

31. The method of any one of claims 26-30, wherein each active layer block in the elastic neural network further comprises a mixture-of-experts layer configured to:receive a layer input embedding belonging to the model embedding space; process the layer input embedding, using a router, to generate a respective probability for each of a plurality of experts;process the layer input embedding, using each of the plurality of experts, to generate a respective expert output embedding belonging to the model embedding space;multiply, for each of the plurality of experts, the respective expert output embedding by the respective probability for the expert;sum the respective expert output embeddings multiplied by the respective probabilities for each of the plurality of experts to generate a layer output embedding belonging to the model embedding space.

32. The method of claim 31 , wherein the mixture-of-experts layer of each active layer block is a mixture-of-experts feedforward layer, and the plurality of experts of the mixture-of-experts feedforward layer is a plurality of feedforward experts each configured to:receive the layer input embedding belonging to the model embedding space; apply a respective input projection matrix to the layer input embedding to generate a respective pre-activated embedding belonging to a feedforward embedding space;apply a respective activation function over the respective pre-activated embedding to generate a respective activated embedding belonging to the feedforward embedding space; and apply a respective output projection matrix to the respective activated embedding to generate the respective expert output embedding belonging to the model embedding space.

33. The method of claim 32, wherein the plurality of architectural dimensions defining the elastic architecture of the elastic neural network comprises:Attorney Docket No. 45288-0651WO1a feedforward dimension defining a dimensionality of the feedforward embedding space of the mixture-of-experts feedforward layer of each active layer block in the elastic neural network.

34. The method of any one of claims 32-33, wherein the plurality of architectural dimensions defining the elastic architecture of the elastic neural network comprises:a feedforward depth defining a total number of the plurality of feedforward experts of the mixture-of-experts feedforward layer of each active layer block in the elastic neural network.

35. The method of any one of claims 32-34, wherein the respective activation function of each of the plurality of feedforward experts of the mixture-of-experts feedforward layer of each active layer block in the elastic neural network is a Rectified Linear Unit, a Gaussian error Linear Unit, or a swish function.

36. The method any one of claims 32-35, wherein each active layer block in the elastic neural network is a transformer layer block.

37. The method of claim 36, wherein each transformer layer block in the elastic neural network comprises:the attention layer;a first additive gate immediately following the attention layer;a first skip connection between: (i) an input of the attention layer, and (ii) the first additive gate;a first normalization layer immediately following the first additive gate;the mixture-of-experts feedforward layer immediately following the first normalization layer;a second additive gate immediately following the mixture-of-experts feedforward layer; a second skip connection between: (i) an input of the mixture-of-experts feedforward layer, and (ii) the second additive gate; anda second normalization layer immediately following the second additive gate.

38. The method of claim 37, wherein each transformer layer block in the elastic neural network comprises:Attorney Docket No. 45288-0651WO1a first normalization layer;the attention layer immediately following the first normalization layer;a first additive gate immediately following the attention layer;a first skip connection between: (i) an input of the first normalization layer, and (ii) the first additive gate;a second normalization layer immediately following the first additive gate;the mixture-of-experts feedforward layer immediately following the second normalization layer;a second additive gate immediately following the mixture-of-experts feedforward layer; anda second skip connection between: (i) an input of the second normalization layer, and (ii) the second additive gate.

39. The method of any one of claims 37-38, where the first and second normalization layers of each transformation layer block in the elastic neural network is a layer normalization layer, a root mean square normalization layer, a batch normalization layer, a weight normalization layer, or a group normalization layer.

40. The method of any one of claims 21-39, wherein the elastic neural network comprises:an input subnetwork configured to:receive a network input for the elastic neural network; andprocess the network input to generate an input embedding belonging to the model embedding space;a residual network immediately following the input subnetwork, the residual network comprising the plurality of active layer blocks;an additive gate immediately following the residual network;a skip connection between: (i) an input of the residual network, and (ii) the additive gate; andan output subnetwork immediately following the additive gate, the output subnetwork configured to:receive an output embedding belonging to the model embedding space; and process the output embedding to generate a network output for the elastic neural network.Attorney Docket No. 45288-0651WO141. The method of any one of claims 1-40, further comprising, after training the set of network parameters shared between the plurality of configurations of the elastic neural network on the training dataset:receiving a query specifying: (i) a network input for the elastic neural network, and (ii) a target configuration in the plurality of configurations of the elastic neural network;generating the target configuration of the elastic neural network;parametrizing the target configuration of the elastic neural network with trained values of the respective subset of network parameters associated with the target configuration; and processing the network input, using the target configuration of the elastic neural network in accordance with the trained values of the subset of network parameters associated with the target configuration, to generate a network output for the network input.

42. The method of claim 41, wherein the network input is a multi-modal input, the network output is a multi-modal output, or both.

43. The method of any one of claims 41-42, wherein the network input comprises one or more of: an input image, an input video, an input audio waveform, or an input text sequence.

44. The method of any one of claims 41-42, wherein the neural network comprises an observation characterizing a state of an environment being interacted with by an agent, and the network output defines an action to be performed by the agent in response to the observation.

45. The method of any one of claims 41-42, wherein the network input comprises an input text sequence comprising a respective input text token at each of a plurality of input positions, and the network output comprises a prediction of a text token that follows the input text token at a last of the plurality of input positions.

46. The method of claim 45, further comprising:generating an output text token using the network output;appending the output text token to the input text sequence; andprocessing the network input comprising the input text sequence appended with the output text token, using the target configuration of the elastic neural network, to generate aAttorney Docket No. 45288-0651WO1network output comprising a prediction of a text token that follows the output text token appended to the input text sequence.

47. A method performed by one or more computers, the method comprising:receiving a query specifying: (i) a network input for an elastic neural network, and (ii) a target configuration in a plurality of configurations of the elastic neural network;generating the target configuration of the elastic neural network; andprocessing the network input, using the target configuration of the elastic neural network, to generate a network output for the network input,wherein a set of network parameters shared between the plurality of configurations of the elastic neural network has been trained via the respective method of any one of claims 1-46.

48. A method performed by one or more computers, the method comprising:receiving a query specifying: (i) a network input for an elastic neural network, and (ii) a target configuration in a plurality of configurations of the elastic neural network;generating the target configuration of the elastic neural network; andprocessing the network input, using the target configuration of the elastic neural network, to generate a network output for the network input,wherein a set of network parameters shared between the plurality of configurations of the elastic neural network has been trained via operations comprising:obtaining a training dataset for training the elastic neural network, the elastic neural network having an elastic architecture defined by a plurality of architectural dimensions;receiving an input specifying: (i) a respective set of sizes of each of the plurality of architectural dimensions of the elastic architecture, and (ii) the plurality of configurations of the elastic neural network, each configuration being specified by, for each architectural dimension, a respective size selected from the respective set of sizes of the architectural dimension;initializing the set of network parameters shared between the plurality of configurations of the elastic neural network,wherein, for each architectural dimension, each respective size is associated with a respective subset of the set of network parameters along the architectural dimension, and the respective subset of network parameters is a subset of the respective subsetAttorney Docket No. 45288-0651WO1of network parameters associated with each size in the set of sizes of the architectural dimension that is larger than the respective size; andtraining the set of network parameters shared between the plurality of configurations of the elastic neural network on the training dataset.

49. A system comprising:one or more computers; andone or more storage devices communicatively coupled to the one or more computers, wherein the one or more storage devices store instructions that, when executed by the one or more computers, cause the one or more computers to perform operations of the respective method of any one of claims 1-48.

50. One or more non-transitory computer storage media storing instructions that, when executed by one or more computers, cause the one or more computers to perform operations of the respective method of any one of claims 1-48.

51. A method performed by one or more computers, the method comprising:obtaining a set of network parameters for an elastic neural network having an elastic architecture defined by a plurality of architectural dimensions,wherein for each architectural dimension, a plurality of potential sizes is defined, each potential size being associated with a respective subset of a complete set of shared network parameters for the elastic neural network, andwherein the respective subset of network parameters for any given potential size is a subset of the respective subset of network parameters associated with each larger potential size for that architectural dimension;receiving a query specifying: (i) a network input, and (ii) a target configuration for the elastic neural network, the target configuration being specified by, for each architectural dimension, a selected potential size;generating the target configuration by selecting, for each architectural dimension, the respective subset of the obtained set of network parameters corresponding to the selected potential size for that architectural dimension; andprocessing the network input, using the generated target configuration parameterized with its selected subsets of network parameters, to generate a network output.Attorney Docket No. 45288-0651WO152. The method of claim 51, wherein obtaining the set of network parameters comprises:providing an initial subset of the complete set of shared network parameters; and in response to the initial subset being insufficient for the target configuration, dynamically retrieving an additional subset of network parameters such that the combination of the initial and additional subsets forms the set of network parameters used for generating the target configuration.

53. One or more non-transitory computer-readable media storing a set of network parameters for an elastic neural network, wherein:the elastic neural network has an elastic architecture defined by a plurality of architectural dimensions;for each architectural dimension of the plurality of architectural dimensions, a plurality of supported sizes are defined, for which corresponding parameters are included in the stored set of network parameters;each supported size in the plurality of supported sizes for an architectural dimension is associated with a respective subset of the stored set of network parameters along that architectural dimension;the respective subset of network parameters associated with any given supported size for an architectural dimension is a subset of the respective subset of network parameters associated with each supported size for that architectural dimension that is larger than the given supported size; andthe stored set of network parameters, when used to parameterize a selected configuration of the elastic neural network specified by a supported size for each architectural dimension, enables the selected configuration to process a network input to generate a network output.

54. The one or more non-transitory computer-readable media of claim 53, wherein:the elastic architecture further defines, for each architectural dimension, a complete set of architectural sizes for the elastic neural network; andthe plurality of supported sizes for each architectural dimension, for which corresponding parameters are included in the stored set of network parameters, comprises all sizes in the complete set of architectural sizes for that architectural dimension.Attorney Docket No. 45288-0651WO155. The one or more non-transitory computer-readable media of any one of claims 53-54, wherein:the elastic architecture is derived from a larger elastic architecture that defines, for each architectural dimension, a complete set of architectural sizes; andthe plurality of supported sizes for at least one architectural dimension, for which corresponding parameters are included in the stored set of network parameters, constitutes a proper subset of the complete set of architectural sizes defined by the larger elastic architecture for that architectural dimension.

56. A method performed by one or more computers, the method comprising:receiving a query specifying: (i) an attention input embedding, and (ii) a target attention configuration selected from a plurality of supported attention configurations, the target attention configuration being defined by a selected attention embedding dimension and a selected number of attention heads;retrieving, from a storage device storing a set of shared attention parameters, a subset of the set of shared attention parameters corresponding to the target attention configuration, wherein: each supported attention configuration in the plurality of supported attention configurations is associated with a respective nested subset of the set of shared attention parameters, and the respective nested subset of the set of shared attention parameters associated with a first supported attention configuration is a subset of the respective nested subset associated with a second supported attention configuration that has a larger attention embedding dimension or a larger number of attention heads;parameterizing an attention layer using the retrieved subset of the set of shared attention parameters; andprocessing the attention input embedding, using the parameterized attention layer, to generate an attention output embedding.

57. The method of claim 56, wherein the plurality of supported attention configurations comprises:a main configuration configured with, for each architectural dimension comprising the attention embedding dimension and the number of attention heads, the largest respective size in the respective set of sizes of the architectural dimension; anda plurality of auxiliary configurations configured differently than the main configuration.Attorney Docket No. 45288-0651WO158. The method of any one of claims 56-57, wherein the attention embedding dimension defines a dimensionality of an attention embedding space of the attention layer.

59. The method of any one of claims 56-58, wherein the attention input embedding comprises a respective triplet of a query, a key, and a value.

60. The method of any one of claims 56-59, wherein the attention output embedding has a same dimensionality as the dimensionality of an attention embedding space of the attention layer.

61. A method performed by one or more computers, the method comprising:receiving a query specifying: (i) an input embedding, and (ii) a target mixture-of-experts configuration selected from a plurality of supported mixture-of-experts configurations, the target mixture-of-experts configuration being defined by a selected feedforward embedding dimension and a selected number of active experts;retrieving, from a storage device storing a set of shared mixture-of-experts parameters, a subset of the set of shared mixture-of-experts parameters corresponding to the target mixture-of-experts configuration, wherein: each supported mixture-of-experts configuration in the plurality of supported mixture-of-experts configurations is associated with a respective nested subset of the set of shared mixture-of-experts parameters, and the respective nested subset of the set of shared mixture-of-experts parameters associated with a first supported mixture-of-experts configuration is a subset of the respective nested subset associated with a second supported mixture-of-experts configuration that has a larger feedforward embedding dimension or a larger number of active experts;parameterizing a mixture-of-experts layer using the retrieved subset of the set of shared mixture-of-experts parameters; andprocessing the input embedding, using the parameterized mixture-of-experts layer, to generate a mixture-of-experts output embedding.

62. The method of claim 61, wherein the plurality of supported mixture-of-experts configurations comprises:Attorney Docket No. 45288-0651WO1a main configuration configured with, for each architectural dimension comprising the feedforward embedding dimension and a feedforward depth defining the number of experts, the largest respective size in the respective set of sizes of the architectural dimension; and a plurality of auxiliary configurations configured differently than the main configuration.

63. The method of any one of claims 61-62, wherein the mixture-of-experts layer is a mixture-of-experts feedforward layer, and the feedforward embedding dimension defines a dimensionality of a feedforward embedding space of the mixture-of-experts feedforward layer.

64. The method of claim 63, wherein a feedforward depth defines a total number of a plurality of feedforward experts of the mixture-of-experts feedforward layer.

65. The method of any one of claims 63-64, wherein a respective activation function of each of a plurality of feedforward experts of the mixture-of-experts feedforward layer is a Rectified Linear Unit, a Gaussian error Linear Unit, or a swish function.