CoolFace
Modelpublic

patdev/k3-a40-bootstrap

sourceHugging Faceotherupdated 19d agoView on Hugging Face
0likes1.3kdownloads
trt_recon2.py77 linesDownload Raw Back to root
1"""Partie C : que propose reellement TensorRT-LLM 1.3.0rc22 pour2   - la SPECULATION (mtp / eagle3 / dflash / dspark / ngram ?)3   - la quantification du cache KV (equivalent TurboQuant ?)4et cote ONNX GenAI, quelles options de KV quantifie existent.5On lit les sources et le --help, pas les annonces."""6import inspect, os, subprocess, sys, traceback7 8 9def log(*a):10    print(*a, flush=True)11 12 13def bloc(t):14    log("\n" + "=" * 12 + " " + t)15 16 17def main():18    bloc("TRT-LLM : methodes de speculation declarees")19    try:20        from tensorrt_llm.llmapi import llm_args21        src = inspect.getsource(llm_args)22        import re23        # enum / litteraux des types de speculation24        for m in re.finditer(r"class (\w*[Ss]pec\w*Config)\b", src):25            log("  classe:", m.group(1))26        mots = sorted(set(re.findall(r"[\"']((?:MTP|EAGLE3?|DRAFT_TOKENS_EXTERNAL|NGRAM|USER_PROVIDED|LOOKAHEAD|MEDUSA|DFLASH|DSPARK|AUTO|SUFFIX)[A-Z_0-9]*)[\"']", src)))27        log("  litteraux trouves:", mots)28    except Exception:29        traceback.print_exc()30    try:31        from tensorrt_llm.llmapi.llm_args import SpeculativeConfig  # noqa: F40132        log("  SpeculativeConfig importable")33    except Exception as e:  # noqa: BLE00134        log("  SpeculativeConfig:", repr(e)[:200])35    try:36        import tensorrt_llm._torch.speculative as sp37        import pkgutil38        log("  modules _torch.speculative:", [m.name for m in pkgutil.iter_modules([os.path.dirname(sp.__file__)])])39    except Exception as e:  # noqa: BLE00140        log("  _torch.speculative:", repr(e)[:200])41 42    bloc("TRT-LLM : --help de trtllm-serve, lignes spec/kv/quant")43    try:44        h = subprocess.run(["trtllm-serve", "serve", "--help"], capture_output=True, text=True, timeout=180).stdout45        garde = [l for l in h.splitlines() if any(k in l.lower() for k in46                 ("spec", "draft", "kv_cache", "kv-cache", "quant", "fp8", "int8", "nvfp4", "eagle", "mtp"))]47        for l in garde[:45]:48            log("   ", l.strip()[:160])49    except Exception as e:  # noqa: BLE00150        log("  help KO:", repr(e)[:200])51 52    bloc("TRT-LLM : dtypes de cache KV acceptes (equivalent TurboQuant ?)")53    try:54        from tensorrt_llm.llmapi.llm_args import KvCacheConfig55        log("  champs KvCacheConfig:", list(getattr(KvCacheConfig, "model_fields", {}).keys()))56        s = inspect.getsource(KvCacheConfig)57        for l in s.splitlines():58            if "dtype" in l or "quant" in l:59                log("   ", l.strip()[:150])60    except Exception:61        traceback.print_exc()62 63    bloc("ONNX GenAI : options de KV quantifie du constructeur")64    try:65        from onnxruntime_genai.models import builder66        s = inspect.getsource(builder)67        import re68        opts = sorted(set(re.findall(r"[\"'](kv_cache_quant\w*|int4_\w+|quant_\w+|block_size|k_quant\w*|use_\w*quant\w*)[\"']", s)))69        log("  options reperees:", opts[:40])70    except Exception as e:  # noqa: BLE00171        log("  builder indisponible:", repr(e)[:200])72    log("\nFIN RECON2")73 74 75if __name__ == "__main__":76    main()77