-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shortfin LLM Debug Ergonomics: one flag to dump them all #668
base: main
Are you sure you want to change the base?
Conversation
…ch vmfb Program invocation
… interface a little; remove catch-all try statement because if we're not debugging we won't need it and if we're debugging we don't want the debugging code to fail silently when loglevel doesn't output info messages
6c9d802
to
dfd2416
Compare
# Invoke. Logits are of shape [bs, bsl, d]. | ||
|
||
# pre-invocation args dump | ||
if SHORTFIN_DEBUG_LLM_SERVICE: | ||
await pre_invocation_debug_dump(executor=self, local_vars=locals()) | ||
|
||
# invoke VMFB | ||
(logits,) = await fn(*args, fiber=self.fiber) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the full # Invoke. Logits are of shape [bs, bsl, d].
comment?
# Get environment variable, default to False if not set | ||
SHORTFIN_DEBUG_LLM_SERVICE = os.getenv( | ||
"SHORTFIN_DEBUG_LLM_SERVICE", "False" | ||
).lower() in ("true", "yes", "1", "y") | ||
if SHORTFIN_DEBUG_LLM_SERVICE: | ||
logger.info("DEBUG_LLM_SERVICE=True") | ||
dump_id = 0 | ||
boot_timestamp = datetime.now().isoformat() | ||
DEBUG_DATA_DIR = Path.home() / ".shortfin/debug/" | ||
DUMP_DIR_THIS_SESSION = ( | ||
DEBUG_DATA_DIR / "llm_service_invocation_dumps" / "{boot_timestamp}" | ||
) | ||
DUMP_DIR_THIS_SESSION.mkdir(parents=True, exist_ok=False) | ||
logger.info( | ||
f"[debug_service.py] Please find debug dumps for service.py in {DUMP_DIR_THIS_SESSION}" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to an init()
function so it doesn't always run at import time? This debug file could provide a class instead of a loose function that uses global variables. Then there would be no need to duplicate this os.getenv
code across both files or add the Importing this should do nothing
comment
# debug_service.py
class ShortfinLLMDebugService:
def __init__(self):
dump_id = 0
dump_dir = ""
dump_dir.mkdir(...)
async def pre_invocation_debug_dump(...):
is_decode = ...
# service.py
class GenerateService:
def __init__(self, ...):
...
SHORTFIN_DEBUG_LLM_SERVICE = os.getenv(
"SHORTFIN_DEBUG_LLM_SERVICE", "False"
).lower() in ("true", "yes", "1", "y")
if SHORTFIN_DEBUG_LLM_SERVICE:
from .debug_service import ShortfinLLMDebugService
llm_debug_service = ShortfinLLMDebugService
...
async def run(self):
...
if self.llm_debug_service:
llm_debug_service.pre_invocation_debug_dump(...)
Thanks @stbaione for originally writing a lot of the debug code in here. I organized his debug logging & dumping into a separate file & made the output easier to deal with.