MCPcopy Create free account
hub / github.com/cli99/llm-analysis / infer

Function infer

llm_analysis/analysis.py:2251–2351  ·  view source on GitHub ↗

_summary_ Args: model_name (str, optional): model name to query the pre-defined `model_configs` dict, or model config json file path, if not found, query Hugging Face to construct ModelConfig. Defaults to "facebook_opt-1.3b". gpu_name (str, optional): gpu name to query the pre-d

(
    model_name="facebook_opt-1.3b",
    gpu_name="a100-sxm-40gb",
    dtype_name="w16a16e16",
    log_level="INFO",
    batch_size_per_gpu=1,
    ds_zero: int = 0,
    dp_size: int = 1,
    tp_size: int = 1,
    pp_size: int = 1,
    sp_size: int = None,
    seq_len=512,
    num_tokens_to_generate=32,
    use_kv_cache: bool = True,
    layernorm_dtype_bytes: int = BYTES_FP16,
    kv_cache_dtype_bytes: int = None,
    achieved_tflops: float = None,
    achieved_memory_bandwidth_GBs: float = None,
    flops_efficiency: float = None,
    hbm_memory_efficiency: float = None,
    intra_node_memory_efficiency=INTRA_NODE_MEMORY_EFFICIENCY,
    inter_node_memory_efficiency=INTER_NODE_MEMORY_EFFICIENCY,
    cost_per_gpu_hour: float = None,
    output_dir: str = None,
    output_file_suffix: str = "",
)

Source from the content-addressed store, hash-verified

2249
2250
2251def infer(
2252 model_name="facebook_opt-1.3b",
2253 gpu_name="a100-sxm-40gb",
2254 dtype_name="w16a16e16",
2255 log_level="INFO",
2256 batch_size_per_gpu=1,
2257 ds_zero: int = 0,
2258 dp_size: int = 1,
2259 tp_size: int = 1,
2260 pp_size: int = 1,
2261 sp_size: int = None,
2262 seq_len=512,
2263 num_tokens_to_generate=32,
2264 use_kv_cache: bool = True,
2265 layernorm_dtype_bytes: int = BYTES_FP16,
2266 kv_cache_dtype_bytes: int = None,
2267 achieved_tflops: float = None,
2268 achieved_memory_bandwidth_GBs: float = None,
2269 flops_efficiency: float = None,
2270 hbm_memory_efficiency: float = None,
2271 intra_node_memory_efficiency=INTRA_NODE_MEMORY_EFFICIENCY,
2272 inter_node_memory_efficiency=INTER_NODE_MEMORY_EFFICIENCY,
2273 cost_per_gpu_hour: float = None,
2274 output_dir: str = None,
2275 output_file_suffix: str = "",
2276) -> dict:
2277 """_summary_
2278
2279 Args:
2280 model_name (str, optional): model name to query the pre-defined `model_configs` dict, or model config json file path, if not found, query Hugging Face to construct ModelConfig. Defaults to "facebook_opt-1.3b".
2281 gpu_name (str, optional): gpu name to query the pre-defined `gpu_configs` dict. Defaults to "a100-sxm-40gb".
2282 dtype_name (str, optional): data type name to pre-defined `dtype_configs` dict. Defaults to "w16a16e16".
2283 log_level (str, optional): logging level. Defaults to "INFO".
2284 batch_size_per_gpu (int, optional): batch size per GPU. Defaults to 1.
2285 ds_zero (int, optional): which DeepSpeed ZeRO stage to use. See `DSZeRO`. Defaults to 0.
2286 dp_size (int, optional): data parallelism size. Defaults to None.
2287 tp_size (int, optional): tensor parallelism size. Defaults to 1.
2288 pp_size (int, optional): pipeline parallelism size. Defaults to 1.
2289 sp_size (int, optional): sequence parallelism size. Defaults to tp_size.
2290 seq_len (int, optional): input sequence length. Defaults to 512.
2291 num_tokens_to_generate (int, optional): number of tokens to generate for generative models. Defaults to 32.
2292 use_kv_cache (bool, optional): whether to use kv cache. Defaults to True.
2293 layernorm_dtype_bytes (int, optional): number of bytes in the data type for the layernorm activations. Defaults to BYTES_FP32. Often has to be at least FP16 in inference to maintain model accuracy.
2294 kv_cache_dtype_bytes (int, optional): number of bytes in the data type for the kv_cache. Defaults to None. Often has to be at least FP16 in inference to maintain model accuracy.
2295 achieved_tflops (float, optional): achieved TFLOPS per GPU. If specified, will override the flops_efficiency passed in. Defaults to None.
2296 achieved_memory_bandwidth_GBs (float, optional): achieved GPU memory bandwidth in GB/s. If specified, will override the hbm_memory_efficiency passed in. Defaults to None.
2297 flops_efficiency (float, optional): flops efficiency, ranging from 0 to 1. Defaults to None.
2298 hbm_memory_efficiency (float, optional): GPU HBM memory efficiency, ranging from 0 to 1. Defaults to HBM_MEMORY_EFFICIENCY.
2299 intra_node_memory_efficiency (float, optional): intra-node memory efficiency, ranging from 0 to 1. Defaults to INTRA_NODE_MEMORY_EFFICIENCY.
2300 inter_node_memory_efficiency (float, optional): inter-node memory efficiency, ranging from 0 to 1. Defaults to INTER_NODE_MEMORY_EFFICIENCY.
2301 cost_per_gpu_hour (float, optional): dollar cost per GPU hour. Defaults to None.
2302 output_dir (str, optional): if set to a directory path, write the return summary dict out to the directory with the setup. Defaults to None.. Defaults to None.
2303 output_file_suffix (str, optional): suffix of the output file. Defaults to "".
2304
2305 Returns:
2306 dict: a summary dictionary of the inference analysis
2307 """
2308

Callers

nothing calls this directly

Calls 7

inferenceMethod · 0.95
get_model_config_by_nameFunction · 0.90
get_gpu_config_by_nameFunction · 0.90
get_dtype_config_by_nameFunction · 0.90
ParallelismConfigClass · 0.90
LLMAnalysisClass · 0.85
DSZeROClass · 0.85

Tested by

no test coverage detected