Fix Monitor.update_model_call_limit always rejecting every call#3855
Open
Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Open
Fix Monitor.update_model_call_limit always rejecting every call#3855Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Conversation
Monitor.model_call_limit_global is initialized to an empty dict and no
code path populates it outside update_model_call_limit itself. The
function, however, early-returns False when the model is not already a
key, which means the first call for any model always fails and the dict
is never populated - making the /update_model_call_limit/{model}/{limit}
endpoint unreachable.
Drop the early-return so the function sets the limit unconditionally.
get_model_call_limit / is_model_limit_reached already treat a missing
key as 'no limit configured', so upserting here is consistent with the
rest of the class.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Monitor.update_model_call_limitexits early and returnsFalsewhenever the model is not already present inself.model_call_limit_global, but the dict is only ever initialized to{}inMonitor.__init__and no other code populates it. The first update for any model always fails, the dict stays empty, and every subsequent update also fails - so the/update_model_call_limit/{model}/{limit}endpoint is unreachable in practice.https://github.com/lm-sys/FastChat/blob/587d5cf/fastchat/serve/call_monitor.py#L73-L77
Root cause
The early-return guards against the only code path that would populate the dict, so the dict never gets populated in the first place.
Fix
Drop the early-return and upsert the limit unconditionally. The neighbouring accessors already treat a missing key as "no limit configured":
get_model_call_limitreturns-1when the key is absent.is_model_limit_reachedreturnsFalsewhen the key is absent.so allowing the first call to create the entry is consistent with the rest of the class.