Record Class MiniMaxModelArgs
java.lang.Object
java.lang.Record
smile.llm.model.minimax.MiniMaxModelArgs
- Record Components:
dim- token embedding / hidden size.numLayers- number of decoder blocks.numHeads- number of query heads.numKvHeads- number of key/value heads.headDim- attention head dimension.vocabSize- vocabulary size.normEps- RMSNorm epsilon (Gemma-style1 + weightscale).ropeTheta- RoPE base theta.rotaryDim- number of rotated head dimensions (partial RoPE).denseIntermediateSize- FFN width of the dense (non-MoE) layers.expertIntermediateSize- FFN width of one routed expert.- FFN width of the shared expert.numExperts- routed experts per MoE layer.numExpertsPerTok- experts selected per token.- shared experts per MoE layer.routedScalingFactor- multiplier applied to the renormalized routing weights.swigluAlpha-swigluoaisigmoid slope.swigluLimit-swigluoaiclamp.moeLayers- per-layer flag:truefor MoE,falsefor dense FFN.sparseLayers- per-layer flag:truefor MSA,falsefor dense GQA.indexDim- MSA index head dimension.numIndexHeads- MSA index-query heads (equalsnumKvHeads; one per GQA group).topkBlocks- MSA blocks selected per query and index head.blockSize- MSA block size in tokens (equals the KV page size).initBlocks- leading blocks always selected.localBlocks- most recent blocks always selected.numMtpModules- native multi-token-prediction modules (0= none).maxBatchSize- maximum inference batch size.maxSeqLen- maximum sequence length.weightMode- how linear weights are stored and multiplied (chosen by the loader, not read fromconfig.json).
public record MiniMaxModelArgs(int dim, int numLayers, int numHeads, int numKvHeads, int headDim, int vocabSize, double normEps, double ropeTheta, int rotaryDim, int denseIntermediateSize, int expertIntermediateSize, int sharedIntermediateSize, int numExperts, int numExpertsPerTok, int numSharedExperts, double routedScalingFactor, double swigluAlpha, double swigluLimit, boolean[] moeLayers, boolean[] sparseLayers, int indexDim, int numIndexHeads, int topkBlocks, int blockSize, int initBlocks, int localBlocks, int numMtpModules, int maxBatchSize, int maxSeqLen, MiniMaxWeightMode weightMode)
extends Record
MiniMax-M3 text-tower hyperparameters: GQA with MiniMax Sparse Attention (MSA)
and a sigmoid-routed mixture of experts.
-
Constructor Summary
ConstructorsConstructorDescriptionMiniMaxModelArgs(int dim, int numLayers, int numHeads, int numKvHeads, int headDim, int vocabSize, double normEps, double ropeTheta, int rotaryDim, int denseIntermediateSize, int expertIntermediateSize, int sharedIntermediateSize, int numExperts, int numExpertsPerTok, int numSharedExperts, double routedScalingFactor, double swigluAlpha, double swigluLimit, boolean[] moeLayers, boolean[] sparseLayers, int indexDim, int numIndexHeads, int topkBlocks, int blockSize, int initBlocks, int localBlocks, int numMtpModules, int maxBatchSize, int maxSeqLen, MiniMaxWeightMode weightMode) Creates an instance of aMiniMaxModelArgsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of theblockSizerecord component.intReturns the value of thedenseIntermediateSizerecord component.intdim()Returns the value of thedimrecord component.final booleanIndicates whether some other object is "equal to" this one.intReturns the value of theexpertIntermediateSizerecord component.static MiniMaxModelArgsfromHuggingFace(String path, int maxBatchSize, int maxSeqLen) Loads hyperparameters from a HuggingFaceconfig.json.static MiniMaxModelArgsfromTextConfig(tools.jackson.databind.JsonNode text, int maxBatchSize, int maxSeqLen) Parses a text-config JSON object into model args.final inthashCode()Returns a hash code value for this object.booleanhasMtp()Returns whether native MTP modules are configured.intheadDim()Returns the value of theheadDimrecord component.intindexDim()Returns the value of theindexDimrecord component.intReturns the value of theinitBlocksrecord component.booleanisMoe(int layerId) Returns whether a layer uses a mixture of experts.booleanisSparse(int layerId) Returns whether a layer uses MiniMax Sparse Attention.Returns the KV cache layout.kvCacheLayout(TensorShardSpec shard) KV layout for a tensor-parallel shard (local KV head count).intReturns the value of thelocalBlocksrecord component.intReturns the value of themaxBatchSizerecord component.intReturns the value of themaxSeqLenrecord component.boolean[]Returns the value of themoeLayersrecord component.doublenormEps()Returns the value of thenormEpsrecord component.intReturns the value of thenumExpertsrecord component.intReturns the value of thenumExpertsPerTokrecord component.intnumHeads()Returns the value of thenumHeadsrecord component.intReturns the value of thenumIndexHeadsrecord component.intReturns the number of index-key heads per token.intReturns the value of thenumKvHeadsrecord component.intReturns the value of thenumLayersrecord component.intReturns the number of MoE layers.intReturns the value of thenumMtpModulesrecord component.intReturns the value of thenumSharedExpertsrecord component.intReturns the number of MSA layers (each also keeps an index-key cache).doubleReturns the value of theropeThetarecord component.intReturns the value of therotaryDimrecord component.doubleReturns the value of theroutedScalingFactorrecord component.intReturns the value of thesharedIntermediateSizerecord component.boolean[]Returns the value of thesparseLayersrecord component.doubleReturns the value of theswigluAlpharecord component.doubleReturns the value of theswigluLimitrecord component.intReturns the value of thetopkBlocksrecord component.final StringtoString()Returns a string representation of this record class.intReturns the value of thevocabSizerecord component.Returns the value of theweightModerecord component.Returns a copy with another weight mode.
-
Constructor Details
-
MiniMaxModelArgs
public MiniMaxModelArgs(int dim, int numLayers, int numHeads, int numKvHeads, int headDim, int vocabSize, double normEps, double ropeTheta, int rotaryDim, int denseIntermediateSize, int expertIntermediateSize, int sharedIntermediateSize, int numExperts, int numExpertsPerTok, int numSharedExperts, double routedScalingFactor, double swigluAlpha, double swigluLimit, boolean[] moeLayers, boolean[] sparseLayers, int indexDim, int numIndexHeads, int topkBlocks, int blockSize, int initBlocks, int localBlocks, int numMtpModules, int maxBatchSize, int maxSeqLen, MiniMaxWeightMode weightMode) Creates an instance of aMiniMaxModelArgsrecord class.- Parameters:
dim- the value for thedimrecord componentnumLayers- the value for thenumLayersrecord componentnumHeads- the value for thenumHeadsrecord componentnumKvHeads- the value for thenumKvHeadsrecord componentheadDim- the value for theheadDimrecord componentvocabSize- the value for thevocabSizerecord componentnormEps- the value for thenormEpsrecord componentropeTheta- the value for theropeThetarecord componentrotaryDim- the value for therotaryDimrecord componentdenseIntermediateSize- the value for thedenseIntermediateSizerecord componentexpertIntermediateSize- the value for theexpertIntermediateSizerecord componentsharedIntermediateSize- the value for thesharedIntermediateSizerecord componentnumExperts- the value for thenumExpertsrecord componentnumExpertsPerTok- the value for thenumExpertsPerTokrecord componentnumSharedExperts- the value for thenumSharedExpertsrecord componentroutedScalingFactor- the value for theroutedScalingFactorrecord componentswigluAlpha- the value for theswigluAlpharecord componentswigluLimit- the value for theswigluLimitrecord componentmoeLayers- the value for themoeLayersrecord componentsparseLayers- the value for thesparseLayersrecord componentindexDim- the value for theindexDimrecord componentnumIndexHeads- the value for thenumIndexHeadsrecord componenttopkBlocks- the value for thetopkBlocksrecord componentblockSize- the value for theblockSizerecord componentinitBlocks- the value for theinitBlocksrecord componentlocalBlocks- the value for thelocalBlocksrecord componentnumMtpModules- the value for thenumMtpModulesrecord componentmaxBatchSize- the value for themaxBatchSizerecord componentmaxSeqLen- the value for themaxSeqLenrecord componentweightMode- the value for theweightModerecord component
-
-
Method Details
-
isMoe
public boolean isMoe(int layerId) Returns whether a layer uses a mixture of experts.- Parameters:
layerId- zero-based decoder layer index.- Returns:
truefor MoE,falsefor the dense FFN.
-
isSparse
public boolean isSparse(int layerId) Returns whether a layer uses MiniMax Sparse Attention.- Parameters:
layerId- zero-based decoder layer index.- Returns:
truefor MSA,falsefor dense GQA.
-
numSparseLayers
public int numSparseLayers()Returns the number of MSA layers (each also keeps an index-key cache).- Returns:
- MSA layer count.
-
numMoeLayers
public int numMoeLayers()Returns the number of MoE layers.- Returns:
- MoE layer count.
-
numIndexKeyHeads
public int numIndexKeyHeads()Returns the number of index-key heads per token. The checkpoint'sindex_k_projhas widthindexDim, i.e. one key head shared by allnumIndexHeadsindex-query heads.- Returns:
- index-key heads.
-
withWeightMode
Returns a copy with another weight mode.- Parameters:
mode- how linear weights are stored and multiplied.- Returns:
- the new args.
-
hasMtp
public boolean hasMtp()Returns whether native MTP modules are configured.- Returns:
truewhen MTP modules exist.
-
kvCacheLayout
Returns the KV cache layout. Every layer, sparse or dense, keeps a full K/V cache.- Returns:
- cache layout for
KvCachePool.
-
kvCacheLayout
KV layout for a tensor-parallel shard (local KV head count).- Parameters:
shard- TP shard description, ornullfor the full layout.- Returns:
- cache layout for
KvCachePool.
-
fromHuggingFace
public static MiniMaxModelArgs fromHuggingFace(String path, int maxBatchSize, int maxSeqLen) throws IOException Loads hyperparameters from a HuggingFaceconfig.json. Accepts the multimodal wrapper (minimax_m3_vl, nestedtext_config) or a bare text config.- Parameters:
path- path toconfig.json.maxBatchSize- maximum batch size.maxSeqLen- maximum sequence length;<= 0usesmax_position_embeddings.- Returns:
- model args.
- Throws:
IOException- if the file cannot be read.
-
fromTextConfig
public static MiniMaxModelArgs fromTextConfig(tools.jackson.databind.JsonNode text, int maxBatchSize, int maxSeqLen) Parses a text-config JSON object into model args.- Parameters:
text- text config node.maxBatchSize- maximum batch size.maxSeqLen- maximum sequence length;<= 0usesmax_position_embeddings.- Returns:
- model args.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
dim
-
numLayers
-
numHeads
-
numKvHeads
public int numKvHeads()Returns the value of thenumKvHeadsrecord component.- Returns:
- the value of the
numKvHeadsrecord component
-
headDim
-
vocabSize
-
normEps
-
ropeTheta
-
rotaryDim
-
denseIntermediateSize
public int denseIntermediateSize()Returns the value of thedenseIntermediateSizerecord component.- Returns:
- the value of the
denseIntermediateSizerecord component
-
expertIntermediateSize
public int expertIntermediateSize()Returns the value of theexpertIntermediateSizerecord component.- Returns:
- the value of the
expertIntermediateSizerecord component
-
numExperts
public int numExperts()Returns the value of thenumExpertsrecord component.- Returns:
- the value of the
numExpertsrecord component
-
numExpertsPerTok
public int numExpertsPerTok()Returns the value of thenumExpertsPerTokrecord component.- Returns:
- the value of the
numExpertsPerTokrecord component
-
routedScalingFactor
public double routedScalingFactor()Returns the value of theroutedScalingFactorrecord component.- Returns:
- the value of the
routedScalingFactorrecord component
-
swigluAlpha
public double swigluAlpha()Returns the value of theswigluAlpharecord component.- Returns:
- the value of the
swigluAlpharecord component
-
swigluLimit
public double swigluLimit()Returns the value of theswigluLimitrecord component.- Returns:
- the value of the
swigluLimitrecord component
-
moeLayers
-
sparseLayers
public boolean[] sparseLayers()Returns the value of thesparseLayersrecord component.- Returns:
- the value of the
sparseLayersrecord component
-
indexDim
-
numIndexHeads
public int numIndexHeads()Returns the value of thenumIndexHeadsrecord component.- Returns:
- the value of the
numIndexHeadsrecord component
-
topkBlocks
public int topkBlocks()Returns the value of thetopkBlocksrecord component.- Returns:
- the value of the
topkBlocksrecord component
-
blockSize
-
initBlocks
public int initBlocks()Returns the value of theinitBlocksrecord component.- Returns:
- the value of the
initBlocksrecord component
-
localBlocks
public int localBlocks()Returns the value of thelocalBlocksrecord component.- Returns:
- the value of the
localBlocksrecord component
-
numMtpModules
public int numMtpModules()Returns the value of thenumMtpModulesrecord component.- Returns:
- the value of the
numMtpModulesrecord component
-
maxBatchSize
public int maxBatchSize()Returns the value of themaxBatchSizerecord component.- Returns:
- the value of the
maxBatchSizerecord component
-
maxSeqLen
-
weightMode
Returns the value of theweightModerecord component.- Returns:
- the value of the
weightModerecord component
-